Skip to content
Snippets Groups Projects
Unverified Commit 7213d150 authored by Ryan Laurie's avatar Ryan Laurie Committed by GitHub
Browse files

Add warning for h2 uploads db (#35664)

parent 5369e1cf
Branches
Tags
No related merge requests found
......@@ -13,13 +13,14 @@ import { updateSettings } from "metabase/admin/settings/settings";
import type { State } from "metabase-types/store";
import { Stack, Group } from "metabase/ui";
import { Stack, Group, Text } from "metabase/ui";
import Link from "metabase/core/components/Link";
import type { SelectChangeEvent } from "metabase/core/components/Select";
import Select from "metabase/core/components/Select";
import Input from "metabase/core/components/Input";
import ActionButton from "metabase/components/ActionButton";
import EmptyState from "metabase/components/EmptyState/EmptyState";
import Alert from "metabase/core/components/Alert";
import type Database from "metabase-lib/metadata/Database";
import type Schema from "metabase-lib/metadata/Schema";
......@@ -163,10 +164,14 @@ export function UploadSettingsView({
tablePrefix !== settings.uploads_table_prefix;
const hasValidDatabases = databaseOptions.length > 0;
const isH2db = Boolean(
dbId && databases.find(db => db.id === dbId)?.engine === "h2",
);
return (
<PaddedForm aria-label={t`Upload Settings Form`}>
<Header />
{isH2db && <H2PersistenceWarning />}
<Group>
<Stack>
<SectionTitle>{t`Database to use for uploads`}</SectionTitle>
......@@ -273,6 +278,16 @@ export function UploadSettingsView({
);
}
const H2PersistenceWarning = () => (
<Stack my="md" maw={620}>
<Alert icon="warning" variant="warning">
<Text>
{t`Warning: uploads to the Sample Database are for testing only and may disappear. If you want your data to stick around, you should upload to a PostgreSQL or MySQL database.`}
</Text>
</Alert>
</Stack>
);
const NoValidDatabasesMessage = () => (
<>
<p>
......
......@@ -554,4 +554,15 @@ describe("Admin > Settings > UploadSetting", () => {
).toBeInTheDocument();
});
});
it("should show a warning for h2 databases", async () => {
setup();
userEvent.click(await screen.findByText("Select a database"));
userEvent.click(await screen.findByText("Db Cinco")); // h2
expect(
screen.getByText(/uploads to the Sample Database are for testing only/i),
).toBeInTheDocument();
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment