Skip to content

Commit ef9de15

Browse files
authored
fix(search-indexes): ui fixes COMPASS-7304 (#4982)
1 parent eef7e4f commit ef9de15

File tree

7 files changed

+480
-723
lines changed

7 files changed

+480
-723
lines changed

package-lock.json

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

packages/compass-components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"@leafygreen-ui/hooks": "^7.3.3",
4747
"@leafygreen-ui/icon": "^11.21.0",
4848
"@leafygreen-ui/icon-button": "^15.0.3",
49+
"@leafygreen-ui/info-sprinkle": "^1.0.0",
4950
"@leafygreen-ui/inline-definition": "^6.0.0",
5051
"@leafygreen-ui/leafygreen-provider": "^3.1.0",
5152
"@leafygreen-ui/lib": "^10.0.0",

packages/compass-components/src/components/leafygreen.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
MongoDBLogo,
2020
} from '@leafygreen-ui/logo';
2121
import { Menu, MenuSeparator, MenuItem } from '@leafygreen-ui/menu';
22+
import { InfoSprinkle } from '@leafygreen-ui/info-sprinkle';
2223

2324
// If a leafygreen Menu (and therefore MenuItems) makes its way into a <form>,
2425
// clicking on a menu item will submit that form. This is because it uses a button
@@ -144,4 +145,5 @@ export {
144145
Link,
145146
Description,
146147
SearchInput,
148+
InfoSprinkle,
147149
};

packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
150150
)}
151151
{isSearchManagementActive && (
152152
<SegmentedControl
153+
size="small"
153154
onChange={(evt) => onChangeIndexView(evt as IndexView)}
154155
className={alignSelfEndStyles}
155156
label="Viewing"

packages/compass-indexes/src/components/search-index-template-dropdown/index.tsx

Lines changed: 29 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,24 @@ import React, { useState, useCallback } from 'react';
44
import {
55
Select,
66
Option,
7-
Icon,
87
css,
9-
Tooltip,
8+
spacing,
9+
InfoSprinkle,
10+
Label,
1011
} from '@mongodb-js/compass-components';
1112

12-
const dropdownLabelStyles = css({
13+
const containerStyles = css({
1314
display: 'flex',
14-
pointerEvents: 'auto', // leafy green specifies none in the label, which is wrong
15+
flexDirection: 'column',
16+
gap: spacing[1],
1517
});
1618

17-
const fillParentStyles = css({
18-
flexGrow: 1,
19+
const dropdownLabelStyles = css({
20+
display: 'flex',
21+
gap: spacing[1],
22+
alignItems: 'center',
1923
});
2024

21-
type SearchIndexTemplateDropdownLabelProps = {
22-
label: string;
23-
tooltip: string;
24-
};
25-
26-
const SearchIndexTemplateDropdownLabel: React.FunctionComponent<
27-
SearchIndexTemplateDropdownLabelProps
28-
> = ({ label, tooltip }) => (
29-
<div className={dropdownLabelStyles}>
30-
<span className={fillParentStyles}>{label}</span>
31-
<Tooltip
32-
align="right"
33-
triggerEvent="hover"
34-
trigger={({ children, ...props }) => (
35-
<div {...props}>
36-
<Icon
37-
data-testid="search-template-info-icon"
38-
glyph="InfoWithCircle"
39-
/>
40-
{children}
41-
</div>
42-
)}
43-
>
44-
{tooltip}
45-
</Tooltip>
46-
</div>
47-
);
48-
4925
type SearchIndexTemplateDropdownProps = {
5026
tooltip: string;
5127
onTemplate: (template: SearchTemplate) => void;
@@ -65,20 +41,24 @@ export const SearchIndexTemplateDropdown: React.FunctionComponent<
6541
);
6642

6743
return (
68-
<Select
69-
value={templateValue}
70-
allowDeselect={false}
71-
onChange={onChooseTemplate}
72-
/* @ts-expect-error The label can be any React component, however, the type definition forces a string. */
73-
label={
74-
<SearchIndexTemplateDropdownLabel label="Template" tooltip={tooltip} />
75-
}
76-
>
77-
{ATLAS_SEARCH_TEMPLATES.map((template, idx) => (
78-
<Option key={idx} value={`${idx}`}>
79-
{template.name}
80-
</Option>
81-
))}
82-
</Select>
44+
<div className={containerStyles}>
45+
<div className={dropdownLabelStyles}>
46+
<Label htmlFor="template-dropdown">Template</Label>
47+
<InfoSprinkle align="right">{tooltip}</InfoSprinkle>
48+
</div>
49+
<Select
50+
id="template-dropdown"
51+
aria-labelledby="Template"
52+
value={templateValue}
53+
allowDeselect={false}
54+
onChange={onChooseTemplate}
55+
>
56+
{ATLAS_SEARCH_TEMPLATES.map((template, idx) => (
57+
<Option key={idx} value={`${idx}`}>
58+
{template.name}
59+
</Option>
60+
))}
61+
</Select>
62+
</div>
8363
);
8464
};

packages/compass-indexes/src/components/search-indexes-modals/base-search-index-modal.tsx

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const templateToolbarStyles = css({
5858
display: 'flex',
5959
flexDirection: 'row',
6060
gap: spacing[3],
61-
padding: spacing[1],
6261
});
6362

6463
const templateToolbarTextDescriptionStyles = css({
@@ -72,13 +71,17 @@ const templateToolbarDropdownStyles = css({
7271
const formContainerStyles = css({
7372
display: 'flex',
7473
flexDirection: 'column',
75-
gap: spacing[3],
74+
gap: spacing[2],
7675
overflow: 'auto',
76+
// This is to accomodate for the focus ring that is visible
77+
// when the index name input is focussed.
7778
padding: spacing[1],
7879
});
7980

80-
const editorStyles = css({
81-
marginTop: spacing[2],
81+
const formFieldContainerStyles = css({
82+
display: 'flex',
83+
flexDirection: 'column',
84+
gap: spacing[1],
8285
});
8386

8487
const footerStyles = css({
@@ -227,7 +230,7 @@ export const BaseSearchIndexModal: React.FunctionComponent<
227230
<div className={formContainerStyles}>
228231
{mode === 'create' && (
229232
<>
230-
<section>
233+
<section className={formFieldContainerStyles}>
231234
<Label htmlFor="name-of-search-index">
232235
Name of Search Index
233236
</Label>
@@ -251,45 +254,46 @@ export const BaseSearchIndexModal: React.FunctionComponent<
251254
<HorizontalRule />
252255
</>
253256
)}
254-
<section className={templateToolbarStyles}>
255-
<div className={templateToolbarTextDescriptionStyles}>
256-
<Label htmlFor="definition-of-search-index">
257-
Index Definition
258-
</Label>
259-
<br />
260-
{mode === 'create' && (
261-
<Body>
262-
By default, search indexes will have the following search
263-
configurations. You can refine this later.
264-
</Body>
265-
)}
266-
<Link
267-
href="https://www.mongodb.com/docs/atlas/atlas-search/tutorial/"
268-
target="_blank"
269-
hideExternalIcon={true}
270-
>
271-
View Atlas Search tutorials{' '}
272-
<Icon size="small" glyph="OpenNewTab"></Icon>
273-
</Link>
274-
</div>
275-
<div className={templateToolbarDropdownStyles}>
276-
<SearchIndexTemplateDropdown
277-
tooltip="Selecting a new template will replace your existing index definition in the code editor."
278-
onTemplate={onChangeTemplate}
279-
/>
280-
</div>
281-
</section>
282-
<CodemirrorMultilineEditor
283-
ref={editorRef}
284-
id="definition-of-search-index"
285-
data-testid="definition-of-search-index"
286-
className={editorStyles}
287-
text={indexDefinition}
288-
annotations={annotations}
289-
onChangeText={onSearchIndexDefinitionChanged}
290-
minLines={16}
291-
completer={completer}
292-
/>
257+
<div className={formFieldContainerStyles}>
258+
<section className={templateToolbarStyles}>
259+
<div className={templateToolbarTextDescriptionStyles}>
260+
<Label htmlFor="definition-of-search-index">
261+
Index Definition
262+
</Label>
263+
<br />
264+
{mode === 'create' && (
265+
<Body>
266+
By default, search indexes will have the following search
267+
configurations. You can refine this later.
268+
</Body>
269+
)}
270+
<Link
271+
href="https://www.mongodb.com/docs/atlas/atlas-search/tutorial/"
272+
target="_blank"
273+
hideExternalIcon={true}
274+
>
275+
View Atlas Search tutorials{' '}
276+
<Icon size="small" glyph="OpenNewTab"></Icon>
277+
</Link>
278+
</div>
279+
<div className={templateToolbarDropdownStyles}>
280+
<SearchIndexTemplateDropdown
281+
tooltip="Selecting a new template will replace your existing index definition in the code editor."
282+
onTemplate={onChangeTemplate}
283+
/>
284+
</div>
285+
</section>
286+
<CodemirrorMultilineEditor
287+
ref={editorRef}
288+
id="definition-of-search-index"
289+
data-testid="definition-of-search-index"
290+
text={indexDefinition}
291+
annotations={annotations}
292+
onChangeText={onSearchIndexDefinitionChanged}
293+
minLines={16}
294+
completer={completer}
295+
/>
296+
</div>
293297
</div>
294298
{parsingError && <WarningSummary warnings={parsingError.message} />}
295299
{!parsingError && error && <ErrorSummary errors={error} />}

packages/compass-indexes/src/modules/search-indexes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ export const createIndex = (
452452
title: `Your index ${indexName} is in progress.`,
453453
dismissible: true,
454454
timeout: 5000,
455-
variant: 'success',
455+
variant: 'progress',
456456
});
457457

458458
void dispatch(switchToSearchIndexes());
@@ -494,7 +494,7 @@ export const updateIndex = (
494494
title: `Your index ${indexName} is being updated.`,
495495
dismissible: true,
496496
timeout: 5000,
497-
variant: 'success',
497+
variant: 'progress',
498498
});
499499
void dispatch(fetchIndexes(SearchIndexesStatuses.REFRESHING));
500500
} catch (e) {
@@ -633,7 +633,7 @@ export const dropSearchIndex = (
633633
title: `Your index ${name} is being deleted.`,
634634
dismissible: true,
635635
timeout: 5000,
636-
variant: 'success',
636+
variant: 'progress',
637637
});
638638
void dispatch(fetchIndexes(SearchIndexesStatuses.REFRESHING));
639639
} catch (e) {

0 commit comments

Comments
 (0)