Skip to content

Commit c21dffc

Browse files
committed
adjust aggregations and unite
1 parent 7c5ac4b commit c21dffc

File tree

8 files changed

+80
-80
lines changed

8 files changed

+80
-80
lines changed
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { DropdownMenuButton } from '@mongodb-js/compass-components';
2+
import { css, DropdownMenuButton } from '@mongodb-js/compass-components';
33
import type { MenuAction } from '@mongodb-js/compass-components';
44

55
export type PipelineOutputOption = 'expand' | 'collapse';
@@ -8,19 +8,29 @@ const pipelineOptionsActions: MenuAction<PipelineOutputOption>[] = [
88
{ action: 'expand', label: 'Expand all fields' },
99
];
1010

11+
const containerStyles = css({
12+
display: 'flex',
13+
alignItems: 'center',
14+
flex: 'none',
15+
});
16+
1117
export const PipelineOutputOptionsMenu: React.FunctionComponent<{
1218
onChangeOption: (option: PipelineOutputOption) => void;
1319
buttonText?: string;
1420
}> = ({ onChangeOption, buttonText }) => {
1521
return (
16-
<DropdownMenuButton<PipelineOutputOption>
17-
data-testid="pipeline-output-options"
18-
actions={pipelineOptionsActions}
19-
onAction={onChangeOption}
20-
buttonText={buttonText ?? 'Output Options'}
21-
buttonProps={{
22-
size: 'xsmall',
23-
}}
24-
></DropdownMenuButton>
22+
<div className={containerStyles}>
23+
<DropdownMenuButton<PipelineOutputOption>
24+
data-testid="pipeline-output-options"
25+
actions={pipelineOptionsActions}
26+
onAction={onChangeOption}
27+
buttonText={buttonText ?? 'Output Options'}
28+
buttonProps={{
29+
size: 'xsmall',
30+
title: buttonText ?? 'Output Options',
31+
['aria-label']: buttonText ?? 'Output Options',
32+
}}
33+
></DropdownMenuButton>
34+
</div>
2535
);
2636
};

