Skip to content

Commit 8ceed8d

Browse files
authored
Port all entities to use new EntityListLoaderRtkQuery (metabase#51496)
* Fix typo * Fix broken memoization * Use undefined instead of 0 * Introduce entityOptions * Fix memoization * Enable EntityListLoaderRtkQuery for alerts (metabase#51501) * Port bookmarks to use new `EntityListLoaderRtkQuery` (metabase#51502) * Fix types * Enable EntityListLoaderRtkQuery for bookmarks * Revert "Fix types" This reverts commit f855c3a. * Enable EntityListLoaderRtkQuery for dashboards (metabase#51503) * Enable EntityListLoaderRtkQuery for persisted models (metabase#51505) * Enable EntityListLoaderRtkQuery for pulses (metabase#51507) * Enable EntityListLoaderRtkQuery for revisions (metabase#51509) * Enable EntityListLoaderRtkQuery for persisted segments (metabase#51512) * Enable EntityListLoaderRtkQuery for snippets (metabase#51513) * Enable EntityListLoaderRtkQuery for persisted questions (metabase#51508) * Enable EntityListLoaderRtkQuery for actions (metabase#51515) * Port tables to use new `EntityListLoaderRtkQuery` (metabase#51518) * Enable EntityListLoaderRtkQuery for tables * Fix polling * Port timelines to use new `EntityListLoaderRtkQuery` (metabase#51516) * Enable EntityListLoaderRtkQuery for timelines * Add missing options * Fix flaky test * Port groups to use new `EntityListLoaderRtkQuery` (metabase#51504) * Enable EntityListLoaderRtkQuery for groups * Bind action creators * Fix flaky test * Port users to use new `EntityListLoaderRtkQuery` (metabase#51514) * Enable EntityListLoaderRtkQuery for users * Add missing options * Fix crash * Reimplement pagination * Enable EntityListLoaderRtkQuery for search (metabase#51568) * Port schemas to use new `EntityListLoaderRtkQuery` (metabase#51511) * Enable EntityListLoaderRtkQuery for persisted schemas * Add missing options * Temporary commit - just to save work at EOY * Fix file upload * Fix unit tests * Fix data being set for different entityQuery * Port collections to use new `EntityListLoaderRtkQuery` (metabase#51519) * Enable EntityListLoaderRtkQuery for collections * Add missing options * Improve typing * Fix data being set for different entityQuery * Fix destructuring crash * Fix typing * Pass options to RTK query where missing * Use undefined instead of 0 for reloadInterval * Port snippet collections to use new `EntityListLoaderRtkQuery` (metabase#51847) * Enable EntityListLoaderRtkQuery for snippet collections * Introduce custom useListQuery * Reduce diff * Reduce diff
1 parent f0842c1 commit 8ceed8d

37 files changed

Lines changed: 535 additions & 92 deletions

e2e/test/scenarios/organization/timelines-question.cy.spec.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,13 @@ describe("scenarios > organization > timelines > question", () => {
340340
cy.button("Create").click();
341341
cy.wait("@createEvent");
342342

343+
H.undoToast().icon("close").click();
343344
H.echartsIcon("star").should("be.visible");
344345

345346
// should then hide the newly created event
347+
timelineEventVisibility("RC2").should("be.checked");
346348
toggleEventVisibility("RC2");
349+
timelineEventVisibility("RC2").should("not.be.checked");
347350

348351
H.echartsIcon("star").should("not.exist");
349352

@@ -550,7 +553,9 @@ function timelineEventCard(eventName) {
550553
}
551554

552555
function toggleEventVisibility(eventName) {
553-
timelineEventCard(eventName).within(() => {
554-
cy.findByRole("checkbox").click();
555-
});
556+
timelineEventVisibility(eventName).click();
557+
}
558+
559+
function timelineEventVisibility(eventName) {
560+
return timelineEventCard(eventName).findByRole("checkbox");
556561
}

frontend/src/metabase-types/api/card.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ export interface CreateCardRequest {
334334
cache_ttl?: number;
335335
}
336336

337+
export interface CreateCardFromCsvRequest {
338+
collection_id?: CollectionId;
339+
file: File;
340+
}
341+
337342
export interface UpdateCardRequest {
338343
id: CardId;
339344
name?: string;

frontend/src/metabase/actions/components/ActionViz/ActionDashcardSettings.unit.spec.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import {
1010
renderWithProviders,
1111
screen,
12+
waitFor,
1213
waitForLoaderToBeRemoved,
1314
within,
1415
} from "__support__/ui";
@@ -480,6 +481,11 @@ describe("ActionViz > ActionDashcardSettings", () => {
480481
});
481482

482483
await waitForLoaderToBeRemoved();
484+
await waitFor(() => {
485+
expect(
486+
screen.getByTestId(`action-item-${actions2[0].name}`),
487+
).toBeInTheDocument();
488+
});
483489

484490
const queryAction = screen.getByTestId(`action-item-${actions2[0].name}`);
485491
const implicitAction = screen.getByTestId(

frontend/src/metabase/admin/people/containers/GroupsListingApp.jsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Component } from "react";
21
import _ from "underscore";
32

43
import Group from "metabase/entities/groups";
@@ -17,13 +16,7 @@ const mapDispatchToProps = {
1716
delete: PLUGIN_GROUP_MANAGERS.deleteGroup ?? Group.actions.delete,
1817
};
1918

20-
class GroupsListingApp extends Component {
21-
render() {
22-
return <GroupsListing {...this.props} />;
23-
}
24-
}
25-
2619
export default _.compose(
2720
Group.loadList({ reload: true }),
2821
connect(mapStateToProps, mapDispatchToProps),
29-
)(GroupsListingApp);
22+
)(GroupsListing);

frontend/src/metabase/api/action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export const actionApi = Api.injectEndpoints({
110110

111111
export const {
112112
useGetActionQuery,
113+
useListActionsQuery,
113114
useListPublicActionsQuery,
114115
useDeleteActionPublicLinkMutation,
115116
endpoints: {

frontend/src/metabase/api/card.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
CardQueryMetadata,
55
CardQueryRequest,
66
CollectionItem,
7+
CreateCardFromCsvRequest,
78
CreateCardRequest,
89
DashboardId,
910
Dataset,
@@ -90,6 +91,27 @@ export const cardApi = Api.injectEndpoints({
9091
}),
9192
invalidatesTags: (_, error) => invalidateTags(error, [listTag("card")]),
9293
}),
94+
createCardFromCsv: builder.mutation<Card, CreateCardFromCsvRequest>({
95+
query: ({ file, collection_id }) => {
96+
const formData = new FormData();
97+
formData.append("file", file);
98+
formData.append("collection_id", String(collection_id));
99+
100+
return {
101+
method: "POST",
102+
url: "/api/card/from-csv",
103+
body: { formData },
104+
formData: true,
105+
fetch: true,
106+
};
107+
},
108+
invalidatesTags: (_, error) =>
109+
invalidateTags(error, [
110+
listTag("card"),
111+
listTag("schema"),
112+
listTag("table"),
113+
]),
114+
}),
93115
updateCard: builder.mutation<Card, UpdateCardRequest>({
94116
query: ({ id, delete_old_dashcards, ...body }) => ({
95117
method: "PUT",

frontend/src/metabase/api/collection.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,20 @@ export const collectionApi = Api.injectEndpoints({
2626
* @deprecated This endpoint is extremely slow on large instances, it should not be used
2727
* you probably only need a few collections, just fetch those
2828
*/
29-
listCollections: builder.query<Collection[], ListCollectionsRequest>({
30-
query: params => ({
31-
method: "GET",
32-
url: `/api/collection`,
33-
params,
34-
}),
35-
providesTags: (collections = []) =>
36-
provideCollectionListTags(collections),
37-
}),
29+
listCollections: builder.query<Collection[], ListCollectionsRequest | void>(
30+
{
31+
query: params => ({
32+
method: "GET",
33+
url: `/api/collection`,
34+
params,
35+
}),
36+
providesTags: (collections = []) =>
37+
provideCollectionListTags(collections),
38+
},
39+
),
3840
listCollectionsTree: builder.query<
3941
Collection[],
40-
ListCollectionsTreeRequest
42+
ListCollectionsTreeRequest | void
4143
>({
4244
query: params => ({
4345
method: "GET",

frontend/src/metabase/api/query.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const isAllowedHTTPMethod = (method: any): method is AllowedHTTPMethods => {
1717
export const apiQuery: BaseQueryFn = async (args, ctx) => {
1818
const method = typeof args === "string" ? "GET" : (args?.method ?? "GET");
1919
const url = typeof args === "string" ? args : args.url;
20-
const { bodyParamName, noEvent } = args;
20+
const { bodyParamName, noEvent, formData, fetch } = args;
2121

2222
if (!isAllowedHTTPMethod(method)) {
2323
return { error: "Invalid HTTP method" };
@@ -26,7 +26,13 @@ export const apiQuery: BaseQueryFn = async (args, ctx) => {
2626
try {
2727
const response = await api[method](url)(
2828
{ ...args?.body, ...args?.params },
29-
{ signal: ctx.signal, bodyParamName, noEvent },
29+
{
30+
signal: ctx.signal,
31+
bodyParamName,
32+
noEvent,
33+
formData,
34+
fetch,
35+
},
3036
);
3137
return { data: response };
3238
} catch (error) {

frontend/src/metabase/api/revision.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { invalidateTags, listTag, provideRevisionListTags } from "./tags";
99

1010
export const revisionApi = Api.injectEndpoints({
1111
endpoints: builder => ({
12-
listRevision: builder.query<Revision[], ListRevisionRequest>({
12+
listRevisions: builder.query<Revision[], ListRevisionRequest>({
1313
query: params => ({
1414
method: "GET",
1515
url: "/api/revision",
@@ -29,4 +29,4 @@ export const revisionApi = Api.injectEndpoints({
2929
}),
3030
});
3131

32-
export const { useListRevisionQuery, useRevertRevisionMutation } = revisionApi;
32+
export const { useListRevisionsQuery, useRevertRevisionMutation } = revisionApi;

frontend/src/metabase/api/timeline.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export const timelineApi = Api.injectEndpoints({
8585
});
8686

8787
export const {
88+
useListCollectionTimelinesQuery,
8889
useListTimelinesQuery,
8990
useGetTimelineQuery,
9091
useCreateTimelineMutation,

0 commit comments

Comments
 (0)