Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace code studio home icon with "Code Studio" as label #1951

Merged
merged 3 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
40 changes: 20 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,15 @@ 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:
key !== DEFAULT_DASHBOARD_ID
? value.title ?? 'Untitled'
: 'Code Studio',
dsmmcken marked this conversation as resolved.
Show resolved Hide resolved
isClosable: key !== DEFAULT_DASHBOARD_ID,
icon: key === DEFAULT_DASHBOARD_ID ? vsTerminal : undefined,
})),
activeTabKey: DEFAULT_DASHBOARD_ID,
layoutIteration: 0,
};
Expand Down Expand Up @@ -856,12 +859,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 +903,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) {
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
Loading