packages/compass-aggregations/src/components/pipeline-results-workspace/pipeline-pagination.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,20 @@ type PipelinePaginationProps = {
2626
const containerStyles = css({
2727
display: 'flex',
2828
alignItems: 'center',
29-
gap: spacing[2],
29+
gap: spacing[200],
3030
});
3131

3232
const paginationStyles = css({
3333
display: 'flex',
34-
gap: spacing[1],
34+
gap: spacing[100],
3535
alignItems: 'baseline',
3636
});
3737

38+
const prevNextStyles = css({
39+
display: 'flex',
40+
alignItems: 'center',
41+
});
42+
3843
export const PipelinePagination: React.FunctionComponent<
3944
PipelinePaginationProps
4045
> = ({
@@ -56,7 +61,7 @@ export const PipelinePagination: React.FunctionComponent<
5661
<PipelinePaginationCount />
5762
</div>
5863
)}
59-
<div>
64+
<div className={prevNextStyles}>
6065
<IconButton
6166
data-testid="pipeline-pagination-prev-action"
6267
aria-label="Previous page"

packages/compass-aggregations/src/components/pipeline-results-workspace/pipeline-results-header.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ export const PipelineResultsHeader: React.FunctionComponent<
6666
<div className={containerStyles} data-testid="pipeline-results-header">
6767
<div className={pipelineOptionsStyles}>
6868
<Overline>All Results</Overline>
69-
<PipelineOutputOptionsMenu
70-
onChangeOption={handlePipelineOutputOptionsMenuChange}
71-
/>
7269
</div>
7370
<div className={pipelinePaginationStyles}>
7471
<PipelinePagination />
72+
<PipelineOutputOptionsMenu
73+
buttonText=""
74+
onChangeOption={handlePipelineOutputOptionsMenuChange}
75+
/>
7576
<PipelineResultsViewControls
7677
value={resultsViewType}
7778
onChange={onChangeResultsView}

packages/compass-aggregations/src/components/pipeline-results-workspace/pipeline-results-view-controls.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
css,
44
SegmentedControl,
55
SegmentedControlOption,
6-
Overline,
76
Icon,
87
spacing,
98
useId,
@@ -29,14 +28,6 @@ const PipelineResultsViewControls: React.FunctionComponent<{
2928
className={containerStyles}
3029
data-testid="pipeline-results-view-controls"
3130
>
32-
<Overline
33-
as="label"
34-
id={labelId}
35-
htmlFor={controlId}
36-
aria-label="Show documents as"
37-
>
38-
View
39-
</Overline>
4031
<SegmentedControl
4132
id={controlId}
4233
aria-labelledby={labelId}

packages/compass-components/src/components/actions/dropdown-menu-button.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export type DropdownMenuButtonProps<Action extends string> = {
2727
activeAction?: Action;
2828
'data-testid'?: string;
2929
buttonText: string;
30-
buttonProps: ButtonProps;
30+
buttonProps: ButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>;
3131
hideOnNarrow?: boolean;
3232
};
3333

@@ -89,7 +89,6 @@ export function DropdownMenuButton<Action extends string>({
8989
}) => {
9090
return (
9191
<Button
92-
{...buttonProps}
9392
ref={menuTriggerRef}
9493
data-testid={dataTestId ? `${dataTestId}-show-actions` : undefined}
9594
onClick={(evt) => {
@@ -98,10 +97,13 @@ export function DropdownMenuButton<Action extends string>({
9897
}}
9998
rightGlyph={<Icon glyph={'CaretDown'} />}
10099
title={buttonText}
100+
{...buttonProps}
101101
>
102-
<span className={hideOnNarrow ? hiddenOnNarrowStyles : undefined}>
103-
{buttonText}
104-
</span>
102+
{buttonText && (
103+
<span className={hideOnNarrow ? hiddenOnNarrowStyles : undefined}>
104+
{buttonText}
105+
</span>
106+
)}
105107
{children}
106108
</Button>
107109
);

packages/compass-crud/src/components/crud-toolbar.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,14 @@ describe('CrudToolbar Component', function () {
370370
});
371371
});
372372

373-
describe.only('expand controls', function () {
373+
describe('Output Options', function () {
374374
describe('table view', function () {
375375
it('should be disabled', function () {
376376
renderCrudToolbar({
377377
activeDocumentView: 'Table',
378378
});
379379

380-
expect(screen.getByTitle('Expand Controls')).to.have.attribute(
380+
expect(screen.getByTitle('Output Options')).to.have.attribute(
381381
'aria-disabled',
382382
'true'
383383
);
@@ -392,7 +392,7 @@ describe('CrudToolbar Component', function () {
392392
onExpandAllClicked,
393393
});
394394

395-
userEvent.click(screen.getByTitle('Expand Controls'));
395+
userEvent.click(screen.getByTitle('Output Options'));
396396
const expandAllBtn = screen.getByText('Expand all documents');
397397
expect(expandAllBtn).to.be.visible;
398398
userEvent.click(expandAllBtn);
@@ -406,7 +406,7 @@ describe('CrudToolbar Component', function () {
406406
onCollapseAllClicked,
407407
});
408408

409-
userEvent.click(screen.getByTitle('Expand Controls'));
409+
userEvent.click(screen.getByTitle('Output Options'));
410410
const collapseAllBtn = screen.getByText('Collapse all documents');
411411
expect(collapseAllBtn).to.be.visible;
412412
userEvent.click(collapseAllBtn);

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

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import UpdateMenu from './update-data-menu';
2222
import DeleteMenu from './delete-data-menu';
2323
import { QueryBar } from '@mongodb-js/compass-query-bar';
2424
import { useConnectionInfoRef } from '@mongodb-js/compass-connections/provider';
25-
import ExpandControl from './expand-control';
2625

2726
const crudQueryBarStyles = css({
2827
width: '100%',
@@ -33,33 +32,42 @@ const crudToolbarStyles = css({
3332
display: 'flex',
3433
flexDirection: 'column',
3534
alignItems: 'center',
36-
gap: spacing[3],
37-
padding: spacing[3],
35+
gap: spacing[300],
36+
padding: spacing[300],
3837
});
3938

4039
const crudBarStyles = css({
4140
width: '100%',
4241
display: 'flex',
43-
gap: spacing[2],
42+
gap: spacing[200],
4443
justifyContent: 'space-between',
4544
});
4645

4746
const toolbarLeftActionStyles = css({
4847
display: 'flex',
4948
alignItems: 'center',
50-
gap: spacing[2],
49+
gap: spacing[200],
5150
});
5251

5352
const toolbarRightActionStyles = css({
5453
display: 'flex',
5554
alignItems: 'center',
56-
gap: spacing[2],
55+
gap: spacing[200],
56+
});
57+
58+
const prevNextStyles = css({
59+
display: 'flex',
60+
alignItems: 'center',
5761
});
5862

5963
const exportCollectionButtonStyles = css({
6064
whiteSpace: 'nowrap',
6165
});
6266

67+
const outputOptionsButtonStyles = css({
68+
whiteSpace: 'nowrap',
69+
});
70+
6371
const docsPerPageOptionStyles = css({
6472
width: spacing[1600] + spacing[300],
6573
});
@@ -70,6 +78,12 @@ const exportDataActions: MenuAction<ExportDataOption>[] = [
7078
{ action: 'export-full-collection', label: 'Export the full collection' },
7179
];
7280

81+
type ExpandControlsOption = 'expand-all' | 'collapse-all';
82+
const expandControlsOptions: MenuAction<ExpandControlsOption>[] = [
83+
{ action: 'expand-all', label: 'Expand all documents' },
84+
{ action: 'collapse-all', label: 'Collapse all documents' },
85+
];
86+
7387
const OUTDATED_WARNING = `The content is outdated and no longer in sync
7488
with the current query. Press "Find" again to see the results for
7589
the current query.`;
@@ -278,7 +292,7 @@ const CrudToolbar: React.FunctionComponent<CrudToolbarProps> = ({
278292
</IconButton>
279293
)}
280294

281-
<div>
295+
<div className={prevNextStyles}>
282296
<IconButton
283297
data-testid="docs-toolbar-prev-page-btn"
284298
aria-label="Previous Page"
@@ -299,10 +313,22 @@ const CrudToolbar: React.FunctionComponent<CrudToolbarProps> = ({
299313
</IconButton>
300314
</div>
301315

302-
<ExpandControl
303-
onExpandAll={onExpandAllClicked}
304-
onCollapseAll={onCollapseAllClicked}
305-
activeView={activeDocumentView}
316+
<DropdownMenuButton<ExpandControlsOption>
317+
data-testid="crud-export-collection"
318+
actions={expandControlsOptions}
319+
onAction={(action: ExpandControlsOption) =>
320+
action === 'expand-all'
321+
? onExpandAllClicked()
322+
: onCollapseAllClicked()
323+
}
324+
buttonText=""
325+
buttonProps={{
326+
className: outputOptionsButtonStyles,
327+
size: 'xsmall',
328+
title: 'Output Options',
329+
['aria-label']: 'Output Options',
330+
disabled: activeDocumentView === 'Table',
331+
}}
306332
/>
307333

308334
<ViewSwitcher

packages/compass-crud/src/components/expand-control.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)