Skip to content

Commit ee413a9

Browse files
authored
feat(sidebar): show header for Data Explorer COMPASS-8904 (#6711)
* (feat)sidebar: show header for Data Explorer COMPASS-8904 * add preview badge * styling
1 parent 9e223fb commit ee413a9

File tree

4 files changed

+44
-20
lines changed

4 files changed

+44
-20
lines changed

packages/compass-sidebar/src/components/multiple-connections/header/sidebar-header.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,28 @@ import {
55
css,
66
type ItemAction,
77
ItemActionControls,
8+
Badge,
9+
BadgeVariant,
810
} from '@mongodb-js/compass-components';
911

1012
const sidebarHeaderStyles = css({
1113
paddingLeft: spacing[400],
1214
paddingRight: spacing[400],
1315
display: 'flex',
1416
justifyContent: 'space-between',
17+
alignItems: 'center',
1518
});
1619

1720
const sidebarHeaderTextStyles = css({
1821
lineHeight: '32px',
1922
fontWeight: 600,
2023
});
2124

25+
const badgeStyles = css({
26+
verticalAlign: 'middle',
27+
marginLeft: spacing[100],
28+
});
29+
2230
type Action = 'open-compass-settings';
2331

2432
const actions: ItemAction<Action>[] = [
@@ -31,18 +39,33 @@ const actions: ItemAction<Action>[] = [
3139

3240
export function SidebarHeader({
3341
onAction,
42+
isCompassWeb,
3443
}: {
3544
onAction(actionName: Action): void;
45+
isCompassWeb?: boolean;
3646
}): React.ReactElement {
3747
return (
3848
<div className={sidebarHeaderStyles} data-testid="sidebar-header">
39-
<Subtitle className={sidebarHeaderTextStyles}>Compass</Subtitle>
40-
<ItemActionControls<Action>
41-
onAction={onAction}
42-
iconSize="small"
43-
actions={actions}
44-
data-testid="connections-sidebar-title-actions"
45-
></ItemActionControls>
49+
<Subtitle className={sidebarHeaderTextStyles}>
50+
{isCompassWeb ? 'Data Explorer' : 'Compass'}
51+
{isCompassWeb && (
52+
<Badge
53+
variant={BadgeVariant.Blue}
54+
className={badgeStyles}
55+
data-testid="sidebar-header-badge"
56+
>
57+
Preview
58+
</Badge>
59+
)}
60+
</Subtitle>
61+
{!isCompassWeb && (
62+
<ItemActionControls<Action>
63+
onAction={onAction}
64+
iconSize="small"
65+
actions={actions}
66+
data-testid="connections-sidebar-title-actions"
67+
></ItemActionControls>
68+
)}
4669
</div>
4770
);
4871
}

packages/compass-sidebar/src/components/multiple-connections/sidebar.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ type MultipleConnectionSidebarProps = {
5050
activeWorkspace: WorkspaceTab | null;
5151
onConnectionCsfleModeChanged(connectionId: string, isEnabled: boolean): void;
5252
onSidebarAction(action: string, ...rest: any[]): void;
53-
showSidebarHeader?: boolean;
5453
onOpenConnectViaModal?: (
5554
atlasMetadata: ConnectionInfo['atlasMetadata']
5655
) => void;
56+
isCompassWeb?: boolean;
5757
};
5858

5959
const sidebarStyles = css({
@@ -92,8 +92,8 @@ export function MultipleConnectionSidebar({
9292
activeWorkspace,
9393
onSidebarAction,
9494
onConnectionCsfleModeChanged,
95-
showSidebarHeader = true,
9695
onOpenConnectViaModal,
96+
isCompassWeb,
9797
}: MultipleConnectionSidebarProps) {
9898
const [csfleModalConnectionId, setCsfleModalConnectionId] = useState<
9999
string | undefined
@@ -167,13 +167,14 @@ export function MultipleConnectionSidebar({
167167
return (
168168
<ResizableSidebar data-testid="navigation-sidebar" useNewTheme={true}>
169169
<aside className={sidebarStyles}>
170-
{showSidebarHeader && (
171-
<>
172-
<SidebarHeader onAction={onSidebarAction} />
173-
<Navigation currentLocation={activeWorkspace?.type ?? null} />
174-
<HorizontalRule />
175-
</>
176-
)}
170+
<>
171+
<SidebarHeader
172+
onAction={onSidebarAction}
173+
isCompassWeb={isCompassWeb}
174+
/>
175+
<Navigation currentLocation={activeWorkspace?.type ?? null} />
176+
<HorizontalRule />
177+
</>
177178
<ConnectionsNavigation
178179
connectionsWithStatus={connectionsWithStatus}
179180
activeWorkspace={activeWorkspace}

packages/compass-sidebar/src/plugin.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ const errorBoundaryStyles = css({
1414
});
1515

1616
export interface SidebarPluginProps {
17-
showSidebarHeader?: boolean;
1817
onOpenConnectViaModal?: (
1918
atlasMetadata: ConnectionInfo['atlasMetadata']
2019
) => void;
20+
isCompassWeb?: boolean;
2121
}
2222

2323
const SidebarPlugin: React.FunctionComponent<SidebarPluginProps> = ({
24-
showSidebarHeader,
2524
onOpenConnectViaModal,
25+
isCompassWeb,
2626
}) => {
2727
const activeWorkspace = useActiveWorkspace();
2828
const { log, mongoLogId } = useLogger('COMPASS-SIDEBAR-UI');
@@ -41,9 +41,9 @@ const SidebarPlugin: React.FunctionComponent<SidebarPluginProps> = ({
4141
}}
4242
>
4343
<MultipleConnectionSidebar
44-
showSidebarHeader={showSidebarHeader}
4544
activeWorkspace={activeWorkspace}
4645
onOpenConnectViaModal={onOpenConnectViaModal}
46+
isCompassWeb={isCompassWeb}
4747
/>
4848
</ErrorBoundary>
4949
);

packages/compass-web/src/entrypoint.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ function CompassWorkspace({
202202
renderSidebar={() => {
203203
return (
204204
<CompassSidebarPlugin
205-
showSidebarHeader={false}
206205
onOpenConnectViaModal={onOpenConnectViaModal}
206+
isCompassWeb={true}
207207
></CompassSidebarPlugin>
208208
);
209209
}}

0 commit comments

Comments
 (0)