Skip to content

Commit 1d48329

Browse files
authored
Revert "breadcrumbs ui" (#5499)
This reverts commit 8b0b3d9.
1 parent a750182 commit 1d48329

File tree

30 files changed

+604
-696
lines changed

30 files changed

+604
-696
lines changed

package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-aggregations/src/modules/create-view/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,7 @@ export const createView = (): CreateViewThunkAction<Promise<void>> => {
226226
const ns = `${database}.${viewName}`;
227227
track('Aggregation Saved As View', { num_stages: viewPipeline.length });
228228
globalAppRegistry.emit('view-created', ns);
229-
workspaces.openCollectionWorkspace(ns, {
230-
newTab: true,
231-
sourceName: viewSource,
232-
});
229+
workspaces.openCollectionWorkspace(ns, { newTab: true });
233230
dispatch(reset());
234231
} catch (e) {
235232
dispatch(stopWithError(e as Error));

packages/compass-aggregations/src/modules/update-view.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ export const updateView = (): PipelineBuilderThunkAction<Promise<void>> => {
111111
});
112112
debug('selecting namespace', viewNamespace);
113113
globalAppRegistry.emit('view-edited', viewNamespace);
114-
workspaces.openCollectionWorkspace(viewNamespace, {
115-
sourceName: state.namespace,
116-
});
114+
workspaces.openCollectionWorkspace(viewNamespace);
117115
} catch (e: any) {
118116
debug('Unexpected error updating view', e);
119117
dispatch(updateViewErrorOccured(e));

packages/compass-collection/src/components/collection-header/collection-header.spec.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function renderCollectionHeader(
1616
isClustered={false}
1717
isFLE={false}
1818
namespace="test.test"
19+
stats={null}
1920
{...props}
2021
/>
2122
);
@@ -33,8 +34,12 @@ describe('CollectionHeader [Component]', function () {
3334
expect(screen.getByTestId('collection-header')).to.exist;
3435
});
3536

36-
it('renders breadcrumbs', function () {
37-
expect(screen.getByTestId('breadcrumbs')).to.exist;
37+
it('renders the db name', function () {
38+
expect(screen.getByTestId('collection-header-title-db')).to.exist;
39+
});
40+
41+
it('renders the collection name', function () {
42+
expect(screen.getByTestId('collection-header-title-collection')).to.exist;
3843
});
3944

4045
it('does not render the readonly badge', function () {
@@ -65,8 +70,12 @@ describe('CollectionHeader [Component]', function () {
6570
expect(screen.getByTestId('collection-header')).to.exist;
6671
});
6772

68-
it('renders breadcrumbs', function () {
69-
expect(screen.getByTestId('breadcrumbs')).to.exist;
73+
it('renders the db name', function () {
74+
expect(screen.getByTestId('collection-header-title-db')).to.exist;
75+
});
76+
77+
it('renders the collection name', function () {
78+
expect(screen.getByTestId('collection-header-title-collection')).to.exist;
7079
});
7180

7281
it('renders the source collection', function () {

packages/compass-collection/src/components/collection-header/collection-header.tsx

Lines changed: 145 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,88 @@
11
import {
22
css,
33
palette,
4+
Link,
45
spacing,
6+
H3,
57
cx,
68
SignalPopover,
79
PerformanceSignals,
810
useDarkMode,
9-
Breadcrumbs,
1011
} from '@mongodb-js/compass-components';
1112
import type { Signal } from '@mongodb-js/compass-components';
1213
import React from 'react';
1314
import toNS from 'mongodb-ns';
1415
import { usePreference } from 'compass-preferences-model/provider';
1516
import CollectionHeaderActions from '../collection-header-actions';
17+
import CollectionStats from '../collection-stats';
1618
import type { CollectionState } from '../../modules/collection-tab';
1719
import { CollectionBadge } from './badges';
18-
import {
19-
useOpenWorkspace,
20-
useWorkspaceBreadcrumbs,
21-
} from '@mongodb-js/compass-workspaces/provider';
20+
import { useOpenWorkspace } from '@mongodb-js/compass-workspaces/provider';
2221
import { connect } from 'react-redux';
2322

2423
const collectionHeaderStyles = css({
25-
padding: spacing[3],
24+
paddingTop: spacing[3],
25+
paddingBottom: spacing[1],
26+
height: +spacing[6] + +spacing[2],
2627
flexShrink: 0,
2728
display: 'flex',
2829
alignItems: 'center',
2930
justifyContent: 'space-between',
31+
});
32+
33+
const collectionHeaderTitleStyles = css({
34+
display: 'flex',
35+
width: '100%',
36+
alignItems: 'center',
37+
padding: `0 ${String(spacing[3])}px`,
38+
margin: 0,
39+
overflow: 'hidden',
3040
gap: spacing[2],
3141
});
3242

43+
const collectionHeaderDBLinkStyles = css({
44+
whiteSpace: 'nowrap',
45+
overflow: 'hidden',
46+
textOverflow: 'ellipsis',
47+
cursor: 'pointer',
48+
textDecoration: 'none',
49+
'&:hover,&:focus': {
50+
textDecoration: 'underline',
51+
},
52+
backgroundColor: 'transparent',
53+
border: 'none',
54+
display: 'inline-block',
55+
padding: 0,
56+
});
57+
58+
const collectionHeaderNamespaceStyles = css({
59+
backgroundColor: 'transparent',
60+
border: 'none',
61+
display: 'flex',
62+
whiteSpace: 'nowrap',
63+
overflow: 'hidden',
64+
});
65+
66+
const collectionHeaderDBNameStyles = css({
67+
overflow: 'hidden',
68+
textOverflow: 'ellipsis',
69+
whiteSpace: 'nowrap',
70+
});
71+
72+
const dbLinkLightStyles = css({
73+
color: palette.green.dark2,
74+
});
75+
76+
const dbLinkDarkStyles = css({
77+
color: palette.green.base,
78+
});
79+
80+
const collectionHeaderCollectionStyles = css({
81+
whiteSpace: 'nowrap',
82+
overflow: 'hidden',
83+
textOverflow: 'ellipsis',
84+
});
85+
3386
const collectionHeaderLightStyles = css({
3487
background: palette.white,
3588
});
@@ -38,6 +91,14 @@ const collectionHeaderDarkStyles = css({
3891
backgroundColor: palette.black,
3992
});
4093

94+
const collectionHeaderTitleCollectionLightStyles = css({
95+
color: palette.gray.dark1,
96+
});
97+
98+
const collectionHeaderTitleCollectionDarkStyles = css({
99+
color: palette.gray.light1,
100+
});
101+
41102
type CollectionHeaderProps = {
42103
namespace: string;
43104
isReadonly: boolean;
@@ -48,6 +109,7 @@ type CollectionHeaderProps = {
48109
sourceName?: string;
49110
editViewName?: string;
50111
sourcePipeline?: unknown[];
112+
stats: CollectionState['stats'];
51113
};
52114

53115
const getInsightsForPipeline = (pipeline: any[], isAtlas: boolean) => {
@@ -84,10 +146,15 @@ export const CollectionHeader: React.FunctionComponent<
84146
sourceName,
85147
editViewName,
86148
sourcePipeline,
149+
stats,
87150
}) => {
88151
const darkMode = useDarkMode();
89152
const showInsights = usePreference('showInsights');
90-
const { openCollectionWorkspace, openEditViewWorkspace } = useOpenWorkspace();
153+
const {
154+
openCollectionsWorkspace,
155+
openCollectionWorkspace,
156+
openEditViewWorkspace,
157+
} = useOpenWorkspace();
91158

92159
const ns = toNS(namespace);
93160
const database = ns.database;
@@ -96,41 +163,85 @@ export const CollectionHeader: React.FunctionComponent<
96163
showInsights && sourcePipeline?.length
97164
? getInsightsForPipeline(sourcePipeline, isAtlas)
98165
: [];
99-
const breadcrumbItems = useWorkspaceBreadcrumbs();
166+
100167
return (
101168
<div
102-
title={`${database}.${collection}`}
103169
className={cx(
104170
collectionHeaderStyles,
105171
darkMode ? collectionHeaderDarkStyles : collectionHeaderLightStyles
106172
)}
107173
data-testid="collection-header"
108174
>
109-
<Breadcrumbs items={breadcrumbItems} />
110-
{isReadonly && <CollectionBadge type="readonly" />}
111-
{isTimeSeries && <CollectionBadge type="timeseries" />}
112-
{isClustered && <CollectionBadge type="clustered" />}
113-
{isFLE && <CollectionBadge type="fle" />}
114-
{isReadonly && sourceName && <CollectionBadge type="view" />}
115-
{!!insights.length && <SignalPopover signals={insights} />}
116-
<CollectionHeaderActions
117-
editViewName={editViewName}
118-
isReadonly={isReadonly}
119-
onEditViewClicked={() => {
120-
if (sourceName && sourcePipeline) {
121-
openEditViewWorkspace(namespace, {
122-
sourceName,
123-
sourcePipeline,
124-
});
125-
}
126-
}}
127-
onReturnToViewClicked={() => {
128-
if (editViewName) {
129-
openCollectionWorkspace(editViewName, { sourceName: namespace });
130-
}
131-
}}
132-
sourceName={sourceName}
133-
/>
175+
<div
176+
title={`${database}.${collection}`}
177+
className={collectionHeaderTitleStyles}
178+
data-testid="collection-header-title"
179+
>
180+
<div
181+
data-testid="collection-header-namespace"
182+
className={collectionHeaderNamespaceStyles}
183+
>
184+
<Link
185+
data-testid="collection-header-title-db"
186+
as="button"
187+
className={cx(
188+
collectionHeaderDBLinkStyles,
189+
darkMode ? dbLinkDarkStyles : dbLinkLightStyles
190+
)}
191+
hideExternalIcon={true}
192+
onClick={() => {
193+
openCollectionsWorkspace(ns.database);
194+
}}
195+
>
196+
<H3
197+
className={cx(
198+
collectionHeaderDBNameStyles,
199+
darkMode ? dbLinkDarkStyles : dbLinkLightStyles
200+
)}
201+
>
202+
{database}
203+
</H3>
204+
</Link>
205+
<H3
206+
data-testid="collection-header-title-collection"
207+
className={cx(
208+
collectionHeaderCollectionStyles,
209+
darkMode
210+
? collectionHeaderTitleCollectionDarkStyles
211+
: collectionHeaderTitleCollectionLightStyles
212+
)}
213+
>
214+
{`.${collection}`}
215+
</H3>
216+
</div>
217+
{isReadonly && <CollectionBadge type="readonly" />}
218+
{isTimeSeries && <CollectionBadge type="timeseries" />}
219+
{isClustered && <CollectionBadge type="clustered" />}
220+
{isFLE && <CollectionBadge type="fle" />}
221+
{isReadonly && sourceName && <CollectionBadge type="view" />}
222+
{!!insights.length && <SignalPopover signals={insights} />}
223+
<CollectionHeaderActions
224+
editViewName={editViewName}
225+
isReadonly={isReadonly}
226+
onEditViewClicked={() => {
227+
if (sourceName && sourcePipeline) {
228+
openEditViewWorkspace(namespace, {
229+
sourceName,
230+
sourcePipeline,
231+
});
232+
}
233+
}}
234+
onReturnToViewClicked={() => {
235+
if (editViewName) {
236+
openCollectionWorkspace(editViewName);
237+
}
238+
}}
239+
sourceName={sourceName}
240+
/>
241+
</div>
242+
{!isReadonly && !editViewName && (
243+
<CollectionStats isTimeSeries={isTimeSeries} stats={stats} />
244+
)}
134245
</div>
135246
);
136247
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from 'react';
2+
import { render, screen, cleanup } from '@testing-library/react';
3+
import { expect } from 'chai';
4+
5+
import CollectionStatsItem from '../collection-stats-item';
6+
7+
describe('CollectionStatsItem [Component]', function () {
8+
context('when the component is not primary', function () {
9+
afterEach(cleanup);
10+
11+
beforeEach(function () {
12+
render(
13+
<CollectionStatsItem label="label" value="10kb" data-testid="test" />
14+
);
15+
});
16+
17+
it('renders the correct root classname', function () {
18+
expect(screen.getByTestId('test-stats-item')).to.exist;
19+
});
20+
21+
it('renders the label', function () {
22+
const label = screen.getByTestId('test-count-label');
23+
expect(label).to.have.text('label');
24+
expect(label).to.be.visible;
25+
});
26+
27+
it('renders the value', function () {
28+
const value = screen.getByTestId('test-count-value');
29+
expect(value).to.have.text('10kb');
30+
expect(value).to.be.visible;
31+
});
32+
});
33+
34+
context('when the component is primary', function () {
35+
afterEach(cleanup);
36+
37+
beforeEach(function () {
38+
render(
39+
<CollectionStatsItem label="label" value="20kb" data-testid="test" />
40+
);
41+
});
42+
43+
it('renders the correct root classname', function () {
44+
expect(screen.getByTestId('test-stats-item')).to.exist;
45+
});
46+
47+
it('renders the label', function () {
48+
const label = screen.getByTestId('test-count-label');
49+
expect(label).to.have.text('label');
50+
expect(label).to.be.visible;
51+
});
52+
53+
it('renders the value', function () {
54+
const value = screen.getByTestId('test-count-value');
55+
expect(value).to.have.text('20kb');
56+
expect(value).to.be.visible;
57+
});
58+
});
59+
});

0 commit comments

Comments
 (0)