Skip to content

Commit 3a757b1

Browse files
authored
implement button to hide view, within each view settings toolbar (#903)
* implement button to hide view, within each view settings toolbar * adjust test to new code * apply formatting changes --------- Co-authored-by: Logende <[email protected]>
1 parent 8dda335 commit 3a757b1

15 files changed

Lines changed: 62 additions & 29 deletions

File tree

meta_configurator/src/components/panels/ai-prompts/AiPromptsPanel.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const props = defineProps<{
1616
<template>
1717
<div class="panel-container">
1818
<PanelSettings
19-
panel-name="AI Prompts View"
19+
panel-display-name="AI Prompts View"
20+
panel-type="aiPrompts"
2021
:panel-settings-path="['aiIntegration']"
2122
:sessionMode="props.sessionMode">
2223
<p>

meta_configurator/src/components/panels/code-editor/CodeEditorPanel.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<template>
22
<div class="panel-container">
33
<PanelSettings
4-
panel-name="Text View"
5-
:panel-settings-path="['codeEditor']"
4+
panel-display-name="Text View"
5+
panel-type="textEditor"
6+
:panel-settings-path="['textEditor']"
67
:sessionMode="props.sessionMode">
78
<p>
89
This panel allows you to view and edit the raw JSON/YAML/XML data of the current document.

meta_configurator/src/components/panels/documentation/DocumentationPanel.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ onUnmounted(() => docsRef.value?.removeEventListener('click', onAnchorClick));
9696
<template>
9797
<div class="panel-container">
9898
<PanelSettings
99-
panel-name="Documentation View"
99+
panel-display-name="Documentation View"
100+
panel-type="documentation"
100101
:panel-settings-path="['documentation']"
101102
:sessionMode="props.sessionMode">
102103
<p>

meta_configurator/src/components/panels/gui-editor/GuiEditorPanel.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const isSchemaBundlingSuggested = computed(() => {
2828
<div class="panel-container">
2929
<div class="gui-panel">
3030
<PanelSettings
31-
panel-name="GUI View"
31+
panel-display-name="GUI View"
32+
panel-type="guiEditor"
3233
:panel-settings-path="['guiEditor']"
3334
:sessionMode="props.sessionMode">
3435
<p>

meta_configurator/src/components/panels/list-analysis/ListAnalysisPanel.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ function exportTableAsCsv() {
8484
<template>
8585
<div class="panel-container">
8686
<PanelSettings
87-
panel-name="Table View"
88-
:panel-settings-path="['listAnalysis']"
87+
panel-display-name="Table View"
88+
panel-type="tableView"
89+
:panel-settings-path="['tableView']"
8990
:sessionMode="props.sessionMode">
9091
<p>
9192
This panel allows you to analyze object arrays in the current document. Select an object

meta_configurator/src/components/panels/schema-diagram/SchemaDiagramPanel.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const props = defineProps<{
1010

1111
<template>
1212
<PanelSettings
13-
panel-name="Diagram View"
13+
panel-display-name="Diagram View"
14+
panel-type="schemaDiagram"
1415
:panel-settings-path="['schemaDiagram']"
1516
:sessionMode="props.sessionMode">
1617
<p>

meta_configurator/src/components/panels/shared-components/PanelSettings.vue

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ import Button from 'primevue/button';
1111
import PropertiesPanel from '@/components/panels/gui-editor/PropertiesPanel.vue';
1212
import {JsonSchemaWrapper} from '@/schema/jsonSchemaWrapper';
1313
import {getDataForMode, getSchemaForMode} from '@/data/useDataLink';
14+
import {useSettings} from '@/settings/useSettings.ts';
15+
import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome';
1416
1517
const props = defineProps<{
16-
panelName: string;
18+
panelDisplayName: string;
19+
panelType: string;
1720
settingsHeader?: string;
1821
panelSettingsPath: Path;
1922
sessionMode: SessionMode;
@@ -50,27 +53,46 @@ const copyToClipboard = async () => {
5053
};
5154
5255
const containsText = computed(() => {
53-
return ['Text View'].includes(props.panelName);
56+
return props.panelType == 'textEditor';
5457
});
5558
5659
const settingsName = computed(() => {
5760
if (props.settingsHeader && props.settingsHeader !== '') {
5861
return props.settingsHeader;
5962
}
60-
if (!props.panelName || props.panelName === '') {
63+
if (!props.panelDisplayName || props.panelDisplayName === '') {
6164
return 'Settings';
6265
}
63-
if (props.panelName.toLowerCase().includes('settings')) {
64-
return props.panelName;
66+
if (props.panelDisplayName.toLowerCase().includes('settings')) {
67+
return props.panelDisplayName;
6568
}
66-
return props.panelName + ' Settings';
69+
return props.panelDisplayName + ' Settings';
6770
});
71+
72+
function hideView() {
73+
const mode = props.sessionMode;
74+
const settings = useSettings().value;
75+
settings.panels[mode] = settings.panels[mode].filter(
76+
panel => panel.panelType !== props.panelType
77+
);
78+
}
6879
</script>
6980

7081
<template>
71-
<Panel :header="panelName" toggleable :collapsed="true" class="panel-settings-scroll">
72-
<template v-if="containsText" #icons>
73-
<Button icon="pi pi-clone" severity="secondary" @click="copyToClipboard" rounded text />
82+
<Panel :header="panelDisplayName" toggleable :collapsed="true" class="panel-settings-scroll">
83+
<template #icons>
84+
<Button
85+
v-if="containsText"
86+
text
87+
severity="secondary"
88+
v-tooltip.left="'Copy text to clipboard'"
89+
@click="copyToClipboard()">
90+
<FontAwesomeIcon icon="fa-regular fa-clone" />
91+
</Button>
92+
93+
<Button text severity="secondary" v-tooltip.left="'Hide view'" @click="hideView()">
94+
<FontAwesomeIcon icon="fa-solid fa-eye-slash" />
95+
</Button>
7496
</template>
7597
<slot></slot>
7698
<div class="properties-panel-container">

meta_configurator/src/components/panels/shared-components/__tests__/panelSettings.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ describe('PanelSettings', () => {
5050
it('copies panel content to the clipboard when the copy button is clicked', async () => {
5151
const wrapper = mount(PanelSettings, {
5252
props: {
53-
panelName: 'Text View',
53+
panelDisplayName: 'Text View',
54+
panelType: 'textEditor',
5455
panelSettingsPath: [],
5556
sessionMode: SessionMode.DataEditor,
5657
},

meta_configurator/src/components/panels/shared-components/aceUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export function setupAceProperties(editor: Editor, settings: SettingsInterfaceRo
3333
editor.setTheme('ace/theme/clouds');
3434
}
3535
editor.setShowPrintMargin(false);
36-
editor.getSession().setTabSize(settings.codeEditor.tabSize);
36+
editor.getSession().setTabSize(settings.textEditor.tabSize);
3737

3838
// it's not clear why timeout is needed here, but without it the
3939
// ace editor starts flashing and becomes unusable
4040
window.setTimeout(() => {
4141
watchImmediate(
42-
() => settings.codeEditor.fontSize,
42+
() => settings.textEditor.fontSize,
4343
fontSize => {
4444
if (editor && fontSize && fontSize > 6 && fontSize < 65) {
4545
editor.setFontSize(fontSize.toString() + 'px');

meta_configurator/src/components/toolbar/TopToolbar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ useMagicKeys({
169169
</div>
170170

171171
<!-- RIGHT side: format selector -->
172-
<div class="format-switch-container" v-if="settings.codeEditor.showFormatSelector">
172+
<div class="format-switch-container" v-if="settings.textEditor.showFormatSelector">
173173
<Select
174174
:options="dataFormatOptions"
175175
v-model="settings.dataFormat"

0 commit comments

Comments
 (0)