Skip to content
Snippets Groups Projects
Unverified Commit 6c6f788e authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Avoid dynamic require (#27780)

parent 15107d36
No related merge requests found
......@@ -2,9 +2,10 @@ import { createEntity } from "metabase/lib/entities";
import { GET, POST } from "metabase/lib/api";
const listRevisions = GET("/api/revision");
import Dashboards from "./dashboards";
import Questions from "./questions";
const ASSOCIATED_ENTITY_TYPES = ["questions", "dashboards"];
const listRevisions = GET("/api/revision");
const Revision = createEntity({
name: "revisions",
......@@ -35,14 +36,11 @@ const Revision = createEntity({
},
actionShouldInvalidateLists(action) {
const entities = require("metabase/entities");
for (const type of ASSOCIATED_ENTITY_TYPES) {
if (entities[type].actionShouldInvalidateLists(action)) {
return true;
}
}
return action.type === this.actionTypes.INVALIDATE_LISTS_ACTION;
return (
action.type === this.actionTypes.INVALIDATE_LISTS_ACTION ||
Dashboards.actionShouldInvalidateLists(action) ||
Questions.actionShouldInvalidateLists(action)
);
},
});
......
......@@ -3,11 +3,19 @@ import { createEntity } from "metabase/lib/entities";
import { GET } from "metabase/lib/api";
import { entityTypeForObject } from "metabase/lib/schema";
import { ObjectUnionSchema, ENTITIES_SCHEMA_MAP } from "metabase/schema";
import { ObjectUnionSchema } from "metabase/schema";
import { canonicalCollectionId } from "metabase/collections/utils";
const ENTITIES_TYPES = Object.keys(ENTITIES_SCHEMA_MAP);
import Bookmarks from "./bookmarks";
import Collections from "./collections";
import Dashboards from "./dashboards";
import Metrics from "./metrics";
import Pulses from "./pulses";
import Questions from "./questions";
import Segments from "./segments";
import Snippets from "./snippets";
import SnippetCollections from "./snippet-collections";
const searchList = GET("/api/search");
const collectionList = GET("/api/collection/:collection/items");
......@@ -82,12 +90,16 @@ export default createEntity({
// delegate to each entity's actionShouldInvalidateLists
actionShouldInvalidateLists(action) {
const entities = require("metabase/entities");
for (const type of ENTITIES_TYPES) {
if (entities[type].actionShouldInvalidateLists(action)) {
return true;
}
}
return false;
return (
Bookmarks.actionShouldInvalidateLists(action) ||
Collections.actionShouldInvalidateLists(action) ||
Dashboards.actionShouldInvalidateLists(action) ||
Metrics.actionShouldInvalidateLists(action) ||
Pulses.actionShouldInvalidateLists(action) ||
Questions.actionShouldInvalidateLists(action) ||
Segments.actionShouldInvalidateLists(action) ||
Snippets.actionShouldInvalidateLists(action) ||
SnippetCollections.actionShouldInvalidateLists(action)
);
},
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment