Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,14 @@ export function GlobalCommandPaletteActions() {
</CMDKAction>

<CMDKAction display={{label: t('Dashboards'), icon: <IconDashboard />}} limit={4}>
{hasPrebuiltDashboards && (
<CMDKAction
display={{label: t('All Dashboards')}}
to={`${prefix}/dashboards/?filter=${DashboardFilter.ALL}`}
/>
)}
<CMDKAction
display={{label: t('All Dashboards')}}
display={{label: t('Custom Dashboards')}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a bit more precise here to do something like

Suggested change
display={{label: t('Custom Dashboards')}}
display={{label: hasPrebuiltDashboards ? t('Custom Dashboards') : t ('All Dashboards')}}

to={`${prefix}/dashboards/`}
/>
{hasPrebuiltDashboards && (
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/dashboards/manage/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Dashboards > Detail', () => {
organization: mockAuthorizedOrg,
});

expect(await screen.findByText('All Dashboards')).toBeInTheDocument();
expect(await screen.findByText('Custom Dashboards')).toBeInTheDocument();

expect(await screen.findByText('Test Dashboard')).toBeInTheDocument();

Expand Down
31 changes: 20 additions & 11 deletions static/app/views/dashboards/manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ import {
OWNED_CURSOR_KEY,
OwnedDashboardsTable,
} from 'sentry/views/dashboards/manage/tableView/ownedDashboardsTable';
import type {DashboardsLayout} from 'sentry/views/dashboards/manage/types';
import {type DashboardsLayout, DashboardsTab} from 'sentry/views/dashboards/manage/types';
import {getDashboardsTab} from 'sentry/views/dashboards/manage/utils/getDashboardsTab';
import {DashboardFilter, PREBUILT_DASHBOARD_LABEL} from 'sentry/views/dashboards/types';
import {PREBUILT_DASHBOARDS} from 'sentry/views/dashboards/utils/prebuiltConfigs';
import {TopBar} from 'sentry/views/navigation/topBar';
Expand All @@ -72,6 +73,18 @@ export const LAYOUT_KEY = 'dashboards-overview-layout';
const GRID = 'grid';
const TABLE = 'table';

const DASHBOARDS_TAB_TITLES: Record<DashboardsTab, string> = {
[DashboardsTab.CUSTOM]: t('Custom Dashboards'),
[DashboardsTab.ALL]: t('All Dashboards'),
[DashboardsTab.PREBUILT]: PREBUILT_DASHBOARD_LABEL,
};

const DASHBOARDS_TAB_API_QUERY: Record<DashboardsTab, {filter?: DashboardFilter}> = {
[DashboardsTab.CUSTOM]: {filter: DashboardFilter.EXCLUDE_PREBUILT},
[DashboardsTab.ALL]: {},
[DashboardsTab.PREBUILT]: {filter: DashboardFilter.ONLY_PREBUILT},
};

function getDashboardsOverviewLayout(): DashboardsLayout {
const dashboardsLayout = localStorageWrapper.getItem(LAYOUT_KEY);

Expand Down Expand Up @@ -156,8 +169,9 @@ function ManageDashboards() {
'dashboards-prebuilt-insights-dashboards'
);
const urlFilter = decodeScalar(location.query.filter) as DashboardFilter | undefined;
const isOnlyPrebuilt =
hasPrebuiltDashboards && urlFilter === DashboardFilter.ONLY_PREBUILT;
const dashboardsTab = getDashboardsTab(hasPrebuiltDashboards, urlFilter);
const isOnlyPrebuilt = dashboardsTab === DashboardsTab.PREBUILT;
const pageTitle = DASHBOARDS_TAB_TITLES[dashboardsTab];

const areAiFeaturesAllowed =
!organization.hideAiFeatures && organization.features.includes('gen-ai-features');
Expand Down Expand Up @@ -193,9 +207,7 @@ function ManageDashboards() {
pin: 'favorites',
per_page:
dashboardsLayout === GRID ? rowCount * columnCount : DASHBOARD_TABLE_NUM_ROWS,
...(isOnlyPrebuilt
? {filter: DashboardFilter.ONLY_PREBUILT}
: {filter: DashboardFilter.EXCLUDE_PREBUILT}),
...DASHBOARDS_TAB_API_QUERY[dashboardsTab],
},
}),
select: selectJsonWithHeaders,
Expand Down Expand Up @@ -601,10 +613,7 @@ function ManageDashboards() {
features="dashboards-edit"
renderDisabled={renderNoAccess}
>
<SentryDocumentTitle
title={isOnlyPrebuilt ? PREBUILT_DASHBOARD_LABEL : t('All Dashboards')}
orgSlug={organization.slug}
>
<SentryDocumentTitle title={pageTitle} orgSlug={organization.slug}>
<ErrorBoundary>
{isError ? (
<Stack flex={1} padding="2xl 3xl">
Expand All @@ -616,7 +625,7 @@ function ManageDashboards() {
<Layout.Header unified>
<Layout.HeaderContent unified>
<Layout.Title>
{isOnlyPrebuilt ? PREBUILT_DASHBOARD_LABEL : t('All Dashboards')}
{pageTitle}
<PageHeadingQuestionTooltip
docsUrl="https://docs.sentry.io/product/dashboards/"
title={
Expand Down
6 changes: 6 additions & 0 deletions static/app/views/dashboards/manage/types.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export type DashboardsLayout = 'grid' | 'table';

export enum DashboardsTab {
CUSTOM = 'custom',
ALL = 'all',
PREBUILT = 'prebuilt',
}
18 changes: 18 additions & 0 deletions static/app/views/dashboards/manage/utils/getDashboardsTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {DashboardsTab} from 'sentry/views/dashboards/manage/types';
import {DashboardFilter} from 'sentry/views/dashboards/types';

export function getDashboardsTab(
hasPrebuiltDashboards: boolean,
urlFilter: DashboardFilter | undefined
): DashboardsTab {
if (!hasPrebuiltDashboards) {
return DashboardsTab.CUSTOM;
}
if (urlFilter === DashboardFilter.ONLY_PREBUILT) {
return DashboardsTab.PREBUILT;
}
if (urlFilter === DashboardFilter.ALL) {
return DashboardsTab.ALL;
}
return DashboardsTab.CUSTOM;
}
1 change: 1 addition & 0 deletions static/app/views/dashboards/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum DashboardFilter {
SHARED = 'shared',
EXCLUDE_PREBUILT = 'excludePrebuilt',
ONLY_PREBUILT = 'onlyPrebuilt',
ALL = 'all',
SHOW_HIDDEN = 'showHidden',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('DashboardsSecondaryNavigation', () => {
expect(await screen.findByText('Dashboard 9999')).toBeInTheDocument();

expect(screen.getAllByRole('link').map(el => el.textContent)).toEqual([
'All Dashboards',
'Custom Dashboards',
'Dashboard 9999',
'Dashboard 1',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {useProjects} from 'sentry/utils/useProjects';
import {useUser} from 'sentry/utils/useUser';
import {useGetStarredDashboards} from 'sentry/views/dashboards/hooks/useGetStarredDashboards';
import {DEFAULT_PREBUILT_SORT} from 'sentry/views/dashboards/manage/settings';
import {DashboardsTab} from 'sentry/views/dashboards/manage/types';
import {getDashboardsTab} from 'sentry/views/dashboards/manage/utils/getDashboardsTab';
import {DashboardFilter, PREBUILT_DASHBOARD_LABEL} from 'sentry/views/dashboards/types';
import type {DashboardListItem} from 'sentry/views/dashboards/types';
import {isPrimaryNavigationLinkActive} from 'sentry/views/navigation/primary/components';
Expand All @@ -30,7 +32,7 @@ export function DashboardsSecondaryNavigation() {
'dashboards-prebuilt-insights-dashboards'
);
const urlFilter = decodeScalar(location.query.filter) as DashboardFilter | undefined;
const isOnlyPrebuilt = urlFilter === DashboardFilter.ONLY_PREBUILT;
const dashboardsTab = getDashboardsTab(hasPrebuiltDashboards, urlFilter);
const isOnDashboardsList = isPrimaryNavigationLinkActive(
`${baseUrl}/`,
location.pathname,
Expand All @@ -45,25 +47,38 @@ export function DashboardsSecondaryNavigation() {
<SecondaryNavigation.Body>
<SecondaryNavigation.Section id="dashboards-all">
<SecondaryNavigation.List>
{hasPrebuiltDashboards ? (
<SecondaryNavigation.ListItem>
<SecondaryNavigation.Link
to={`${baseUrl}/?filter=${DashboardFilter.ALL}`}
isActive={isOnDashboardsList && dashboardsTab === DashboardsTab.ALL}
analyticsItemName="dashboards_all_combined"
>
{t('All Dashboards')}
</SecondaryNavigation.Link>
</SecondaryNavigation.ListItem>
) : null}
<SecondaryNavigation.ListItem>
<SecondaryNavigation.Link
to={`${baseUrl}/`}
end
isActive={
hasPrebuiltDashboards
? isOnDashboardsList && !isOnlyPrebuilt
? isOnDashboardsList && dashboardsTab === DashboardsTab.CUSTOM
: undefined
}
analyticsItemName="dashboards_all"
>
{t('All Dashboards')}
{t('Custom Dashboards')}
Comment thread
DominikB2014 marked this conversation as resolved.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note as above, I think if someone doesn't have pre-built dashboards it should continue to say "All Dashboards", but not a big deal

</SecondaryNavigation.Link>
</SecondaryNavigation.ListItem>
{hasPrebuiltDashboards ? (
<SecondaryNavigation.ListItem>
<SecondaryNavigation.Link
to={`${baseUrl}/?filter=${DashboardFilter.ONLY_PREBUILT}&sort=${DEFAULT_PREBUILT_SORT}`}
isActive={isOnDashboardsList && isOnlyPrebuilt}
isActive={
isOnDashboardsList && dashboardsTab === DashboardsTab.PREBUILT
}
analyticsItemName="dashboards_sentry_built"
>
{PREBUILT_DASHBOARD_LABEL}
Expand Down
Loading