Skip to content

Commit

Permalink
fix(UX): Reset overrides should be disabled if not applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
surajshetty3416 committed Jan 14, 2025
1 parent 194fe1c commit 74ccb14
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
1 change: 1 addition & 0 deletions frontend/src/builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ declare interface ContextMenuOption {
label: string;
action: CallableFunction;
condition?: () => boolean;
disabled?: () => boolean;
}

declare interface ComponentData {
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/components/BlockContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ const contextMenuOptions: ContextMenuOption[] = [
return selectedBlocks.every((block: Block) => block.getParentBlock() === parentBlock);
},
},
{
label: "Save As Component",
action: () => (showNewComponentDialog.value = true),
condition: () => !block.value.isExtendedFromComponent(),
},
{
label: "Repeat Block",
action: () => {
Expand All @@ -166,7 +160,8 @@ const contextMenuOptions: ContextMenuOption[] = [
},
{
label: "Reset Overrides",
condition: () => block.value.hasOverrides(store.activeBreakpoint),
condition: () => store.activeBreakpoint !== "desktop",
disabled: () => !block.value?.hasOverrides(store.activeBreakpoint),
action: () => {
block.value.resetOverrides(store.activeBreakpoint);
},
Expand Down Expand Up @@ -216,6 +211,11 @@ const contextMenuOptions: ContextMenuOption[] = [
},
condition: () => !block.value.isExtendedFromComponent() && Boolean(window.is_developer_mode),
},
{
label: "Save As Component",
action: () => (showNewComponentDialog.value = true),
condition: () => !block.value.isExtendedFromComponent(),
},
{
label: "Detach Component",
action: () => {
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/components/ContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
<MenuItem
v-slot="{ active, disabled }"
class="block cursor-pointer rounded-sm px-3 py-1 text-ink-gray-9"
:disabled="option.disabled && option.disabled()"
v-for="(option, index) in options"
v-show="!option.condition || option.condition()">
<div
@click.prevent.stop="(!option.condition || option.condition()) && handleClick(option.action)"
:class="{
'text-gray-900': !disabled,
'bg-surface-gray-4': active,
'text-ink-gray-4': disabled,
'!cursor-default !text-ink-gray-4': disabled,
}">
{{ option.label }}
</div>
Expand All @@ -28,12 +29,6 @@ import { computed, ref } from "vue";
const menu = ref(null) as unknown as typeof Menu;
interface ContextMenuOption {
label: string;
action: CallableFunction;
condition?: () => boolean;
}
const props = defineProps({
posX: {
type: Number,
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/PageClientScriptManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ const selectScript = (script: attachedScript) => {
};
const updateScript = (value: string) => {
console.log(value);
if (!activeScript.value) return;
clientScriptResource.setValue
.submit({
Expand Down

0 comments on commit 74ccb14

Please sign in to comment.