Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Convert `embedding/saved-entity-picker/utils` to TypeScript (#69442)

Frasera8715223ae40
diff --git a/enterprise/frontend/src/embedding/data-picker/saved-entity-picker/utils.js b/enterprise/frontend/src/embedding/data-picker/saved-entity-picker/utils.ts
similarity index 50%
rename from enterprise/frontend/src/embedding/data-picker/saved-entity-picker/utils.js
rename to enterprise/frontend/src/embedding/data-picker/saved-entity-picker/utils.ts
index 63b2bc3cc18..bfbe0c1a116 100644
--- a/enterprise/frontend/src/embedding/data-picker/saved-entity-picker/utils.js
+++ b/enterprise/frontend/src/embedding/data-picker/saved-entity-picker/utils.ts
@@ -1,4 +1,9 @@
-export const findCollectionById = (collections, collectionId) => {
+import type { Collection, CollectionId } from "metabase-types/api";
+
+export const findCollectionById = (
+ collections: Collection[],
+ collectionId: CollectionId,
+): Collection | null => {
if (!collections || collections.length === 0) {
return null;
}
@@ -10,10 +15,7 @@ export const findCollectionById = (collections, collectionId) => {
}
return findCollectionById(
- collections
- .map((c) => c.children)
- .filter(Boolean)
- .flat(),
+ collections.flatMap((c) => c.children ?? []),
collectionId,
);
};