Skip to content

Commit 51d99c2

Browse files
refactor: combine panel status menu
We remove 'open on load' column and have 4 choice in the select drop down menu: - Hidden - Available - Active = current active - Open = current active + open on load close #3685
1 parent f26b72a commit 51d99c2

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/component/modal/setting/settings-tabs/DisplayTabContent.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Checkbox, Switch } from '@blueprintjs/core';
1+
import { Switch } from '@blueprintjs/core';
22
import type { NMRiumPanelPreferences } from '@zakodium/nmrium-core';
33
import { useCallback, useMemo } from 'react';
44
import { Controller, useFormContext } from 'react-hook-form';
@@ -18,7 +18,7 @@ interface ListItem {
1818
hideOpenOption?: boolean;
1919
}
2020

21-
type PanelStatus = 'hidden' | 'available' | 'active';
21+
type PanelStatus = 'hidden' | 'available' | 'active' | 'open';
2222
interface PanelStatusItem {
2323
label: string;
2424
value: PanelStatus;
@@ -33,6 +33,10 @@ const PANEL_STATUS: PanelStatusItem[] = [
3333
label: 'Available',
3434
value: 'available',
3535
},
36+
{
37+
label: 'Open',
38+
value: 'open',
39+
},
3640
{
3741
label: 'Active',
3842
value: 'active',
@@ -108,6 +112,7 @@ function DisplayTabContent() {
108112
(panelName: keyof NMRiumPanelPreferences, status: PanelStatus) => {
109113
let visible = false;
110114
let display = false;
115+
let open = false;
111116

112117
if (status === 'available') {
113118
visible = true;
@@ -117,7 +122,13 @@ function DisplayTabContent() {
117122
visible = true;
118123
display = true;
119124
}
125+
if (status === 'open') {
126+
visible = true;
127+
display = true;
128+
open = true;
129+
}
120130

131+
setValue(`${basePath}.${panelName}.open`, open);
121132
setValue(`${basePath}.${panelName}.display`, display);
122133
setValue(`${basePath}.${panelName}.visible`, visible);
123134
},
@@ -172,19 +183,8 @@ function DisplayTabContent() {
172183
/>
173184
),
174185
},
175-
{
176-
index: 4,
177-
Header: 'Open on load',
178-
style: { textAlign: 'center' },
179-
Cell: ({ row }) => (
180-
<Checkbox
181-
style={{ margin: 0 }}
182-
{...register(`${basePath}.${row.original.name}.open`)}
183-
/>
184-
),
185-
},
186186
],
187-
[control, onChange, register],
187+
[control, onChange],
188188
);
189189

190190
return (

0 commit comments

Comments
 (0)