Skip to content

Commit 54052c1

Browse files
authored
chore(compass-aggregations): remove more and fewer from options button label (#5224)
1 parent 32f6083 commit 54052c1

File tree

9 files changed

+35
-47
lines changed

9 files changed

+35
-47
lines changed

packages/compass-aggregations/src/components/pipeline-toolbar/index.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('PipelineToolbar', function () {
5454
).to.exist;
5555
expect(
5656
within(header).getByTestId('pipeline-toolbar-options-button'),
57-
'shows more options button'
57+
'shows options button'
5858
).to.exist;
5959
});
6060

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.spec.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ describe('PipelineActions', function () {
7676
it('calls onToggleOptions on click', function () {
7777
const button = screen.getByTestId('pipeline-toolbar-options-button');
7878
expect(button).to.exist;
79-
expect(button?.textContent?.toLowerCase().trim()).to.equal(
80-
'fewer options'
81-
);
79+
expect(button?.textContent?.toLowerCase().trim()).to.equal('options');
8280
expect(within(button).getByLabelText('Caret Down Icon')).to.exist;
8381

8482
userEvent.click(button);
@@ -114,9 +112,7 @@ describe('PipelineActions', function () {
114112
it('toggle options action button', function () {
115113
const button = screen.getByTestId('pipeline-toolbar-options-button');
116114
expect(button).to.exist;
117-
expect(button?.textContent?.toLowerCase().trim()).to.equal(
118-
'more options'
119-
);
115+
expect(button?.textContent?.toLowerCase().trim()).to.equal('options');
120116
expect(within(button).getByLabelText('Caret Right Icon')).to.exist;
121117

122118
userEvent.click(button);

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { connect } from 'react-redux';
33
import {
44
Button,
5-
MoreOptionsToggle,
5+
OptionsToggle,
66
PerformanceSignals,
77
SignalPopover,
88
css,
@@ -153,7 +153,7 @@ export const PipelineActions: React.FunctionComponent<PipelineActionsProps> = ({
153153
</Button>
154154
)}
155155
{enableAggregationBuilderExtraOptions && (
156-
<MoreOptionsToggle
156+
<OptionsToggle
157157
isExpanded={!!isOptionsVisible}
158158
aria-controls="pipeline-options"
159159
id="pipeline-toolbar-options"

packages/compass-aggregations/src/components/stage-toolbar/option-menu.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('OptionMenu', function () {
1515
onCollapse={() => {}}
1616
/>
1717
);
18-
expect(screen.getByLabelText('More options')).to.exist;
18+
expect(screen.getByLabelText('Options')).to.exist;
1919
});
2020
it('opens the menu when clicked', function () {
2121
render(
@@ -27,7 +27,7 @@ describe('OptionMenu', function () {
2727
onCollapse={() => {}}
2828
/>
2929
);
30-
screen.getByLabelText('More options').click();
30+
screen.getByLabelText('Options').click();
3131
expect(screen.getByText('Add stage after')).to.exist;
3232
expect(screen.getByText('Add stage before')).to.exist;
3333
expect(screen.getByText('Delete stage')).to.exist;
@@ -43,7 +43,7 @@ describe('OptionMenu', function () {
4343
onCollapse={() => {}}
4444
/>
4545
);
46-
screen.getByLabelText('More options').click();
46+
screen.getByLabelText('Options').click();
4747
expect(onAddStageClick).to.not.have.been.called;
4848
screen.getByText('Add stage after').click();
4949
expect(onAddStageClick).to.have.been.calledOnceWith(1);
@@ -59,7 +59,7 @@ describe('OptionMenu', function () {
5959
onCollapse={() => {}}
6060
/>
6161
);
62-
screen.getByLabelText('More options').click();
62+
screen.getByLabelText('Options').click();
6363
expect(onAddStageClick).to.not.have.been.called;
6464
screen.getByText('Add stage before').click();
6565
expect(onAddStageClick).to.have.been.calledOnceWith(0);
@@ -75,7 +75,7 @@ describe('OptionMenu', function () {
7575
onCollapse={() => {}}
7676
/>
7777
);
78-
screen.getByLabelText('More options').click();
78+
screen.getByLabelText('Options').click();
7979
expect(onDeleteStageClick).to.not.have.been.called;
8080
screen.getByText('Delete stage').click();
8181
expect(onDeleteStageClick).to.have.been.calledOnceWith(0);
@@ -91,7 +91,7 @@ describe('OptionMenu', function () {
9191
onCollapse={() => {}}
9292
/>
9393
);
94-
screen.getByLabelText('More options').click();
94+
screen.getByLabelText('Options').click();
9595
expect(expandPreviewDocsForStageSpy).to.not.have.been.called;
9696
screen.getByText('Expand documents').click();
9797
expect(expandPreviewDocsForStageSpy).to.have.been.calledOnceWith(0);
@@ -107,7 +107,7 @@ describe('OptionMenu', function () {
107107
onCollapse={collapsePreviewDocsForStageSpy}
108108
/>
109109
);
110-
screen.getByLabelText('More options').click();
110+
screen.getByLabelText('Options').click();
111111
expect(collapsePreviewDocsForStageSpy).to.not.have.been.called;
112112
screen.getByText('Collapse documents').click();
113113
expect(collapsePreviewDocsForStageSpy).to.have.been.calledOnceWith(0);

packages/compass-aggregations/src/components/stage-toolbar/option-menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export const OptionMenu = ({
5050
<IconButton
5151
data-testid="stage-option-menu-button"
5252
onClick={onClick}
53-
aria-label="More options"
54-
title="More options"
53+
aria-label="Options"
54+
title="Options"
5555
>
5656
<Icon glyph="Ellipsis" size="small"></Icon>
5757
</IconButton>

packages/compass-components/src/components/more-options-toggle.spec.tsx renamed to packages/compass-components/src/components/options-toggle.spec.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import sinon from 'sinon';
44

55
import { fireEvent, render, screen, cleanup } from '@testing-library/react';
66

7-
import { MoreOptionsToggle } from './more-options-toggle';
7+
import { OptionsToggle } from './options-toggle';
88

9-
function renderMoreOptionsToggle(
10-
props?: Partial<React.ComponentProps<typeof MoreOptionsToggle>>
9+
function renderOptionsToggle(
10+
props?: Partial<React.ComponentProps<typeof OptionsToggle>>
1111
) {
1212
return render(
13-
<MoreOptionsToggle
13+
<OptionsToggle
1414
isExpanded={false}
1515
aria-controls="test"
1616
onToggleOptions={() => {}}
@@ -19,39 +19,39 @@ function renderMoreOptionsToggle(
1919
);
2020
}
2121

22-
describe('MoreOptionsToggle Component', function () {
22+
describe('OptionsToggle Component', function () {
2323
afterEach(function () {
2424
cleanup();
2525
});
2626

2727
it('should call to open the options dropdown on click', function () {
2828
const onToggleOptionsSpy = sinon.spy();
29-
renderMoreOptionsToggle({
29+
renderOptionsToggle({
3030
isExpanded: false,
3131
onToggleOptions: onToggleOptionsSpy,
3232
});
3333

3434
expect(onToggleOptionsSpy.calledOnce).to.be.false;
35-
const button = screen.getByText('More Options');
35+
const button = screen.getByText('Options');
3636
fireEvent.click(button);
3737
expect(onToggleOptionsSpy.calledOnce).to.be.true;
3838
});
3939

4040
it('should call to close the options dropdown on click', function () {
4141
const onToggleOptionsSpy = sinon.spy();
42-
renderMoreOptionsToggle({
42+
renderOptionsToggle({
4343
isExpanded: true,
4444
onToggleOptions: onToggleOptionsSpy,
4545
});
4646

4747
expect(onToggleOptionsSpy.calledOnce).to.be.false;
48-
const button = screen.getByText('Fewer Options');
48+
const button = screen.getByText('Options');
4949
fireEvent.click(button);
5050
expect(onToggleOptionsSpy.calledOnce).to.be.true;
5151
});
5252

5353
it('should the test id', function () {
54-
renderMoreOptionsToggle({
54+
renderOptionsToggle({
5555
'data-testid': 'pineapple',
5656
});
5757

packages/compass-components/src/components/more-options-toggle.tsx renamed to packages/compass-components/src/components/options-toggle.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const optionStyles = css({
2525
alignItems: 'center',
2626
});
2727

28-
type MoreOptionsToggleProps = {
28+
type OptionsToggleProps = {
2929
label?: (expanded: boolean) => string;
3030
'aria-label'?: (expanded: boolean) => string;
3131
'aria-controls': string;
@@ -35,18 +35,16 @@ type MoreOptionsToggleProps = {
3535
id?: string;
3636
};
3737

38-
export const MoreOptionsToggle: React.FunctionComponent<
39-
MoreOptionsToggleProps
40-
> = ({
38+
export const OptionsToggle: React.FunctionComponent<OptionsToggleProps> = ({
4139
'aria-controls': ariaControls,
4240
isExpanded,
4341
id,
4442
'data-testid': dataTestId,
4543
onToggleOptions,
46-
label = (expanded) => {
44+
label = () => 'Options',
45+
'aria-label': ariaLabel = (expanded) => {
4746
return expanded ? 'Fewer Options' : 'More Options';
4847
},
49-
'aria-label': ariaLabel,
5048
}) => {
5149
const optionsIcon = useMemo(
5250
() => (isExpanded ? 'CaretDown' : 'CaretRight'),
@@ -60,7 +58,7 @@ export const MoreOptionsToggle: React.FunctionComponent<
6058
width: `calc(${maxLabelLength}ch + ${spacing[3]}px + ${spacing[2]}px)`,
6159
};
6260
}, [label]);
63-
const optionsAriaLabel = ariaLabel?.(isExpanded) ?? optionsLabel;
61+
const optionsAriaLabel = ariaLabel(isExpanded);
6462
const focusRingProps = useFocusRing();
6563
const buttonProps = mergeProps(
6664
{ className: optionsButtonStyles },

packages/compass-components/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import FileInput, {
2323
createElectronFileInputBackend,
2424
FileInputBackendProvider,
2525
} from './components/file-input';
26-
import { MoreOptionsToggle } from './components/more-options-toggle';
26+
import { OptionsToggle } from './components/options-toggle';
2727
import {
2828
ErrorSummary,
2929
WarningSummary,
@@ -103,7 +103,7 @@ export {
103103
FileInput,
104104
FileInputBackendProvider,
105105
IndexIcon,
106-
MoreOptionsToggle,
106+
OptionsToggle,
107107
RadioBoxGroup,
108108
ResizeHandle,
109109
ResizeDirection,

packages/compass-query-bar/src/components/query-bar.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useCallback, useMemo } from 'react';
22
import {
33
Button,
44
Icon,
5-
MoreOptionsToggle,
5+
OptionsToggle,
66
css,
77
cx,
88
spacing,
@@ -114,20 +114,14 @@ const queryAIContainerStyles = css({
114114
const queryBarDocumentationLink =
115115
'https://docs.mongodb.com/compass/current/query/filter/';
116116

117-
const QueryMoreOptionsToggle = connect(
117+
const QueryOptionsToggle = connect(
118118
(state: RootState) => {
119119
return {
120120
isExpanded: state.queryBar.expanded,
121-
label() {
122-
return 'Options';
123-
},
124-
'aria-label'(expanded: boolean) {
125-
return expanded ? 'Fewer Options' : 'More Options';
126-
},
127121
};
128122
},
129123
{ onToggleOptions: toggleQueryOptions }
130-
)(MoreOptionsToggle);
124+
)(OptionsToggle);
131125

132126
type QueryBarProps = {
133127
buttonLabel?: string;
@@ -314,7 +308,7 @@ export const QueryBar: React.FunctionComponent<QueryBarProps> = ({
314308

315309
{queryOptionsLayout && queryOptionsLayout.length > 0 && (
316310
<div className={moreOptionsContainerStyles}>
317-
<QueryMoreOptionsToggle
311+
<QueryOptionsToggle
318312
aria-controls="additional-query-options-container"
319313
data-testid="query-bar-options-toggle"
320314
/>

0 commit comments

Comments
 (0)