Skip to content

Commit 3140db0

Browse files
committed
show the search warning in all three places
1 parent 0828207 commit 3140db0

File tree

4 files changed

+62
-31
lines changed

4 files changed

+62
-31
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
3+
import {
4+
css,
5+
palette,
6+
spacing,
7+
Body,
8+
useDarkMode,
9+
Subtitle,
10+
} from '@mongodb-js/compass-components';
11+
12+
const centeredContent = css({
13+
display: 'flex',
14+
alignItems: 'center',
15+
justifyContent: 'center',
16+
height: '100%',
17+
padding: spacing[3],
18+
flexDirection: 'column',
19+
textAlign: 'center',
20+
});
21+
22+
const missingAtlasIndexLightStyles = css({
23+
color: palette.green.dark2,
24+
});
25+
26+
const missingAtlasIndexDarkStyles = css({
27+
color: palette.green.base,
28+
});
29+
30+
export default function AtlasNoResults() {
31+
const darkMode = useDarkMode();
32+
33+
return (
34+
<div className={centeredContent}>
35+
<Subtitle
36+
className={css(
37+
darkMode ? missingAtlasIndexDarkStyles : missingAtlasIndexLightStyles
38+
)}
39+
>
40+
No results found
41+
</Subtitle>
42+
<Body>
43+
This may be because your search has no results or your search index does
44+
not exist.
45+
</Body>
46+
</div>
47+
);
48+
}

packages/compass-aggregations/src/components/focus-mode/focus-mode-stage-preview.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
expandPreviewDocsForStage,
2525
} from '../../modules/pipeline-builder/stage-editor';
2626
import type { StoreStage } from '../../modules/pipeline-builder/stage-editor';
27+
import AtlasNoResults from '../atlas-no-results';
2728

2829
const containerStyles = css({
2930
display: 'flex',
@@ -149,6 +150,8 @@ export const FocusModePreview = ({
149150
className={documentListStyles}
150151
/>
151152
);
153+
} else if (isAtlasOnlyStage(stageOperator)) {
154+
return <AtlasNoResults />;
152155
} else {
153156
content = (
154157
<div className={centerStyles}>

packages/compass-aggregations/src/components/pipeline-builder-workspace/pipeline-as-text-workspace/pipeline-preview.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
expandPreviewDocs,
2626
collapsePreviewDocs,
2727
} from '../../../modules/pipeline-builder/text-editor-pipeline';
28+
import AtlasNoResults from '../../atlas-no-results';
2829

2930
const containerStyles = css({
3031
display: 'flex',
@@ -126,6 +127,9 @@ const PreviewResults = ({
126127
}
127128

128129
if (previewDocs.length === 0) {
130+
if (atlasOperator) {
131+
return <AtlasNoResults />;
132+
}
129133
return (
130134
<div className={centerStyles}>
131135
<DocumentIcon />

packages/compass-aggregations/src/components/stage-preview/index.tsx

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
Body,
1010
KeylineCard,
1111
useDarkMode,
12-
Subtitle,
1312
} from '@mongodb-js/compass-components';
1413
import { Document } from '@mongodb-js/compass-crud';
1514

@@ -26,6 +25,8 @@ import OutputStagePreivew from './output-stage-preview';
2625
import StagePreviewHeader from './stage-preview-header';
2726
import type { StoreStage } from '../../modules/pipeline-builder/stage-editor';
2827

28+
import AtlasNoResults from '../atlas-no-results';
29+
2930
const centeredContent = css({
3031
display: 'flex',
3132
alignItems: 'center',
@@ -52,7 +53,7 @@ const emptyStylesLight = css({
5253
stroke: palette.gray.base,
5354
});
5455

55-
function EmptyIcon() {
56+
function NoPreviewDocuments() {
5657
const darkMode = useDarkMode();
5758

5859
return (
@@ -97,14 +98,6 @@ const documentStyles = css({
9798
padding: 0,
9899
});
99100

100-
const missingAtlasIndexLightStyles = css({
101-
color: palette.green.dark2,
102-
});
103-
104-
const missingAtlasIndexDarkStyles = css({
105-
color: palette.green.base,
106-
});
107-
108101
type StagePreviewProps = {
109102
index: number;
110103
isLoading: boolean;
@@ -123,9 +116,8 @@ function StagePreviewBody({
123116
shouldRenderStage,
124117
isLoading,
125118
}: StagePreviewProps) {
126-
const darkMode = useDarkMode();
127119
if (!shouldRenderStage) {
128-
return <EmptyIcon />;
120+
return <NoPreviewDocuments />;
129121
}
130122

131123
if (isMissingAtlasOnlyStageSupport) {
@@ -154,23 +146,7 @@ function StagePreviewBody({
154146
}
155147

156148
if (isAtlasOnlyStage(stageOperator ?? '') && documents?.length === 0) {
157-
return (
158-
<div className={centeredContent}>
159-
<Subtitle
160-
className={css(
161-
darkMode
162-
? missingAtlasIndexDarkStyles
163-
: missingAtlasIndexLightStyles
164-
)}
165-
>
166-
No results found
167-
</Subtitle>
168-
<Body>
169-
This may be because your search has no results or your search index
170-
does not exist.
171-
</Body>
172-
</div>
173-
);
149+
return <AtlasNoResults />;
174150
}
175151

176152
if (documents && documents.length > 0) {
@@ -186,7 +162,7 @@ function StagePreviewBody({
186162
return <div className={documentsStyles}>{docs}</div>;
187163
}
188164

189-
return <EmptyIcon />;
165+
return <NoPreviewDocuments />;
190166
}
191167

192168
const containerStyles = css({
@@ -208,7 +184,7 @@ export function StagePreview(props: StagePreviewProps) {
208184
if (props.isDisabled) {
209185
return (
210186
<div className={containerStyles}>
211-
<EmptyIcon />
187+
<NoPreviewDocuments />
212188
</div>
213189
);
214190
}

0 commit comments

Comments
 (0)