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
Workspace setup entry point from zero state (#74887)
Alexander Polyankindb65e87b1329
diff --git a/e2e/support/helpers/e2e-workspace-helpers.ts b/e2e/support/helpers/e2e-workspace-helpers.tsindex 53e8d379dce..f9b38e4951b 100644--- a/e2e/support/helpers/e2e-workspace-helpers.ts+++ b/e2e/support/helpers/e2e-workspace-helpers.ts@@ -14,6 +14,10 @@ export const WorkspaceListPage = {WorkspaceListPage.get().findByRole("button", {name: first ? "Create a workspace" : "New",}),+ setupInstanceButton: () =>+ WorkspaceListPage.get().findByRole("button", {+ name: "upload a workspace config",+ }),workspaceList: () => WorkspaceListPage.get().findByTestId("workspace-list"),workspace: (name: string) =>WorkspaceListPage.get().findByRole("region", { name }),@@ -153,17 +157,9 @@ export const WorkspaceInstancePage = {},database: (name: string) =>WorkspaceInstancePage.get().findByRole("region", { name }),- emptyState: () =>- WorkspaceInstancePage.get().findByText(- /Tables will be remapped here the first time a transform runs/,- ),remappingRow: (canonicalName: string) =>WorkspaceInstancePage.get().findByText(canonicalName),- setupButton: () =>- WorkspaceInstancePage.get().findByRole("button", {- name: "Set up a workspace",- }),- exitButton: () =>+ leaveButton: () =>WorkspaceInstancePage.get().findByRole("button", {name: "Leave workspace",}),diff --git a/e2e/test/scenarios/workspaces/workspace-instance.cy.spec.ts b/e2e/test/scenarios/workspaces/workspace-instance.cy.spec.tsindex e8195e522f8..bfb43844717 100644--- a/e2e/test/scenarios/workspaces/workspace-instance.cy.spec.ts+++ b/e2e/test/scenarios/workspaces/workspace-instance.cy.spec.ts@@ -88,7 +88,6 @@ describe("scenarios > workspaces > workspace instance", () => {H.restore("postgres-writable");cy.signInAsAdmin();H.activateToken("bleeding-edge");- stubDevelopmentModeTokenFeature();H.resetTestTable({ type: "postgres", table: "multi_schema" });H.queryWritableDB(`CREATE SCHEMA IF NOT EXISTS ${POSTGRES_OUTPUT_SCHEMA}`,@@ -107,8 +106,8 @@ describe("scenarios > workspaces > workspace instance", () => {it("runs a transform, surfaces the remapping on the instance page, and queries the remapped table", () => {cy.log("set up the workspace");- H.WorkspaceInstancePage.visit();- H.WorkspaceInstancePage.setupButton().click();+ H.WorkspaceListPage.visit();+ H.WorkspaceListPage.setupInstanceButton().click();H.SetupWorkspaceModal.uploadConfig(POSTGRES_CONFIG);H.SetupWorkspaceModal.setupButton().click();H.WorkspaceInstancePage.get().should("be.visible");@@ -157,11 +156,11 @@ describe("scenarios > workspaces > workspace instance", () => {expect(Number(result.rows[0].count)).to.eq(ROW_COUNT);});- cy.log("exit the workspace through the UI");+ cy.log("leave the workspace through the UI");H.WorkspaceInstancePage.visit();- H.WorkspaceInstancePage.exitButton().click();+ H.WorkspaceInstancePage.leaveButton().click();H.ExitWorkspaceModal.confirmButton().click();- H.WorkspaceInstancePage.setupButton().should("be.visible");+ H.WorkspaceListPage.setupInstanceButton().should("be.visible");});});@@ -170,7 +169,6 @@ describe("scenarios > workspaces > workspace instance", () => {H.restore("mysql-writable");cy.signInAsAdmin();H.activateToken("bleeding-edge");- stubDevelopmentModeTokenFeature();H.resetTestTable({ type: "mysql", table: MYSQL_SOURCE_TABLE });H.queryWritableDB(`DROP DATABASE IF EXISTS ${MYSQL_OUTPUT_DATABASE}`,@@ -190,8 +188,8 @@ describe("scenarios > workspaces > workspace instance", () => {it("runs a transform, surfaces the remapping on the instance page, and queries the remapped table", () => {cy.log("set up the workspace");- H.WorkspaceInstancePage.visit();- H.WorkspaceInstancePage.setupButton().click();+ H.WorkspaceListPage.visit();+ H.WorkspaceListPage.setupInstanceButton().click();H.SetupWorkspaceModal.uploadConfig(MYSQL_CONFIG);H.SetupWorkspaceModal.setupButton().click();H.WorkspaceInstancePage.get().should("be.visible");@@ -236,23 +234,15 @@ describe("scenarios > workspaces > workspace instance", () => {expect(Number(result.rows[0].count)).to.eq(ROW_COUNT);});- cy.log("exit the workspace through the UI");+ cy.log("leave the workspace through the UI");H.WorkspaceInstancePage.visit();- H.WorkspaceInstancePage.exitButton().click();+ H.WorkspaceInstancePage.leaveButton().click();H.ExitWorkspaceModal.confirmButton().click();- H.WorkspaceInstancePage.setupButton().should("be.visible");+ H.WorkspaceListPage.setupInstanceButton().should("be.visible");});});});-function stubDevelopmentModeTokenFeature() {- cy.intercept("/api/session/properties", (req) => {- req.continue((res) => {- res.body["token-features"].development_mode = true;- });- });-}-function createAndRunTransform({sourceTable,sourceSchema,diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/analytics.ts b/enterprise/frontend/src/metabase-enterprise/workspaces/analytics.tsindex 7f538dc6859..e08e6645905 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/analytics.ts+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/analytics.ts@@ -47,8 +47,8 @@ export function trackWorkspaceInstanceSetup() {});}-export function trackWorkspaceInstanceTeardown() {+export function trackWorkspaceInstanceLeave() {trackSimpleEvent({- event: "workspaces_instance_teardown",+ event: "workspaces_instance_leave",});}diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/components/WorkspaceEmptyState/WorkspaceEmptyState.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/components/WorkspaceEmptyState/WorkspaceEmptyState.tsxdeleted file mode 100644index 758519117ea..00000000000--- a/enterprise/frontend/src/metabase-enterprise/workspaces/components/WorkspaceEmptyState/WorkspaceEmptyState.tsx+++ /dev/null@@ -1,94 +0,0 @@-import type { ReactNode } from "react";-import { Link } from "react-router";-import { t } from "ttag";--import { useDocsUrl } from "metabase/common/hooks";-import {- Box,- Card,- FixedSizeIcon,- Group,- Stack,- Text,- Title,-} from "metabase/ui";--import S from "./WorkspaceEmptyState.module.css";--type WorkspaceEmptyStateProps = {- description: ReactNode;- children?: ReactNode;-};--export function WorkspaceEmptyState({- description,- children,-}: WorkspaceEmptyStateProps) {- const { url: fileBasedDevDocsUrl, showMetabaseLinks: showFileBasedDevLink } =- useDocsUrl("ai/file-based-development");- const { url: remoteSyncDocsUrl, showMetabaseLinks: showRemoteSyncLink } =- useDocsUrl("installation-and-operation/remote-sync");-- return (- <Card p="xl" maw="40rem" mx="auto" shadow="none" withBorder>- <Box p="md">- <Title- order={3}- mb="sm"- >{t`Isolated spaces for agents and developers`}</Title>- <Text c="text-secondary" mb="md">- {description}- </Text>- {children}- {(showFileBasedDevLink || showRemoteSyncLink) && (- <Group pt="md" gap="sm" align="stretch">- {showFileBasedDevLink && (- <DocsLink- title={t`File-based development`}- description={t`How to use the CLI to develop content locally.`}- link={fileBasedDevDocsUrl}- />- )}- {showRemoteSyncLink && (- <DocsLink- title={t`Using remote sync`}- description={t`How to sync and review instance content with git.`}- link={remoteSyncDocsUrl}- />- )}- </Group>- )}- </Box>- </Card>- );-}--type DocsLinkProps = {- title: string;- description: string;- link: string;-};--function DocsLink({ title, description, link }: DocsLinkProps) {- return (- <Box- className={S.docsLink}- component={Link}- to={link}- target="_blank"- rel="noreferrer"- p="md"- bdrs="md"- flex="1"- miw="16rem"- >- <Group gap="sm" wrap="nowrap" align="flex-start">- <FixedSizeIcon c="brand" name="reference" />- <Stack gap="xs">- <Title order={5}>{title}</Title>- <Box c="text-secondary">{description}</Box>- </Stack>- </Group>- </Box>- );-}diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceIndexPage/WorkspaceIndexPage.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceIndexPage/WorkspaceIndexPage.tsxindex 8ec465a55e3..9dbea58c6bb 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceIndexPage/WorkspaceIndexPage.tsx+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceIndexPage/WorkspaceIndexPage.tsx@@ -2,16 +2,12 @@ import { DelayedLoadingAndErrorWrapper } from "metabase/common/components/Loadinimport { useSelector } from "metabase/redux";import { useGetCurrentWorkspaceQuery } from "metabase-enterprise/api";-import {- canManageWorkspaceInstance,- getIsDevelopmentMode,-} from "../../selectors";+import { canManageWorkspaceInstance } from "../../selectors";import { WorkspaceInstancePage } from "../WorkspaceInstancePage";import { WorkspaceListPage } from "../WorkspaceListPage";export function WorkspaceIndexPage() {const canManageInstance = useSelector(canManageWorkspaceInstance);- const isDevelopmentMode = useSelector(getIsDevelopmentMode);const {data: workspace,@@ -23,7 +19,7 @@ export function WorkspaceIndexPage() {return <DelayedLoadingAndErrorWrapper loading={isLoading} error={error} />;}- if (workspace != null || isDevelopmentMode) {+ if (workspace != null && canManageInstance) {return <WorkspaceInstancePage />;}diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceIndexPage/WorkspaceIndexPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceIndexPage/WorkspaceIndexPage.unit.spec.tsxindex f479bc6c183..248b1d05e2f 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceIndexPage/WorkspaceIndexPage.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceIndexPage/WorkspaceIndexPage.unit.spec.tsx@@ -36,14 +36,12 @@ type SetupOpts = {isAdmin?: boolean;canManageWorkspaces?: boolean;workspace?: WorkspaceInstance | null;- isDevelopmentMode?: boolean;};function setup({isAdmin = true,canManageWorkspaces = false,workspace = null,- isDevelopmentMode = false,}: SetupOpts = {}) {setupDatabasesEndpoints([POSTGRES]);setupGetCurrentWorkspaceEndpoint(workspace);@@ -62,7 +60,6 @@ function setup({settings: mockSettings({"token-features": createMockTokenFeatures({workspaces: true,- development_mode: isDevelopmentMode,}),}),});@@ -83,17 +80,8 @@ describe("WorkspaceIndexPage", () => {expect(screen.queryByTestId("workspace-list-page")).not.toBeInTheDocument();});- it("admin in development mode sees the instance page even without a workspace", async () => {- setup({ isAdmin: true, workspace: null, isDevelopmentMode: true });-- expect(- await screen.findByTestId("workspace-instance-page"),- ).toBeInTheDocument();- expect(screen.queryByTestId("workspace-list-page")).not.toBeInTheDocument();- });-- it("admin without a workspace and not in development mode sees the list page", async () => {- setup({ isAdmin: true, workspace: null, isDevelopmentMode: false });+ it("admin without a workspace sees the list page", async () => {+ setup({ isAdmin: true, workspace: null });expect(await screen.findByTestId("workspace-list-page"),diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/DeleteSection/DeleteSection.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/DeleteSection/DeleteSection.tsxindex bcf91d5ff07..a2c780f0580 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/DeleteSection/DeleteSection.tsx+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/DeleteSection/DeleteSection.tsx@@ -5,7 +5,7 @@ import { TitleSection } from "metabase/data-studio/common/components/TitleSectioimport { Button, Code, Group, Text } from "metabase/ui";import { useDeleteWorkspaceInstanceMutation } from "metabase-enterprise/api";-import { trackWorkspaceInstanceTeardown } from "../../../analytics";+import { trackWorkspaceInstanceLeave } from "../../../analytics";const CONFIG_FILENAME = "config.yml";@@ -23,7 +23,7 @@ export function DeleteSection() {confirmButtonProps: { color: "danger" },onConfirm: async () => {await deleteInstance().unwrap();- trackWorkspaceInstanceTeardown();+ trackWorkspaceInstanceLeave();},});};diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/DeleteSection/DeleteSection.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/DeleteSection/DeleteSection.unit.spec.tsxindex 54f99a7e602..b36fe98fce7 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/DeleteSection/DeleteSection.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/DeleteSection/DeleteSection.unit.spec.tsx@@ -56,7 +56,7 @@ describe("DeleteSection", () => {await waitFor(() =>expect(trackSimpleEvent).toHaveBeenCalledWith({- event: "workspaces_instance_teardown",+ event: "workspaces_instance_leave",}),);});diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/WorkspaceInstanceEmptyState.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/WorkspaceInstanceEmptyState.tsxdeleted file mode 100644index c64c1ad38a6..00000000000--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/WorkspaceInstanceEmptyState.tsx+++ /dev/null@@ -1,38 +0,0 @@-import { useDisclosure } from "@mantine/hooks";-import { t } from "ttag";--import { useSelector } from "metabase/redux";-import { Box, Button } from "metabase/ui";--import { trackWorkspaceSetupButtonClicked } from "../../../analytics";-import { WorkspaceEmptyState } from "../../../components/WorkspaceEmptyState";-import { getIsDevelopmentMode } from "../../../selectors";-import { SetupWorkspaceModal } from "../SetupWorkspaceModal";--export function WorkspaceInstanceEmptyState() {- const [opened, { open, close }] = useDisclosure(false);- const isDevelopmentMode = useSelector(getIsDevelopmentMode);-- return (- <>- <WorkspaceEmptyState- description={t`Set up this developer instance to remap transform tables into an isolated workspace schema, so you can develop and test transforms without affecting your production tables.`}- >- {isDevelopmentMode && (- <Box pb="xl">- <Button- variant="filled"- onClick={() => {- trackWorkspaceSetupButtonClicked();- open();- }}- >- {t`Set up a workspace`}- </Button>- </Box>- )}- </WorkspaceEmptyState>- <SetupWorkspaceModal opened={opened} onClose={close} />- </>- );-}diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/WorkspaceInstanceEmptyState.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/WorkspaceInstanceEmptyState.unit.spec.tsxdeleted file mode 100644index 09f9d6d59d1..00000000000--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/WorkspaceInstanceEmptyState.unit.spec.tsx+++ /dev/null@@ -1,60 +0,0 @@-import userEvent from "@testing-library/user-event";--import { renderWithProviders, screen } from "__support__/ui";-import { createMockSettingsState } from "metabase/redux/store/mocks";-import {- createMockSettings,- createMockTokenFeatures,-} from "metabase-types/api/mocks";--import { WorkspaceInstanceEmptyState } from "./WorkspaceInstanceEmptyState";--const { trackSimpleEvent } = jest.requireMock("metabase/analytics");--function setup({ isDevelopmentMode = true } = {}) {- renderWithProviders(<WorkspaceInstanceEmptyState />, {- storeInitialState: {- settings: createMockSettingsState(- createMockSettings({- "token-features": createMockTokenFeatures({- development_mode: isDevelopmentMode,- }),- }),- ),- },- });-}--describe("WorkspaceInstanceEmptyState", () => {- beforeEach(() => {- trackSimpleEvent.mockClear();- });-- it("shows the set up button in development mode", () => {- setup({ isDevelopmentMode: true });-- expect(- screen.getByRole("button", { name: "Set up a workspace" }),- ).toBeInTheDocument();- });-- it("hides the set up button outside of development mode", () => {- setup({ isDevelopmentMode: false });-- expect(- screen.queryByRole("button", { name: "Set up a workspace" }),- ).not.toBeInTheDocument();- });-- it("tracks an analytics event when the set up button is clicked", async () => {- setup({ isDevelopmentMode: true });-- await userEvent.click(- screen.getByRole("button", { name: "Set up a workspace" }),- );-- expect(trackSimpleEvent).toHaveBeenCalledWith({- event: "workspaces_setup_button_clicked",- });- });-});diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/index.ts b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/index.tsdeleted file mode 100644index c36b2e49103..00000000000--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstanceEmptyState/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./WorkspaceInstanceEmptyState";diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstancePage.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstancePage.tsxindex abf1f8c891b..e47a970bafa 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstancePage.tsx+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstancePage.tsx@@ -5,7 +5,6 @@ import { DelayedLoadingAndErrorWrapper } from "metabase/common/components/Loadinimport { DataStudioBreadcrumbs } from "metabase/data-studio/common/components/DataStudioBreadcrumbs";import { PageContainer } from "metabase/data-studio/common/components/PageContainer";import { PaneHeader } from "metabase/data-studio/common/components/PaneHeader";-import { useSelector } from "metabase/redux";import { Stack, Title } from "metabase/ui";import {useGetCurrentWorkspaceQuery,@@ -18,11 +17,9 @@ import type {} from "metabase-types/api";import { HelpMenu } from "../../components/HelpMenu";-import { getIsDevelopmentMode } from "../../selectors";import { DeleteSection } from "./DeleteSection";import { TableRemappingSection } from "./TableRemappingSection";-import { WorkspaceInstanceEmptyState } from "./WorkspaceInstanceEmptyState";import { getDatabasesInfo } from "./utils";export function WorkspaceInstancePage() {@@ -49,6 +46,7 @@ export function WorkspaceInstancePage() {if (isLoading ||error != null ||+ workspace == null ||remappings == null ||databasesResponse == null) {@@ -57,7 +55,7 @@ export function WorkspaceInstancePage() {return (<WorkspaceInstancePageBody- workspace={workspace ?? null}+ workspace={workspace}remappings={remappings}databases={databasesResponse.data}/>@@ -65,7 +63,7 @@ export function WorkspaceInstancePage() {}type WorkspaceInstancePageBodyProps = {- workspace: WorkspaceInstance | null;+ workspace: WorkspaceInstance;remappings: TableRemapping[];databases: Database[];};@@ -75,36 +73,29 @@ function WorkspaceInstancePageBody({remappings,databases,}: WorkspaceInstancePageBodyProps) {- const databasesInfo =- workspace != null ? getDatabasesInfo(workspace, databases, remappings) : [];- const isDevelopmentMode = useSelector(getIsDevelopmentMode);+ const databasesInfo = getDatabasesInfo(workspace, databases, remappings);return (<PageContainer data-testid="workspace-instance-page"><PaneHeader- title={- workspace != null ? <Title order={3}>{workspace.name}</Title> : null- }+ title={<Title order={3}>{workspace.name}</Title>}breadcrumbs={<DataStudioBreadcrumbs>{t`Workspaces`}</DataStudioBreadcrumbs>}- actions={workspace != null ? <HelpMenu /> : null}+ actions={<HelpMenu />}py={0}/>- {workspace == null ? (- <WorkspaceInstanceEmptyState />- ) : (- <Stack gap="3.5rem">- {databasesInfo.map(({ database, remappings }) => (- <TableRemappingSection- key={database.id}- database={database}- remappings={remappings}- />- ))}- {isDevelopmentMode && <DeleteSection />}- </Stack>- )}+ <Stack gap="3.5rem">+ {databasesInfo.map(({ database, remappings }) => (+ <TableRemappingSection+ key={database.id}+ database={database}+ remappings={remappings}+ />+ ))}+ {/* TODO: restore `workspace.can_write && ` gate once the backend exposes it */}+ <DeleteSection />+ </Stack></PageContainer>);}diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstancePage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstancePage.unit.spec.tsxindex 5227bf80c0a..349755884e8 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstancePage.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/WorkspaceInstancePage.unit.spec.tsx@@ -6,13 +6,10 @@ import {setupListTableRemappingsEndpoint,} from "__support__/server-mocks";import { renderWithProviders, screen } from "__support__/ui";-import { createMockSettingsState } from "metabase/redux/store/mocks";-import type { TableRemapping, WorkspaceInstance } from "metabase-types/api";+import type { TableRemapping } from "metabase-types/api";import {createMockDatabase,- createMockSettings,createMockTableRemapping,- createMockTokenFeatures,createMockWorkspaceInstance,createMockWorkspaceInstanceDatabase,} from "metabase-types/api/mocks";@@ -31,8 +28,8 @@ function setup({output: { schema: "ws_dev" },}),},- }) as WorkspaceInstance | null,- isDevelopmentMode = false,+ can_write: true,+ }),} = {}) {setupDatabasesEndpoints([POSTGRES]);setupGetCurrentWorkspaceEndpoint(workspace);@@ -40,15 +37,6 @@ function setup({renderWithProviders(<Route path="*" component={WorkspaceInstancePage} />, {withRouter: true,- storeInitialState: {- settings: createMockSettingsState(- createMockSettings({- "token-features": createMockTokenFeatures({- development_mode: isDevelopmentMode,- }),- }),- ),- },});}@@ -81,42 +69,6 @@ describe("WorkspaceInstancePage", () => {).toBeInTheDocument();});- it("renders the empty state when no workspace is set up", async () => {- setup({ workspace: null });-- expect(- await screen.findByRole("heading", {- name: /Isolated spaces for agents and developers/,- }),- ).toBeInTheDocument();- expect(- screen.queryByRole("button", { name: "Set up a workspace" }),- ).not.toBeInTheDocument();- });-- it("shows the set up button in the empty state on a developer instance", async () => {- setup({ workspace: null, isDevelopmentMode: true });-- expect(- await screen.findByRole("button", {- name: "Set up a workspace",- }),- ).toBeInTheDocument();- });-- it("hides the help menu in the empty state", async () => {- setup({ workspace: null });-- expect(- await screen.findByRole("heading", {- name: /Isolated spaces for agents and developers/,- }),- ).toBeInTheDocument();- expect(- screen.queryByRole("button", { name: /Help/ }),- ).not.toBeInTheDocument();- });-it("shows the help menu when a workspace is set up", async () => {setup();@@ -126,17 +78,8 @@ describe("WorkspaceInstancePage", () => {).toBeInTheDocument();});- it("does not render the delete section on the main instance", async () => {- setup({ isDevelopmentMode: false });-- expect(await screen.findByText("Dev workspace")).toBeInTheDocument();- expect(- screen.queryByTestId("workspace-instance-delete-section"),- ).not.toBeInTheDocument();- });-- it("renders the delete section on a developer instance", async () => {- setup({ isDevelopmentMode: true });+ it("renders the delete section", async () => {+ setup();expect(await screen.findByText("Dev workspace")).toBeInTheDocument();expect(diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/SetupWorkspaceModal/SetupWorkspaceModal.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/SetupWorkspaceModal/SetupWorkspaceModal.tsxsimilarity index 100%rename from enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/SetupWorkspaceModal/SetupWorkspaceModal.tsxrename to enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/SetupWorkspaceModal/SetupWorkspaceModal.tsxdiff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/SetupWorkspaceModal/SetupWorkspaceModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/SetupWorkspaceModal/SetupWorkspaceModal.unit.spec.tsxsimilarity index 100%rename from enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/SetupWorkspaceModal/SetupWorkspaceModal.unit.spec.tsxrename to enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/SetupWorkspaceModal/SetupWorkspaceModal.unit.spec.tsxdiff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/SetupWorkspaceModal/index.ts b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/SetupWorkspaceModal/index.tssimilarity index 100%rename from enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceInstancePage/SetupWorkspaceModal/index.tsrename to enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/SetupWorkspaceModal/index.tsdiff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/components/WorkspaceEmptyState/WorkspaceEmptyState.module.css b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/WorkspaceEmptyState.module.csssimilarity index 100%rename from enterprise/frontend/src/metabase-enterprise/workspaces/components/WorkspaceEmptyState/WorkspaceEmptyState.module.cssrename to enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/WorkspaceEmptyState.module.cssdiff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/WorkspaceEmptyState.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/WorkspaceEmptyState.tsxnew file mode 100644index 00000000000..80463672e97--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/WorkspaceEmptyState.tsx@@ -0,0 +1,144 @@+import { useDisclosure } from "@mantine/hooks";+import { Link } from "react-router";+import { push } from "react-router-redux";+import { jt, t } from "ttag";++import { useDocsUrl } from "metabase/common/hooks";+import { useDispatch, useSelector } from "metabase/redux";+import {+ Anchor,+ Box,+ Button,+ Card,+ FixedSizeIcon,+ Group,+ Stack,+ Text,+ Title,+} from "metabase/ui";+import * as Urls from "metabase/urls";+import type { Workspace } from "metabase-types/api";++import { trackWorkspaceSetupButtonClicked } from "../../../analytics";+import { canManageWorkspaceInstance } from "../../../selectors";+import { NewWorkspaceModal } from "../NewWorkspaceModal";+import { SetupWorkspaceModal } from "../SetupWorkspaceModal";++import S from "./WorkspaceEmptyState.module.css";++export function WorkspaceEmptyState() {+ const [isCreateOpen, { open: openCreate, close: closeCreate }] =+ useDisclosure(false);+ const [isSetupOpen, { open: openSetup, close: closeSetup }] =+ useDisclosure(false);+ const dispatch = useDispatch();+ const canManageInstance = useSelector(canManageWorkspaceInstance);++ const { url: fileBasedDevDocsUrl, showMetabaseLinks: showFileBasedDevLink } =+ useDocsUrl("ai/file-based-development");+ const { url: remoteSyncDocsUrl, showMetabaseLinks: showRemoteSyncLink } =+ useDocsUrl("installation-and-operation/remote-sync");++ const handleCreate = (workspace: Workspace) => {+ closeCreate();+ dispatch(push(Urls.workspace(workspace.id)));+ };++ const handleSetupClick = () => {+ trackWorkspaceSetupButtonClicked();+ openSetup();+ };++ const createButton = (+ <Button key="create" variant="filled" onClick={openCreate}>+ {t`Create a workspace`}+ </Button>+ );++ const setupButton = (+ <Anchor+ key="setup"+ role="button"+ component="button"+ onClick={handleSetupClick}+ >+ {t`upload a workspace config`}+ </Anchor>+ );++ return (+ <>+ <Card p="xl" maw="40rem" mx="auto" shadow="none" withBorder>+ <Box p="md">+ <Title+ order={3}+ mb="sm"+ >{t`Isolated spaces for agents and developers`}</Title>+ <Text mb="md">+ {t`Develop transforms and the semantic layer without touching production tables. Each workspace gets its own schema and database user in the warehouses you pick.`}+ </Text>+ <Stack gap="sm" pb="xl">+ <Box>{createButton}</Box>+ {canManageInstance && (+ <Box>{jt`or ${setupButton} generated from your production instance to put this development instance into a workspace.`}</Box>+ )}+ </Stack>+ {(showFileBasedDevLink || showRemoteSyncLink) && (+ <Group pt="md" gap="sm" align="stretch">+ {showFileBasedDevLink && (+ <DocsLink+ title={t`File-based development`}+ description={t`How to use the CLI to develop content locally.`}+ link={fileBasedDevDocsUrl}+ />+ )}+ {showRemoteSyncLink && (+ <DocsLink+ title={t`Using remote sync`}+ description={t`How to sync and review instance content with git.`}+ link={remoteSyncDocsUrl}+ />+ )}+ </Group>+ )}+ </Box>+ </Card>+ <NewWorkspaceModal+ opened={isCreateOpen}+ onCreate={handleCreate}+ onClose={closeCreate}+ />+ <SetupWorkspaceModal opened={isSetupOpen} onClose={closeSetup} />+ </>+ );+}++type DocsLinkProps = {+ title: string;+ description: string;+ link: string;+};++function DocsLink({ title, description, link }: DocsLinkProps) {+ return (+ <Box+ className={S.docsLink}+ component={Link}+ to={link}+ target="_blank"+ rel="noreferrer"+ p="md"+ bdrs="md"+ flex="1"+ miw="16rem"+ >+ <Group gap="sm" wrap="nowrap" align="flex-start">+ <FixedSizeIcon c="brand" name="reference" />+ <Stack gap="xs">+ <Title order={5}>{title}</Title>+ <Box c="text-secondary">{description}</Box>+ </Stack>+ </Group>+ </Box>+ );+}diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/WorkspaceEmptyState.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/WorkspaceEmptyState.unit.spec.tsxnew file mode 100644index 00000000000..d16affc5e2c--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/WorkspaceEmptyState.unit.spec.tsx@@ -0,0 +1,56 @@+import { Route } from "react-router";++import { setupApplyAdvancedConfigEndpoint } from "__support__/server-mocks";+import { renderWithProviders, screen } from "__support__/ui";+import { createMockSettingsState } from "metabase/redux/store/mocks";+import { createMockUser } from "metabase-types/api/mocks";++import { WorkspaceEmptyState } from "./WorkspaceEmptyState";++function setup({ isAdmin = false }: { isAdmin?: boolean } = {}) {+ setupApplyAdvancedConfigEndpoint();+ renderWithProviders(<Route path="*" component={WorkspaceEmptyState} />, {+ withRouter: true,+ storeInitialState: {+ currentUser: createMockUser({ is_superuser: isAdmin }),+ settings: createMockSettingsState({ "show-metabase-links": true }),+ },+ });+}++describe("WorkspaceEmptyState", () => {+ it("renders the create workspace button", () => {+ setup();++ expect(+ screen.getByRole("button", { name: "Create a workspace" }),+ ).toBeInTheDocument();+ });++ it("renders docs link buttons", () => {+ setup();++ expect(+ screen.getByRole("link", { name: /File-based development/ }),+ ).toBeInTheDocument();+ expect(+ screen.getByRole("link", { name: /Using remote sync/ }),+ ).toBeInTheDocument();+ });++ it("does not show the upload-workspace-config button for non-admins", () => {+ setup({ isAdmin: false });++ expect(+ screen.queryByRole("button", { name: "upload a workspace config" }),+ ).not.toBeInTheDocument();+ });++ it("shows the upload-workspace-config button for admins", () => {+ setup({ isAdmin: true });++ expect(+ screen.getByRole("button", { name: "upload a workspace config" }),+ ).toBeInTheDocument();+ });+});diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/components/WorkspaceEmptyState/index.ts b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/index.tssimilarity index 100%rename from enterprise/frontend/src/metabase-enterprise/workspaces/components/WorkspaceEmptyState/index.tsrename to enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceEmptyState/index.tsdiff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/WorkspaceListEmptyState.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/WorkspaceListEmptyState.tsxdeleted file mode 100644index 9dbf2bfd6b7..00000000000--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/WorkspaceListEmptyState.tsx+++ /dev/null@@ -1,40 +0,0 @@-import { useDisclosure } from "@mantine/hooks";-import { push } from "react-router-redux";-import { t } from "ttag";--import { useDispatch } from "metabase/redux";-import { Box, Button } from "metabase/ui";-import * as Urls from "metabase/urls";-import type { Workspace } from "metabase-types/api";--import { WorkspaceEmptyState } from "../../../components/WorkspaceEmptyState";-import { NewWorkspaceModal } from "../NewWorkspaceModal";--export function WorkspaceListEmptyState() {- const [opened, { open, close }] = useDisclosure(false);- const dispatch = useDispatch();-- const handleCreate = (workspace: Workspace) => {- close();- dispatch(push(Urls.workspace(workspace.id)));- };-- return (- <>- <WorkspaceEmptyState- description={t`Develop transforms and the semantic layer without touching production tables. Each workspace gets its own schema and database user in the warehouses you pick.`}- >- <Box pb="xl">- <Button variant="filled" onClick={open}>- {t`Create a workspace`}- </Button>- </Box>- </WorkspaceEmptyState>- <NewWorkspaceModal- opened={opened}- onCreate={handleCreate}- onClose={close}- />- </>- );-}diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/WorkspaceListEmptyState.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/WorkspaceListEmptyState.unit.spec.tsxdeleted file mode 100644index 6e6997eba10..00000000000--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/WorkspaceListEmptyState.unit.spec.tsx+++ /dev/null@@ -1,39 +0,0 @@-import { Route } from "react-router";--import { renderWithProviders, screen } from "__support__/ui";-import { createMockSettingsState } from "metabase/redux/store/mocks";-import { createMockSettings } from "metabase-types/api/mocks";--import { WorkspaceListEmptyState } from "./WorkspaceListEmptyState";--function setup() {- renderWithProviders(<Route path="*" component={WorkspaceListEmptyState} />, {- withRouter: true,- storeInitialState: {- settings: createMockSettingsState(- createMockSettings({ "show-metabase-links": true }),- ),- },- });-}--describe("WorkspaceListEmptyState", () => {- it("renders the create workspace button", () => {- setup();-- expect(- screen.getByRole("button", { name: "Create a workspace" }),- ).toBeInTheDocument();- });-- it("renders docs link buttons", () => {- setup();-- expect(- screen.getByRole("link", { name: /File-based development/ }),- ).toBeInTheDocument();- expect(- screen.getByRole("link", { name: /Using remote sync/ }),- ).toBeInTheDocument();- });-});diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/index.ts b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/index.tsdeleted file mode 100644index 6738debab8a..00000000000--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListEmptyState/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from "./WorkspaceListEmptyState";diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListPage.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListPage.tsxindex a011ede3441..fe6df262e28 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListPage.tsx+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspaceListPage/WorkspaceListPage.tsx@@ -12,8 +12,8 @@ import type { Database, Workspace } from "metabase-types/api";import { HelpMenu } from "../../components/HelpMenu";import { NewWorkspaceButton } from "./NewWorkspaceButton";+import { WorkspaceEmptyState } from "./WorkspaceEmptyState";import { WorkspaceItem } from "./WorkspaceItem";-import { WorkspaceListEmptyState } from "./WorkspaceListEmptyState";export function WorkspaceListPage() {const {@@ -85,7 +85,7 @@ function WorkspaceListPageBody({))}</Stack>) : (- <WorkspaceListEmptyState />+ <WorkspaceEmptyState />)}</PageContainer>);diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspacePage/SetupSection/SetupSection.tsx b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspacePage/SetupSection/SetupSection.tsxindex 07497721f65..61139caaac4 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspacePage/SetupSection/SetupSection.tsx+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/pages/WorkspacePage/SetupSection/SetupSection.tsx@@ -13,7 +13,8 @@ export type SetupSectionProps = {};export function SetupSection({ workspace }: SetupSectionProps) {- const description = jt`Download this ${<Code key="config">{CONFIG_FILENAME}</Code>} and upload it on the developer instance to load this isolated workspace. The file carries the database credentials the developer instance needs.`;+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- referring to the product name is intentional+ const description = jt`Run a local Metabase instance backed by this workspace's data so you can make changes safely. Pass this ${<Code key="config">{CONFIG_FILENAME}</Code>} file, containing the database credentials, when starting the instance.`;const isDisabled = workspace.databases.length === 0;return (diff --git a/enterprise/frontend/src/metabase-enterprise/workspaces/selectors.ts b/enterprise/frontend/src/metabase-enterprise/workspaces/selectors.tsindex ac4016de307..ef01cf098b7 100644--- a/enterprise/frontend/src/metabase-enterprise/workspaces/selectors.ts+++ b/enterprise/frontend/src/metabase-enterprise/workspaces/selectors.ts@@ -1,6 +1,5 @@import type { State } from "metabase/redux/store";import { getUser, getUserIsAdmin } from "metabase/selectors/user";-import { getTokenFeature } from "metabase/setup/selectors";export function canManageWorkspaces(state: State): boolean {if (getUserIsAdmin(state)) {@@ -13,7 +12,3 @@ export function canManageWorkspaces(state: State): boolean {export function canManageWorkspaceInstance(state: State): boolean {return getUserIsAdmin(state);}--export function getIsDevelopmentMode(state: State): boolean {- return getTokenFeature(state, "development_mode");-}diff --git a/frontend/src/metabase-types/api/mocks/workspace-instance.ts b/frontend/src/metabase-types/api/mocks/workspace-instance.tsindex 1de45f92fa8..07d2cd1f04b 100644--- a/frontend/src/metabase-types/api/mocks/workspace-instance.ts+++ b/frontend/src/metabase-types/api/mocks/workspace-instance.ts@@ -20,6 +20,7 @@ export function createMockWorkspaceInstance(return {name: "Test workspace",databases: {},+ can_write: false,...opts,};}diff --git a/frontend/src/metabase-types/api/workspace-instance.ts b/frontend/src/metabase-types/api/workspace-instance.tsindex 8c5a6f5d207..4c384ff8976 100644--- a/frontend/src/metabase-types/api/workspace-instance.ts+++ b/frontend/src/metabase-types/api/workspace-instance.ts@@ -13,6 +13,7 @@ export type WorkspaceInstanceDatabase = {export type WorkspaceInstance = {name: string;databases: Record<DatabaseId, WorkspaceInstanceDatabase>;+ can_write: boolean;};export type GetCurrentWorkspaceResponse = {