Skip to content

Commit

Permalink
Merge pull request #624 from madeindjs/WF-104
Browse files Browse the repository at this point in the history
feat(ui): add an option `hideRoot` for `CoreJsonViewer` - WF-104
  • Loading branch information
ramedina86 authored Nov 14, 2024
2 parents cd46ddf + 8e46e8f commit 0c98a28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/ui/src/components/core/content/CoreJsonViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:data="data ?? {}"
:initial-depth="initialDepth"
:enable-copy-to-json="fields.copy.value === 'yes'"
:hide-root="fields.hideRoot.value === 'yes'"
/>
</div>
</template>
Expand Down Expand Up @@ -54,6 +55,17 @@ const definition: WriterComponentDefinition = {
type: FieldType.Number,
init: "0",
},
hideRoot: {
name: "Hide root",
desc: "Don't show the type of the root node when it's an Object or an Array.",
type: FieldType.Text,
options: {
yes: "yes",
no: "no",
},
default: "no",
category: FieldCategory.Style,
},
copy: {
name: "Copy",
desc: "If active, adds a control bar with copy JSON button.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ const props = defineProps({
type: Array as PropType<JsonPath>,
default: () => [],
},
hideRoot: {
type: Boolean,
required: false,
},
initialDepth: { type: Number, default: 0 },
enableCopyToJson: { type: Boolean, required: false },
});
Expand All @@ -80,7 +84,7 @@ defineEmits({
toggle: jsonViewerToggleEmitDefinition,
});
const isRoot = computed(() => props.path.length === 0);
const isRoot = computed(() => props.path.length === 0 && !props.hideRoot);
const isRootOpen = computed(
() => props.initialDepth === -1 || props.initialDepth > 0,
);
Expand Down

0 comments on commit 0c98a28

Please sign in to comment.