From 862ca7ea27c6b397327f5e2738cc40d321b9df61 Mon Sep 17 00:00:00 2001
From: Uladzimir Havenchyk <125459446+uladzimirdev@users.noreply.github.com>
Date: Fri, 31 May 2024 16:50:48 +0300
Subject: [PATCH] Optimize imports from collection (#43241)

---
 .../snippets/components/SnippetCollectionForm.tsx           | 2 +-
 .../components/CollectionPicker/components/RootItemList.tsx | 2 +-
 .../metabase/common/components/CollectionPicker/utils.ts    | 2 +-
 .../src/metabase/common/components/DashboardPicker/utils.ts | 2 +-
 .../src/metabase/common/components/QuestionPicker/utils.ts  | 2 +-
 .../metabase/components/CollectionItem/CollectionItem.jsx   | 2 +-
 .../metabase/containers/AddToDashSelectDashModal/utils.ts   | 2 +-
 .../src/metabase/containers/DataPicker/CardPicker/utils.ts  | 6 ++----
 .../src/metabase/containers/DataPicker/tests/common.tsx     | 2 +-
 frontend/src/metabase/containers/UserCollectionList.tsx     | 2 +-
 .../LinkOptions/LinkedEntityPicker/LinkedEntityPicker.tsx   | 2 +-
 frontend/src/metabase/entities/dashboards.js                | 2 +-
 frontend/src/metabase/entities/pulses.js                    | 2 +-
 .../MainNavbar/MainNavbarContainer/MainNavbarView.tsx       | 6 ++----
 .../MainNavbar/SidebarItems/SidebarCollectionLink.tsx       | 2 +-
 frontend/src/metabase/palette/hooks/useCommandPalette.tsx   | 2 +-
 .../DataSelector/saved-entity-picker/SavedEntityList.tsx    | 2 +-
 frontend/test/__support__/server-mocks/collection.ts        | 2 +-
 18 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionForm.tsx b/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionForm.tsx
index d37969bcf7b..c939ecf3356 100644
--- a/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionForm.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionForm.tsx
@@ -11,7 +11,7 @@ import FormFooter from "metabase/core/components/FormFooter";
 import FormInput from "metabase/core/components/FormInput";
 import FormSubmitButton from "metabase/core/components/FormSubmitButton";
 import FormTextArea from "metabase/core/components/FormTextArea";
-import { DEFAULT_COLLECTION_COLOR_ALIAS } from "metabase/entities/collections";
+import { DEFAULT_COLLECTION_COLOR_ALIAS } from "metabase/entities/collections/constants";
 import SnippetCollections from "metabase/entities/snippet-collections";
 import { Form, FormProvider } from "metabase/forms";
 import { color } from "metabase/lib/colors";
diff --git a/frontend/src/metabase/common/components/CollectionPicker/components/RootItemList.tsx b/frontend/src/metabase/common/components/CollectionPicker/components/RootItemList.tsx
index 2318b4caf87..33657f0aa6b 100644
--- a/frontend/src/metabase/common/components/CollectionPicker/components/RootItemList.tsx
+++ b/frontend/src/metabase/common/components/CollectionPicker/components/RootItemList.tsx
@@ -6,7 +6,7 @@ import {
   useGetCollectionQuery,
   useListCollectionItemsQuery,
 } from "metabase/api";
-import { PERSONAL_COLLECTIONS } from "metabase/entities/collections";
+import { PERSONAL_COLLECTIONS } from "metabase/entities/collections/constants";
 import { useSelector } from "metabase/lib/redux";
 import { getUser, getUserIsAdmin } from "metabase/selectors/user";
 
diff --git a/frontend/src/metabase/common/components/CollectionPicker/utils.ts b/frontend/src/metabase/common/components/CollectionPicker/utils.ts
index a25dfb2ab27..729e8da690c 100644
--- a/frontend/src/metabase/common/components/CollectionPicker/utils.ts
+++ b/frontend/src/metabase/common/components/CollectionPicker/utils.ts
@@ -1,4 +1,4 @@
-import { PERSONAL_COLLECTIONS } from "metabase/entities/collections";
+import { PERSONAL_COLLECTIONS } from "metabase/entities/collections/constants";
 import type {
   CollectionId,
   ListCollectionItemsRequest,
diff --git a/frontend/src/metabase/common/components/DashboardPicker/utils.ts b/frontend/src/metabase/common/components/DashboardPicker/utils.ts
index 25e6d1f8aaa..ee7dd4f2287 100644
--- a/frontend/src/metabase/common/components/DashboardPicker/utils.ts
+++ b/frontend/src/metabase/common/components/DashboardPicker/utils.ts
@@ -1,6 +1,6 @@
 import _ from "underscore";
 
-import { PERSONAL_COLLECTIONS } from "metabase/entities/collections";
+import { PERSONAL_COLLECTIONS } from "metabase/entities/collections/constants";
 import type {
   CollectionId,
   CollectionItemModel,
diff --git a/frontend/src/metabase/common/components/QuestionPicker/utils.ts b/frontend/src/metabase/common/components/QuestionPicker/utils.ts
index d9615ae4219..219e4e4929d 100644
--- a/frontend/src/metabase/common/components/QuestionPicker/utils.ts
+++ b/frontend/src/metabase/common/components/QuestionPicker/utils.ts
@@ -1,6 +1,6 @@
 import _ from "underscore";
 
-import { PERSONAL_COLLECTIONS } from "metabase/entities/collections";
+import { PERSONAL_COLLECTIONS } from "metabase/entities/collections/constants";
 import type {
   CollectionId,
   CollectionItemModel,
diff --git a/frontend/src/metabase/components/CollectionItem/CollectionItem.jsx b/frontend/src/metabase/components/CollectionItem/CollectionItem.jsx
index 7ad8e8341f3..06c12110d89 100644
--- a/frontend/src/metabase/components/CollectionItem/CollectionItem.jsx
+++ b/frontend/src/metabase/components/CollectionItem/CollectionItem.jsx
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
 import Card from "metabase/components/Card";
 import { Ellipsified } from "metabase/core/components/Ellipsified";
 import CS from "metabase/css/core/index.css";
-import { getCollectionIcon } from "metabase/entities/collections";
+import { getCollectionIcon } from "metabase/entities/collections/utils";
 
 import {
   ItemLink,
diff --git a/frontend/src/metabase/containers/AddToDashSelectDashModal/utils.ts b/frontend/src/metabase/containers/AddToDashSelectDashModal/utils.ts
index 3d1cf39cc00..cb82a1be289 100644
--- a/frontend/src/metabase/containers/AddToDashSelectDashModal/utils.ts
+++ b/frontend/src/metabase/containers/AddToDashSelectDashModal/utils.ts
@@ -3,7 +3,7 @@ import {
   isPublicCollection,
 } from "metabase/collections/utils";
 import type { DashboardPickerItem } from "metabase/common/components/DashboardPicker";
-import { ROOT_COLLECTION } from "metabase/entities/collections";
+import { ROOT_COLLECTION } from "metabase/entities/collections/constants";
 import type {
   CollectionId,
   Dashboard,
diff --git a/frontend/src/metabase/containers/DataPicker/CardPicker/utils.ts b/frontend/src/metabase/containers/DataPicker/CardPicker/utils.ts
index 7401e303937..0190a25981f 100644
--- a/frontend/src/metabase/containers/DataPicker/CardPicker/utils.ts
+++ b/frontend/src/metabase/containers/DataPicker/CardPicker/utils.ts
@@ -3,10 +3,8 @@ import {
   nonPersonalOrArchivedCollection,
   currentUserPersonalCollections,
 } from "metabase/collections/utils";
-import {
-  PERSONAL_COLLECTIONS,
-  buildCollectionTree as _buildCollectionTree,
-} from "metabase/entities/collections";
+import { PERSONAL_COLLECTIONS } from "metabase/entities/collections/constants";
+import { buildCollectionTree as _buildCollectionTree } from "metabase/entities/collections/utils";
 import type {
   Collection,
   CollectionContentModel,
diff --git a/frontend/src/metabase/containers/DataPicker/tests/common.tsx b/frontend/src/metabase/containers/DataPicker/tests/common.tsx
index 81006ab4592..2ef14c20fa3 100644
--- a/frontend/src/metabase/containers/DataPicker/tests/common.tsx
+++ b/frontend/src/metabase/containers/DataPicker/tests/common.tsx
@@ -9,7 +9,7 @@ import {
 } from "__support__/server-mocks";
 import { renderWithProviders, waitForLoaderToBeRemoved } from "__support__/ui";
 import Input from "metabase/core/components/Input";
-import { ROOT_COLLECTION } from "metabase/entities/collections";
+import { ROOT_COLLECTION } from "metabase/entities/collections/constants";
 import {
   createMockCard,
   createMockCollection,
diff --git a/frontend/src/metabase/containers/UserCollectionList.tsx b/frontend/src/metabase/containers/UserCollectionList.tsx
index bf577c68873..1c15f4ef1c4 100644
--- a/frontend/src/metabase/containers/UserCollectionList.tsx
+++ b/frontend/src/metabase/containers/UserCollectionList.tsx
@@ -8,7 +8,7 @@ import CS from "metabase/css/core/index.css";
 import {
   ROOT_COLLECTION,
   PERSONAL_COLLECTIONS,
-} from "metabase/entities/collections";
+} from "metabase/entities/collections/constants";
 import { usePagination } from "metabase/hooks/use-pagination";
 import { color } from "metabase/lib/colors";
 import * as Urls from "metabase/lib/urls";
diff --git a/frontend/src/metabase/dashboard/components/ClickBehaviorSidebar/LinkOptions/LinkedEntityPicker/LinkedEntityPicker.tsx b/frontend/src/metabase/dashboard/components/ClickBehaviorSidebar/LinkOptions/LinkedEntityPicker/LinkedEntityPicker.tsx
index dd6ee1c52e6..a7586ceaf62 100644
--- a/frontend/src/metabase/dashboard/components/ClickBehaviorSidebar/LinkOptions/LinkedEntityPicker/LinkedEntityPicker.tsx
+++ b/frontend/src/metabase/dashboard/components/ClickBehaviorSidebar/LinkOptions/LinkedEntityPicker/LinkedEntityPicker.tsx
@@ -11,7 +11,7 @@ import {
   clickTargetObjectType,
 } from "metabase/dashboard/components/ClickMappings";
 import { getDashboard } from "metabase/dashboard/selectors";
-import { ROOT_COLLECTION } from "metabase/entities/collections";
+import { ROOT_COLLECTION } from "metabase/entities/collections/constants";
 import Dashboards from "metabase/entities/dashboards";
 import Questions from "metabase/entities/questions";
 import { useSelector } from "metabase/lib/redux";
diff --git a/frontend/src/metabase/entities/dashboards.js b/frontend/src/metabase/entities/dashboards.js
index df5826b844d..22fa2d73aab 100644
--- a/frontend/src/metabase/entities/dashboards.js
+++ b/frontend/src/metabase/entities/dashboards.js
@@ -8,7 +8,7 @@ import {
 import {
   getCollectionType,
   normalizedCollection,
-} from "metabase/entities/collections";
+} from "metabase/entities/collections/utils";
 import { color } from "metabase/lib/colors";
 import {
   createEntity,
diff --git a/frontend/src/metabase/entities/pulses.js b/frontend/src/metabase/entities/pulses.js
index 8ce8b0709c5..4f7cff809b7 100644
--- a/frontend/src/metabase/entities/pulses.js
+++ b/frontend/src/metabase/entities/pulses.js
@@ -1,7 +1,7 @@
 import { t } from "ttag";
 
 import { subscriptionApi } from "metabase/api";
-import { getCollectionType } from "metabase/entities/collections";
+import { getCollectionType } from "metabase/entities/collections/utils";
 import { color } from "metabase/lib/colors";
 import {
   createEntity,
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarView.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarView.tsx
index ecfbec3255d..892ce20fcc3 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarView.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/MainNavbarView.tsx
@@ -7,10 +7,8 @@ import CollapseSection from "metabase/components/CollapseSection";
 import TippyPopoverWithTrigger from "metabase/components/PopoverWithTrigger/TippyPopoverWithTrigger";
 import { Tree } from "metabase/components/tree";
 import CS from "metabase/css/core/index.css";
-import {
-  getCollectionIcon,
-  PERSONAL_COLLECTIONS,
-} from "metabase/entities/collections";
+import { PERSONAL_COLLECTIONS } from "metabase/entities/collections/constants";
+import { getCollectionIcon } from "metabase/entities/collections/utils";
 import { isSmallScreen } from "metabase/lib/dom";
 import * as Urls from "metabase/lib/urls";
 import { WhatsNewNotification } from "metabase/nav/components/WhatsNewNotification";
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/SidebarItems/SidebarCollectionLink.tsx b/frontend/src/metabase/nav/containers/MainNavbar/SidebarItems/SidebarCollectionLink.tsx
index cffc89ab81f..6eb4ecb435d 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/SidebarItems/SidebarCollectionLink.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/SidebarItems/SidebarCollectionLink.tsx
@@ -5,7 +5,7 @@ import { usePrevious } from "react-use";
 import { TreeNode } from "metabase/components/tree/TreeNode";
 import type { TreeNodeProps } from "metabase/components/tree/types";
 import CollectionDropTarget from "metabase/containers/dnd/CollectionDropTarget";
-import { getCollectionIcon } from "metabase/entities/collections";
+import { getCollectionIcon } from "metabase/entities/collections/utils";
 import * as Urls from "metabase/lib/urls";
 import { PLUGIN_COLLECTIONS } from "metabase/plugins";
 import type { Collection } from "metabase-types/api";
diff --git a/frontend/src/metabase/palette/hooks/useCommandPalette.tsx b/frontend/src/metabase/palette/hooks/useCommandPalette.tsx
index f7b6f26adc7..67dee403ff9 100644
--- a/frontend/src/metabase/palette/hooks/useCommandPalette.tsx
+++ b/frontend/src/metabase/palette/hooks/useCommandPalette.tsx
@@ -9,7 +9,7 @@ import { getAdminPaths } from "metabase/admin/app/selectors";
 import { getSectionsWithPlugins } from "metabase/admin/settings/selectors";
 import { useListRecentItemsQuery, useSearchQuery } from "metabase/api";
 import { useSetting } from "metabase/common/hooks";
-import { ROOT_COLLECTION } from "metabase/entities/collections";
+import { ROOT_COLLECTION } from "metabase/entities/collections/constants";
 import Search from "metabase/entities/search";
 import { SEARCH_DEBOUNCE_DURATION } from "metabase/lib/constants";
 import { getIcon } from "metabase/lib/icon";
diff --git a/frontend/src/metabase/query_builder/components/DataSelector/saved-entity-picker/SavedEntityList.tsx b/frontend/src/metabase/query_builder/components/DataSelector/saved-entity-picker/SavedEntityList.tsx
index 38d348d5193..24f85ec9137 100644
--- a/frontend/src/metabase/query_builder/components/DataSelector/saved-entity-picker/SavedEntityList.tsx
+++ b/frontend/src/metabase/query_builder/components/DataSelector/saved-entity-picker/SavedEntityList.tsx
@@ -2,7 +2,7 @@ import { Fragment } from "react";
 import { t } from "ttag";
 
 import EmptyState from "metabase/components/EmptyState";
-import { PERSONAL_COLLECTIONS } from "metabase/entities/collections";
+import { PERSONAL_COLLECTIONS } from "metabase/entities/collections/constants";
 import Search from "metabase/entities/search";
 import { PLUGIN_MODERATION } from "metabase/plugins";
 import { getQuestionVirtualTableId } from "metabase-lib/v1/metadata/utils/saved-questions";
diff --git a/frontend/test/__support__/server-mocks/collection.ts b/frontend/test/__support__/server-mocks/collection.ts
index 5d23062885a..a10a463684e 100644
--- a/frontend/test/__support__/server-mocks/collection.ts
+++ b/frontend/test/__support__/server-mocks/collection.ts
@@ -1,7 +1,7 @@
 import fetchMock from "fetch-mock";
 import _ from "underscore";
 
-import { ROOT_COLLECTION } from "metabase/entities/collections";
+import { ROOT_COLLECTION } from "metabase/entities/collections/constants";
 import {
   SAVED_QUESTIONS_VIRTUAL_DB_ID,
   convertSavedQuestionToVirtualTable,
-- 
GitLab