Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboards): Add releases overlay on dashboard charts #77947

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
15 changes: 9 additions & 6 deletions static/app/components/modals/widgetViewerModal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ describe('Modals -> WidgetViewerModal', function () {
query: {
viewerEnd: '2022-03-01T07:33:20',
viewerStart: '2022-03-01T02:00:00',
unselectedSeries: 'Releases',
},
})
)
Expand All @@ -336,7 +337,7 @@ describe('Modals -> WidgetViewerModal', function () {
expect(initialData.router.replace).toHaveBeenCalledWith(
expect.objectContaining({
pathname: '/mock-pathname/',
query: {query: 1},
query: {query: 1, unselectedSeries: 'Releases'},
})
);
// Need to manually set the new router location and rerender to simulate the dropdown selection click
Expand Down Expand Up @@ -370,13 +371,13 @@ describe('Modals -> WidgetViewerModal', function () {
it('renders with first legend disabled by default', async function () {
mockEvents();
// Rerender with first legend disabled
initialData.router.location.query = {legend: ['Query Name']};
initialData.router.location.query = {legend: ['Query Name', 'Releases']};
await renderModal({initialData, widget: mockWidget});
expect(ReactEchartsCore).toHaveBeenLastCalledWith(
expect.objectContaining({
option: expect.objectContaining({
legend: expect.objectContaining({
selected: {'Query Name': false},
selected: {Releases: false},
}),
}),
}),
Expand Down Expand Up @@ -463,6 +464,7 @@ describe('Modals -> WidgetViewerModal', function () {
query: {
viewerEnd: '2022-03-01T05:53:20',
viewerStart: '2022-03-01T03:40:00',
unselectedSeries: 'Releases',
},
})
)
Expand Down Expand Up @@ -753,7 +755,7 @@ describe('Modals -> WidgetViewerModal', function () {
expect(initialData.router.push).toHaveBeenCalledWith(
expect.objectContaining({
pathname: '/mock-pathname/',
query: {sort: '-count()'},
query: {sort: '-count()', unselectedSeries: 'Releases'},
})
);
// Need to manually set the new router location and rerender to simulate the sortable column click
Expand Down Expand Up @@ -829,7 +831,7 @@ describe('Modals -> WidgetViewerModal', function () {
await userEvent.click(screen.getByRole('button', {name: 'Next'}));
expect(initialData.router.replace).toHaveBeenCalledWith(
expect.objectContaining({
query: {cursor: '0:10:0'},
query: {cursor: '0:10:0', unselectedSeries: 'Releases'},
})
);
// Need to manually set the new router location and rerender to simulate the next page click
Expand Down Expand Up @@ -919,6 +921,7 @@ describe('Modals -> WidgetViewerModal', function () {
query: {
viewerEnd: '2022-03-01T05:53:20',
viewerStart: '2022-03-01T03:40:00',
unselectedSeries: 'Releases',
},
})
);
Expand Down Expand Up @@ -1388,7 +1391,7 @@ describe('Modals -> WidgetViewerModal', function () {
expect(initialData.router.push).toHaveBeenCalledWith(
expect.objectContaining({
pathname: '/mock-pathname/',
query: {sort: '-sum(session)'},
query: {sort: '-sum(session)', unselectedSeries: 'Releases'},
})
);
// Need to manually set the new router location and rerender to simulate the sortable column click
Expand Down
4 changes: 4 additions & 0 deletions static/app/components/modals/widgetViewerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface WidgetViewerModalOptions {
onEdit?: () => void;
onMetricWidgetEdit?: (widget: Widget) => void;
pageLinks?: string;
releaseSeries?: Series[];
seriesData?: Series[];
seriesResultsType?: Record<string, AggregationOutputType>;
tableData?: TableDataWithTitle[];
Expand Down Expand Up @@ -181,6 +182,7 @@ function WidgetViewerModal(props: Props) {
pageLinks: defaultPageLinks,
seriesResultsType,
dashboardFilters,
releaseSeries,
} = props;
const location = useLocation();
const {projects} = useProjects();
Expand Down Expand Up @@ -870,6 +872,7 @@ function WidgetViewerModal(props: Props) {
showSlider={shouldShowSlider}
noPadding
chartZoomOptions={chartZoomOptions}
releaseSeries={releaseSeries}
/>
) : (
<MemoizedWidgetCardChartContainer
Expand All @@ -887,6 +890,7 @@ function WidgetViewerModal(props: Props) {
showSlider={shouldShowSlider}
noPadding
chartZoomOptions={chartZoomOptions}
releaseSeries={releaseSeries}
/>
)}
</Container>
Expand Down
8 changes: 7 additions & 1 deletion static/app/views/dashboards/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {t} from 'sentry/locale';
import GroupStore from 'sentry/stores/groupStore';
import {space} from 'sentry/styles/space';
import type {PageFilters} from 'sentry/types/core';
import type {Series} from 'sentry/types/echarts';
import type {InjectedRouter} from 'sentry/types/legacyReactRouter';
import type {Organization} from 'sentry/types/organization';
import {trackAnalytics} from 'sentry/utils/analytics';
Expand Down Expand Up @@ -53,7 +54,7 @@ import {
} from './layoutUtils';
import SortableWidget from './sortableWidget';
import type {DashboardDetails, Widget} from './types';
import {DashboardWidgetSource, WidgetType} from './types';
import {DashboardWidgetSource, DisplayType, WidgetType} from './types';
import {connectDashboardCharts, getDashboardFiltersFromURL} from './utils';

export const DRAG_HANDLE_CLASS = 'widget-drag';
Expand Down Expand Up @@ -94,6 +95,7 @@ type Props = {
onSetNewWidget?: () => void;
paramDashboardId?: string;
paramTemplateId?: string;
releaseSeries?: Series[];
};

type State = {
Expand Down Expand Up @@ -398,6 +400,10 @@ class Dashboard extends Component<Props, State> {
isPreview,

dashboardFilters: getDashboardFiltersFromURL(location) ?? dashboard.filters,
releaseSeries:
widget.displayType === DisplayType.AREA || widget.displayType === DisplayType.LINE
? this.props.releaseSeries
: undefined,
};

const key = constructGridItemKey(widget);
Expand Down
8 changes: 8 additions & 0 deletions static/app/views/dashboards/detail.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ describe('Dashboards > Detail', function () {
});
const projects = [ProjectFixture()];

beforeEach(function () {
MockApiClient.addMockResponse({
method: 'GET',
url: '/organizations/org-slug/releases/stats/',
body: [],
});
});

describe('prebuilt dashboards', function () {
let initialData;

Expand Down
Loading
Loading