Skip to content

Commit 88d91d2

Browse files
edwardgou-sentrybillyvg
authored andcommitted
feat(explore): Update Explore Saved Queries table to use SavedEntityTable component (#89415)
- Refactors the Explore Saved Queries table to use the shared SavedEntityTable component - Updates saved queries query column to display visualization and group by
1 parent abd1c38 commit 88d91d2

File tree

4 files changed

+177
-278
lines changed

4 files changed

+177
-278
lines changed

static/app/components/modals/explore/saveQueryModal.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('SaveQueryModal', function () {
2626
queries={[
2727
{
2828
query: 'span.op:pageload',
29-
visualizes: [{chartType: 1, yAxes: ['avg(span.duration)'], label: 'A'}],
29+
visualizes: [{chartType: 1, yAxes: ['avg(span.duration)']}],
3030
groupBys: ['span.op'],
3131
},
3232
]}
@@ -57,7 +57,7 @@ describe('SaveQueryModal', function () {
5757
queries={[
5858
{
5959
query: 'span.op:pageload',
60-
visualizes: [{chartType: 1, yAxes: ['avg(span.duration)'], label: 'A'}],
60+
visualizes: [{chartType: 1, yAxes: ['avg(span.duration)']}],
6161
groupBys: ['span.op'],
6262
},
6363
]}
@@ -85,7 +85,7 @@ describe('SaveQueryModal', function () {
8585
queries={[
8686
{
8787
query: 'span.op:pageload',
88-
visualizes: [{chartType: 1, yAxes: ['avg(span.duration)'], label: 'A'}],
88+
visualizes: [{chartType: 1, yAxes: ['avg(span.duration)']}],
8989
groupBys: ['span.op'],
9090
},
9191
]}

static/app/components/modals/explore/saveQueryModal.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import {defined} from 'sentry/utils';
2020
import {trackAnalytics} from 'sentry/utils/analytics';
2121
import useOrganization from 'sentry/utils/useOrganization';
2222
import {useSetExplorePageParams} from 'sentry/views/explore/contexts/pageParamsContext';
23-
import type {Visualize} from 'sentry/views/explore/contexts/pageParamsContext/visualizes';
23+
import type {BaseVisualize} from 'sentry/views/explore/contexts/pageParamsContext/visualizes';
2424

2525
type SingleQueryProps = {
2626
query: string;
27-
visualizes: Visualize[];
27+
visualizes: BaseVisualize[];
2828
groupBys?: string[]; // This needs to be passed in because saveQuery relies on being within the Explore PageParamsContext to fetch params
2929
};
3030

@@ -122,11 +122,16 @@ function SaveQueryModal({
122122
);
123123
}
124124

125-
function ExploreParams({query, visualizes, groupBys}: SingleQueryProps) {
125+
export function ExploreParams({
126+
query,
127+
visualizes,
128+
groupBys,
129+
className,
130+
}: SingleQueryProps & {className?: string}) {
126131
const yAxes = visualizes.flatMap(visualize => visualize.yAxes);
127132

128133
return (
129-
<ExploreParamsContainer>
134+
<ExploreParamsContainer className={className}>
130135
<ExploreParamSection>
131136
<ExploreParamTitle>{t('Visualize')}</ExploreParamTitle>
132137
<ExploreParamSection>
@@ -153,7 +158,6 @@ function ExploreParams({query, visualizes, groupBys}: SingleQueryProps) {
153158
</ExploreParamSection>
154159
</ExploreParamSection>
155160
)}
156-
<ExploreParamSection>...</ExploreParamSection>
157161
</ExploreParamsContainer>
158162
);
159163
}

static/app/views/explore/savedQueries/savedQueriesTable.spec.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('SavedQueriesTable', () => {
1919
id: 1,
2020
name: 'Query Name',
2121
projects: [1],
22+
environment: ['production'],
2223
createdBy: {
2324
name: 'Test User',
2425
},
@@ -56,9 +57,9 @@ describe('SavedQueriesTable', () => {
5657
it('should render', async () => {
5758
render(<SavedQueriesTable mode="owned" />);
5859
expect(screen.getByText('Name')).toBeInTheDocument();
59-
expect(screen.getByText('Projects')).toBeInTheDocument();
60+
expect(screen.getByText('Project')).toBeInTheDocument();
6061
expect(screen.getByText('Query')).toBeInTheDocument();
61-
expect(screen.getByText('Owner')).toBeInTheDocument();
62+
expect(screen.getByText('Creator')).toBeInTheDocument();
6263
expect(screen.getByText('Last Viewed')).toBeInTheDocument();
6364
await screen.findByText('Query Name');
6465
});
@@ -98,7 +99,7 @@ describe('SavedQueriesTable', () => {
9899
it('deletes a query', async () => {
99100
render(<SavedQueriesTable mode="owned" />);
100101
await screen.findByText('Query Name');
101-
await userEvent.click(screen.getByLabelText('Query actions'));
102+
await userEvent.click(screen.getByLabelText('More options'));
102103
await userEvent.click(screen.getByText('Delete'));
103104
await waitFor(() =>
104105
expect(deleteQueryMock).toHaveBeenCalledWith(
@@ -114,7 +115,7 @@ describe('SavedQueriesTable', () => {
114115
render(<SavedQueriesTable mode="owned" />);
115116
expect(await screen.findByText('Query Name')).toHaveAttribute(
116117
'href',
117-
'/organizations/org-slug/traces/?dataset=spansRpc&groupBy=&id=1&project=1&title=Query%20Name'
118+
'/organizations/org-slug/traces/?dataset=spansRpc&environment=production&groupBy=&id=1&project=1&title=Query%20Name'
118119
);
119120
});
120121

@@ -126,6 +127,7 @@ describe('SavedQueriesTable', () => {
126127
id: 1,
127128
name: 'Query Name',
128129
projects: [1],
130+
environment: ['production'],
129131
createdBy: {
130132
name: 'Test User',
131133
},
@@ -145,7 +147,7 @@ describe('SavedQueriesTable', () => {
145147
render(<SavedQueriesTable mode="owned" />);
146148
expect(await screen.findByText('Query Name')).toHaveAttribute(
147149
'href',
148-
'/organizations/org-slug/explore/traces/compare/?dataset=spansRpc&id=1&project=1&queries=%7B%22groupBys%22%3A%5B%5D%2C%22yAxes%22%3A%5B%5D%7D&queries=%7B%22groupBys%22%3A%5B%5D%2C%22yAxes%22%3A%5B%5D%7D&title=Query%20Name'
150+
'/organizations/org-slug/explore/traces/compare/?dataset=spansRpc&environment=production&id=1&project=1&queries=%7B%22groupBys%22%3A%5B%5D%2C%22yAxes%22%3A%5B%5D%7D&queries=%7B%22groupBys%22%3A%5B%5D%2C%22yAxes%22%3A%5B%5D%7D&title=Query%20Name'
149151
);
150152
});
151153

@@ -157,6 +159,7 @@ describe('SavedQueriesTable', () => {
157159
id: 1,
158160
name: 'Query Name',
159161
projects: [1],
162+
environment: ['production'],
160163
createdBy: {
161164
name: 'Test User',
162165
},
@@ -172,6 +175,7 @@ describe('SavedQueriesTable', () => {
172175
id: 2,
173176
name: 'Starred Query',
174177
projects: [1],
178+
environment: ['production'],
175179
createdBy: {
176180
name: 'Test User',
177181
},
@@ -202,7 +206,7 @@ describe('SavedQueriesTable', () => {
202206
})
203207
)
204208
);
205-
await userEvent.click(screen.getByLabelText('Unstar'));
209+
await userEvent.click(screen.getAllByLabelText('Unstar')[1]!);
206210
await waitFor(() =>
207211
expect(unstarQueryMock).toHaveBeenCalledWith(
208212
`/organizations/${organization.slug}/explore/saved/2/starred/`,
@@ -241,7 +245,7 @@ describe('SavedQueriesTable', () => {
241245
it('should duplicate a query', async () => {
242246
render(<SavedQueriesTable mode="owned" />);
243247
await screen.findByText('Query Name');
244-
await userEvent.click(screen.getByLabelText('Query actions'));
248+
await userEvent.click(screen.getByLabelText('More options'));
245249
await userEvent.click(screen.getByText('Duplicate'));
246250
await waitFor(() =>
247251
expect(saveQueryMock).toHaveBeenCalledWith(

0 commit comments

Comments
 (0)