Skip to content

Commit c92e8d5

Browse files
committed
shrunk btns in dashboard corner and fixed tests
1 parent 864de60 commit c92e8d5

File tree

8 files changed

+134
-132
lines changed

8 files changed

+134
-132
lines changed

static/app/views/dashboards/controls.tsx

Lines changed: 71 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {Button} from 'sentry/components/core/button';
99
import {ButtonBar} from 'sentry/components/core/button/buttonBar';
1010
import {Tooltip} from 'sentry/components/core/tooltip';
1111
import {DropdownMenu, type MenuItemProps} from 'sentry/components/dropdownMenu';
12-
import FeedbackWidgetButton from 'sentry/components/feedback/widget/feedbackWidgetButton';
1312
import {Hovercard} from 'sentry/components/hovercard';
1413
import LoadingIndicator from 'sentry/components/loadingIndicator';
1514
import {IconAdd, IconDownload, IconEdit, IconStar} from 'sentry/icons';
@@ -197,84 +196,87 @@ function Controls({
197196
: t('You do not have permission to edit this dashboard');
198197
return (
199198
<StyledButtonBar key="controls">
200-
<FeedbackWidgetButton />
201199
<DashboardEditFeature>
202200
{hasFeature => (
203201
<Fragment>
204202
<Feature features="dashboards-import">
205-
<Button
206-
data-test-id="dashboard-export"
207-
onClick={e => {
208-
e.preventDefault();
209-
exportDashboard();
210-
}}
211-
icon={<IconDownload />}
212-
priority="default"
213-
size="sm"
214-
>
215-
{t('Export Dashboard')}
216-
</Button>
203+
<Tooltip title={t('Export Dashboard')}>
204+
<Button
205+
data-test-id="dashboard-export"
206+
aria-label={t('export-dashboard')}
207+
onClick={e => {
208+
e.preventDefault();
209+
exportDashboard();
210+
}}
211+
icon={<IconDownload />}
212+
priority="default"
213+
size="sm"
214+
/>
215+
</Tooltip>
217216
</Feature>
218-
{dashboard.id !== 'default-overview' && (
219-
<Button
220-
size="sm"
221-
aria-label={'dashboards-favourite'}
222-
icon={
223-
<IconStar
224-
color={isFavorited ? 'yellow300' : 'gray300'}
225-
isSolid={isFavorited}
226-
aria-label={isFavorited ? t('UnFavorite') : t('Favorite')}
227-
data-test-id={isFavorited ? 'yellow-star' : 'empty-star'}
228-
/>
229-
}
230-
onClick={async () => {
231-
try {
232-
setIsFavorited(!isFavorited);
233-
await updateDashboardFavorite(
234-
api,
235-
queryClient,
236-
organization,
237-
dashboard.id,
238-
!isFavorited
239-
);
240-
trackAnalytics('dashboards_manage.toggle_favorite', {
241-
organization,
242-
dashboard_id: dashboard.id,
243-
favorited: !isFavorited,
244-
});
245-
} catch (error) {
246-
// If the api call fails, revert the state
247-
setIsFavorited(isFavorited);
248-
}
249-
}}
250-
/>
251-
)}
252217
{dashboard.id !== 'default-overview' && (
253218
<EditAccessSelector
254219
dashboard={dashboard}
255220
onChangeEditAccess={onChangeEditAccess}
256221
/>
257222
)}
258-
<Button
259-
data-test-id="dashboard-edit"
260-
onClick={e => {
261-
e.preventDefault();
262-
onEdit();
263-
}}
264-
icon={isSaving ? <LoadingIndicator size={14} /> : <IconEdit />}
265-
disabled={!hasFeature || hasUnsavedFilters || !hasEditAccess || isSaving}
266-
title={
267-
isSaving
268-
? DASHBOARD_SAVING_MESSAGE
269-
: hasEditAccess
270-
? hasUnsavedFilters && UNSAVED_FILTERS_MESSAGE
271-
: t('You do not have permission to edit this dashboard')
272-
}
273-
priority="default"
274-
size="sm"
275-
>
276-
{t('Edit Dashboard')}
277-
</Button>
223+
{dashboard.id !== 'default-overview' && (
224+
<Tooltip title={isFavorited ? t('Starred Dashboard') : t('Star Dashboard')}>
225+
<Button
226+
size="sm"
227+
aria-label={t('star-dashboard')}
228+
icon={
229+
<IconStar
230+
color={isFavorited ? 'yellow300' : 'gray500'}
231+
isSolid={isFavorited}
232+
aria-label={isFavorited ? t('Unstar') : t('Star')}
233+
data-test-id={isFavorited ? 'yellow-star' : 'empty-star'}
234+
/>
235+
}
236+
onClick={async () => {
237+
try {
238+
setIsFavorited(!isFavorited);
239+
await updateDashboardFavorite(
240+
api,
241+
queryClient,
242+
organization,
243+
dashboard.id,
244+
!isFavorited
245+
);
246+
trackAnalytics('dashboards_manage.toggle_favorite', {
247+
organization,
248+
dashboard_id: dashboard.id,
249+
favorited: !isFavorited,
250+
});
251+
} catch (error) {
252+
// If the api call fails, revert the state
253+
setIsFavorited(isFavorited);
254+
}
255+
}}
256+
/>
257+
</Tooltip>
258+
)}
259+
<Tooltip title={t('Edit Dashboard')}>
260+
<Button
261+
data-test-id="dashboard-edit"
262+
aria-label={t('edit-dashboard')}
263+
onClick={e => {
264+
e.preventDefault();
265+
onEdit();
266+
}}
267+
icon={isSaving ? <LoadingIndicator size={14} /> : <IconEdit />}
268+
disabled={!hasFeature || hasUnsavedFilters || !hasEditAccess || isSaving}
269+
title={
270+
isSaving
271+
? DASHBOARD_SAVING_MESSAGE
272+
: hasEditAccess
273+
? hasUnsavedFilters && UNSAVED_FILTERS_MESSAGE
274+
: t('You do not have permission to edit this dashboard')
275+
}
276+
priority="default"
277+
size="sm"
278+
/>
279+
</Tooltip>
278280
{hasFeature ? (
279281
<Tooltip
280282
title={tooltipMessage}
@@ -288,7 +290,7 @@ function Controls({
288290
'aria-label': t('Add Widget'),
289291
size: 'sm',
290292
showChevron: true,
291-
icon: <IconAdd isCircled size="sm" />,
293+
icon: <IconAdd size="sm" />,
292294
priority: 'primary',
293295
}}
294296
position="bottom-end"

static/app/views/dashboards/detail.spec.tsx

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ describe('Dashboards > Detail', () => {
486486
await waitFor(() => expect(mockVisit).toHaveBeenCalledTimes(1));
487487

488488
// Enter edit mode.
489-
await userEvent.click(screen.getByRole('button', {name: 'Edit Dashboard'}));
489+
await userEvent.click(screen.getByRole('button', {name: 'edit-dashboard'}));
490490

491491
// Remove the second and third widgets
492492
await userEvent.click(
@@ -585,7 +585,7 @@ describe('Dashboards > Detail', () => {
585585
);
586586

587587
// Enter edit mode.
588-
await userEvent.click(await screen.findByRole('button', {name: 'Edit Dashboard'}));
588+
await userEvent.click(await screen.findByRole('button', {name: 'edit-dashboard'}));
589589
expect(await screen.findByRole('button', {name: 'Add Widget'})).toBeInTheDocument();
590590
});
591591

@@ -657,7 +657,7 @@ describe('Dashboards > Detail', () => {
657657
);
658658

659659
// Enter edit mode.
660-
await userEvent.click(await screen.findByRole('button', {name: 'Edit Dashboard'}));
660+
await userEvent.click(await screen.findByRole('button', {name: 'edit-dashboard'}));
661661
expect(screen.queryByRole('button', {name: 'Add widget'})).not.toBeInTheDocument();
662662
});
663663

@@ -773,10 +773,10 @@ describe('Dashboards > Detail', () => {
773773
}
774774
);
775775

776-
await userEvent.click(await screen.findByText('Edit Dashboard'));
776+
await userEvent.click(await screen.findByRole('button', {name: 'edit-dashboard'}));
777777
await userEvent.click(await screen.findByText('Save and Finish'));
778778

779-
expect(screen.getByText('Edit Dashboard')).toBeInTheDocument();
779+
expect(screen.getByRole('button', {name: 'edit-dashboard'})).toBeInTheDocument();
780780
expect(mockPut).not.toHaveBeenCalled();
781781
});
782782

@@ -826,7 +826,7 @@ describe('Dashboards > Detail', () => {
826826
}
827827
);
828828

829-
await userEvent.click(await screen.findByText('Edit Dashboard'));
829+
await userEvent.click(await screen.findByRole('button', {name: 'edit-dashboard'}));
830830
const widget = (await screen.findByText('First Widget')).closest(
831831
'.react-grid-item'
832832
) as HTMLElement;
@@ -882,7 +882,7 @@ describe('Dashboards > Detail', () => {
882882
}
883883
);
884884

885-
await userEvent.click(await screen.findByText('Edit Dashboard'));
885+
await userEvent.click(await screen.findByRole('button', {name: 'edit-dashboard'}));
886886
await userEvent.click(await screen.findByText('Cancel'));
887887

888888
expect(window.confirm).not.toHaveBeenCalled();
@@ -1476,7 +1476,7 @@ describe('Dashboards > Detail', () => {
14761476
);
14771477
});
14781478

1479-
it('disables the Edit Dashboard button when there are unsaved filters', async () => {
1479+
it('disables the edit-dashboard button when there are unsaved filters', async () => {
14801480
const router = RouterFixture({
14811481
location: {
14821482
...LocationFixture(),
@@ -1534,7 +1534,7 @@ describe('Dashboards > Detail', () => {
15341534

15351535
expect(await screen.findByText('Save')).toBeInTheDocument();
15361536
expect(screen.getByTestId('filter-bar-cancel')).toBeInTheDocument();
1537-
expect(screen.getByRole('button', {name: 'Edit Dashboard'})).toBeDisabled();
1537+
expect(screen.getByRole('button', {name: 'edit-dashboard'})).toBeDisabled();
15381538
});
15391539

15401540
it('ignores the order of selection of page filters to render unsaved filters', async () => {
@@ -1875,9 +1875,9 @@ describe('Dashboards > Detail', () => {
18751875
}
18761876
);
18771877

1878-
await userEvent.click(await screen.findByText('Edit Access:'));
1878+
await userEvent.click(await screen.findByText('Editors:'));
18791879
expect(screen.getByText('Creator')).toBeInTheDocument();
1880-
expect(screen.getByText('All users')).toBeInTheDocument();
1880+
expect(screen.getByText('All Users')).toBeInTheDocument();
18811881
});
18821882

18831883
it('creates and updates new permissions for dashboard with no edit perms initialized', async () => {
@@ -1906,16 +1906,16 @@ describe('Dashboards > Detail', () => {
19061906
deprecatedRouterMocks: true,
19071907
}
19081908
);
1909-
await userEvent.click(await screen.findByText('Edit Access:'));
1909+
await userEvent.click(await screen.findByText('Editors:'));
19101910

19111911
// deselects 'All users' so only creator has edit access
1912-
expect(await screen.findByText('All users')).toBeEnabled();
1913-
expect(await screen.findByRole('option', {name: 'All users'})).toHaveAttribute(
1912+
expect(await screen.findByText('All Users')).toBeEnabled();
1913+
expect(await screen.findByRole('option', {name: 'All Users'})).toHaveAttribute(
19141914
'aria-selected',
19151915
'true'
19161916
);
1917-
await userEvent.click(screen.getByRole('option', {name: 'All users'}));
1918-
expect(await screen.findByRole('option', {name: 'All users'})).toHaveAttribute(
1917+
await userEvent.click(screen.getByRole('option', {name: 'All Users'}));
1918+
expect(await screen.findByRole('option', {name: 'All Users'})).toHaveAttribute(
19191919
'aria-selected',
19201920
'false'
19211921
);
@@ -1973,16 +1973,16 @@ describe('Dashboards > Detail', () => {
19731973
deprecatedRouterMocks: true,
19741974
}
19751975
);
1976-
await userEvent.click(await screen.findByText('Edit Access:'));
1976+
await userEvent.click(await screen.findByText('Editors:'));
19771977

19781978
// selects 'All users' so everyone has edit access
1979-
expect(await screen.findByText('All users')).toBeEnabled();
1980-
expect(await screen.findByRole('option', {name: 'All users'})).toHaveAttribute(
1979+
expect(await screen.findByText('All Users')).toBeEnabled();
1980+
expect(await screen.findByRole('option', {name: 'All Users'})).toHaveAttribute(
19811981
'aria-selected',
19821982
'false'
19831983
);
1984-
await userEvent.click(screen.getByRole('option', {name: 'All users'}));
1985-
expect(await screen.findByRole('option', {name: 'All users'})).toHaveAttribute(
1984+
await userEvent.click(screen.getByRole('option', {name: 'All Users'}));
1985+
expect(await screen.findByRole('option', {name: 'All Users'})).toHaveAttribute(
19861986
'aria-selected',
19871987
'true'
19881988
);
@@ -2061,10 +2061,10 @@ describe('Dashboards > Detail', () => {
20612061
deprecatedRouterMocks: true,
20622062
}
20632063
);
2064-
await userEvent.click(await screen.findByText('Edit Access:'));
2064+
await userEvent.click(await screen.findByText('Editors:'));
20652065

2066-
expect(await screen.findByText('All users')).toBeEnabled();
2067-
expect(await screen.findByRole('option', {name: 'All users'})).toHaveAttribute(
2066+
expect(await screen.findByText('All Users')).toBeEnabled();
2067+
expect(await screen.findByRole('option', {name: 'All Users'})).toHaveAttribute(
20682068
'aria-selected',
20692069
'false'
20702070
);
@@ -2136,8 +2136,8 @@ describe('Dashboards > Detail', () => {
21362136
}
21372137
);
21382138

2139-
await screen.findByText('Edit Access:');
2140-
expect(screen.getByRole('button', {name: 'Edit Dashboard'})).toBeDisabled();
2139+
await screen.findByText('Editors:');
2140+
expect(screen.getByRole('button', {name: 'edit-dashboard'})).toBeDisabled();
21412141
expect(screen.getByRole('button', {name: 'Add Widget'})).toBeDisabled();
21422142
});
21432143

@@ -2202,8 +2202,8 @@ describe('Dashboards > Detail', () => {
22022202
}
22032203
);
22042204

2205-
await screen.findByText('Edit Access:');
2206-
expect(screen.getByRole('button', {name: 'Edit Dashboard'})).toBeDisabled();
2205+
await screen.findByText('Editors:');
2206+
expect(screen.getByRole('button', {name: 'edit-dashboard'})).toBeDisabled();
22072207
expect(screen.getByRole('button', {name: 'Add Widget'})).toBeDisabled();
22082208
await userEvent.click(await screen.findByLabelText('Widget actions'));
22092209
expect(
@@ -2219,7 +2219,7 @@ describe('Dashboards > Detail', () => {
22192219
);
22202220
});
22212221

2222-
it('renders favorite button in unfavorited state', async () => {
2222+
it('renders favorite button in Unstard state', async () => {
22232223
const router = RouterFixture({
22242224
location: LocationFixture(),
22252225
params: {orgId: 'org-slug', dashboardId: '1'},
@@ -2248,9 +2248,9 @@ describe('Dashboards > Detail', () => {
22482248
}
22492249
);
22502250

2251-
const favoriteButton = await screen.findByLabelText('dashboards-favourite');
2251+
const favoriteButton = await screen.findByLabelText('star-dashboard');
22522252
expect(favoriteButton).toBeInTheDocument();
2253-
expect(await screen.findByLabelText('Favorite')).toBeInTheDocument();
2253+
expect(await screen.findByLabelText('Star')).toBeInTheDocument();
22542254
});
22552255

22562256
it('renders favorite button in favorited state', async () => {
@@ -2282,9 +2282,9 @@ describe('Dashboards > Detail', () => {
22822282
}
22832283
);
22842284

2285-
const favoriteButton = await screen.findByLabelText('dashboards-favourite');
2285+
const favoriteButton = await screen.findByLabelText('star-dashboard');
22862286
expect(favoriteButton).toBeInTheDocument();
2287-
expect(await screen.findByLabelText('UnFavorite')).toBeInTheDocument();
2287+
expect(await screen.findByLabelText('Unstar')).toBeInTheDocument();
22882288
});
22892289

22902290
it('toggles favorite button', async () => {
@@ -2322,12 +2322,12 @@ describe('Dashboards > Detail', () => {
23222322
}
23232323
);
23242324

2325-
const favoriteButton = await screen.findByLabelText('dashboards-favourite');
2325+
const favoriteButton = await screen.findByLabelText('star-dashboard');
23262326
expect(favoriteButton).toBeInTheDocument();
23272327

2328-
expect(await screen.findByLabelText('UnFavorite')).toBeInTheDocument();
2328+
expect(await screen.findByLabelText('Unstar')).toBeInTheDocument();
23292329
await userEvent.click(favoriteButton);
2330-
expect(await screen.findByLabelText('Favorite')).toBeInTheDocument();
2330+
expect(await screen.findByLabelText('Star')).toBeInTheDocument();
23312331
});
23322332

23332333
describe('widget builder redesign', () => {

0 commit comments

Comments
 (0)