Skip to content

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

Remove sync buttons for managed cloud databases (#71203)

Romeo Van Snickc8cb9c2f0403
diff --git a/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.tsx b/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.tsx
index abc45c284de..8c7c2a083be 100644
--- a/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.tsx
+++ b/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.tsx
@@ -73,35 +73,37 @@ export const DatabaseConnectionInfoSection = ({
<DatabaseInfoSectionDivider condensed />
- <Flex gap="sm" wrap="wrap">
- {!isSynced && <Button disabled>{t`Syncing database…`}</Button>}
- <ActionButton
- className={S.actionButton}
- actionFn={handleSyncDatabaseSchema}
- normalText={t`Sync database schema`}
- activeText={t`Starting…`}
- failedText={t`Failed to sync`}
- successText={t`Sync triggered!`}
- />
- <ActionButton
- className={S.actionButton}
- actionFn={() => rescanDatabaseFieldValues(database.id).unwrap()}
- normalText={t`Re-scan field values`}
- activeText={t`Starting…`}
- failedText={t`Failed to start scan`}
- successText={t`Scan triggered!`}
- />
- {!isSynced && (
+ {!database.is_attached_dwh && (
+ <Flex gap="sm" wrap="wrap">
+ {!isSynced && <Button disabled>{t`Syncing database…`}</Button>}
<ActionButton
className={S.actionButton}
- actionFn={handleDismissSyncSpinner}
- normalText={t`Dismiss sync spinner manually`}
- activeText={t`Dismissing…`}
- failedText={t`Failed to dismiss sync spinner`}
- successText={t`Sync spinners dismissed!`}
+ actionFn={handleSyncDatabaseSchema}
+ normalText={t`Sync database schema`}
+ activeText={t`Starting…`}
+ failedText={t`Failed to sync`}
+ successText={t`Sync triggered!`}
/>
- )}
- </Flex>
+ <ActionButton
+ className={S.actionButton}
+ actionFn={() => rescanDatabaseFieldValues(database.id).unwrap()}
+ normalText={t`Re-scan field values`}
+ activeText={t`Starting…`}
+ failedText={t`Failed to start scan`}
+ successText={t`Scan triggered!`}
+ />
+ {!isSynced && (
+ <ActionButton
+ className={S.actionButton}
+ actionFn={handleDismissSyncSpinner}
+ normalText={t`Dismiss sync spinner manually`}
+ activeText={t`Dismissing…`}
+ failedText={t`Failed to dismiss sync spinner`}
+ successText={t`Sync spinners dismissed!`}
+ />
+ )}
+ </Flex>
+ )}
</DatabaseInfoSection>
);
};
diff --git a/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.unit.spec.tsx b/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.unit.spec.tsx
index ea3f7794669..9339d3ab256 100644
--- a/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.unit.spec.tsx
+++ b/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.unit.spec.tsx
@@ -176,4 +176,16 @@ describe("DatabaseConnectionInfoSection", () => {
});
});
});
+
+ describe("Cloud-attached databases", () => {
+ it("should not show the sync actions", async () => {
+ setup({ database: createMockDatabase({ is_attached_dwh: true }) });
+ expect(
+ screen.queryByText(/Sync database schema/i),
+ ).not.toBeInTheDocument();
+ expect(
+ screen.queryByText(/Re-scan field values/i),
+ ).not.toBeInTheDocument();
+ });
+ });
});
diff --git a/frontend/src/metabase/data-studio/data-model/components/TableSection/TableSection.tsx b/frontend/src/metabase/data-studio/data-model/components/TableSection/TableSection.tsx
index ed601371bfe..6d470ee3808 100644
--- a/frontend/src/metabase/data-studio/data-model/components/TableSection/TableSection.tsx
+++ b/frontend/src/metabase/data-studio/data-model/components/TableSection/TableSection.tsx
@@ -251,13 +251,15 @@ const TableSectionBase = ({
{table.is_published ? t`Unpublish` : t`Publish`}
</Button>
)}
- <Button
- flex="1"
- leftSection={<Icon name="settings" />}
- onClick={onSyncOptionsClick}
- >
- {t`Sync settings`}
- </Button>
+ {!table.db?.is_attached_dwh && (
+ <Button
+ flex="1"
+ leftSection={<Icon name="settings" />}
+ onClick={onSyncOptionsClick}
+ >
+ {t`Sync settings`}
+ </Button>
+ )}
<PLUGIN_REPLACEMENT.SourceReplacementButton>
{({ tooltip, isDisabled }) => (
<Tooltip label={tooltip ?? t`Find and replace`}>
diff --git a/frontend/src/metabase/data-studio/data-model/components/TableSection/tests/common.unit.spec.tsx b/frontend/src/metabase/data-studio/data-model/components/TableSection/tests/common.unit.spec.tsx
index 5c9ccaafa2b..94cd9445f2a 100644
--- a/frontend/src/metabase/data-studio/data-model/components/TableSection/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/data-studio/data-model/components/TableSection/tests/common.unit.spec.tsx
@@ -1,5 +1,9 @@
import { screen } from "__support__/ui";
-import { createMockSegment, createMockTable } from "metabase-types/api/mocks";
+import {
+ createMockDatabase,
+ createMockSegment,
+ createMockTable,
+} from "metabase-types/api/mocks";
import { setup } from "./setup";
@@ -16,6 +20,14 @@ describe("TableSection", () => {
);
});
+ it("should not render sync settings button when the database is datawarehouse attached", () => {
+ setup({
+ database: createMockDatabase({ is_attached_dwh: true }),
+ });
+
+ expect(screen.queryByText("Sync settings")).not.toBeInTheDocument();
+ });
+
describe("tabs", () => {
it("should render Fields and Segments tabs", () => {
setup({ activeTab: "field" });
diff --git a/frontend/src/metabase/data-studio/data-model/components/TableSection/tests/setup.tsx b/frontend/src/metabase/data-studio/data-model/components/TableSection/tests/setup.tsx
index c651dcc2deb..bd12c1985d6 100644
--- a/frontend/src/metabase/data-studio/data-model/components/TableSection/tests/setup.tsx
+++ b/frontend/src/metabase/data-studio/data-model/components/TableSection/tests/setup.tsx
@@ -10,12 +10,14 @@ import { renderWithProviders } from "__support__/ui";
import type { RouteParams } from "metabase/data-studio/data-model/pages/DataModel/types";
import type { DataStudioTableMetadataTab } from "metabase/lib/urls";
import type {
+ Database,
EnterpriseSettings,
Segment,
Table,
TokenFeatures,
} from "metabase-types/api";
import {
+ createMockDatabase,
createMockTable,
createMockTokenFeatures,
createMockUser,
@@ -25,6 +27,7 @@ import { createMockState } from "metabase-types/store/mocks";
import { TableSection } from "../TableSection";
export type SetupOpts = {
+ database?: Database;
table?: Table;
params?: RouteParams;
activeTab?: DataStudioTableMetadataTab;
@@ -37,7 +40,8 @@ export type SetupOpts = {
};
export function setup({
- table = createMockTable(),
+ database = createMockDatabase(),
+ table = createMockTable({ db: database }),
activeTab = "field",
segments,
isAdmin = false,
diff --git a/frontend/src/metabase/metadata/components/TableSection/TableSection.tsx b/frontend/src/metabase/metadata/components/TableSection/TableSection.tsx
index 1fbf1b051cf..77a68104540 100644
--- a/frontend/src/metabase/metadata/components/TableSection/TableSection.tsx
+++ b/frontend/src/metabase/metadata/components/TableSection/TableSection.tsx
@@ -220,7 +220,7 @@ const TableSectionBase = ({
>{t`Sorting`}</ResponsiveButton>
)}
- {!isSorting && (
+ {!isSorting && !table.db?.is_attached_dwh && (
<ResponsiveButton
icon="gear_settings_filled"
showLabel={showButtonLabel}
diff --git a/frontend/src/metabase/metadata/components/TableSection/TableSection.unit.spec.tsx b/frontend/src/metabase/metadata/components/TableSection/TableSection.unit.spec.tsx
index 45fc8e82b2b..8d430423117 100644
--- a/frontend/src/metabase/metadata/components/TableSection/TableSection.unit.spec.tsx
+++ b/frontend/src/metabase/metadata/components/TableSection/TableSection.unit.spec.tsx
@@ -2,7 +2,7 @@ import { Route } from "react-router";
import { renderWithProviders, screen } from "__support__/ui";
import type { FieldId, Table } from "metabase-types/api";
-import { createMockTable } from "metabase-types/api/mocks";
+import { createMockDatabase, createMockTable } from "metabase-types/api/mocks";
import { TableSection } from "./TableSection";
@@ -45,4 +45,11 @@ describe("TableSection", () => {
`/question#?db=${table.db_id}&table=${table.id}`,
);
});
+
+ it("should not render the sync options button when the database is hosted", () => {
+ const database = createMockDatabase({ is_attached_dwh: true });
+ const table = createMockTable({ db: database });
+ setup({ table });
+ expect(screen.queryByText("Sync options")).not.toBeInTheDocument();
+ });
});