The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
feat: add library/transforms toggles to modal (#68852)
Edward Paget8ae78915ed53
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/app/pages/DataStudioLayout/DataStudioLayout.setup.spec.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/app/pages/DataStudioLayout/DataStudioLayout.setup.spec.tsxindex cb4132eb4d0..bfd70c709cd 100644--- a/enterprise/frontend/src/metabase-enterprise/data-studio/app/pages/DataStudioLayout/DataStudioLayout.setup.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/app/pages/DataStudioLayout/DataStudioLayout.setup.spec.tsx@@ -1,6 +1,7 @@import { setupEnterprisePlugins } from "__support__/enterprise";import {setupCollectionsEndpoints,+ setupLibraryEndpoints,setupPropertiesEndpoints,setupRemoteSyncEndpoints,setupSettingsEndpoints,@@ -201,6 +202,7 @@ export const setup = ({setupRemoteSyncSettingsEndpoints(remoteSyncSettings);setupDirtyEndpoints({ dirty, collections });setupNavbarEndpoints(isNavbarOpened);+ setupLibraryEndpoints(false);renderDataStudioLayout({isAdmin,diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/CollectionSyncList/CollectionSyncList.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/CollectionSyncList/CollectionSyncList.tsxindex 916403b23f8..ab7b6801b12 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/CollectionSyncList/CollectionSyncList.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/CollectionSyncList/CollectionSyncList.tsx@@ -11,6 +11,7 @@ import type {import { COLLECTIONS_KEY, TYPE_KEY } from "../../constants";import { CollectionSyncRow } from "../CollectionSyncRow";+import { LibrarySyncRow } from "../LibrarySyncRow";import { TransformsSyncRow } from "../TransformsSyncRow";import S from "./CollectionSyncList.module.css";@@ -21,6 +22,10 @@ interface CollectionSyncListProps {error: string | null;isLoading: boolean;showTransformsRow?: boolean;+ /**+ * When true and no library collection exists, show a placeholder row for library.+ */+ showLibraryPlaceholder?: boolean;}export const CollectionSyncList = ({@@ -29,6 +34,7 @@ export const CollectionSyncList = ({error,isLoading,showTransformsRow,+ showLibraryPlaceholder,}: CollectionSyncListProps) => {const { values, setFieldValue, initialValues } =useFormikContext<RemoteSyncConfigurationSettings>();@@ -64,6 +70,12 @@ export const CollectionSyncList = ({/>));+ if (showLibraryPlaceholder) {+ rowsItems.unshift(+ <LibrarySyncRow key="library-placeholder" isReadOnly={isReadOnly} />,+ );+ }+if (showTransformsRow) {const transformsRow = (<TransformsSyncRow key="transforms" isReadOnly={isReadOnly} />@@ -72,16 +84,26 @@ export const CollectionSyncList = ({(collection) => collection.type === "library",);- // Insert transforms row before library collection or as last item+ // Insert transforms row after library collection or placeholderif (libraryIndex !== -1) {rowsItems.splice(libraryIndex + 1, 0, transformsRow);+ } else if (showLibraryPlaceholder) {+ // Insert after library placeholder (at index 1)+ rowsItems.splice(1, 0, transformsRow);} else {rowsItems.push(transformsRow);}}return rowsItems;- }, [collections, handleToggle, isReadOnly, showTransformsRow, values]);+ }, [+ collections,+ handleToggle,+ isReadOnly,+ showTransformsRow,+ values,+ showLibraryPlaceholder,+ ]);if (isLoading) {return (diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/LibrarySyncRow/LibrarySyncRow.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/LibrarySyncRow/LibrarySyncRow.tsxnew file mode 100644index 00000000000..612d8eb3ae6--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/LibrarySyncRow/LibrarySyncRow.tsx@@ -0,0 +1,46 @@+import { useFormikContext } from "formik";+import { t } from "ttag";++import CS from "metabase/css/core/bordered.module.css";+import { Box, Flex, Icon, Switch, Text } from "metabase/ui";+import type { RemoteSyncConfigurationSettings } from "metabase-types/api";++import { SYNC_LIBRARY_PENDING_KEY } from "../../constants";++type FormValues = RemoteSyncConfigurationSettings & {+ [SYNC_LIBRARY_PENDING_KEY]?: boolean;+};++interface LibrarySyncRowProps {+ isReadOnly: boolean;+}++export const LibrarySyncRow = ({ isReadOnly }: LibrarySyncRowProps) => {+ const { values, setFieldValue } = useFormikContext<FormValues>();+ const isChecked = values[SYNC_LIBRARY_PENDING_KEY] ?? false;++ const handleToggle = (checked: boolean) => {+ setFieldValue(SYNC_LIBRARY_PENDING_KEY, checked);+ };++ return (+ <Box p="md" className={CS.borderRowDivider}>+ <Flex justify="space-between" align="center">+ <Flex align="center" gap="sm">+ <Icon name="repository" c="text-secondary" />+ <Text fw="medium">{t`Library`}</Text>+ </Flex>+ <Flex align="center" gap="sm">+ <Switch+ size="sm"+ checked={isChecked}+ onChange={(e) => handleToggle(e.currentTarget.checked)}+ disabled={isReadOnly}+ aria-label={t`Sync Library`}+ />+ <Text>{t`Sync`}</Text>+ </Flex>+ </Flex>+ </Box>+ );+};diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/LibrarySyncRow/index.ts b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/LibrarySyncRow/index.tsnew file mode 100644index 00000000000..78c22b71cc5--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/LibrarySyncRow/index.ts@@ -0,0 +1 @@+export { LibrarySyncRow } from "./LibrarySyncRow";diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/RemoteSyncAdminSettings/RemoteSyncSettingsForm.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/RemoteSyncAdminSettings/RemoteSyncSettingsForm.tsxindex 6c8e9b960f0..9bea0af75fb 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/RemoteSyncAdminSettings/RemoteSyncSettingsForm.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/RemoteSyncAdminSettings/RemoteSyncSettingsForm.tsx@@ -20,6 +20,7 @@ import {FormTextInput,} from "metabase/forms";import { useSelector } from "metabase/lib/redux";+import { PLUGIN_TRANSFORMS } from "metabase/plugins";import { getApplicationName } from "metabase/selectors/whitelabel";import {Box,@@ -31,7 +32,10 @@ import {Text,Tooltip,} from "metabase/ui";-import { useGetLibraryCollectionQuery } from "metabase-enterprise/api";+import {+ useCreateLibraryMutation,+ useGetLibraryCollectionQuery,+} from "metabase-enterprise/api";import {useGetRemoteSyncChangesQuery,useUpdateRemoteSyncSettingsMutation,@@ -52,7 +56,9 @@ import {COLLECTIONS_KEY,REMOTE_SYNC_KEY,REMOTE_SYNC_SCHEMA,+ SYNC_LIBRARY_PENDING_KEY,TOKEN_KEY,+ TRANSFORMS_KEY,TYPE_KEY,URL_KEY,} from "../../constants";@@ -67,6 +73,10 @@ export type RemoteSyncSettingsFormProps = {variant?: "admin" | "settings-modal";};+type RemoteSyncSettingsFormState = RemoteSyncConfigurationSettings & {+ [SYNC_LIBRARY_PENDING_KEY]?: boolean;+};+export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {const { onCancel, onSaveSuccess, variant = "admin" } = props;const { data: settingValues } = useGetSettingsQuery();@@ -75,6 +85,8 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {updateRemoteSyncSettings,{ isLoading: isUpdatingRemoteSyncSettings },] = useUpdateRemoteSyncSettingsMutation();+ const [createLibrary, { isLoading: isCreatingLibrary }] =+ useCreateLibraryMutation();const { data: dirtyData } = useGetRemoteSyncChangesQuery(undefined, {refetchOnFocus: true,refetchOnMountOrArgChange: true,@@ -92,10 +104,13 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {{ skip: !isRemoteSyncEnabled },);+ const isModalVariant = variant === "settings-modal";+// Fetch library collection to build initial sync state+ // For modal variant, always fetch to enable default-checked togglesconst { data: libraryCollectionData } = useGetLibraryCollectionQuery(undefined,- { skip: !isRemoteSyncEnabled },+ { skip: !isRemoteSyncEnabled && !isModalVariant },);// Library collection endpoint returns { data: null } when not foundconst libraryCollection =@@ -122,20 +137,49 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {show: showDisableConfirmation,modalContent: disableConfirmationModal,} = useConfirmation();- const isModalVariant = variant === "settings-modal";const handleSubmit = useCallback(- async (values: RemoteSyncConfigurationSettings) => {+ async (values: RemoteSyncSettingsFormState) => {const didBranchChange =values[BRANCH_KEY] !== settingValues?.[BRANCH_KEY];+ const collectionsMap: Record<number, boolean> = {+ ...values[COLLECTIONS_KEY],+ };++ // If user wants to sync library but it doesn't exist yet, create it first+ const wantsSyncLibrary = values[SYNC_LIBRARY_PENDING_KEY];+ if (isModalVariant && !libraryCollection && wantsSyncLibrary) {+ try {+ const newLibrary = await createLibrary().unwrap();+ // Cast to number since the newly created library will have a numeric ID+ collectionsMap[newLibrary.id as number] = true;+ } catch (error) {+ sendToast({+ message: t`Failed to create Library`,+ icon: "warning",+ });+ throw error;+ }+ }+// Don't send collections when in read-only mode- const settingsToSave =- values[TYPE_KEY] === "read-only"- ? (Object.fromEntries(- Object.entries(values).filter(([key]) => key !== COLLECTIONS_KEY),- ) as RemoteSyncConfigurationSettings)- : values;+ // Also filter out the sync-library-pending key as it's not a real setting+ const isReadOnly = values[TYPE_KEY] === "read-only";+ const settingsToSave: RemoteSyncConfigurationSettings = {+ [REMOTE_SYNC_KEY]: values[REMOTE_SYNC_KEY],+ [URL_KEY]: values[URL_KEY],+ [TOKEN_KEY]: values[TOKEN_KEY],+ [TYPE_KEY]: values[TYPE_KEY],+ [BRANCH_KEY]: values[BRANCH_KEY],+ [AUTO_IMPORT_KEY]: values[AUTO_IMPORT_KEY],+ [TRANSFORMS_KEY]: values[TRANSFORMS_KEY],+ ...(isReadOnly+ ? {}+ : {+ [COLLECTIONS_KEY]: collectionsMap,+ }),+ };const saveSettings = async (settings: RemoteSyncConfigurationSettings,@@ -196,6 +240,8 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {settingValues,updateRemoteSyncSettings,isModalVariant,+ libraryCollection,+ createLibrary,sendToast,onSaveSuccess,showChangeBranchConfirmation,@@ -237,10 +283,14 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {// Build initial collection sync map from server dataconst collectionSyncMap: Record<number, boolean> = {};+ // For modal variant during first-time setup, default library to checked+ const shouldDefaultToChecked = isModalVariant && !isRemoteSyncEnabled;+// Add library collectionif (libraryCollection) {- collectionSyncMap[libraryCollection.id] =- libraryCollection.is_remote_synced ?? false;+ collectionSyncMap[libraryCollection.id] = shouldDefaultToChecked+ ? true+ : (libraryCollection.is_remote_synced ?? false);}// Add top-level collections (excluding personal)@@ -259,6 +309,13 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {...values,[TOKEN_KEY]: tokenValue,[COLLECTIONS_KEY]: collectionSyncMap,+ // For modal variant during first-time setup, default transforms to checked (if enabled)+ [TRANSFORMS_KEY]:+ shouldDefaultToChecked && PLUGIN_TRANSFORMS.isEnabled+ ? true+ : values[TRANSFORMS_KEY],+ // For modal variant when library doesn't exist, default to wanting to create and sync it+ [SYNC_LIBRARY_PENDING_KEY]: shouldDefaultToChecked && !libraryCollection,};}, [settingValues,@@ -266,6 +323,8 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {libraryCollection,topLevelCollectionsData,tenantCollectionsData,+ isModalVariant,+ isRemoteSyncEnabled,]);// eslint-disable-next-line metabase/no-unconditional-metabase-links-render -- This links only shows for admins.@@ -281,7 +340,7 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {return (<><FormProvider- initialValues={initialValues as RemoteSyncConfigurationSettings}+ initialValues={initialValues}enableReinitializevalidationSchema={REMOTE_SYNC_SCHEMA}validationContext={settingValues}@@ -432,11 +491,14 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {</RemoteSyncSettingsSection>)}- {/* Read-write mode info */}+ {/* Content to sync section for modal variant */}{isModalVariant && values?.[TYPE_KEY] === "read-write" && (- <Text c="text-secondary" size="sm">- {t`In read-write mode, the Library collection will be enabled for syncing.`}- </Text>+ <RemoteSyncSettingsSection+ title={t`Content to sync`}+ variant={variant}+ >+ <TopLevelCollectionsList skipCollections />+ </RemoteSyncSettingsSection>)}{/* Footer Actions - Outside Sections */}@@ -477,7 +539,7 @@ export const RemoteSyncSettingsForm = (props: RemoteSyncSettingsFormProps) => {}variant="filled"disabled={isRemoteSyncEnabled ? !dirty : !values?.[URL_KEY]}- loading={isUpdatingRemoteSyncSettings}+ loading={isUpdatingRemoteSyncSettings || isCreatingLibrary}/></Flex></Flex>diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/RemoteSyncAdminSettings/RemoteSyncSettingsForm.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/RemoteSyncAdminSettings/RemoteSyncSettingsForm.unit.spec.tsxindex 2d8b5b7caaa..1a58159e376 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/RemoteSyncAdminSettings/RemoteSyncSettingsForm.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/RemoteSyncAdminSettings/RemoteSyncSettingsForm.unit.spec.tsx@@ -143,21 +143,285 @@ describe("RemoteSyncSettingsForm", () => {});describe("settings-modal variant", () => {- it("should show info text when read-write mode is selected", async () => {- setup({ remoteSyncType: "read-write", variant: "settings-modal" });+ it("should not show set up help link", async () => {+ setup({ variant: "settings-modal" });+ expect(+ screen.queryByRole("link", { name: "setup guide" }),+ ).not.toBeInTheDocument();+ });++ it("should show 'Content to sync' section when read-write mode is selected", async () => {+ const libraryCollection = createMockLibraryCollection({ id: 999 });++ setup({+ remoteSyncType: "read-write",+ variant: "settings-modal",+ libraryCollection,+ });await waitFor(() => {- expect(- screen.getByText(/Library collection will be enabled for syncing/i),- ).toBeInTheDocument();+ expect(screen.getByText("Content to sync")).toBeInTheDocument();});});- it("should now show set up help link", async () => {- setup({ variant: "settings-modal" });- expect(- screen.queryByRole("link", { name: "setup guide" }),- ).not.toBeInTheDocument();+ it("should not show 'Content to sync' section when read-only mode is selected", async () => {+ const libraryCollection = createMockLibraryCollection({ id: 999 });++ setup({+ remoteSyncType: "read-only",+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByLabelText("Read-only")).toBeChecked();+ });++ expect(screen.queryByText("Content to sync")).not.toBeInTheDocument();+ });++ describe("library toggle", () => {+ it("should show library toggle in modal variant when read-write mode is selected", async () => {+ const libraryCollection = createMockLibraryCollection({+ id: 999,+ name: "Library",+ });++ setup({+ remoteSyncType: "read-write",+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ expect(screen.getByLabelText("Sync Library")).toBeInTheDocument();+ });++ it("should have library toggle checked by default during first-time setup", async () => {+ const libraryCollection = createMockLibraryCollection({+ id: 999,+ name: "Library",+ is_remote_synced: false,+ });++ setup({+ remoteSyncType: "read-write",+ remoteSyncEnabled: false,+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ const libraryToggle = screen.getByLabelText("Sync Library");+ expect(libraryToggle).toBeChecked();+ });++ it("should respect existing sync state when remote sync is already enabled", async () => {+ const libraryCollection = createMockLibraryCollection({+ id: 999,+ name: "Library",+ is_remote_synced: false,+ });++ setup({+ remoteSyncType: "read-write",+ remoteSyncEnabled: true,+ remoteSyncUrl: "https://github.com/test/repo.git",+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ const libraryToggle = screen.getByLabelText("Sync Library");+ expect(libraryToggle).not.toBeChecked();+ });++ it("should allow toggling library sync state", async () => {+ const libraryCollection = createMockLibraryCollection({+ id: 999,+ name: "Library",+ });++ setup({+ remoteSyncType: "read-write",+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ const libraryToggle = screen.getByLabelText("Sync Library");+ expect(libraryToggle).toBeChecked();++ await userEvent.click(libraryToggle);+ expect(libraryToggle).not.toBeChecked();+ });+ });++ describe("library toggle when library does not exist", () => {+ it("should show library toggle even when library collection does not exist", async () => {+ setup({+ remoteSyncType: "read-write",+ variant: "settings-modal",+ libraryCollection: null,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ expect(screen.getByLabelText("Sync Library")).toBeInTheDocument();+ expect(screen.getByText("Library")).toBeInTheDocument();+ });++ it("should have library toggle checked by default when library does not exist", async () => {+ setup({+ remoteSyncType: "read-write",+ remoteSyncEnabled: false,+ variant: "settings-modal",+ libraryCollection: null,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ const libraryToggle = screen.getByLabelText("Sync Library");+ expect(libraryToggle).toBeChecked();+ });++ it("should allow toggling library sync state when library does not exist", async () => {+ setup({+ remoteSyncType: "read-write",+ variant: "settings-modal",+ libraryCollection: null,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ const libraryToggle = screen.getByLabelText("Sync Library");+ expect(libraryToggle).toBeChecked();++ await userEvent.click(libraryToggle);+ expect(libraryToggle).not.toBeChecked();+ });+ });++ describe("transforms toggle", () => {+ afterEach(() => {+ PLUGIN_TRANSFORMS.isEnabled = false;+ });++ it("should show transforms toggle in modal variant when feature is enabled", async () => {+ PLUGIN_TRANSFORMS.isEnabled = true;+ const libraryCollection = createMockLibraryCollection({ id: 999 });++ setup({+ remoteSyncType: "read-write",+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ expect(screen.getByLabelText("Sync Transforms")).toBeInTheDocument();+ });++ it("should not show transforms toggle in modal variant when feature is disabled", async () => {+ PLUGIN_TRANSFORMS.isEnabled = false;+ const libraryCollection = createMockLibraryCollection({ id: 999 });++ setup({+ remoteSyncType: "read-write",+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ expect(+ screen.queryByLabelText("Sync Transforms"),+ ).not.toBeInTheDocument();+ });++ it("should have transforms toggle checked by default during first-time setup when feature is enabled", async () => {+ PLUGIN_TRANSFORMS.isEnabled = true;+ const libraryCollection = createMockLibraryCollection({ id: 999 });++ setup({+ remoteSyncType: "read-write",+ remoteSyncEnabled: false,+ remoteSyncTransforms: false,+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ const transformsToggle = screen.getByLabelText("Sync Transforms");+ expect(transformsToggle).toBeChecked();+ });++ it("should respect existing sync state when remote sync is already enabled", async () => {+ PLUGIN_TRANSFORMS.isEnabled = true;+ const libraryCollection = createMockLibraryCollection({ id: 999 });++ setup({+ remoteSyncType: "read-write",+ remoteSyncEnabled: true,+ remoteSyncUrl: "https://github.com/test/repo.git",+ remoteSyncTransforms: false,+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ const transformsToggle = screen.getByLabelText("Sync Transforms");+ expect(transformsToggle).not.toBeChecked();+ });++ it("should allow toggling transforms sync state", async () => {+ PLUGIN_TRANSFORMS.isEnabled = true;+ const libraryCollection = createMockLibraryCollection({ id: 999 });++ setup({+ remoteSyncType: "read-write",+ variant: "settings-modal",+ libraryCollection,+ });++ await waitFor(() => {+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ });++ const transformsToggle = screen.getByLabelText("Sync Transforms");+ expect(transformsToggle).toBeChecked();++ await userEvent.click(transformsToggle);+ expect(transformsToggle).not.toBeChecked();+ });});});@@ -195,14 +459,16 @@ describe("RemoteSyncSettingsForm", () => {expect(screen.getByLabelText("Sync Transforms")).toBeInTheDocument();});- it("should not display transforms row in modal variant (collections section is hidden)", async () => {+ it("should display transforms toggle in modal variant 'Content to sync' section when feature is enabled", async () => {PLUGIN_TRANSFORMS.isEnabled = true;+ const libraryCollection = createMockLibraryCollection({ id: 999 });setup({remoteSyncEnabled: true,remoteSyncType: "read-write",remoteSyncUrl: "https://github.com/test/repo.git",variant: "settings-modal",+ libraryCollection,});// Wait for the form to be fully rendered with read-write mode@@ -210,10 +476,9 @@ describe("RemoteSyncSettingsForm", () => {expect(screen.getByLabelText("Read-write")).toBeChecked();});- // In modal variant, collections section is hidden, so transforms row is also hidden- expect(- screen.queryByLabelText("Sync Transforms"),- ).not.toBeInTheDocument();+ // In modal variant, transforms toggle is shown in "Content to sync" section+ expect(screen.getByText("Content to sync")).toBeInTheDocument();+ expect(screen.getByLabelText("Sync Transforms")).toBeInTheDocument();});});diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/TopLevelCollectionsList/TopLevelCollectionsList.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/TopLevelCollectionsList/TopLevelCollectionsList.tsxindex 11c41907e29..c7710eb4fa5 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/TopLevelCollectionsList/TopLevelCollectionsList.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/TopLevelCollectionsList/TopLevelCollectionsList.tsx@@ -8,11 +8,24 @@ import type { CollectionItem } from "metabase-types/api";import { CollectionSyncList } from "../CollectionSyncList";-export const TopLevelCollectionsList = () => {- const { data, isLoading, error } = useListCollectionItemsQuery({- id: "root",- models: ["collection"],- });+interface TopLevelCollectionsListProps {+ /**+ * When true, skip other top-level collections and only show Library and Transforms.+ * Useful for modal variant where only these options should be shown.+ */+ skipCollections?: boolean;+}++export const TopLevelCollectionsList = ({+ skipCollections,+}: TopLevelCollectionsListProps = {}) => {+ const { data, isLoading, error } = useListCollectionItemsQuery(+ {+ id: "root",+ models: ["collection"],+ },+ { skip: skipCollections },+ );const { data: libraryCollectionData, isLoading: isLoadingLibrary } =useGetLibraryCollectionQuery();@@ -25,6 +38,11 @@ export const TopLevelCollectionsList = () => {// Filter out personal collections and analytics collections, combine with library collectionconst collections = useMemo(() => {+ // When skipCollections is true, only show library collection+ if (skipCollections) {+ return libraryCollection ? [libraryCollection] : [];+ }+const topLevelCollections = (data?.data ?? []).filter((c) => !c.personal_owner_id && c.type !== "instance-analytics",);@@ -35,7 +53,7 @@ export const TopLevelCollectionsList = () => {}return topLevelCollections;- }, [data, libraryCollection]);+ }, [data, libraryCollection, skipCollections]);return (<CollectionSyncList@@ -44,6 +62,7 @@ export const TopLevelCollectionsList = () => {error={error ? t`Failed to load collections` : null}isLoading={isLoading || isLoadingLibrary}showTransformsRow={PLUGIN_TRANSFORMS.isEnabled}+ showLibraryPlaceholder={skipCollections && !libraryCollection}/>);};diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/constants.ts b/enterprise/frontend/src/metabase-enterprise/remote_sync/constants.tsindex 973bbcc2acf..a78a8bf5214 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/constants.ts+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/constants.ts@@ -1,6 +1,11 @@import type { TagDescription } from "@reduxjs/toolkit/query";import * as Yup from "yup";+import {+ REMOTE_SYNC_TYPES,+ type RemoteSyncType,+} from "metabase-types/api/settings";+import { type EnterpriseTagType, tag } from "../api/tags";export const URL_KEY = "remote-sync-url";@@ -11,6 +16,8 @@ export const REMOTE_SYNC_KEY = "remote-sync-enabled";export const AUTO_IMPORT_KEY = "remote-sync-auto-import";export const TRANSFORMS_KEY = "remote-sync-transforms";export const COLLECTIONS_KEY = "collections";+// Used in modal variant when library doesn't exist yet but user wants to sync it+export const SYNC_LIBRARY_PENDING_KEY = "sync-library-pending";export const REMOTE_SYNC_SCHEMA = Yup.object({[REMOTE_SYNC_KEY]: Yup.boolean().nullable().default(true),@@ -18,12 +25,13 @@ export const REMOTE_SYNC_SCHEMA = Yup.object({[TOKEN_KEY]: Yup.string().nullable().default(null),[AUTO_IMPORT_KEY]: Yup.boolean().nullable().default(false),[TRANSFORMS_KEY]: Yup.boolean().nullable().default(false),- [TYPE_KEY]: Yup.string()- .oneOf(["read-only", "read-write"] as const)+ [TYPE_KEY]: Yup.mixed<RemoteSyncType>()+ .oneOf([...REMOTE_SYNC_TYPES]).nullable()- .default("read-only"),+ .default("read-only" as const),[BRANCH_KEY]: Yup.string().nullable().default("main"),[COLLECTIONS_KEY]: Yup.object().nullable().default({}),+ [SYNC_LIBRARY_PENDING_KEY]: Yup.boolean().nullable().default(false),});export const REMOTE_SYNC_INVALIDATION_TAGS: TagDescription<EnterpriseTagType>[] =diff --git a/frontend/src/metabase-types/api/remote-sync.ts b/frontend/src/metabase-types/api/remote-sync.tsindex bb6b0ed9f02..c9cf93d8006 100644--- a/frontend/src/metabase-types/api/remote-sync.ts+++ b/frontend/src/metabase-types/api/remote-sync.ts@@ -84,6 +84,7 @@ export type RemoteSyncConfigurationSettings = Pick<| "remote-sync-token"| "remote-sync-type"| "remote-sync-branch"+ | "remote-sync-auto-import"| "remote-sync-transforms"> & {collections?: CollectionSyncPreferences;diff --git a/frontend/src/metabase-types/api/settings.ts b/frontend/src/metabase-types/api/settings.tsindex fa7eeca976c..99ba58b9d0e 100644--- a/frontend/src/metabase-types/api/settings.ts+++ b/frontend/src/metabase-types/api/settings.ts@@ -282,6 +282,9 @@ const tokenStatusFeatures = [export type TokenStatusFeature = (typeof tokenStatusFeatures)[number];+export const REMOTE_SYNC_TYPES = ["read-only", "read-write"] as const;+export type RemoteSyncType = (typeof REMOTE_SYNC_TYPES)[number];+interface TokenStatusStoreUsers {email: string;}@@ -676,7 +679,7 @@ export interface EnterpriseSettings extends Settings {"remote-sync-token"?: string | null;"remote-sync-url"?: string | null;"remote-sync-branch"?: string | null;- "remote-sync-type"?: "read-only" | "read-write" | null;+ "remote-sync-type"?: RemoteSyncType | null;"remote-sync-auto-import"?: boolean | null;"remote-sync-transforms"?: boolean | null;"login-page-illustration"?: IllustrationSettingValue;