Skip to content

Commit

Permalink
feat: control the visibility of NMRium header items
Browse files Browse the repository at this point in the history
close #2642

Control the visibility of those items (help,logs, general setting, workspaces and maximize) from
the workspace preferences
  • Loading branch information
hamed-musallam committed Aug 25, 2023
1 parent 819f828 commit 7a24c77
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 21 deletions.
56 changes: 54 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -89,6 +89,7 @@
"nmr-correlation": "^2.3.3",
"nmr-load-save": "^0.18.0",
"nmr-processing": "^10.0.7",
"nmredata": "^0.9.2",
"numeral": "^2.0.6",
"openchemlib": "^8.3.0",
"openchemlib-utils": "^5.2.0",
Expand Down Expand Up @@ -147,4 +148,4 @@
"vite": "^4.4.9",
"vitest": "^0.34.1"
}
}
}
38 changes: 20 additions & 18 deletions src/component/header/Header.tsx
Expand Up @@ -98,9 +98,11 @@ function HeaderInner(props: HeaderInnerProps) {
} = usePreferences();

const workspacesList = useWorkspacesList();

const hideGeneralSettings = !!(
general?.hideGeneralSettings && workspace.base
);
const hideWorkspaces = !!(general?.hideWorkspaces && workspace.base);

const selectedPanel = useMemo(() => {
switch (selectedOptionPanel) {
Expand Down Expand Up @@ -161,33 +163,33 @@ function HeaderInner(props: HeaderInnerProps) {
alignItems: 'center',
}}
>
{!hideGeneralSettings && (
<>
<DropDownButton
data={workspacesList}
selectedKey={workspace.current}
onSelect={changeWorkspaceHandler}
renderItem={renderItem}
/>
<SaveButton />
</>
{!hideWorkspaces && (
<DropDownButton
data={workspacesList}
selectedKey={workspace.current}
onSelect={changeWorkspaceHandler}
renderItem={renderItem}
/>
)}
{!hideGeneralSettings && <SaveButton />}
{!general?.hideLogs && <LogsHistoryModal />}

<div>
<Toolbar orientation="horizontal">
<Toolbar.Item
id="user-manual"
title="User manual"
onClick={() => window.open(docsBaseUrl, '_blank')}
>
<FaQuestionCircle />
</Toolbar.Item>
{!general?.hideHelp && (
<Toolbar.Item
id="user-manual"
title="User manual"
onClick={() => window.open(docsBaseUrl, '_blank')}
>
<FaQuestionCircle />
</Toolbar.Item>
)}
{!hideGeneralSettings && (
<GeneralSettingsModal height={height / 2} />
)}

{!isFullscreenEnabled && (
{!isFullscreenEnabled && !general?.hideMaximize && (
<Toolbar.Item
id="full-screen"
onClick={onEnableFullscreen}
Expand Down
5 changes: 5 additions & 0 deletions src/component/workspaces/embedded.ts
Expand Up @@ -7,6 +7,11 @@ export const embedded: InnerWorkspace = {
general: {
experimentalFeatures: { display: true },
hidePanelOnLoad: true,
hideHelp: true,
hideLogs: true,
hideMaximize: true,
hideWorkspaces: true,
hideGeneralSettings: true,
},

panels: {
Expand Down
3 changes: 3 additions & 0 deletions src/component/workspaces/workspaceDefaultProperties.ts
Expand Up @@ -8,6 +8,9 @@ export const workspaceDefaultProperties: Required<WorkspacePreferences> = {
experimentalFeatures: { display: false },
hidePanelOnLoad: false,
hideLogs: false,
hideHelp: false,
hideMaximize: false,
hideWorkspaces: false,
},

panels: {
Expand Down

0 comments on commit 7a24c77

Please sign in to comment.