Skip to content

Commit

Permalink
fix(dashboards): Updates metric widget context menu to also hide and …
Browse files Browse the repository at this point in the history
…show on hover (#78379)

Extends the hover/focus to show widget menu
feature to also work on
metric widgets
  • Loading branch information
edwardgou-sentry authored Oct 1, 2024
1 parent 19c98eb commit 6c126ab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
48 changes: 27 additions & 21 deletions static/app/views/dashboards/metrics/widgetCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ import {
} from 'sentry/views/dashboards/metrics/utils';
import type {DashboardFilters, Widget} from 'sentry/views/dashboards/types';
import {DisplayType} from 'sentry/views/dashboards/types';
import {WidgetCardPanel, WidgetTitleRow} from 'sentry/views/dashboards/widgetCard';
import {
WidgetCardContextMenuContainer,
WidgetCardPanel,
WidgetTitleRow,
} from 'sentry/views/dashboards/widgetCard';
import {DashboardsMEPContext} from 'sentry/views/dashboards/widgetCard/dashboardsMEPContext';
import {Toolbar} from 'sentry/views/dashboards/widgetCard/toolbar';
import WidgetCardContextMenu from 'sentry/views/dashboards/widgetCard/widgetCardContextMenu';
Expand Down Expand Up @@ -196,26 +200,28 @@ export function MetricWidgetCard({

<ContextMenuWrapper>
{showContextMenu && !isEditingDashboard && (
<WidgetCardContextMenu
organization={organization}
widget={widget}
selection={selection}
showContextMenu
isPreview={false}
widgetLimitReached={false}
onEdit={() => {
router.push({
pathname: `${location.pathname}${
location.pathname.endsWith('/') ? '' : '/'
}widget/${widget.id}/`,
query: location.query,
});
}}
router={router}
location={location}
onDelete={onDelete}
onDuplicate={onDuplicate}
/>
<WidgetCardContextMenuContainer>
<WidgetCardContextMenu
organization={organization}
widget={widget}
selection={selection}
showContextMenu
isPreview={false}
widgetLimitReached={false}
onEdit={() => {
router.push({
pathname: `${location.pathname}${
location.pathname.endsWith('/') ? '' : '/'
}widget/${widget.id}/`,
query: location.query,
});
}}
router={router}
location={location}
onDelete={onDelete}
onDuplicate={onDuplicate}
/>
</WidgetCardContextMenuContainer>
)}
</ContextMenuWrapper>
</WidgetHeaderWrapper>
Expand Down
8 changes: 4 additions & 4 deletions static/app/views/dashboards/widgetCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class WidgetCard extends Component<Props, State> {
}

return (
<StyledWidgetCardContextMenuContainer>
<WidgetCardContextMenuContainer>
<WidgetCardContextMenu
organization={organization}
widget={widget}
Expand All @@ -192,7 +192,7 @@ class WidgetCard extends Component<Props, State> {
description={widget.description}
title={widget.title}
/>
</StyledWidgetCardContextMenuContainer>
</WidgetCardContextMenuContainer>
);
}

Expand Down Expand Up @@ -493,7 +493,7 @@ const ErrorCard = styled(Placeholder)`
margin-bottom: ${space(2)};
`;

const StyledWidgetCardContextMenuContainer = styled('div')`
export const WidgetCardContextMenuContainer = styled('div')`
opacity: 1;
transition: opacity 0.1s;
`;
Expand All @@ -512,7 +512,7 @@ export const WidgetCardPanel = styled(Panel, {
flex-direction: column;
&:not(:hover):not(:focus-within) {
${StyledWidgetCardContextMenuContainer} {
${WidgetCardContextMenuContainer} {
opacity: 0;
clip: rect(0 0 0 0);
clip-path: inset(50%);
Expand Down

0 comments on commit 6c126ab

Please sign in to comment.