Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 11 additions & 2 deletions static/app/views/dashboards/editAccessSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import type {

interface EditAccessSelectorProps {
dashboard: DashboardDetails | DashboardListItem;
disabled?: boolean;
listOnly?: boolean;
onChangeEditAccess?: (newDashboardPermissions: DashboardPermissions) => void;
}
Expand All @@ -46,6 +47,7 @@ function EditAccessSelector({
dashboard,
onChangeEditAccess,
listOnly = false,
disabled = false,
}: EditAccessSelectorProps) {
const currentUser: User = useUser();
const dashboardCreator: User | undefined = dashboard.createdBy;
Expand Down Expand Up @@ -320,6 +322,7 @@ function EditAccessSelector({
}}
priority="primary"
disabled={
disabled ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Not major, can be done later, but this block is hard to read, maybe we should move dropdownFooterButtons to it's own component, and consolidate some of the disabling logic below.

!userCanEditDashboardPermissions ||
isEqual(getDashboardPermissions(), {
...dashboard.permissions,
Expand Down Expand Up @@ -369,14 +372,20 @@ function EditAccessSelector({
onSearch={debounce(val => void onSearch(val), DEFAULT_DEBOUNCE_DURATION)}
strategy="fixed"
preventOverflowOptions={{mainAxis: false}}
disabled={disabled}
/>
);

const tooltipTitle = disabled
? t('Prebuilt dashboards cannot be edited')
: t('Only the creator of this dashboard can manage editor access');

return (
<Tooltip
title={t('Only the creator of this dashboard can manage editor access')}
title={tooltipTitle}
disabled={
userCanEditDashboardPermissions || isMenuOpen || isCollapsedAvatarTooltipOpen
!disabled &&
(userCanEditDashboardPermissions || isMenuOpen || isCollapsedAvatarTooltipOpen)
}
>
{dropdownMenu}
Expand Down
5 changes: 5 additions & 0 deletions static/app/views/dashboards/manage/dashboardGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {IconEllipsis} from 'sentry/icons';
import {t, tn} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {Organization} from 'sentry/types/organization';
import {defined} from 'sentry/utils';
import {trackAnalytics} from 'sentry/utils/analytics';
import {useQueryClient} from 'sentry/utils/queryClient';
import withApi from 'sentry/utils/withApi';
Expand Down Expand Up @@ -122,6 +123,10 @@ function DashboardGrid({
onConfirm: () => handleDeleteDashboard(dashboard, 'grid'),
});
},
disabled: defined(dashboard.prebuiltId),
tooltip: defined(dashboard.prebuiltId)
? t('Prebuilt dashboards cannot be deleted')
: undefined,
},
];

Expand Down
18 changes: 16 additions & 2 deletions static/app/views/dashboards/manage/dashboardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {Location} from 'history';
import cloneDeep from 'lodash/cloneDeep';

import {Flex} from '@sentry/scraps/layout';
import {Tooltip} from '@sentry/scraps/tooltip/tooltip';

import {
updateDashboardFavorite,
Expand All @@ -27,6 +28,7 @@ import {IconCopy, IconDelete, IconStar} from 'sentry/icons';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {Organization} from 'sentry/types/organization';
import {defined} from 'sentry/utils';
import {trackAnalytics} from 'sentry/utils/analytics';
import {useQueryClient} from 'sentry/utils/queryClient';
import {decodeScalar} from 'sentry/utils/queryString';
Expand Down Expand Up @@ -229,7 +231,11 @@ function DashboardTable({
<UserAvatar hasTooltip user={dataRow[ResponseKeys.OWNER]} size={26} />
</BodyCellContainer>
) : (
<ActivityAvatar type="system" size={26} />
<BodyCellContainer>
<Tooltip title="Sentry">
<ActivityAvatar type="system" size={26} />
</Tooltip>
</BodyCellContainer>
);
}

Expand All @@ -253,6 +259,7 @@ function DashboardTable({
dashboard={dataRow}
onChangeEditAccess={onChangeEditAccess}
listOnly
disabled={defined(dataRow.prebuiltId)} // Prebuilt dashboards cannot be edited
/>
);
}
Expand Down Expand Up @@ -309,7 +316,14 @@ function DashboardTable({
data-test-id="dashboard-delete"
icon={<IconDelete />}
size="sm"
disabled={dashboards && dashboards.length <= 1}
disabled={
(dashboards && dashboards.length <= 1) || defined(dataRow.prebuiltId)
}
title={
defined(dataRow.prebuiltId)
? t('Prebuilt dashboards cannot be deleted')
: undefined
}
/>
</Flex>
</BodyCellContainer>
Expand Down
20 changes: 19 additions & 1 deletion static/app/views/dashboards/manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import OwnedDashboardsTable, {
} from 'sentry/views/dashboards/manage/tableView/ownedDashboardsTable';
import type {DashboardsLayout} from 'sentry/views/dashboards/manage/types';
import type {DashboardDetails, DashboardListItem} from 'sentry/views/dashboards/types';
import {PREBUILT_DASHBOARDS} from 'sentry/views/dashboards/utils/prebuiltConfigs';
import RouteError from 'sentry/views/routeError';

import DashboardGrid from './dashboardGrid';
Expand Down Expand Up @@ -155,7 +156,7 @@ function ManageDashboards() {
});

const {
data: dashboards,
data: dashboardsWithoutPrebuiltConfigs,
isLoading,
isError,
error,
Expand Down Expand Up @@ -183,6 +184,23 @@ function ManageDashboards() {
}
);

const dashboards = dashboardsWithoutPrebuiltConfigs?.map(dashboard => {
if (dashboard.prebuiltId && dashboard.prebuiltId in PREBUILT_DASHBOARDS) {
return {
...dashboard,
widgetDisplay: PREBUILT_DASHBOARDS[dashboard.prebuiltId].widgets.map(
widget => widget.displayType
),
widgetPreview: PREBUILT_DASHBOARDS[dashboard.prebuiltId].widgets.map(widget => ({
displayType: widget.displayType,
layout: widget.layout ?? null,
})),
projects: [],
};
}
return dashboard;
});

const ownedDashboards = useOwnedDashboards({
query: decodeScalar(location.query.query, ''),
cursor: decodeScalar(location.query[OWNED_CURSOR_KEY], ''),
Expand Down
1 change: 1 addition & 0 deletions static/app/views/dashboards/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export type DashboardListItem = {
isFavorited?: boolean;
lastVisited?: string;
permissions?: DashboardPermissions;
prebuiltId?: PrebuiltDashboardId;
};

export enum DashboardFilterKeys {
Expand Down
Loading