|
1 | 1 | import {useMemo} from 'react';
|
2 |
| -import styled from '@emotion/styled'; |
3 | 2 | import * as Sentry from '@sentry/react';
|
4 | 3 |
|
5 | 4 | import {openAddToDashboardModal, openModal} from 'sentry/actionCreators/modal';
|
6 | 5 | import {navigateTo} from 'sentry/actionCreators/navigation';
|
7 | 6 | import Feature from 'sentry/components/acl/feature';
|
| 7 | +import FeatureDisabled from 'sentry/components/acl/featureDisabled'; |
8 | 8 | import type {MenuItemProps} from 'sentry/components/dropdownMenu';
|
9 | 9 | import {DropdownMenu} from 'sentry/components/dropdownMenu';
|
| 10 | +import {Hovercard} from 'sentry/components/hovercard'; |
10 | 11 | import {CreateMetricAlertFeature} from 'sentry/components/metrics/createMetricAlertFeature';
|
11 | 12 | import {
|
12 | 13 | IconClose,
|
@@ -66,6 +67,7 @@ export function MetricQueryContextMenu({
|
66 | 67 |
|
67 | 68 | // At least one query must remain
|
68 | 69 | const canDelete = widgets.filter(isMetricsQueryWidget).length > 1;
|
| 70 | + const hasDashboardFeature = organization.features.includes('dashboards-edit'); |
69 | 71 |
|
70 | 72 | const items = useMemo<MenuItemProps[]>(
|
71 | 73 | () => [
|
@@ -103,15 +105,24 @@ export function MetricQueryContextMenu({
|
103 | 105 | organization={organization}
|
104 | 106 | hookName="feature-disabled:dashboards-edit"
|
105 | 107 | features="dashboards-edit"
|
106 |
| - > |
107 |
| - {({hasFeature}) => ( |
108 |
| - <AddToDashboardItem disabled={!hasFeature}> |
109 |
| - {t('Add to Dashboard')} |
110 |
| - </AddToDashboardItem> |
| 108 | + renderDisabled={p => ( |
| 109 | + <Hovercard |
| 110 | + body={ |
| 111 | + <FeatureDisabled |
| 112 | + features={p.features} |
| 113 | + hideHelpToggle |
| 114 | + featureName={t('Metric Alerts')} |
| 115 | + /> |
| 116 | + } |
| 117 | + > |
| 118 | + {typeof p.children === 'function' ? p.children(p) : p.children} |
| 119 | + </Hovercard> |
111 | 120 | )}
|
| 121 | + > |
| 122 | + <span>{t('Add to Dashboard')}</span> |
112 | 123 | </Feature>
|
113 | 124 | ),
|
114 |
| - disabled: !createDashboardWidget, |
| 125 | + disabled: !createDashboardWidget || !hasDashboardFeature, |
115 | 126 | onAction: () => {
|
116 | 127 | if (!organization.features.includes('dashboards-edit')) {
|
117 | 128 | return;
|
@@ -155,10 +166,11 @@ export function MetricQueryContextMenu({
|
155 | 166 | ],
|
156 | 167 | [
|
157 | 168 | createAlert,
|
| 169 | + organization, |
158 | 170 | createDashboardWidget,
|
| 171 | + hasDashboardFeature, |
159 | 172 | metricsQuery.mri,
|
160 | 173 | canDelete,
|
161 |
| - organization, |
162 | 174 | duplicateWidget,
|
163 | 175 | widgetIndex,
|
164 | 176 | router,
|
@@ -235,7 +247,3 @@ export function useCreateDashboardWidget(
|
235 | 247 | });
|
236 | 248 | }, [metricsQuery, selection, displayType, organization, router]);
|
237 | 249 | }
|
238 |
| - |
239 |
| -const AddToDashboardItem = styled('div')<{disabled: boolean}>` |
240 |
| - color: ${p => (p.disabled ? p.theme.disabled : p.theme.textColor)}; |
241 |
| -`; |
|
0 commit comments