Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client):improve getter #230

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const props = withDefaults(defineProps<{
depth: number
showAddIfNeeded?: boolean
disableEdit?: boolean
disableDelete?: boolean
rootId: string
}>(), {
showAddIfNeeded: true,
})
Expand Down Expand Up @@ -118,7 +120,7 @@ function quickEditNum(v: number | string, offset: 1 | -1) {
</template>
</template>
<!-- delete prop, only appear if depth > 0 -->
<VueButton v-if="!props.disableEdit && depth > 0" v-bind="iconButtonProps" :class="buttonClass" @click.stop="quickEdit(rawValue, true)">
<VueButton v-if="!props.disableEdit && !props.disableDelete && depth > 0" v-bind="iconButtonProps" :class="buttonClass" @click.stop="quickEdit(rawValue, true)">
<template #icon>
<VueIcon icon="i-material-symbols-delete-rounded" />
</template>
Expand Down
4 changes: 4 additions & 0 deletions packages/client/src/components/inspector/InspectorState.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ const props = withDefaults(defineProps<{
nodeId: string
inspectorId: string
disableEdit?: boolean
disableDelete?: boolean
}>(), {
disableEdit: false,
})

const undeletableIds = ['getters']

const { isExpanded, toggleCollapse } = useCollapse('inspector-state', props.id)
// expand the root node by default
!isExpanded.value && toggleCollapse()
Expand All @@ -21,6 +24,7 @@ createStateEditorContext({
nodeId: props.nodeId!,
inspectorId: props.inspectorId!,
disableEdit: props.disableEdit,
disableDelete: undeletableIds.includes(props.id),
})
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const { isHovering } = useHover(() => containerRef.value)
<span v-html="normalizedValue" />
</span>
<Actions
:hovering="isHovering" :disable-edit="state.disableEdit"
:hovering="isHovering" :disable-edit="state.disableEdit" :root-id="rootId" :disable-delete="state.disableDelete"
:data="data" :depth="depth" @enable-edit-input="toggleEditing"
@add-new-prop="addNewProp"
/>
Expand All @@ -200,8 +200,8 @@ const { isHovering } = useHover(() => containerRef.value)
<span v-html="normalizedValue" />
</span>
<Actions
:show-add-if-needed="!draftingNewProp.enable"
:hovering="isHovering" :data="data" :disable-edit="state.disableEdit"
:show-add-if-needed="!draftingNewProp.enable" :root-id="rootId"
:hovering="isHovering" :data="data" :disable-edit="state.disableEdit" :disable-delete="state.disableDelete"
:depth="depth" @enable-edit-input="toggleEditing" @add-new-prop="addNewProp"
/>
</template>
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/composables/inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface StateEditorContext {
nodeId: string
inspectorId: string
disableEdit: boolean
disableDelete: boolean
}
const StateEditorSymbolKey: InjectionKey<Ref<StateEditorContext>> = Symbol('StateEditorSymbol')

Expand Down
Loading