Skip to content

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

Move the DataReference library pane slot into querying (#81858)

Fraser9fff12013e29
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/index.ts b/enterprise/frontend/src/metabase-enterprise/data-studio/library/index.ts
index 28995ee1439..d9fe4ac94d4 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/index.ts
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/index.ts
@@ -1,4 +1,5 @@
import { PLUGIN_LIBRARY } from "metabase/plugins";
+import { PLUGIN_DATA_REFERENCE } from "metabase/querying/components/DataReference/plugins";
import { useGetLibraryCollectionQuery } from "metabase-enterprise/api";
import { hasPremiumFeature } from "metabase-enterprise/settings";
@@ -32,7 +33,7 @@ export function initializePlugin() {
PLUGIN_LIBRARY.getCollectionPickerItems = getCollectionPickerItems;
PLUGIN_LIBRARY.getEntityPickerSyntheticLibraryItem =
getEntityPickerSyntheticLibraryItem;
- PLUGIN_LIBRARY.DataReferenceLibraryPane = DataReferenceLibraryPane;
+ PLUGIN_DATA_REFERENCE.LibraryPane = DataReferenceLibraryPane;
PLUGIN_LIBRARY.CreateLibraryModal = CreateLibraryModal;
PLUGIN_LIBRARY.CollectionPermissionsModal = CollectionPermissionsModal;
PLUGIN_LIBRARY.PublishTablesModal = PublishTablesModal;
diff --git a/frontend/src/metabase/plugins/oss/library.ts b/frontend/src/metabase/plugins/oss/library.ts
index 9dbb7093834..44bc188683d 100644
--- a/frontend/src/metabase/plugins/oss/library.ts
+++ b/frontend/src/metabase/plugins/oss/library.ts
@@ -9,10 +9,6 @@ import type {
} from "metabase/common/components/Pickers/EntityPicker/types";
import type { MiniPickerCollectionFolderItem } from "metabase/common/components/Pickers/MiniPicker/types";
import { PluginPlaceholder } from "metabase/plugins/components/PluginPlaceholder";
-import type {
- DataReferenceLibraryItem,
- DataReferencePaneProps,
-} from "metabase/querying/components/DataReference/types";
import type {
Collection,
CollectionId,
@@ -110,9 +106,6 @@ type LibraryPlugin = {
items: CollectionItem[];
}) => OmniPickerItem[] | undefined;
getEntityPickerSyntheticLibraryItem: GetEntityPickerSyntheticLibraryItemFunction;
- DataReferenceLibraryPane: ComponentType<
- DataReferencePaneProps<DataReferenceLibraryItem>
- >;
CreateLibraryModal: ComponentType<CreateLibraryModalProps>;
CollectionPermissionsModal: ComponentType<CollectionPermissionsModalProps>;
PublishTablesModal: ComponentType<PublishTablesModalProps>;
@@ -147,9 +140,6 @@ const getDefaultPluginLibrary = (): LibraryPlugin => ({
}),
getCollectionPickerItems: () => undefined,
getEntityPickerSyntheticLibraryItem: () => undefined,
- DataReferenceLibraryPane: PluginPlaceholder<
- DataReferencePaneProps<DataReferenceLibraryItem>
- >,
CreateLibraryModal:
// Unjustified type cast. FIXME
PluginPlaceholder as ComponentType<CreateLibraryModalProps>,
diff --git a/frontend/src/metabase/querying/components/DataReference/DataReference.tsx b/frontend/src/metabase/querying/components/DataReference/DataReference.tsx
index a31831f8711..036235fc9b2 100644
--- a/frontend/src/metabase/querying/components/DataReference/DataReference.tsx
+++ b/frontend/src/metabase/querying/components/DataReference/DataReference.tsx
@@ -1,9 +1,9 @@
import type { ComponentType } from "react";
-import { PLUGIN_LIBRARY } from "metabase/plugins";
import type { DatabaseId } from "metabase-types/api";
import { MainPane } from "./MainPane";
+import { PLUGIN_DATA_REFERENCE } from "./plugins";
import {
type DataReferenceItem,
type DataReferencePaneProps,
@@ -30,7 +30,7 @@ export const DataReference = ({
if (page.type === "library") {
return (
- <PLUGIN_LIBRARY.DataReferenceLibraryPane
+ <PLUGIN_DATA_REFERENCE.LibraryPane
{...page}
onItemClick={pushDataReferenceStack}
onClose={onClose}
diff --git a/frontend/src/metabase/querying/components/DataReference/plugins.ts b/frontend/src/metabase/querying/components/DataReference/plugins.ts
new file mode 100644
index 00000000000..4e57a10356b
--- /dev/null
+++ b/frontend/src/metabase/querying/components/DataReference/plugins.ts
@@ -0,0 +1,18 @@
+import type { ComponentType } from "react";
+
+import { definePluginSlot } from "metabase/plugins";
+import { PluginPlaceholder } from "metabase/plugins/components/PluginPlaceholder";
+
+import type { DataReferenceLibraryItem, DataReferencePaneProps } from "./types";
+
+type LibraryPaneProps = DataReferencePaneProps<DataReferenceLibraryItem>;
+
+type DataReferencePlugin = {
+ LibraryPane: ComponentType<LibraryPaneProps>;
+};
+
+export const PLUGIN_DATA_REFERENCE = definePluginSlot(
+ (): DataReferencePlugin => ({
+ LibraryPane: PluginPlaceholder<LibraryPaneProps>,
+ }),
+);
diff --git a/frontend/src/metabase/querying/components/DataReference/types.ts b/frontend/src/metabase/querying/components/DataReference/types.ts
index 6fed2d111d7..0a3f163ba93 100644
--- a/frontend/src/metabase/querying/components/DataReference/types.ts
+++ b/frontend/src/metabase/querying/components/DataReference/types.ts
@@ -13,8 +13,6 @@ import { QuestionPane } from "./QuestionPane";
import { SchemaPane } from "./SchemaPane";
import { TablePane } from "./TablePane";
-// The library pane is rendered from PLUGIN_LIBRARY.DataReferenceLibraryPane
-// (see DataReference), so it is intentionally absent from PANES.
export const PANES = {
database: DatabasePane, // lists schemas, tables and models of a database
schema: SchemaPane, // lists tables of a schema