Skip to content
Merged
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
49 changes: 11 additions & 38 deletions static/app/views/dashboards/manage/dashboardGrid.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {DashboardListItemFixture} from 'sentry-fixture/dashboard';
import {LocationFixture} from 'sentry-fixture/locationFixture';
import {OrganizationFixture} from 'sentry-fixture/organization';
import {UserFixture} from 'sentry-fixture/user';

import {initializeOrg} from 'sentry-test/initializeOrg';
import {
render,
renderGlobalModal,
Expand All @@ -25,8 +23,6 @@ describe('Dashboards - DashboardGrid', () => {
features: ['dashboards-basic', 'dashboards-edit', 'discover-query'],
});

const {router} = initializeOrg();

beforeEach(() => {
MockApiClient.clearMockResponses();

Expand Down Expand Up @@ -106,7 +102,6 @@ describe('Dashboards - DashboardGrid', () => {
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={[]}
location={router.location}
columnCount={3}
rowCount={3}
/>
Expand All @@ -124,7 +119,6 @@ describe('Dashboards - DashboardGrid', () => {
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
location={router.location}
columnCount={3}
rowCount={3}
/>
Expand All @@ -140,7 +134,6 @@ describe('Dashboards - DashboardGrid', () => {
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
location={router.location}
columnCount={3}
rowCount={3}
/>
Expand All @@ -156,42 +149,28 @@ describe('Dashboards - DashboardGrid', () => {
);
});

it('persists global selection headers', () => {
it('does not forward query params from the list page to dashboard links', () => {
render(
<DashboardGrid
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
location={{...LocationFixture(), query: {statsPeriod: '7d'}}}
columnCount={3}
rowCount={3}
/>
);

expect(screen.getByRole('link', {name: 'Dashboard 1'})).toHaveAttribute(
'href',
'/organizations/org-slug/dashboard/1/?statsPeriod=7d'
);
});

it('does not forward search query parameter to dashboard links', () => {
render(
<DashboardGrid
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
location={{
...LocationFixture(),
query: {query: 'agent', statsPeriod: '7d'},
}}
columnCount={3}
rowCount={3}
/>
/>,
{
initialRouterConfig: {
location: {
pathname: '/organizations/org-slug/dashboards/',
query: {sort: 'title', query: 'agent'},
},
},
}
);

expect(screen.getByRole('link', {name: 'Dashboard 1'})).toHaveAttribute(
'href',
'/organizations/org-slug/dashboard/1/?statsPeriod=7d'
'/organizations/org-slug/dashboard/1/'
);
});

Expand All @@ -200,7 +179,6 @@ describe('Dashboards - DashboardGrid', () => {
<DashboardGrid
organization={organization}
dashboards={dashboards}
location={{...LocationFixture(), query: {}}}
onDashboardsChange={dashboardUpdateMock}
columnCount={3}
rowCount={3}
Expand Down Expand Up @@ -239,7 +217,6 @@ describe('Dashboards - DashboardGrid', () => {
<DashboardGrid
organization={organization}
dashboards={singleDashboard}
location={LocationFixture()}
onDashboardsChange={dashboardUpdateMock}
columnCount={3}
rowCount={3}
Expand All @@ -258,7 +235,6 @@ describe('Dashboards - DashboardGrid', () => {
<DashboardGrid
organization={organization}
dashboards={dashboards}
location={{...LocationFixture(), query: {}}}
onDashboardsChange={dashboardUpdateMock}
columnCount={3}
rowCount={3}
Expand Down Expand Up @@ -294,7 +270,6 @@ describe('Dashboards - DashboardGrid', () => {
<DashboardGrid
organization={organization}
dashboards={dashboards}
location={{...LocationFixture(), query: {}}}
onDashboardsChange={dashboardUpdateMock}
columnCount={3}
rowCount={3}
Expand Down Expand Up @@ -340,7 +315,6 @@ describe('Dashboards - DashboardGrid', () => {
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
location={router.location}
columnCount={3}
rowCount={3}
/>,
Expand Down Expand Up @@ -383,7 +357,6 @@ describe('Dashboards - DashboardGrid', () => {
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
location={router.location}
columnCount={3}
rowCount={3}
/>,
Expand Down
15 changes: 1 addition & 14 deletions static/app/views/dashboards/manage/dashboardGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Fragment, useEffect, useState} from 'react';
import styled from '@emotion/styled';
import type {Location} from 'history';
import isEqual from 'lodash/isEqual';

import {Button} from '@sentry/scraps/button';
Expand Down Expand Up @@ -36,7 +35,6 @@ type Props = {
api: Client;
columnCount: number;
dashboards: DashboardListItem[] | undefined;
location: Location;
onDashboardsChange: () => void;
organization: Organization;
rowCount: number;
Expand All @@ -46,7 +44,6 @@ type Props = {
function DashboardGrid({
api,
organization,
location,
dashboards,
onDashboardsChange,
rowCount,
Expand Down Expand Up @@ -167,13 +164,6 @@ function DashboardGrid({
return <GridPreview widgetPreview={dashboard.widgetPreview} />;
}

// TODO(__SENTRY_USING_REACT_ROUTER_SIX): We can remove this later, react
// router 6 handles empty query objects without appending a trailing ?
const {query: _searchQuery, ...queryWithoutSearch} = location.query;
const queryLocation = {
...(Object.keys(queryWithoutSearch).length > 0 ? {query: queryWithoutSearch} : {}),
};

function renderMiniDashboards() {
// on pagination, render no dashboards to show placeholders while loading
if (
Expand All @@ -189,10 +179,7 @@ function DashboardGrid({
{dashboardLimitData => (
<DashboardCard
title={dashboard.title}
to={{
pathname: `/organizations/${organization.slug}/dashboard/${dashboard.id}/`,
...queryLocation,
}}
to={`/organizations/${organization.slug}/dashboard/${dashboard.id}/`}
detail={tn('%s widget', '%s widgets', dashboard.widgetPreview.length)}
dateStatus={
dashboard.dateCreated ? (
Expand Down
22 changes: 3 additions & 19 deletions static/app/views/dashboards/manage/dashboardTable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,38 +155,22 @@ describe('Dashboards - DashboardTable', () => {
);
});

it('persists global selection headers', async () => {
render(
<DashboardTable
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
location={{...LocationFixture(), query: {statsPeriod: '7d'}}}
/>
);

expect(await screen.findByRole('link', {name: 'Dashboard 1'})).toHaveAttribute(
'href',
'/organizations/org-slug/dashboard/1/?statsPeriod=7d'
);
});

it('does not forward search query parameter to dashboard links', async () => {
it('does not forward query params from the list page to dashboard links', async () => {
render(
<DashboardTable
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
location={{
...LocationFixture(),
query: {query: 'agent', statsPeriod: '7d'},
query: {sort: 'title', query: 'agent', statsPeriod: '7d'},
}}
/>
);

expect(await screen.findByRole('link', {name: 'Dashboard 1'})).toHaveAttribute(
'href',
'/organizations/org-slug/dashboard/1/?statsPeriod=7d'
'/organizations/org-slug/dashboard/1/'
);
});

Expand Down
14 changes: 1 addition & 13 deletions static/app/views/dashboards/manage/dashboardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ function DashboardTable({
{key: ResponseKeys.CREATED, name: t('Created'), width: COL_WIDTH_UNDEFINED},
];

// TODO(__SENTRY_USING_REACT_ROUTER_SIX): We can remove this later, react
// router 6 handles empty query objects without appending a trailing ?
const {query: _searchQuery, ...queryWithoutSearch} = location.query;
const queryLocation = {
...(Object.keys(queryWithoutSearch).length > 0 ? {query: queryWithoutSearch} : {}),
};

function renderHeadCell(column: GridColumnOrder<string>) {
if (column.key in SortKeys) {
const urlSort = decodeScalar(location.query.sort, 'mydashboards');
Expand Down Expand Up @@ -212,12 +205,7 @@ function DashboardTable({
if (column.key === ResponseKeys.NAME) {
return (
<Text ellipsis variant="accent">
<Link
to={{
pathname: `/organizations/${organization.slug}/dashboard/${dataRow.id}/`,
...queryLocation,
}}
>
<Link to={`/organizations/${organization.slug}/dashboard/${dataRow.id}/`}>
{dataRow[ResponseKeys.NAME]}
</Link>
</Text>
Expand Down
5 changes: 1 addition & 4 deletions static/app/views/dashboards/manage/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ describe('Dashboards > Detail', () => {

await userEvent.click(await screen.findByTestId('dashboard-create'));

expect(mockNavigate).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/dashboards/new/',
query: {},
});
expect(mockNavigate).toHaveBeenCalledWith('/organizations/org-slug/dashboards/new/');
});

it('can sort', async () => {
Expand Down
20 changes: 3 additions & 17 deletions static/app/views/dashboards/manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ function ManageDashboards() {
api={api}
dashboards={dashboards}
organization={organization}
location={location}
onDashboardsChange={() => refetchDashboards()}
isLoading={isLoading}
rowCount={rowCount}
Expand Down Expand Up @@ -543,19 +542,12 @@ function ManageDashboards() {
);
}

const {query: _query, ...queryWithoutSearch} = location.query;

function onCreate() {
trackAnalytics('dashboards_manage.create.start', {
organization,
});

navigate(
normalizeUrl({
pathname: `/organizations/${organization.slug}/dashboards/new/`,
query: queryWithoutSearch,
})
);
navigate(normalizeUrl(`/organizations/${organization.slug}/dashboards/new/`));
}

async function onAdd(dashboard: DashboardDetails) {
Expand All @@ -578,10 +570,7 @@ function ManageDashboards() {

function loadDashboard(dashboardId: string) {
navigate(
normalizeUrl({
pathname: `/organizations/${organization.slug}/dashboards/${dashboardId}/`,
query: queryWithoutSearch,
})
normalizeUrl(`/organizations/${organization.slug}/dashboards/${dashboardId}/`)
);
}

Expand All @@ -592,10 +581,7 @@ function ManageDashboards() {
});

navigate(
normalizeUrl({
pathname: `/organizations/${organization.slug}/dashboards/new/${dashboardId}/`,
query: queryWithoutSearch,
})
normalizeUrl(`/organizations/${organization.slug}/dashboards/new/${dashboardId}/`)
);
}

Expand Down
Loading