Skip to content
Merged
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
1 change: 1 addition & 0 deletions packages/code-studio/src/main/AppInit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ function AppInit(props: AppInitProps): JSX.Element {
});

const dashboardData = {
title: 'Code Studio',
filterSets: data.filterSets,
links: data.links,
};
Expand Down
37 changes: 17 additions & 20 deletions packages/code-studio/src/main/AppMainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import {
dhPanels,
vsDebugDisconnect,
dhSquareFilled,
vsHome,
vsTerminal,
} from '@deephaven/icons';
import { getVariableDescriptor } from '@deephaven/jsapi-bootstrap';
import dh from '@deephaven/jsapi-shim';
Expand Down Expand Up @@ -256,12 +256,12 @@ export class AppMainContainer extends Component<
isSettingsMenuShown: false,
unsavedNotebookCount: 0,
widgets: [],
tabs: Object.entries(allDashboardData)
.filter(([key]) => key !== DEFAULT_DASHBOARD_ID)
.map(([key, value]) => ({
key,
title: value.title ?? 'Untitled',
})),
tabs: Object.entries(allDashboardData).map(([key, value]) => ({
key,
title: value.title ?? 'Untitled',
isClosable: key !== DEFAULT_DASHBOARD_ID,
icon: key === DEFAULT_DASHBOARD_ID ? vsTerminal : undefined,
})),
activeTabKey: DEFAULT_DASHBOARD_ID,
layoutIteration: 0,
};
Expand Down Expand Up @@ -856,12 +856,14 @@ export class AppMainContainer extends Component<
layoutConfig: layoutConfig as ItemConfigType[],
key: `${DEFAULT_DASHBOARD_ID}-${layoutIteration}`,
},
...tabs.map(tab => ({
id: tab.key,
layoutConfig: (allDashboardData[tab.key]?.layoutConfig ??
EMPTY_ARRAY) as ItemConfigType[],
key: `${tab.key}-${layoutIteration}`,
})),
...tabs
.filter(tab => tab.key !== DEFAULT_DASHBOARD_ID)
.map(tab => ({
id: tab.key,
layoutConfig: (allDashboardData[tab.key]?.layoutConfig ??
EMPTY_ARRAY) as ItemConfigType[],
key: `${tab.key}-${layoutIteration}`,
})),
];
}

Expand Down Expand Up @@ -898,14 +900,9 @@ export class AppMainContainer extends Component<
>
<div className="app-main-top-nav-menus">
<Logo className="ml-1" style={{ maxHeight: '20px' }} />
{tabs.length > 0 && (
{/* Only show the Code Studio tab if there is also an open dashboard */}
{tabs.length > 1 && (
<div style={{ flexShrink: 0, flexGrow: 1, display: 'flex' }}>
<Button
kind="ghost"
icon={vsHome}
tooltip="Go to Code Studio"
onClick={this.handleHomeClick}
/>
<NavTabList
tabs={tabs}
activeKey={activeTabKey}
Expand Down
15 changes: 13 additions & 2 deletions packages/components/src/navigation/NavTab.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { memo } from 'react';
import classNames from 'classnames';
import { Draggable } from 'react-beautiful-dnd';
import { vsClose } from '@deephaven/icons';
import { IconDefinition, vsClose } from '@deephaven/icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { NavTabItem } from './NavTabList';
import Button from '../Button';
import ContextActions from '../context-actions/ContextActions';
Expand Down Expand Up @@ -29,7 +30,16 @@ const NavTab = memo(
isDraggable,
contextActions,
}: NavTabProps) => {
const { key, isClosable = onClose != null, title } = tab;
const { key, isClosable = onClose != null, title, icon } = tab;

let iconElem: JSX.Element | undefined;
if (icon != null) {
iconElem = React.isValidElement(icon) ? (
icon
) : (
<FontAwesomeIcon icon={icon as IconDefinition} />
);
}

return (
<Draggable
Expand Down Expand Up @@ -68,6 +78,7 @@ const NavTab = memo(
if (event.key === 'Enter') onSelect(key);
}}
>
{iconElem}
{title}
{isClosable && (
<Button
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/navigation/NavTabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
OnDragEndResponder,
} from 'react-beautiful-dnd';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
import { vsChevronRight, vsChevronLeft } from '@deephaven/icons';
import { useResizeObserver } from '@deephaven/react-hooks';
import DragUtils from '../DragUtils';
Expand All @@ -39,6 +40,11 @@ export interface NavTabItem {
*/
title: string;

/**
* Icon to display on the tab.
*/
icon?: IconDefinition | JSX.Element;

/**
* Whether the tab is closable.
* If omitted, the tab will be closeable if onClose exists.
Expand Down