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
GDGT-3363: Let shared forms render modal footers (#84400)
Will Fry9287edbfa552
diff --git a/enterprise/frontend/src/metabase-enterprise/advanced_permissions/components/ImpersonationModal/ImpersonationModalView.tsx b/enterprise/frontend/src/metabase-enterprise/advanced_permissions/components/ImpersonationModal/ImpersonationModalView.tsxindex a080c02b52f..09de9ad9626 100644--- a/enterprise/frontend/src/metabase-enterprise/advanced_permissions/components/ImpersonationModal/ImpersonationModalView.tsx+++ b/enterprise/frontend/src/metabase-enterprise/advanced_permissions/components/ImpersonationModal/ImpersonationModalView.tsx@@ -104,7 +104,7 @@ export const ImpersonationModalView = ({>{t`Edit connection`}</Link></Alert>- <FormFooter hasTopBorder>+ <FormFooter><Button type="button" onClick={onCancel}>{t`Close`}</Button></FormFooter></>@@ -128,7 +128,7 @@ export const ImpersonationModalView = ({<ImpersonationWarning database={database} />- <FormFooter hasTopBorder>+ <FormFooter><FormErrorMessage /><Button type="button" onClick={onCancel}>{t`Cancel`}</Button><FormSubmitButton@@ -150,7 +150,7 @@ export const ImpersonationModalView = ({>{t`Edit user settings`}</Link></Alert>- <FormFooter hasTopBorder>+ <FormFooter><Button type="button" onClick={onCancel}>{t`Close`}</Button></FormFooter></>diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/MetricCachingModal.tsx b/enterprise/frontend/src/metabase-enterprise/caching/components/MetricCachingModal.tsxindex 1a3341c349e..18d34abecf2 100644--- a/enterprise/frontend/src/metabase-enterprise/caching/components/MetricCachingModal.tsx+++ b/enterprise/frontend/src/metabase-enterprise/caching/components/MetricCachingModal.tsx@@ -56,6 +56,7 @@ export function MetricCachingModal({return (<Modal+ density="relaxed"openedonClose={handleClose}title={t`Caching`}diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/CreateLibraryDashboardModal/CreateLibraryDashboardModal.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/CreateLibraryDashboardModal/CreateLibraryDashboardModal.tsxindex 48ae08a630f..a4c705e9bde 100644--- a/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/CreateLibraryDashboardModal/CreateLibraryDashboardModal.tsx+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/library/dashboards/components/CreateLibraryDashboardModal/CreateLibraryDashboardModal.tsx@@ -110,7 +110,7 @@ export function CreateLibraryDashboardModal({options: LIBRARY_COLLECTION_PICKER_OPTIONS,}}/>- <FormFooter mt="lg">+ <FormFooter><FormErrorMessage inline /><Button type="button" onClick={onClose}>{t`Cancel`}</Button><FormSubmitButton label={t`Create`} variant="filled" />diff --git a/enterprise/frontend/src/metabase-enterprise/database_routing/DestinationDatabaseConnectionModal/DestinationDatabaseConnectionModal.tsx b/enterprise/frontend/src/metabase-enterprise/database_routing/DestinationDatabaseConnectionModal/DestinationDatabaseConnectionModal.tsxindex 61c65de1ffb..bc8df2eae5f 100644--- a/enterprise/frontend/src/metabase-enterprise/database_routing/DestinationDatabaseConnectionModal/DestinationDatabaseConnectionModal.tsx+++ b/enterprise/frontend/src/metabase-enterprise/database_routing/DestinationDatabaseConnectionModal/DestinationDatabaseConnectionModal.tsx@@ -97,6 +97,7 @@ export const DestinationDatabaseConnectionModal = () => {return (<Modal+ density="relaxed"title={addingNewDatabase? t`Add destination database`diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabaseAIProviderSetup.tsx b/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabaseAIProviderSetup.tsxindex 09ca2255f03..b50837e6340 100644--- a/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabaseAIProviderSetup.tsx+++ b/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabaseAIProviderSetup.tsx@@ -8,6 +8,7 @@ import {useRefreshTokenStatusMutation,} from "metabase/api";import { getErrorMessage } from "metabase/api/utils";+import { FormFooter } from "metabase/common/components/FormFooter";import { getUserIsAdmin } from "metabase/current-user";import { MetabotManagedProviderLimitActions } from "metabase/metabot/components/MetabotManagedProviderLimit";import type { MetabaseAIProviderSetupProps } from "metabase/plugins";@@ -141,112 +142,109 @@ export function MetabaseAIProviderSetup({return (<>- {isConfigured ? (- <MetabaseManagedProviderCard- isLoadingPricing={isLoadingMetabaseManagedAiPricing}- pricing={metabaseManagedAiPricing}- hasDeprecatedMetabaseAiProvider={hasDeprecatedMetabaseAiProvider}- hasMetabaseManagedAiProviderFeature={- hasMetabaseManagedAiProviderFeature- }- offerMetabaseManagedAi={offerMetabaseManagedAi}- />- ) : (- <>- <Stack gap="lg">- <Text>{- // eslint-disable-next-line metabase/no-literal-metabase-strings -- Metabase AI service- t`The simplest way to get started with AI in Metabase. We pick a benchmarked, cost effective model for you, and billing is managed through your Metabase account.`- }</Text>- {isLoadingMetabaseManagedAiPricing ? (- <PricingCallout>- <Skeleton h="1rem" w="14rem" />- <Skeleton h="1rem" w="18rem" />- </PricingCallout>- ) : metabaseManagedAiPricing ? (- <MetabasePricingText pricing={metabaseManagedAiPricing} />- ) : null}- </Stack>-- {match({- hasDeprecatedMetabaseAiProvider,- hasMetabaseManagedAiProviderFeature,- offerMetabaseManagedAi,- isAdmin,- })- .with(- {- hasDeprecatedMetabaseAiProvider: true,- hasMetabaseManagedAiProviderFeature: false,- offerMetabaseManagedAi: true,- },- () => (- <Text>- {t`You're on legacy tiered AI pricing today. On your next billing cycle, you'll switch to metered AI pricing.`}- </Text>- ),- )- .with({ hasDeprecatedMetabaseAiProvider: true }, () => null)- .with({ hasMetabaseManagedAiProviderFeature: true }, () => null)- .with({ isAdmin: false }, () => (- <Text fw="bold">- {t`Please ask an Admin user to enable this for you.`}- </Text>- ))- .otherwise(() => (- <Checkbox- checked={hasAcceptedTerms}- disabled={isMutating}- onChange={(event) =>- setHasAcceptedTerms(event.currentTarget.checked)- }+ <Stack gap="xl">+ {isConfigured ? (+ <MetabaseManagedProviderCard+ isLoadingPricing={isLoadingMetabaseManagedAiPricing}+ pricing={metabaseManagedAiPricing}+ hasDeprecatedMetabaseAiProvider={hasDeprecatedMetabaseAiProvider}+ hasMetabaseManagedAiProviderFeature={+ hasMetabaseManagedAiProviderFeature+ }+ offerMetabaseManagedAi={offerMetabaseManagedAi}+ />+ ) : (+ <>+ <Stack gap="lg">+ <Text>{// eslint-disable-next-line metabase/no-literal-metabase-strings -- Metabase AI service- label={jt`I agree with the Metabase AI Service ${(- <Anchor- key="metabase-ai-terms-link"- href={METABASE_MANAGED_AI_TERMS_URL}- target="_blank"- >- {t`Terms of Service`}- </Anchor>- )}`}- />- ))}-- {(onCancel || connectAction) && (- <Flex justify="end">- <Group gap="sm">- {onCancel && (- <Button disabled={isMutating} onClick={onCancel}>- {t`Back`}- </Button>- )}- {connectAction && (- <Button- variant="filled"- loading={isMutating}- disabled={isMutating || needsTermsAcceptance}- onClick={connectAction}- >- {t`Connect`}- </Button>- )}- </Group>- </Flex>+ t`The simplest way to get started with AI in Metabase. We pick a benchmarked, cost effective model for you, and billing is managed through your Metabase account.`+ }</Text>+ {isLoadingMetabaseManagedAiPricing ? (+ <PricingCallout>+ <Skeleton h="1rem" w="14rem" />+ <Skeleton h="1rem" w="18rem" />+ </PricingCallout>+ ) : metabaseManagedAiPricing ? (+ <MetabasePricingText pricing={metabaseManagedAiPricing} />+ ) : null}+ </Stack>++ {match({+ hasDeprecatedMetabaseAiProvider,+ hasMetabaseManagedAiProviderFeature,+ offerMetabaseManagedAi,+ isAdmin,+ })+ .with(+ {+ hasDeprecatedMetabaseAiProvider: true,+ hasMetabaseManagedAiProviderFeature: false,+ offerMetabaseManagedAi: true,+ },+ () => (+ <Text>+ {t`You're on legacy tiered AI pricing today. On your next billing cycle, you'll switch to metered AI pricing.`}+ </Text>+ ),+ )+ .with({ hasDeprecatedMetabaseAiProvider: true }, () => null)+ .with({ hasMetabaseManagedAiProviderFeature: true }, () => null)+ .with({ isAdmin: false }, () => (+ <Text fw="bold">+ {t`Please ask an Admin user to enable this for you.`}+ </Text>+ ))+ .otherwise(() => (+ <Checkbox+ checked={hasAcceptedTerms}+ disabled={isMutating}+ onChange={(event) =>+ setHasAcceptedTerms(event.currentTarget.checked)+ }+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- Metabase AI service+ label={jt`I agree with the Metabase AI Service ${(+ <Anchor+ key="metabase-ai-terms-link"+ href={METABASE_MANAGED_AI_TERMS_URL}+ target="_blank"+ >+ {t`Terms of Service`}+ </Anchor>+ )}`}+ />+ ))}+ </>+ )}+ {metabaseManagedAiPurchaseError && (+ <Text size="sm" c="feedback-negative">+ {metabaseManagedAiPurchaseError}+ </Text>+ )}+ {createLlmProviderError && (+ <Text size="sm" c="feedback-negative">+ {createLlmProviderError}+ </Text>+ )}+ </Stack>+ {!isConfigured && (onCancel || connectAction) && (+ <FormFooter pageProps={{ mt: "xl" }}>+ {onCancel && (+ <Button disabled={isMutating} onClick={onCancel}>+ {t`Back`}+ </Button>)}- </>- )}-- {metabaseManagedAiPurchaseError && (- <Text size="sm" c="feedback-negative">- {metabaseManagedAiPurchaseError}- </Text>- )}-- {createLlmProviderError && (- <Text size="sm" c="feedback-negative">- {createLlmProviderError}- </Text>+ {connectAction && (+ <Button+ variant="filled"+ loading={isMutating}+ disabled={isMutating || needsTermsAcceptance}+ onClick={connectAction}+ >+ {t`Connect`}+ </Button>+ )}+ </FormFooter>)}<MetabotSettingUpModaldiff --git a/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/AccountSecurityPanel/RecoveryCodesModal/RecoveryCodesModal.tsx b/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/AccountSecurityPanel/RecoveryCodesModal/RecoveryCodesModal.tsxindex a5e2468a363..5823944e9e9 100644--- a/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/AccountSecurityPanel/RecoveryCodesModal/RecoveryCodesModal.tsx+++ b/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/AccountSecurityPanel/RecoveryCodesModal/RecoveryCodesModal.tsx@@ -21,6 +21,7 @@ export function RecoveryCodesModal({return (<Modaltitle={t`Generate recovery codes`}+ density="relaxed"opened={opened}onClose={onCancel}>diff --git a/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/AccountSecurityPanel/SetupModal/SetupModal.tsx b/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/AccountSecurityPanel/SetupModal/SetupModal.tsxindex db14a38fc3b..66ee210c20c 100644--- a/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/AccountSecurityPanel/SetupModal/SetupModal.tsx+++ b/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/AccountSecurityPanel/SetupModal/SetupModal.tsx@@ -32,6 +32,7 @@ export function SetupModal({ opened, onSuccess, onCancel }: SetupModalProps) {return (<Modaltitle={t`Set up two-factor authentication`}+ density="relaxed"opened={opened}onClose={onCancel}>diff --git a/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/common/RecoveryCodesForm/RecoveryCodesForm.tsx b/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/common/RecoveryCodesForm/RecoveryCodesForm.tsxindex fed0da513c7..34bcf7fd827 100644--- a/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/common/RecoveryCodesForm/RecoveryCodesForm.tsx+++ b/enterprise/frontend/src/metabase-enterprise/multi_factor_auth/components/common/RecoveryCodesForm/RecoveryCodesForm.tsx@@ -1,7 +1,8 @@import type { ReactNode } from "react";import { t } from "ttag";-import { Box, Button, Group, Input, Stack, Text } from "metabase/ui";+import { FormFooter } from "metabase/common/components/FormFooter";+import { Box, Button, Input, Stack, Text, useIsInModal } from "metabase/ui";import { CopyableCodeBlock } from "../CopyableCodeBlock";@@ -16,19 +17,23 @@ export function RecoveryCodesForm({message,onDone,}: RecoveryCodesFormProps) {+ const isInModal = useIsInModal();+return (- <Stack gap="lg">- <Text c="text-secondary">{message}</Text>- <Input.Wrapper label={t`Your recovery codes`}>- <Box mt="xxs">- <CopyableCodeBlock codes={recoveryCodes} />- </Box>- </Input.Wrapper>- <Group justify="flex-end">+ <>+ <Stack gap={isInModal ? "xl" : "lg"}>+ <Text c="text-secondary">{message}</Text>+ <Input.Wrapper label={t`Your recovery codes`}>+ <Box mt="xxs">+ <CopyableCodeBlock codes={recoveryCodes} />+ </Box>+ </Input.Wrapper>+ </Stack>+ <FormFooter pageProps={{ mt: "lg" }}><Button variant="filled" onClick={onDone}>{t`Done`}</Button>- </Group>- </Stack>+ </FormFooter>+ </>);}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 6b4943159a5..1f3d23e8630 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@@ -1,6 +1,7 @@import { jt, t } from "ttag";import { ExternalLink } from "metabase/common/components/ExternalLink";+import { FormFooter } from "metabase/common/components/FormFooter";import { useDocsUrl } from "metabase/common/hooks";import {Form,@@ -13,7 +14,7 @@ import {useGetSettingsQuery,useSetting,} from "metabase/settings";-import { Box, Button, Flex, Icon, Stack, Text } from "metabase/ui";+import { Button, Icon, Stack, Text, useIsInModal } from "metabase/ui";import { useGetRemoteSyncChangesQuery } from "metabase-enterprise/api";import {@@ -76,6 +77,7 @@ export const RemoteSyncSettingsForm = ({const dirtyEntities = dirtyData?.dirty ?? [];const requiredSyncs = unsyncedDependenciesError?.errors.required;const isModalVariant = variant === "settings-modal";+ const isInModal = useIsInModal();const isSaving = isUpdating || isDisabling;const canDisable =isRemoteSyncEnabled && !settingDetails?.[REMOTE_SYNC_KEY]?.is_env_setting;@@ -95,7 +97,7 @@ export const RemoteSyncSettingsForm = ({return (<Form disabled={!dirty}>- <Stack gap="xxl" maw="52rem">+ <Stack gap={isInModal ? "xl" : "xxl"} maw="52rem">{!isModalVariant && !isRemoteSyncEnabled && <SetupGuideLink />}<GitSettingsSection />@@ -113,44 +115,37 @@ export const RemoteSyncSettingsForm = ({<TopLevelCollectionsList skipCollections /></RemoteSyncSettingsSection>)}-- <Flex justify="space-between" align="center">- <Box>- {canDisable && (- <Button- color="negative"- variant="subtle"- leftSection={<Icon name="close" />}- onClick={handleDisable}- >- {t`Disable remote sync`}- </Button>- )}- </Box>-- <Flex align="center" gap="lg">- <FormErrorMessage />- {onCancel && (- <Button onClick={onCancel} disabled={isSaving}>- {t`Cancel`}- </Button>- )}- <FormSubmitButton- data-testid="remote-sync-submit-button"- label={- isRemoteSyncEnabled- ? t`Save changes`- : t`Set up remote sync`- }- variant="filled"- disabled={- isRemoteSyncEnabled ? !dirty : !values?.[URL_KEY]- }- loading={isSaving || isCreatingLibrary}- />- </Flex>- </Flex></Stack>+ <FormFooter pageProps={{ gap: "lg", maw: "52rem", mt: "xxl" }}>+ {canDisable && (+ <Button+ color="negative"+ variant="subtle"+ leftSection={<Icon name="close" />}+ mr="auto"+ onClick={handleDisable}+ >+ {t`Disable remote sync`}+ </Button>+ )}+ <FormErrorMessage />+ {onCancel && (+ <Button onClick={onCancel} disabled={isSaving}>+ {t`Cancel`}+ </Button>+ )}+ <FormSubmitButton+ data-testid="remote-sync-submit-button"+ label={+ isRemoteSyncEnabled+ ? t`Save changes`+ : t`Set up remote sync`+ }+ variant="filled"+ disabled={isRemoteSyncEnabled ? !dirty : !values?.[URL_KEY]}+ loading={isSaving || isCreatingLibrary}+ />+ </FormFooter>{/* Inside the form so its fix-and-save can write through formik; Mantine portals it out. */}{!isModalVariant && (diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/BranchNameInput.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/BranchNameInput.tsxindex 02d42cb7f9d..434c5105f3e 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/BranchNameInput.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/BranchNameInput.tsx@@ -36,7 +36,6 @@ export const BranchNameInput = (props: BranchNameInputProps) => {<TextInputerror={error}label={t`Name for your new branch`}- mt="xl"onChange={(event) => setValue(event.target.value.trim())}placeholder={t`your-branch-name`}value={value}diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/ForcePushWarning.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/ForcePushWarning.tsxindex e3e99378f42..b6e31a3943f 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/ForcePushWarning.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/ForcePushWarning.tsx@@ -60,7 +60,6 @@ export const ForcePushWarning = ({return (<Box- mt="lg"p="lg"bg="background_surface-error-subtle"style={{ borderRadius: "var(--mantine-radius-sm)" }}diff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/OutOfSyncOptions.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/OutOfSyncOptions.tsxindex f8c39eea54b..f3f08b0126e 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/OutOfSyncOptions.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/OutOfSyncOptions.tsx@@ -95,7 +95,7 @@ export const OutOfSyncOptions = (props: BranchSwitchOptionsProps) => {);return (- <Box mt="xxl">+ <Box><Text fw="bold" mb="sm" pb="xxs">{t`Choose how to proceed:`}</Text><Radio.Group// Unjustified type cast. FIXMEdiff --git a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/SyncConflictModal.tsx b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/SyncConflictModal.tsxindex bb15bdb28ef..93efa17a6e8 100644--- a/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/SyncConflictModal.tsx+++ b/enterprise/frontend/src/metabase-enterprise/remote_sync/components/SyncConflictModal/SyncConflictModal.tsx@@ -4,7 +4,7 @@ import { t } from "ttag";import { useMetadataToasts } from "metabase/common/hooks";import { useSelector } from "metabase/redux";import { useGetSettingsQuery, useSetting } from "metabase/settings";-import { Box, Button, Icon, Modal } from "metabase/ui";+import { Button, Icon, Modal, Stack } from "metabase/ui";import {useGetBranchesQuery,useUpdateRemoteSyncSettingsMutation,@@ -195,48 +195,42 @@ export const SyncConflictModal = (props: UnsyncedWarningModalProps) => {title={getModalTitle(variant, canMerge)}withCloseButton={false}>- {variant === "setup" ? (- <SetupConflictInfo />- ) : conflicts && conflicts.length > 0 ? (- <ConflictingChangesList conflicts={conflicts} />- ) : (- <ChangesLists />- )}+ <Stack gap="xl">+ <ConflictSummary variant={variant} conflicts={conflicts} />- <OutOfSyncOptions- currentBranch={currentBranch}- handleOptionChange={setOptionValue}- isRemoteSyncReadOnly={isRemoteSyncReadOnly}- optionValue={optionValue}- variant={variant}- canMerge={canMerge}- />-- {optionValue === "force-push" && forcePushCasualties && (- <ForcePushWarning- casualties={forcePushCasualties}- branch={currentBranch}- historyRewritten={historyRewritten}+ <OutOfSyncOptions+ currentBranch={currentBranch}+ handleOptionChange={setOptionValue}+ isRemoteSyncReadOnly={isRemoteSyncReadOnly}+ optionValue={optionValue}+ variant={variant}+ canMerge={canMerge}/>- )}- {optionValue === "new-branch" && (- <BranchNameInput- existingBranches={existingBranches}- setValue={setNewBranchName}- value={newBranchName}- />- )}+ {optionValue === "force-push" && forcePushCasualties && (+ <ForcePushWarning+ casualties={forcePushCasualties}+ branch={currentBranch}+ historyRewritten={historyRewritten}+ />+ )}- {/* Pushing (merge / force / new branch) needs a commit message; pull/switch/setup don't. */}- {variant === "push" && optionValue && optionValue !== "discard" && (- <Box mt="xl">+ {optionValue === "new-branch" && (+ <BranchNameInput+ existingBranches={existingBranches}+ setValue={setNewBranchName}+ value={newBranchName}+ />+ )}++ {/* Pushing (merge / force / new branch) needs a commit message; pull/switch/setup don't. */}+ {variant === "push" && optionValue && optionValue !== "discard" && (<CommitMessageSectionvalue={commitMessage}onChange={setCommitMessage}/>- </Box>- )}+ )}+ </Stack><Modal.Footer><Button onClick={onClose} variant="subtle" color="neutral">@@ -263,3 +257,20 @@ export const SyncConflictModal = (props: UnsyncedWarningModalProps) => {</Modal>);};++interface ConflictSummaryProps {+ variant: RemoteSyncConflictVariant;+ conflicts?: string[];+}++function ConflictSummary({ variant, conflicts }: ConflictSummaryProps) {+ if (variant === "setup") {+ return <SetupConflictInfo />;+ }++ if (conflicts && conflicts.length > 0) {+ return <ConflictingChangesList conflicts={conflicts} />;+ }++ return <ChangesLists />;+}diff --git a/enterprise/frontend/src/metabase-enterprise/tenants/components/TenantFormWidget/TenantFormWidget.tsx b/enterprise/frontend/src/metabase-enterprise/tenants/components/TenantFormWidget/TenantFormWidget.tsxindex ef2d9c50438..721043e1561 100644--- a/enterprise/frontend/src/metabase-enterprise/tenants/components/TenantFormWidget/TenantFormWidget.tsx+++ b/enterprise/frontend/src/metabase-enterprise/tenants/components/TenantFormWidget/TenantFormWidget.tsx@@ -33,7 +33,6 @@ export const FormTenantWidget = ({ name, ...props }: FormTenantWidget) => {onChange={(val) => setValue(parseInt(val))}data={options}label={t`Tenant`}- mb="1rem"{...props}></Select>);diff --git a/frontend/src/metabase/actions/components/ActionForm/ActionForm.tsx b/frontend/src/metabase/actions/components/ActionForm/ActionForm.tsxindex 07f940b51ef..ba6ad8c2173 100644--- a/frontend/src/metabase/actions/components/ActionForm/ActionForm.tsx+++ b/frontend/src/metabase/actions/components/ActionForm/ActionForm.tsx@@ -7,13 +7,14 @@ import {getSubmitButtonColor,getSubmitButtonLabel,} from "metabase/actions/utils";+import { FormFooter } from "metabase/common/components/FormFooter";import {Form,FormErrorMessage,FormProvider,FormSubmitButton,} from "metabase/forms";-import { Button, Flex } from "metabase/ui";+import { Button, Stack, useIsInModal } from "metabase/ui";import type {ActionFormInitialValues,ParameterId,@@ -51,6 +52,8 @@ function ActionForm({onSubmit,onClose,}: ActionFormProps): JSX.Element {+ const isInModal = useIsInModal();+const { initialValues, form, validationSchema, getCleanValues } =useActionForm({action,@@ -78,11 +81,13 @@ function ActionForm({enableReinitialize><Form role="form" data-testid="action-form">- {editableFields.map((field) => (- <ActionFormFieldWidget key={field.name} formField={field} />- ))}-- <Flex justify="flex-end" gap="sm">+ <Stack gap={isInModal ? "xl" : "lg"}>+ {editableFields.map((field) => (+ <ActionFormFieldWidget key={field.name} formField={field} />+ ))}+ </Stack>+ <FormFooter pageProps={{ mt: "lg" }}>+ {isInModal && <FormErrorMessage flex={1} />}{onClose && (<Button type="button" onClick={onClose}>{t`Cancel`}</Button>)}@@ -92,9 +97,8 @@ function ActionForm({color={getSubmitButtonColor(action)}fullWidth={submitButtonFullWidth}/>- </Flex>-- <FormErrorMessage mt="lg" />+ </FormFooter>+ {!isInModal && <FormErrorMessage mt="lg" />}</Form></FormProvider>);diff --git a/frontend/src/metabase/actions/components/ActionFormFieldWidget/ActionFormFieldWidget.tsx b/frontend/src/metabase/actions/components/ActionFormFieldWidget/ActionFormFieldWidget.tsxindex 004ba21379d..22d2ecd498c 100644--- a/frontend/src/metabase/actions/components/ActionFormFieldWidget/ActionFormFieldWidget.tsx+++ b/frontend/src/metabase/actions/components/ActionFormFieldWidget/ActionFormFieldWidget.tsx@@ -2,7 +2,6 @@ import type { FunctionComponent, ReactNode, Ref } from "react";import { forwardRef } from "react";import type { ActionFormFieldProps } from "metabase/actions/types";-import { FormToggle as FormBooleanWidget } from "metabase/common/components/FormToggle";import { FormRadioGroup, type FormRadioGroupProps } from "metabase/forms";import { Radio, Stack } from "metabase/ui";import type { InputComponentType } from "metabase-types/api";@@ -10,6 +9,7 @@ import type { InputComponentType } from "metabase-types/api";import { FormInputWidget } from "./FormInputWidget";import { FormNumberInputWidget } from "./FormNumberInputWidget";import { FormSelectWidget } from "./FormSelectWidget";+import { FormSwitchWidget } from "./FormSwitchWidget";import { FormTextareaWidget } from "./FormTextareaWidget";type RadioOption = {@@ -50,7 +50,7 @@ const WIDGETS: Record<InputComponentType, FunctionComponent<any>> = {"datetime-local": FormInputWidget,textarea: FormTextareaWidget,number: FormNumberInputWidget,- boolean: FormBooleanWidget,+ boolean: FormSwitchWidget,radio: VerticalRadio,select: FormSelectWidget,};diff --git a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormInputWidget.tsx b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormInputWidget.tsxindex 5262451e402..40c01a74463 100644--- a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormInputWidget.tsx+++ b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormInputWidget.tsx@@ -30,7 +30,6 @@ export const FormInputWidget = forwardRef(function FormInputWidget(return (<FormField- mb="lg"title={title}description={description}actions={actions}diff --git a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormNumberInputWidget.tsx b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormNumberInputWidget.tsxindex 03f98e57a96..8af764f9bb3 100644--- a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormNumberInputWidget.tsx+++ b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormNumberInputWidget.tsx@@ -28,7 +28,6 @@ export const FormNumberInputWidget = forwardRef(function FormNumberInputWidget(return (<FormField- mb="lg"title={title}actions={actions}description={description}diff --git a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSelectWidget.tsx b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSelectWidget.tsxindex 3c3d91fbd27..6c42c3d56e2 100644--- a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSelectWidget.tsx+++ b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSelectWidget.tsx@@ -2,9 +2,8 @@ import type { ReactNode, Ref } from "react";import { forwardRef } from "react";import type { ActionFormFieldProps } from "metabase/actions/types";-import { FormField } from "metabase/common/components/FormField";import { useUniqueId } from "metabase/common/hooks/use-unique-id";-import { FormSelect } from "metabase/forms/components/FormSelect";+import { FormField, FormSelect } from "metabase/forms";type FormSelectWidgetProps = ActionFormFieldProps & {actions?: ReactNode;diff --git a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSwitchWidget.tsx b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSwitchWidget.tsxnew file mode 100644index 00000000000..d188e6e8f5a--- /dev/null+++ b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSwitchWidget.tsx@@ -0,0 +1,60 @@+import { useField } from "formik";+import type { ChangeEvent, ReactNode, Ref } from "react";+import { forwardRef } from "react";++import type { ActionFormFieldProps } from "metabase/actions/types";+import { useUniqueId } from "metabase/common/hooks/use-unique-id";+import { FormField } from "metabase/forms";+import { Flex, Switch } from "metabase/ui";++type FormSwitchWidgetProps = ActionFormFieldProps & {+ actions?: ReactNode;+ disabled?: boolean;+};++export const FormSwitchWidget = forwardRef(function FormSwitchWidget(+ {+ name,+ title,+ actions,+ description,+ optional,+ disabled,+ }: FormSwitchWidgetProps,+ ref: Ref<HTMLInputElement>,+) {+ const id = useUniqueId();+ const [{ value, onBlur }, { error, touched }, { setValue }] =+ useField<boolean>(name);++ const handleChange = (event: ChangeEvent<HTMLInputElement>) => {+ setValue(event.currentTarget.checked);+ };++ return (+ <Flex+ justify="space-between"+ align={description ? "flex-start" : "center"}+ gap="sm"+ >+ <FormField+ flex={1}+ title={title}+ actions={actions}+ description={description}+ optional={optional}+ error={touched ? error : undefined}+ htmlFor={id}+ />+ <Switch+ ref={ref}+ id={id}+ name={name}+ checked={value ?? false}+ disabled={disabled}+ onChange={handleChange}+ onBlur={onBlur}+ />+ </Flex>+ );+});diff --git a/frontend/src/metabase/common/components/FormToggle/FormToggle.unit.spec.tsx b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSwitchWidget.unit.spec.tsxsimilarity index 52%rename from frontend/src/metabase/common/components/FormToggle/FormToggle.unit.spec.tsxrename to frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSwitchWidget.unit.spec.tsxindex f7186e33d98..854e54426e0 100644--- a/frontend/src/metabase/common/components/FormToggle/FormToggle.unit.spec.tsx+++ b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormSwitchWidget.unit.spec.tsx@@ -1,72 +1,84 @@import userEvent from "@testing-library/user-event";-import { Form, Formik } from "formik";+import { Form, Formik, type FormikHelpers } from "formik";+import type { ReactNode } from "react";import * as Yup from "yup";import { render, screen, waitFor } from "__support__/ui";-import { FormToggle } from "./FormToggle";+import { FormSwitchWidget } from "./FormSwitchWidget";const TEST_SCHEMA = Yup.object({value: Yup.boolean().isTrue("error"),});-interface TestFormToggleProps {+type FormValues = {+ value: boolean;+};++type SetupOpts = {initialValue?: boolean;- onSubmit: () => void;-}+ actions?: ReactNode;+};-const TestFormToggle = ({- initialValue = false,- onSubmit,-}: TestFormToggleProps) => {- return (+function setup({ initialValue = false, actions }: SetupOpts = {}) {+ const onSubmit = jest.fn<void, [FormValues, FormikHelpers<FormValues>]>();++ render(<FormikinitialValues={{ value: initialValue }}validationSchema={TEST_SCHEMA}onSubmit={onSubmit}><Form>- <FormToggle name="value" title="Label" />+ <FormSwitchWidget+ name="value"+ title="Label"+ type="boolean"+ actions={actions}+ /><button type="submit">Submit</button></Form>- </Formik>+ </Formik>,);-};-describe("FormToggle", () => {- it("should use the initial value from the form", () => {- const onSubmit = jest.fn();+ return { onSubmit };+}- render(<TestFormToggle initialValue={true} onSubmit={onSubmit} />);+describe("FormSwitchWidget", () => {+ it("should use the initial value from the form", () => {+ setup({ initialValue: true });expect(screen.getByRole("switch")).toBeChecked();});it("should propagate the changed value to the form", async () => {- const onSubmit = jest.fn();+ const { onSubmit } = setup();- render(<TestFormToggle onSubmit={onSubmit} />);await userEvent.click(screen.getByRole("switch"));await userEvent.click(screen.getByText("Submit"));await waitFor(() => {- const values = { value: true };- expect(onSubmit).toHaveBeenCalledWith(values, expect.anything());+ expect(onSubmit).toHaveBeenCalledWith({ value: true }, expect.anything());});});it("should be referenced by the label", () => {- const onSubmit = jest.fn();-- render(<TestFormToggle onSubmit={onSubmit} />);+ setup();expect(screen.getByLabelText("Label")).toBeInTheDocument();});+ it("should render field actions", () => {+ setup({ actions: <button type="button">Show field</button> });++ expect(+ screen.getByRole("button", { name: "Show field" }),+ ).toBeInTheDocument();+ });+it("should be validated on blur", async () => {- const onSubmit = jest.fn();+ setup({ initialValue: true });- render(<TestFormToggle initialValue={true} onSubmit={onSubmit} />);await userEvent.click(screen.getByRole("switch"));await userEvent.tab();diff --git a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormTextareaWidget.tsx b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormTextareaWidget.tsxindex e301295855d..60cba48b3c4 100644--- a/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormTextareaWidget.tsx+++ b/frontend/src/metabase/actions/components/ActionFormFieldWidget/FormTextareaWidget.tsx@@ -30,7 +30,6 @@ export const FormTextareaWidget = forwardRef(function FormTextareaWidget(return (<FormField- mb="lg"title={title}actions={actions}description={description}diff --git a/frontend/src/metabase/actions/containers/ActionCreator/InlineActionSettings.tsx b/frontend/src/metabase/actions/containers/ActionCreator/InlineActionSettings.tsxindex 13b17f4a208..b05e7d45a46 100644--- a/frontend/src/metabase/actions/containers/ActionCreator/InlineActionSettings.tsx+++ b/frontend/src/metabase/actions/containers/ActionCreator/InlineActionSettings.tsx@@ -8,14 +8,14 @@ import {} from "metabase/api";import { ConfirmModal } from "metabase/common/components/ConfirmModal";import { CopyTextInput } from "metabase/common/components/CopyTextInput";-import { FormField } from "metabase/common/components/FormField";import { SidebarContent } from "metabase/common/components/SidebarContent";import { TextArea } from "metabase/common/components/TextArea";import { useUniqueId } from "metabase/common/hooks/use-unique-id";import { getUserIsAdmin } from "metabase/current-user";+import { FormField } from "metabase/forms";import { useSelector } from "metabase/redux";import { getSetting } from "metabase/settings";-import { ActionIcon, Box, Icon, Switch, Tooltip } from "metabase/ui";+import { ActionIcon, Flex, Icon, Stack, Switch, Tooltip } from "metabase/ui";import * as Urls from "metabase/urls";import type { ActionFormSettings, WritebackAction } from "metabase-types/api";@@ -104,14 +104,14 @@ export function InlineActionSettings({onClose={onClose}onBack={onBack}>- <Box mx="xl" my="lg">+ <Stack mx="xl" my="lg" gap="lg">{action && hasSharingPermission && (- <FormField- title={t`Make public`}- description={t`Creates a publicly shareable link to this action form.`}- orientation="horizontal"- htmlFor={`${id}-public`}- >+ <Flex justify="space-between" align="flex-start" gap="sm">+ <FormField+ title={t`Make public`}+ description={t`Creates a publicly shareable link to this action form.`}+ htmlFor={`${id}-public`}+ /><Tooltipdisabled={isSavedAction(action)}label={t`To enable creating a shareable link you first need to save your action`}@@ -125,15 +125,13 @@ export function InlineActionSettings({/></div></Tooltip>- </FormField>+ </Flex>)}{action?.public_uuid && hasSharingPermission && (- <Box mb="1.25rem">- <CopyTextInput- value={Urls.publicAction(siteUrl, action.public_uuid)}- aria-label={t`Public action form URL`}- />- </Box>+ <CopyTextInput+ value={Urls.publicAction(siteUrl, action.public_uuid)}+ aria-label={t`Public action form URL`}+ />)}<ConfirmModalopened={modalOpened}@@ -152,7 +150,7 @@ export function InlineActionSettings({onChange={handleSuccessMessageChange}/></FormField>- </Box>+ </Stack></SidebarContent>);}diff --git a/frontend/src/metabase/actions/containers/ActionExecuteModal/ActionExecuteModal.tsx b/frontend/src/metabase/actions/containers/ActionExecuteModal/ActionExecuteModal.tsxindex 665cedc52e6..74c82f4ddd7 100644--- a/frontend/src/metabase/actions/containers/ActionExecuteModal/ActionExecuteModal.tsx+++ b/frontend/src/metabase/actions/containers/ActionExecuteModal/ActionExecuteModal.tsx@@ -88,6 +88,7 @@ export const ActionExecuteModal = ({return (<Modal+ density="relaxed"opened={opened}onClose={onClose}title={action?.name}diff --git a/frontend/src/metabase/admin/databases/components/DeleteDatabaseModel/DeleteDatabaseModal.tsx b/frontend/src/metabase/admin/databases/components/DeleteDatabaseModel/DeleteDatabaseModal.tsxindex 377d2e1e371..e3af0f10f82 100644--- a/frontend/src/metabase/admin/databases/components/DeleteDatabaseModel/DeleteDatabaseModal.tsx+++ b/frontend/src/metabase/admin/databases/components/DeleteDatabaseModel/DeleteDatabaseModal.tsx@@ -8,8 +8,6 @@ import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrimport { useNavigate } from "metabase/router";import {Alert,- Box,- type BoxProps,Button,Icon,Input,@@ -86,8 +84,8 @@ export const DeleteDatabaseModal = ({const isDatabaseNameConfirmed =databaseNameConfirmation.trim().toLowerCase() ===database.name.trim().toLowerCase();- const canDelete =- (isContentRemovalConfirmed || !hasContent) && isDatabaseNameConfirmed;+ const canConfirmName = isContentRemovalConfirmed || !hasContent;+ const canDelete = canConfirmName && isDatabaseNameConfirmed;const deleteButtonLabel = t`Delete this DB connection`;@@ -96,10 +94,10 @@ export const DeleteDatabaseModal = ({const databaseNameConfirmationRef = useRef<HTMLInputElement>(null);useEffect(() => {- if (isContentRemovalConfirmed || !hasContent) {+ if (canConfirmName) {databaseNameConfirmationRef.current?.focus();}- }, [isContentRemovalConfirmed, hasContent]);+ }, [canConfirmName, loading]);return (<Modal@@ -112,65 +110,60 @@ export const DeleteDatabaseModal = ({<LoadingAndErrorWrapper loading={loading}><form onSubmit={canDelete ? handleSubmit : undefined}><Stack gap="xl">- {hasContent && (- <DeleteDatabaseModalSection isHidden={isContentRemovalConfirmed}>- <Alert icon={<Icon name="info" />}>- {jt`If you’re trying to migrate from a development DB to a production one, you don’t need to do this. You can just ${(- <UnstyledButton- key="button"- onClick={handleEditConnectionDetailsClick}- c="core-brand"- fw="bold"- >{t`edit your connection details.`}</UnstyledButton>- )}`}- </Alert>- </DeleteDatabaseModalSection>+ {hasContent && !isContentRemovalConfirmed && (+ <Alert icon={<Icon name="info" />}>+ {jt`If you’re trying to migrate from a development DB to a production one, you don’t need to do this. You can just ${(+ <UnstyledButton+ key="button"+ onClick={handleEditConnectionDetailsClick}+ c="core-brand"+ fw="bold"+ >{t`edit your connection details.`}</UnstyledButton>+ )}`}+ </Alert>)}{hasContent && (<>- <DeleteDatabaseModalSection>+ <Text>{hasMoreThanOneEntityType? t`Deleting this database will also delete everything based on it. If you’re really trying to do this, please check each of these boxes:`: t`Deleting this database will also delete everything based on it. If you’re really trying to do this, please check the box below:`}- </DeleteDatabaseModalSection>-- <DeleteDatabaseModalSection>- <ContentRemovalConfirmation- usageInfo={usageInfo}- onChange={setIsContentRemovalConfirmed}+ </Text>+ <ContentRemovalConfirmation+ usageInfo={usageInfo}+ onChange={setIsContentRemovalConfirmed}+ />+ </>+ )}+ {canConfirmName && (+ <>+ <Alert+ size="compact"+ icon={<Icon name="warning" />}+ color="error"+ >+ {defaultDatabaseRemovalMessage}+ </Alert>+ <Stack gap="sm">+ <Text>+ {jt`If you’re sure, please type ${(+ <strong key="name">{database.name}</strong>+ )} in this box:`}+ </Text>+ <Input+ w="20rem"+ data-testid="database-name-confirmation-input"+ data-autofocus="true"+ placeholder={t`Are you completely sure?`}+ value={databaseNameConfirmation}+ ref={databaseNameConfirmationRef}+ onChange={(e) =>+ setDatabaseNameConfirmation(e.target.value)+ }/>- </DeleteDatabaseModalSection>+ </Stack></>)}- <DeleteDatabaseModalSection- isHidden={!isContentRemovalConfirmed && hasContent}- >- <Alert- size="compact"- icon={<Icon name="warning" />}- color="error"- >- {defaultDatabaseRemovalMessage}- </Alert>- </DeleteDatabaseModalSection>- <DeleteDatabaseModalSection- isHidden={!isContentRemovalConfirmed && hasContent}- >- <p>- {jt`If you’re sure, please type ${(- <strong key="name">{database.name}</strong>- )} in this box:`}- </p>- <Input- w="20rem"- data-testid="database-name-confirmation-input"- data-autofocus="true"- placeholder={t`Are you completely sure?`}- value={databaseNameConfirmation}- ref={databaseNameConfirmationRef}- onChange={(e) => setDatabaseNameConfirmation(e.target.value)}- />- </DeleteDatabaseModalSection></Stack><Modal.Footer>{errorMessage && (@@ -193,21 +186,3 @@ export const DeleteDatabaseModal = ({</Modal>);};--export const DeleteDatabaseModalSection = ({- isHidden,- ...props-}: { isHidden?: boolean; children: React.ReactNode } & BoxProps) => {- return (- <Box- h={isHidden ? 0 : "unset"}- opacity={isHidden ? 0 : 1}- p="xxs"- style={{- transition: "all 350ms, opacity 200ms",- overflow: "hidden",- }}- {...props}- />- );-};diff --git a/frontend/src/metabase/admin/performance/components/StrategyForm.module.css b/frontend/src/metabase/admin/performance/components/StrategyForm.module.cssindex 2b0eadb02fd..092d4dc3da7 100644--- a/frontend/src/metabase/admin/performance/components/StrategyForm.module.css+++ b/frontend/src/metabase/admin/performance/components/StrategyForm.module.css@@ -21,5 +21,5 @@flex: 1;overflow-y: auto;min-height: 0;- margin-top: var(--mantine-spacing-xxl);+ margin-top: var(--mantine-spacing-xl);}diff --git a/frontend/src/metabase/admin/performance/components/StrategyForm.tsx b/frontend/src/metabase/admin/performance/components/StrategyForm.tsxindex 93d8cf9de3c..29df9b184f0 100644--- a/frontend/src/metabase/admin/performance/components/StrategyForm.tsx+++ b/frontend/src/metabase/admin/performance/components/StrategyForm.tsx@@ -28,6 +28,7 @@ import {Flex,Group,Icon,+ Modal,Select,Stack,Text,@@ -216,9 +217,7 @@ const StrategyFormBody = ({data-testid={`strategy-form-for-${targetModel}-${targetId}`}>{layout === "modal" && (- <Box pt="lg">- <StrategySelectorHeading headingId={headingId} />- </Box>+ <StrategySelectorHeading headingId={headingId} />)}<BoxclassName={cx({@@ -240,7 +239,7 @@ const StrategyFormBody = ({</Group></Box>)}- <Stack maw="35rem" gap="xxl">+ <Stack maw="35rem" gap={layout === "modal" ? "xl" : "xxl"}><StrategySelectortargetId={targetId}model={targetModel}@@ -340,28 +339,23 @@ const FormButtons = ({if (layout === "modal") {return (- <Group- justify={canInvalidate ? "space-between" : "flex-end"}- wrap="nowrap"- mt="xxl"- gap="lg"- >+ <Modal.Footer>{canInvalidate && (- <PLUGIN_CACHING.InvalidateNowButton- targetId={targetId}- targetModel={targetModel}- targetName={targetName}- />+ <Box mr="auto">+ <PLUGIN_CACHING.InvalidateNowButton+ targetId={targetId}+ targetModel={targetModel}+ targetName={targetName}+ />+ </Box>)}- <Group gap="lg" wrap="nowrap">- <Button onClick={onDiscard}>{buttonLabels.discard}</Button>- <FormSubmitButton- label={buttonLabels.save}- variant="filled"- data-testid="strategy-form-submit-button"- />- </Group>- </Group>+ <Button onClick={onDiscard}>{buttonLabels.discard}</Button>+ <FormSubmitButton+ label={buttonLabels.save}+ variant="filled"+ data-testid="strategy-form-submit-button"+ />+ </Modal.Footer>);}diff --git a/frontend/src/metabase/common/components/FormDashboardTabSelect/FormDashboardTabSelect.tsx b/frontend/src/metabase/common/components/FormDashboardTabSelect/FormDashboardTabSelect.tsxindex d4a8bcc759f..745cd4fbc79 100644--- a/frontend/src/metabase/common/components/FormDashboardTabSelect/FormDashboardTabSelect.tsx+++ b/frontend/src/metabase/common/components/FormDashboardTabSelect/FormDashboardTabSelect.tsx@@ -7,7 +7,6 @@ import type { DashboardId } from "metabase-types/api";export const FormDashboardTabSelect = ({dashboardId,- styles,...props}: { dashboardId: DashboardId | null | undefined } & Omit<FormSelectProps,@@ -58,14 +57,5 @@ export const FormDashboardTabSelect = ({return null;}- return (- <FormSelect- {...props}- styles={{- ...(styles ?? {}),- wrapper: { marginBottom: "1.25rem" },- }}- data={options}- />- );+ return <FormSelect {...props} data={options} />;};diff --git a/frontend/src/metabase/common/components/FormField/FormField.module.css b/frontend/src/metabase/common/components/FormField/FormField.module.cssdeleted file mode 100644index 4a6d94f5ba1..00000000000--- a/frontend/src/metabase/common/components/FormField/FormField.module.css+++ /dev/null@@ -1,32 +0,0 @@-/* Classes rather than style props, so consumers can override the root margin and the label color */-.root {- margin-bottom: 1.25rem;-}--.selfCenter {- align-self: center;-}--.label {- color: var(--mb-color-text-secondary);-}--.invalid {- color: var(--mb-color-feedback-negative);-}--.root:focus-within .label {- color: var(--mb-color-text-secondary);-}--.root:focus-within .labelError {- display: none;-}--.infoIcon {- color: var(--mb-color-background_page-tertiary-inverse);-- &:hover {- color: var(--mb-color-core-brand);- }-}diff --git a/frontend/src/metabase/common/components/FormField/FormField.tsx b/frontend/src/metabase/common/components/FormField/FormField.tsxdeleted file mode 100644index 9eb213d0b38..00000000000--- a/frontend/src/metabase/common/components/FormField/FormField.tsx+++ /dev/null@@ -1,174 +0,0 @@-import cx from "classnames";-import type { HTMLAttributes, ReactNode, Ref } from "react";-import { forwardRef } from "react";-import { t } from "ttag";--import CS from "metabase/css/core/index.css";-import { Box, Flex, Icon, Text, Tooltip } from "metabase/ui";--import S from "./FormField.module.css";-import type { FieldAlignment, FieldOrientation } from "./types";--export interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {- title?: string;- actions?: ReactNode;- description?: ReactNode;- alignment?: FieldAlignment;- orientation?: FieldOrientation;- optional?: boolean;- error?: string;- htmlFor?: string;- infoLabel?: string;- infoTooltip?: string;-}--type FieldLabelContainerProps = {- orientation: FieldOrientation;- hasDescription: boolean;- children?: ReactNode;-};--const FieldLabelContainer = ({- orientation,- hasDescription,- children,-}: FieldLabelContainerProps) => (- <Flex- align="center"- mb={orientation === "vertical" || hasDescription ? "xs" : undefined}- >- {children}- </Flex>-);--type FieldLabelProps = {- hasError: boolean;- htmlFor?: string;- children?: ReactNode;-};--const FieldLabel = ({ hasError, htmlFor, children }: FieldLabelProps) => (- <Box- component="label"- className={cx(S.label, { [S.invalid]: hasError })}- htmlFor={htmlFor}- fz="sm"- fw={900}- >- {children}- </Box>-);--const FormFieldInner = forwardRef(function FormField(- {- title,- actions,- description,- alignment = "end",- orientation = "vertical",- error,- htmlFor,- infoLabel,- infoTooltip,- children,- optional,- className,- ...props- }: FormFieldProps,- ref: Ref<HTMLDivElement>,-) {- const hasTitle = Boolean(title);- const hasDescription = Boolean(description);- const hasError = Boolean(error);- const isHorizontal = orientation === "horizontal";-- return (- <Box- {...props}- ref={ref}- className={cx(- S.root,- {- [CS.flex]: isHorizontal,- [CS.justifyBetween]: isHorizontal && alignment === "end",- },- className,- )}- >- {alignment === "start" && children}- {(hasTitle || hasDescription) && (- <Box- className={cx({ [S.selfCenter]: isHorizontal && !hasDescription })}- ml={isHorizontal && alignment === "start" ? "sm" : undefined}- mr={isHorizontal && alignment === "end" ? "sm" : undefined}- >- <FieldLabelContainer- orientation={orientation}- hasDescription={hasDescription}- >- {hasTitle && (- <FieldLabel hasError={hasError} htmlFor={htmlFor}>- {title}- {hasError && (- <Text- component="span"- className={S.labelError}- inherit- lh="inherit"- c="feedback-negative"- role="alert"- >- : {error}- </Text>- )}- </FieldLabel>- )}- {!!optional && !hasError && (- <Text- component="span"- c="text-secondary"- fz="sm"- fw={900}- lh="md"- ml="xxs"- >{t`(optional)`}</Text>- )}- {(infoLabel || infoTooltip) && (- <Tooltip multiline label={infoTooltip}>- {infoLabel ? (- <Text- className={CS.cursorDefault}- c="text-secondary"- fz="sm"- lh="md"- ml="auto"- >- {infoLabel}- </Text>- ) : (- <Icon className={S.infoIcon} name="info" size={12} ml="sm" />- )}- </Tooltip>- )}- {actions && (- <Text c="text-secondary" fz="sm" fw={900} lh="md" ml="auto">- {actions}- </Text>- )}- </FieldLabelContainer>- {description && (- <Text c="text-secondary" lh="md" mb="sm">- {description}- </Text>- )}- </Box>- )}- {alignment === "end" && children}- </Box>- );-});--export const FormField = Object.assign(FormFieldInner, {- Label: FieldLabel,- LabelContainer: FieldLabelContainer,-});diff --git a/frontend/src/metabase/common/components/FormField/index.ts b/frontend/src/metabase/common/components/FormField/index.tsdeleted file mode 100644index add1238458e..00000000000--- a/frontend/src/metabase/common/components/FormField/index.ts+++ /dev/null@@ -1,3 +0,0 @@-export { FormField } from "./FormField";-export type { FormFieldProps } from "./FormField";-export type { FieldAlignment, FieldOrientation } from "./types";diff --git a/frontend/src/metabase/common/components/FormField/types.ts b/frontend/src/metabase/common/components/FormField/types.tsdeleted file mode 100644index c2dc2f099c1..00000000000--- a/frontend/src/metabase/common/components/FormField/types.ts+++ /dev/null@@ -1,3 +0,0 @@-export type FieldAlignment = "start" | "end";--export type FieldOrientation = "horizontal" | "vertical";diff --git a/frontend/src/metabase/common/components/FormFileInput/FormFileInput.tsx b/frontend/src/metabase/common/components/FormFileInput/FormFileInput.tsxindex d27f998fbc5..a09fa2add18 100644--- a/frontend/src/metabase/common/components/FormFileInput/FormFileInput.tsx+++ b/frontend/src/metabase/common/components/FormFileInput/FormFileInput.tsx@@ -4,15 +4,15 @@ import { forwardRef, useCallback } from "react";import type { FileInputProps } from "metabase/common/components/FileInput";import { FileInput } from "metabase/common/components/FileInput";-import { FormField } from "metabase/common/components/FormField";import { useUniqueId } from "metabase/common/hooks/use-unique-id";+import { FormField, type FormFieldProps } from "metabase/forms";export type FormFileInputEncoding = "base64";-export interface FormFileInputProps extends Omit<- FileInputProps,- "value" | "onChange" | "onBlur"-> {+export interface FormFileInputProps+ extends+ Omit<FileInputProps, "value" | "onChange" | "onBlur">,+ Pick<FormFieldProps, "mb" | "gap"> {name: string;encoding?: FormFileInputEncoding;title?: string;@@ -26,6 +26,8 @@ export const FormFileInput = forwardRef(function FormFileInput(encoding,className,style,+ mb,+ gap,title,description,optional,@@ -48,6 +50,8 @@ export const FormFileInput = forwardRef(function FormFileInput(ref={ref}className={className}style={style}+ mb={mb}+ gap={gap}title={title}description={description}htmlFor={id}diff --git a/frontend/src/metabase/common/components/FormFooter/FormFooter.tsx b/frontend/src/metabase/common/components/FormFooter/FormFooter.tsxindex a9160c2b36f..e803189fa64 100644--- a/frontend/src/metabase/common/components/FormFooter/FormFooter.tsx+++ b/frontend/src/metabase/common/components/FormFooter/FormFooter.tsx@@ -1,37 +1,40 @@import cx from "classnames";-import type { PropsWithChildren } from "react";-import CS from "metabase/css/core/index.css";-import { Group, type GroupProps } from "metabase/ui";-interface FormFooterProps extends GroupProps {- hasTopBorder?: boolean;- justify?: GroupProps["justify"];- className?: string;-}+import {+ Group,+ type GroupProps,+ Modal,+ type ModalFooterProps,+ useIsInModal,+} from "metabase/ui";+type FormFooterProps = ModalFooterProps & {+ /** Applied only outside a modal, where the footer is a right-aligned row. */+ pageProps?: GroupProps;+};++/** A form's button row: `Modal.Footer` inside a `Modal`, otherwise a right-aligned row */export const FormFooter = ({- hasTopBorder,- children,- justify = "right",+ pageProps,className,- ...extraGroupProps-}: PropsWithChildren<FormFooterProps>) => {- const groupProps = hasTopBorder- ? {- mt: "sm",- pt: "xl",- className: cx(className, CS.borderTop),- }- : { className };+ ...props+}: FormFooterProps) => {+ const isInModal = useIsInModal();++ if (isInModal) {+ return <Modal.Footer className={className} {...props} />;+ }++ const { className: pageClassName, ...pageGroupProps } = pageProps ?? {};+return (<Groupalign="center"- justify={justify}+ justify="right"gap="sm"- {...groupProps}- {...extraGroupProps}- >- {children}- </Group>+ className={cx(className, pageClassName)}+ {...pageGroupProps}+ {...props}+ />);};diff --git a/frontend/src/metabase/common/components/FormFooter/FormFooter.unit.spec.tsx b/frontend/src/metabase/common/components/FormFooter/FormFooter.unit.spec.tsxnew file mode 100644index 00000000000..4cc90783a56--- /dev/null+++ b/frontend/src/metabase/common/components/FormFooter/FormFooter.unit.spec.tsx@@ -0,0 +1,36 @@+import { render, screen } from "__support__/ui";+import { Button, Modal } from "metabase/ui";++import { FormFooter } from "./FormFooter";++const Footer = () => (+ <FormFooter data-testid="footer" pageProps={{ className: "page-row" }}>+ <Button>Save</Button>+ </FormFooter>+);++describe("FormFooter", () => {+ it("applies its props and page props outside a modal", () => {+ render(<Footer />);++ const footer = screen.getByTestId("footer");+ expect(footer).toHaveClass("page-row");+ expect(footer).toContainElement(+ screen.getByRole("button", { name: "Save" }),+ );+ });++ it("applies its props but not its page props inside a modal", () => {+ render(+ <Modal opened title="Title" onClose={jest.fn()}>+ <Footer />+ </Modal>,+ );++ const footer = screen.getByTestId("footer");+ expect(footer).not.toHaveClass("page-row");+ expect(footer).toContainElement(+ screen.getByRole("button", { name: "Save" }),+ );+ });+});diff --git a/frontend/src/metabase/common/components/FormToggle/FormToggle.stories.tsx b/frontend/src/metabase/common/components/FormToggle/FormToggle.stories.tsxdeleted file mode 100644index d947005af7e..00000000000--- a/frontend/src/metabase/common/components/FormToggle/FormToggle.stories.tsx+++ /dev/null@@ -1,40 +0,0 @@-import type { StoryFn } from "@storybook/react";--import { Form, FormProvider } from "metabase/forms";--import { FormToggle } from "./FormToggle";--export default {- title: "Components/Ask Before Using/FormToggle",- component: FormToggle,-};--const Template: StoryFn<typeof FormToggle> = (args) => {- const initialValues = { value: false };- const handleSubmit = () => undefined;-- return (- <FormProvider initialValues={initialValues} onSubmit={handleSubmit}>- <Form>- <FormToggle {...args} name="value" />- </Form>- </FormProvider>- );-};--export const Default = {- render: Template,-- args: {- title: "Title",- },-};--export const WithDescription = {- render: Template,-- args: {- title: "Title",- description: "Description",- },-};diff --git a/frontend/src/metabase/common/components/FormToggle/FormToggle.tsx b/frontend/src/metabase/common/components/FormToggle/FormToggle.tsxdeleted file mode 100644index 11c3022d9e3..00000000000--- a/frontend/src/metabase/common/components/FormToggle/FormToggle.tsx+++ /dev/null@@ -1,69 +0,0 @@-import { useField } from "formik";-import type { CSSProperties, ChangeEvent, ReactNode, Ref } from "react";-import { forwardRef, useCallback } from "react";--import { FormField } from "metabase/common/components/FormField";-import { useUniqueId } from "metabase/common/hooks/use-unique-id";-import type { SwitchProps } from "metabase/ui";-import { Switch } from "metabase/ui";--export interface FormToggleProps extends Omit<- SwitchProps,- "value" | "onBlur" | "style" | "onChange"-> {- name: string;- title?: string;- actions?: ReactNode;- description?: ReactNode;- optional?: boolean;- nullable?: boolean;- style?: CSSProperties;-}--export const FormToggle = forwardRef(function FormToggle(- {- name,- className,- style,- title,- actions,- description,- optional,- nullable: _nullable,- ...props- }: FormToggleProps,- ref: Ref<HTMLDivElement>,-) {- const id = useUniqueId();- const [{ value, onBlur }, { error, touched }, { setValue }] = useField(name);-- const handleChange = useCallback(- (event: ChangeEvent<HTMLInputElement>) => {- setValue(event.currentTarget.checked);- },- [setValue],- );-- return (- <FormField- ref={ref}- className={className}- style={style}- title={title}- description={description}- orientation="horizontal"- htmlFor={id}- error={touched ? error : undefined}- optional={optional}- >- <Switch- {...props}- id={id}- name={name}- checked={value ?? false}- onChange={handleChange}- onBlur={onBlur}- />- </FormField>- );-});diff --git a/frontend/src/metabase/common/components/FormToggle/index.ts b/frontend/src/metabase/common/components/FormToggle/index.tsdeleted file mode 100644index 0337ad7665e..00000000000--- a/frontend/src/metabase/common/components/FormToggle/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export { FormToggle } from "./FormToggle";-export type { FormToggleProps } from "./FormToggle";diff --git a/frontend/src/metabase/common/components/SaveQuestionForm/SaveQuestionForm.tsx b/frontend/src/metabase/common/components/SaveQuestionForm/SaveQuestionForm.tsxindex 8e940c797b8..bafed914737 100644--- a/frontend/src/metabase/common/components/SaveQuestionForm/SaveQuestionForm.tsx+++ b/frontend/src/metabase/common/components/SaveQuestionForm/SaveQuestionForm.tsx@@ -14,7 +14,7 @@ import {FormTextInput,FormTextarea,} from "metabase/forms";-import { Box, Button, Radio, Stack } from "metabase/ui";+import { Button, Radio, Stack, useIsInModal } from "metabase/ui";import type { OmniPickerItem } from "../Pickers";@@ -37,6 +37,8 @@ export const SaveQuestionForm = ({saveToDashboard,} = useSaveQuestionContext();+ const isInModal = useIsInModal();+const nameInputPlaceholder = getPlaceholder(question.type());const isDashboardQuestion = !!question.dashboardId();@@ -57,73 +59,68 @@ export const SaveQuestionForm = ({return (<Form>- {showSaveType && (- <FormRadioGroup name="saveType" label={title}>- <Stack gap="sm" mb="lg">- <Radio- name={overwriteOptionName}- value="overwrite"- label={overwriteOptionName}- classNames={{- labelWrapper: S.labelWrapper,- label: cx(S.label, {- [S.labelActive]: values.saveType === "overwrite",- }),- }}+ <Stack gap={isInModal ? "xl" : "lg"}>+ {showSaveType && (+ <FormRadioGroup name="saveType" label={title}>+ <Stack gap="sm">+ <Radio+ name={overwriteOptionName}+ value="overwrite"+ label={overwriteOptionName}+ classNames={{+ labelWrapper: S.labelWrapper,+ label: cx(S.label, {+ [S.labelActive]: values.saveType === "overwrite",+ }),+ }}+ />+ <Radio+ name={t`Save as new question`}+ value="create"+ classNames={{+ label: cx(S.label, {+ [S.labelActive]: values.saveType === "create",+ }),+ }}+ label={t`Save as new question`}+ />+ </Stack>+ </FormRadioGroup>+ )}+ {values.saveType === "create" && (+ <>+ <FormTextInput+ name="name"+ label={t`Name`}+ placeholder={nameInputPlaceholder}/>- <Radio- name={t`Save as new question`}- value="create"- classNames={{- label: cx(S.label, {- [S.labelActive]: values.saveType === "create",- }),- }}- label={t`Save as new question`}+ <FormTextarea+ name="description"+ label={t`Description`}+ minRows={4}+ placeholder={t`It's optional but oh, so helpful`}/>- </Stack>- </FormRadioGroup>- )}- {values.saveType === "create" && (- <Stack gap="lg" mb="lg">- <FormTextInput- name="name"- label={t`Name`}- placeholder={nameInputPlaceholder}- />-- <FormTextarea- name="description"- label={t`Description`}- minRows={4}- placeholder={t`It's optional but oh, so helpful`}- />-- <div>{showPickerInput && (- <Box mb="lg">- <FormCollectionAndDashboardPicker- collectionIdFieldName="collection_id"- dashboardIdFieldName="dashboard_id"- title={t`Where do you want to save this?`}- entityType={getEntityTypeFromCardType(question.type())}- collectionPickerModalProps={{- models,- }}- />- </Box>+ <FormCollectionAndDashboardPicker+ collectionIdFieldName="collection_id"+ dashboardIdFieldName="dashboard_id"+ title={t`Where do you want to save this?`}+ entityType={getEntityTypeFromCardType(question.type())}+ collectionPickerModalProps={{+ models,+ }}+ />)}-<FormDashboardTabSelectname="dashboard_tab_id"label={c("'this' refers to the question that's being saved").t`Which tab should this go on?`}dashboardId={values.dashboard_id}/>- </div>- </Stack>- )}- <FormFooter>+ </>+ )}+ </Stack>+ <FormFooter pageProps={{ mt: "lg" }}><FormErrorMessage inline /><Button onClick={onCancel}>{t`Cancel`}</Button><FormSubmitButtondiff --git a/frontend/src/metabase/common/components/SaveQuestionModal/SaveQuestionModal.tsx b/frontend/src/metabase/common/components/SaveQuestionModal/SaveQuestionModal.tsxindex c2e8c62b89b..cff9ebd14f8 100644--- a/frontend/src/metabase/common/components/SaveQuestionModal/SaveQuestionModal.tsx+++ b/frontend/src/metabase/common/components/SaveQuestionModal/SaveQuestionModal.tsx@@ -40,7 +40,12 @@ export const SaveQuestionModal = ({initialCollectionId={initialCollectionId}targetCollection={targetCollection}>- <Modal.Root padding="xxl" {...modalProps} onClose={onClose}>+ <Modal.Root+ density="relaxed"+ padding="xxl"+ {...modalProps}+ onClose={onClose}+ ><Modal.Overlay /><Modal.Content data-testid="save-question-modal"><Modal.Header>diff --git a/frontend/src/metabase/common/components/UserForm.module.css b/frontend/src/metabase/common/components/UserForm.module.cssdeleted file mode 100644index 8d8ce0972bb..00000000000--- a/frontend/src/metabase/common/components/UserForm.module.css+++ /dev/null@@ -1,4 +0,0 @@-.loginAttributes {- margin-top: var(--mantine-spacing-xxl);- margin-bottom: var(--mantine-spacing-lg);-}diff --git a/frontend/src/metabase/common/components/UserForm.tsx b/frontend/src/metabase/common/components/UserForm.tsxindex 7a1c3ab5dd9..8089e3daed2 100644--- a/frontend/src/metabase/common/components/UserForm.tsx+++ b/frontend/src/metabase/common/components/UserForm.tsx@@ -1,10 +1,7 @@import { useField } from "formik";-import type { HTMLAttributes } from "react";import { t } from "ttag";import * as Yup from "yup";-import { FormField } from "metabase/common/components/FormField";-import { FormFooter } from "metabase/common/components/FormFooter";import { GroupsMultiSelect } from "metabase/common/components/GroupsMultiSelect";import { isAdminGroup, isDefaultGroup } from "metabase/common/utils/groups";import {@@ -18,12 +15,10 @@ import {PLUGIN_ADMIN_USER_FORM_FIELDS,PLUGIN_TENANTS,} from "metabase/plugins";-import { Alert, Button } from "metabase/ui";+import { Alert, Button, Input, Modal, Stack } from "metabase/ui";import * as Errors from "metabase/utils/errors";import type { GroupId, GroupInfo, User, UserId } from "metabase-types/api";-import S from "./UserForm.module.css";-const localUserSchema = Yup.object({first_name: Yup.string().nullable().max(100, Errors.maxLength).default(null),last_name: Yup.string().nullable().max(100, Errors.maxLength).default(null),@@ -42,8 +37,9 @@ interface InviteTargetAccess {warningMessage: string;}-interface FormGroupsWidgetProps extends HTMLAttributes<HTMLDivElement> {+interface FormGroupsWidgetProps {name: string;+ title?: string;external?: boolean;groups?: GroupInfo[];inviteTargetAccess?: InviteTargetAccess;@@ -51,8 +47,6 @@ interface FormGroupsWidgetProps extends HTMLAttributes<HTMLDivElement> {const FormGroupsWidget = ({name,- className,- style,title = t`Groups`,external,groups,@@ -113,7 +107,7 @@ const FormGroupsWidget = ({!memberships.some(({ id }) => accessGroupIds.includes(id));return (- <FormField className={className} style={style} title={title}>+ <Input.Wrapper label={title}><GroupsMultiSelectgroups={groups}value={memberships.map((membership) => membership.id)}@@ -135,7 +129,7 @@ const FormGroupsWidget = ({{inviteTargetAccess?.warningMessage}</Alert>)}- </FormField>+ </Input.Wrapper>);};@@ -175,65 +169,63 @@ export const UserForm = ({>{({ dirty }: { dirty: boolean }) => (<Form disabled={!dirty}>- {!hideNameFields && (- <>- <FormTextInput- name="first_name"- title={t`First name`}- placeholder={t`Johnny`}- label={t`First name`}- mb="lg"- nullable- />- <FormTextInput- name="last_name"- title={t`Last name`}- placeholder={t`Appleseed`}- label={t`Last name`}- mb="lg"- nullable- />- </>- )}- <FormTextInput- name="email"- type="email"- title={t`Email`}- placeholder="[email protected]"- label={t`Email`}- required- mb="lg"- />- <FormGroupsWidget- name="user_group_memberships"- external={external}- title={PLUGIN_TENANTS.getFormGroupsTitle(external) ?? t`Groups`}- groups={groups}- inviteTargetAccess={inviteTargetAccess}- />- {external && (- <PLUGIN_TENANTS.FormTenantWidget+ <Stack gap="xl">+ {!hideNameFields && (+ <>+ <FormTextInput+ name="first_name"+ title={t`First name`}+ placeholder={t`Johnny`}+ label={t`First name`}+ nullable+ />+ <FormTextInput+ name="last_name"+ title={t`Last name`}+ placeholder={t`Appleseed`}+ label={t`Last name`}+ nullable+ />+ </>+ )}+ <FormTextInput+ name="email"+ type="email"+ title={t`Email`}+ placeholder="[email protected]"+ label={t`Email`}required- name="tenant_id"- placeholder={t`Select a tenant`}- disabled={edit}/>- )}- {!hideAttributes && (- <PLUGIN_ADMIN_USER_FORM_FIELDS.FormLoginAttributes- userId={userId}- className={S.loginAttributes}+ <FormGroupsWidget+ name="user_group_memberships"+ external={external}+ title={PLUGIN_TENANTS.getFormGroupsTitle(external) ?? t`Groups`}+ groups={groups}+ inviteTargetAccess={inviteTargetAccess}/>- )}- <FormFooter>- <FormErrorMessage inline />+ {external && (+ <PLUGIN_TENANTS.FormTenantWidget+ required+ name="tenant_id"+ placeholder={t`Select a tenant`}+ disabled={edit}+ />+ )}+ {!hideAttributes && (+ <PLUGIN_ADMIN_USER_FORM_FIELDS.FormLoginAttributes+ userId={userId}+ />+ )}+ </Stack>+ <Modal.Footer>+ <FormErrorMessage flex={1} /><Button type="button" onClick={onCancel}>{t`Cancel`}</Button><FormSubmitButtonlabel={submitText}disabled={!dirty}variant="filled"/>- </FormFooter>+ </Modal.Footer></Form>)}</FormProvider>diff --git a/frontend/src/metabase/dashboard/components/ActionSidebar/ActionSidebar.tsx b/frontend/src/metabase/dashboard/components/ActionSidebar/ActionSidebar.tsxindex 91840e3269b..28852c03688 100644--- a/frontend/src/metabase/dashboard/components/ActionSidebar/ActionSidebar.tsx+++ b/frontend/src/metabase/dashboard/components/ActionSidebar/ActionSidebar.tsx@@ -4,7 +4,6 @@ import { useMemo } from "react";import { t } from "ttag";import { isActionDashCard } from "metabase/actions/utils";-import { FormField } from "metabase/common/components/FormField/FormField";import { Sidebar } from "metabase/common/components/Sidebar";import CS from "metabase/css/core/index.css";import ActionViz from "metabase/dashboard/components/ActionViz";@@ -17,6 +16,7 @@ import {Divider,Ellipsified,Flex,+ Input,Modal,Stack,Title,@@ -101,13 +101,7 @@ export function ActionSidebar() {/></Form></FormProvider>- <Box>- <FormField.LabelContainer- orientation="vertical"- hasDescription={false}- >- <FormField.Label hasError={false}>{t`Action`}</FormField.Label>- </FormField.LabelContainer>+ <Input.Wrapper label={t`Action`}>{!dashcard.action ? (<Buttonvariant="filled"@@ -125,7 +119,7 @@ export function ActionSidebar() {>{t`Change action`}</Button></Flex>)}- </Box>+ </Input.Wrapper><Modal.Rootopened={actionModalOpened}diff --git a/frontend/src/metabase/databases/components/DatabaseForm/DatabaseFormBody.tsx b/frontend/src/metabase/databases/components/DatabaseForm/DatabaseFormBody.tsxindex aaf53ba5f87..929896f7a22 100644--- a/frontend/src/metabase/databases/components/DatabaseForm/DatabaseFormBody.tsx+++ b/frontend/src/metabase/databases/components/DatabaseForm/DatabaseFormBody.tsx@@ -67,6 +67,10 @@ export const DatabaseFormBody = ({const px = match(location).with("admin", "embedding_setup", () => "xl").otherwise(() => undefined);+ // In the admin modal, `Modal.Footer` brings its own space above the buttons.+ const mb = match(location)+ .with("admin", () => 0)+ .otherwise(() => "lg");const mah = match(location).with("admin", "embedding_setup", () => "calc(100vh - 20rem)").with("full-page", () => "100%")@@ -75,7 +79,7 @@ export const DatabaseFormBody = ({return (<Boxmah={mah}- mb="lg"+ mb={mb}px={px}flex={1}style={mah ? { overflowY: "auto" } : undefined}diff --git a/frontend/src/metabase/databases/components/DatabaseForm/DatabaseFormFooter.tsx b/frontend/src/metabase/databases/components/DatabaseForm/DatabaseFormFooter.tsxindex 9f4c674969b..789f42e83c7 100644--- a/frontend/src/metabase/databases/components/DatabaseForm/DatabaseFormFooter.tsx+++ b/frontend/src/metabase/databases/components/DatabaseForm/DatabaseFormFooter.tsx@@ -47,32 +47,27 @@ export const DatabaseFormFooter = ({if (isAdvanced) {return (<FormFooter data-testid="form-footer" px={isFullPage ? undefined : "xxl"}>- <Flex justify="space-between" align="center" w="100%">- <Flex gap="sm" align="center">- <DatabaseTestConnectionButton />- {isNew && (- <Tooltip label={t`Need help connecting?`}>- <ActionIcon- variant="subtle"- component={ExternalLink}- href={docsUrl}- aria-label={t`Need help connecting?`}- >- <Icon name="question" />- </ActionIcon>- </Tooltip>- )}- </Flex>-- <Flex gap="sm">- {!isFullPage && <Button onClick={onCancel}>{t`Cancel`}</Button>}- <FormSubmitButton- disabled={!isDirty}- label={isNew ? t`Save` : t`Save changes`}- variant="filled"- />- </Flex>+ <Flex gap="sm" align="center" mr="auto">+ <DatabaseTestConnectionButton />+ {isNew && (+ <Tooltip label={t`Need help connecting?`}>+ <ActionIcon+ variant="subtle"+ component={ExternalLink}+ href={docsUrl}+ aria-label={t`Need help connecting?`}+ >+ <Icon name="question" />+ </ActionIcon>+ </Tooltip>+ )}</Flex>+ {!isFullPage && <Button onClick={onCancel}>{t`Cancel`}</Button>}+ <FormSubmitButton+ disabled={!isDirty}+ label={isNew ? t`Save` : t`Save changes`}+ variant="filled"+ /></FormFooter>);}diff --git a/frontend/src/metabase/databases/components/DatabaseSectionField/DatabaseSectionField.tsx b/frontend/src/metabase/databases/components/DatabaseSectionField/DatabaseSectionField.tsxindex d8b1a2f0850..85cb72d69d0 100644--- a/frontend/src/metabase/databases/components/DatabaseSectionField/DatabaseSectionField.tsx+++ b/frontend/src/metabase/databases/components/DatabaseSectionField/DatabaseSectionField.tsx@@ -2,8 +2,7 @@ import { useField } from "formik";import { useCallback } from "react";import { t } from "ttag";-import { FormField } from "metabase/common/components/FormField";-import { Button, Icon } from "metabase/ui";+import { Box, Button, Icon } from "metabase/ui";export interface DatabaseSectionFieldProps {name: string;@@ -19,7 +18,7 @@ const DatabaseSectionField = ({}, [value, setValue]);return (- <FormField>+ <Box mb="xl"><Buttonw="fit-content"type="button"@@ -30,7 +29,7 @@ const DatabaseSectionField = ({>{value ? t`Hide advanced options` : t`Show advanced options`}</Button>- </FormField>+ </Box>);};diff --git a/frontend/src/metabase/databases/components/styles.ts b/frontend/src/metabase/databases/components/styles.tsindex 343f38b7802..e4241e8588b 100644--- a/frontend/src/metabase/databases/components/styles.ts+++ b/frontend/src/metabase/databases/components/styles.ts@@ -1,9 +1,10 @@import type { FieldType } from "../types";export function getSharedFieldStyleProps(type?: FieldType) {- // the file input isn't a Mantine field, so it takes no style props+ // the file input isn't a Mantine field, so it takes the label gap as `gap`+ // rather than through `labelProps`if (type === "textFile") {- return {};+ return { mb: "xl", gap: "sm" };}// our boolean (Switch) fields don't support the labelPropsdiff --git a/frontend/src/metabase/embedding/components/SharingMenu/InviteToViewModal.tsx b/frontend/src/metabase/embedding/components/SharingMenu/InviteToViewModal.tsxindex 32c21d7374d..988813f7876 100644--- a/frontend/src/metabase/embedding/components/SharingMenu/InviteToViewModal.tsx+++ b/frontend/src/metabase/embedding/components/SharingMenu/InviteToViewModal.tsx@@ -197,7 +197,7 @@ export const InviteToViewModal = ({}return (- <Modal opened title={title} onClose={onClose}>+ <Modal density="relaxed" opened title={title} onClose={onClose}>{body}</Modal>);diff --git a/frontend/src/metabase/metabot/components/AIProviderConfigurationForm/AIProviderSetup.tsx b/frontend/src/metabase/metabot/components/AIProviderConfigurationForm/AIProviderSetup.tsxindex 870f2c87c20..0e750ce6d7f 100644--- a/frontend/src/metabase/metabot/components/AIProviderConfigurationForm/AIProviderSetup.tsx+++ b/frontend/src/metabase/metabot/components/AIProviderConfigurationForm/AIProviderSetup.tsx@@ -6,7 +6,8 @@ import {useListLlmProvidersQuery,} from "metabase/api";import { getErrorMessage } from "metabase/api/utils";-import { Button, Flex, Stack, Text } from "metabase/ui";+import { FormFooter } from "metabase/common/components/FormFooter";+import { Button, Text } from "metabase/ui";import type {LlmProviderConnection,LlmProviderType,@@ -78,14 +79,14 @@ function AIProviderSetupContent({if (isPickingModel) {return (- <Stack gap="xl">+ <><LlmModelPicker />- <Flex justify="end">+ <FormFooter pageProps={{ mt: "xl" }}><Button variant="filled" onClick={onDone}>{t`Done`}</Button>- </Flex>- </Stack>+ </FormFooter>+ </>);}diff --git a/frontend/src/metabase/metabot/components/AIProviderConfigurationForm/ProviderConnectionForm.tsx b/frontend/src/metabase/metabot/components/AIProviderConfigurationForm/ProviderConnectionForm.tsxindex 840c2ffd6d6..bc507d18cbd 100644--- a/frontend/src/metabase/metabot/components/AIProviderConfigurationForm/ProviderConnectionForm.tsx+++ b/frontend/src/metabase/metabot/components/AIProviderConfigurationForm/ProviderConnectionForm.tsx@@ -9,12 +9,13 @@ import {useUpdateLlmProviderMutation,} from "metabase/api";import { getErrorMessage } from "metabase/api/utils";+import { FormFooter } from "metabase/common/components/FormFooter";import { PLUGIN_METABOT } from "metabase/plugins";import { useSetting } from "metabase/settings";import {+ Box,Button,Collapse,- Flex,Group,Icon,Select,@@ -216,136 +217,120 @@ export function ProviderConnectionForm({const MetabaseAIProviderSetup = PLUGIN_METABOT.MetabaseAIProviderSetup;- return (- <Stack gap="xl">- {match({ isEditing, providerType })- .with({ isEditing: false, providerType: P.nullish }, () => (- <ProviderTypePicker- providerTypes={providerTypes}- onSelect={handleTypeChange}+ return match({ isEditing, providerType })+ .with({ isEditing: false, providerType: P.nullish }, () => (+ <ProviderTypePicker+ providerTypes={providerTypes}+ onSelect={handleTypeChange}+ />+ ))+ .with({ providerType: { managed: true } }, ({ providerType: selected }) => (+ <>+ {!isEditing && (+ <Box mb="xl">+ <SelectedProvider providerType={selected} />+ </Box>+ )}+ <MetabaseAIProviderSetup+ isConnected={isEditing}+ onConnect={() => onSaved()}+ onCancel={isEditing ? undefined : handleBack}+ />+ </>+ ))+ .with({ providerType: P.nonNullable }, ({ providerType: selected }) => (+ <form onSubmit={handleSubmit}>+ <Stack gap="xl">+ {!isEditing && <SelectedProvider providerType={selected} />}+ <ProviderConfigFields+ fields={primaryFields}+ values={config}+ onChange={(key, value) =>+ setConfig((current) => ({ ...current, [key]: value }))+ }+ disabled={isSaving}+ disabledFields={connection?.env_fields}+ autoFocusFirstField/>- ))- .with(- { providerType: { managed: true } },- ({ providerType: selected }) => (- <Stack gap="xl">- {!isEditing && <SelectedProvider providerType={selected} />}- <MetabaseAIProviderSetup- isConnected={isEditing}- onConnect={() => onSaved()}- onCancel={isEditing ? undefined : handleBack}- />- </Stack>- ),- )- .with({ providerType: P.nonNullable }, ({ providerType: selected }) => (- <form onSubmit={handleSubmit}>- <Stack gap="xl">- {!isEditing && <SelectedProvider providerType={selected} />}- <ProviderConfigFields- fields={primaryFields}- values={config}- onChange={(key, value) =>- setConfig((current) => ({ ...current, [key]: value }))- }- disabled={isSaving}- disabledFields={connection?.env_fields}- autoFocusFirstField- />- {selected.type === OLLAMA_TYPE &&- !connection?.env_fields.includes(BASE_URL_FIELD) && (- <Group>- <Button- type="button"- variant="subtle"- onClick={() =>- setConfig((current) => ({- ...current,- [BASE_URL_FIELD]: OLLAMA_CLOUD_BASE_URL,- }))- }- disabled={isSaving}- >- {t`Use Ollama Cloud`}- </Button>- </Group>- )}- {selected.models.length > 0 && !hasConfiguredModel && (- <Select- label={t`Model`}- description={t`Connecting checks your credentials against this model, and Metabot starts on it.`}- data={selected.models.map(({ id, display_name }) => ({- value: id,- label: display_name,- }))}- value={model ?? null}- onChange={(next) => setModel(next ?? undefined)}- disabled={isSaving}- />- )}- <AdvancedSettings- isOpened={isAdvancedOpen}- onToggle={toggleAdvanced}- >- <TextInput- label={t`Display name`}- description={t`What this connection is called in the model picker.`}- value={name}- onChange={(event) => setName(event.currentTarget.value)}- disabled={isSaving}- />- <ProviderConfigFields- fields={advancedFields}- values={config}- onChange={(key, value) =>- setConfig((current) => ({ ...current, [key]: value }))+ {selected.type === OLLAMA_TYPE &&+ !connection?.env_fields.includes(BASE_URL_FIELD) && (+ <Group>+ <Button+ type="button"+ variant="subtle"+ onClick={() =>+ setConfig((current) => ({+ ...current,+ [BASE_URL_FIELD]: OLLAMA_CLOUD_BASE_URL,+ }))}disabled={isSaving}- disabledFields={connection?.env_fields}- />- </AdvancedSettings>- {error && <Text c="feedback-negative">{error}</Text>}- <Flex justify="end">- <Group gap="sm">- {match({ isEditing, onCancel })- .with(- { isEditing: true, onCancel: P.nonNullable },- ({ onCancel }) => (- <Button- type="button"- onClick={onCancel}- disabled={isSaving}- >- {t`Cancel`}- </Button>- ),- )- .with({ isEditing: false }, () => (- <Button- type="button"- onClick={handleBack}- disabled={isSaving}- >- {t`Back`}- </Button>- ))- .otherwise(() => null)}- <Button- type="submit"- variant="filled"- loading={isSaving}- disabled={isSaving || !isComplete}- >- {isEditing ? t`Save` : t`Connect`}- </Button>- </Group>- </Flex>- </Stack>- </form>- ))- .otherwise(() => null)}- </Stack>- );+ >+ {t`Use Ollama Cloud`}+ </Button>+ </Group>+ )}+ {selected.models.length > 0 && !hasConfiguredModel && (+ <Select+ label={t`Model`}+ description={t`Connecting checks your credentials against this model, and Metabot starts on it.`}+ data={selected.models.map(({ id, display_name }) => ({+ value: id,+ label: display_name,+ }))}+ value={model ?? null}+ onChange={(next) => setModel(next ?? undefined)}+ disabled={isSaving}+ />+ )}+ <AdvancedSettings isOpened={isAdvancedOpen} onToggle={toggleAdvanced}>+ <TextInput+ label={t`Display name`}+ description={t`What this connection is called in the model picker.`}+ value={name}+ onChange={(event) => setName(event.currentTarget.value)}+ disabled={isSaving}+ />+ <ProviderConfigFields+ fields={advancedFields}+ values={config}+ onChange={(key, value) =>+ setConfig((current) => ({ ...current, [key]: value }))+ }+ disabled={isSaving}+ disabledFields={connection?.env_fields}+ />+ </AdvancedSettings>+ {error && <Text c="feedback-negative">{error}</Text>}+ </Stack>+ <FormFooter pageProps={{ mt: "xl" }}>+ {match({ isEditing, onCancel })+ .with(+ { isEditing: true, onCancel: P.nonNullable },+ ({ onCancel }) => (+ <Button type="button" onClick={onCancel} disabled={isSaving}>+ {t`Cancel`}+ </Button>+ ),+ )+ .with({ isEditing: false }, () => (+ <Button type="button" onClick={handleBack} disabled={isSaving}>+ {t`Back`}+ </Button>+ ))+ .otherwise(() => null)}+ <Button+ type="submit"+ variant="filled"+ loading={isSaving}+ disabled={isSaving || !isComplete}+ >+ {isEditing ? t`Save` : t`Connect`}+ </Button>+ </FormFooter>+ </form>+ ))+ .otherwise(() => null);}function hasStoredAdvancedValues(diff --git a/frontend/src/metabase/metabot/components/AIProviderConfigurationModal.tsx b/frontend/src/metabase/metabot/components/AIProviderConfigurationModal.tsxindex 807258a77d9..c553408c366 100644--- a/frontend/src/metabase/metabot/components/AIProviderConfigurationModal.tsx+++ b/frontend/src/metabase/metabot/components/AIProviderConfigurationModal.tsx@@ -10,6 +10,7 @@ export function AIProviderConfigurationModal({}: Pick<ModalProps, "opened" | "onClose">) {return (<Modal+ density="relaxed"opened={opened}onClose={onClose}title={t`Connect to an AI provider`}diff --git a/frontend/src/metabase/metabot/components/MetabotManagedProviderLimit.tsx b/frontend/src/metabase/metabot/components/MetabotManagedProviderLimit.tsxindex 396408599d8..b315c6cdc7e 100644--- a/frontend/src/metabase/metabot/components/MetabotManagedProviderLimit.tsx+++ b/frontend/src/metabase/metabot/components/MetabotManagedProviderLimit.tsx@@ -40,6 +40,7 @@ export const MetabotManagedProviderLimitActions = ({// alongside it, not to cancel the subscription behind it.const configureModal = (<Modal+ density="relaxed"title={t`Add an AI provider`}onClose={close}opened={isOpen}diff --git a/frontend/src/metabase/ui/components/overlays/Modal/InModalContext.ts b/frontend/src/metabase/ui/components/overlays/Modal/InModalContext.tsnew file mode 100644index 00000000000..bbd429581e2--- /dev/null+++ b/frontend/src/metabase/ui/components/overlays/Modal/InModalContext.ts@@ -0,0 +1,12 @@+import { createContext, useContext } from "react";++const InModalContext = createContext(false);++/**+ * Overrides `useIsInModal` for its children. `Modal` and `Modal.Root` provide+ * `true`; pass `false` for modal content that should keep its page layout.+ */+export const InModalProvider = InModalContext.Provider;++/** Whether the component renders inside a `Modal` or `Modal.Root`. */+export const useIsInModal = () => useContext(InModalContext);diff --git a/frontend/src/metabase/ui/components/overlays/Modal/InModalContext.unit.spec.tsx b/frontend/src/metabase/ui/components/overlays/Modal/InModalContext.unit.spec.tsxnew file mode 100644index 00000000000..749514cc418--- /dev/null+++ b/frontend/src/metabase/ui/components/overlays/Modal/InModalContext.unit.spec.tsx@@ -0,0 +1,51 @@+import { render, screen } from "__support__/ui";++import { InModalProvider, Modal, useIsInModal } from "./index";++function Probe() {+ return <div>{useIsInModal() ? "in modal" : "not in modal"}</div>;+}++describe("useIsInModal", () => {+ it("is false outside a modal", () => {+ render(<Probe />);++ expect(screen.getByText("not in modal")).toBeInTheDocument();+ });++ it("is true inside a Modal", () => {+ render(+ <Modal opened title="Title" onClose={jest.fn()}>+ <Probe />+ </Modal>,+ );++ expect(screen.getByText("in modal")).toBeInTheDocument();+ });++ it("is true inside a Modal.Root", () => {+ render(+ <Modal.Root opened onClose={jest.fn()}>+ <Modal.Content>+ <Modal.Body>+ <Probe />+ </Modal.Body>+ </Modal.Content>+ </Modal.Root>,+ );++ expect(screen.getByText("in modal")).toBeInTheDocument();+ });++ it("can be overridden inside a modal", () => {+ render(+ <Modal opened title="Title" onClose={jest.fn()}>+ <InModalProvider value={false}>+ <Probe />+ </InModalProvider>+ </Modal>,+ );++ expect(screen.getByText("not in modal")).toBeInTheDocument();+ });+});diff --git a/frontend/src/metabase/ui/components/overlays/Modal/index.tsx b/frontend/src/metabase/ui/components/overlays/Modal/index.tsxindex 289bfaf2841..b8e6ab0568a 100644--- a/frontend/src/metabase/ui/components/overlays/Modal/index.tsx+++ b/frontend/src/metabase/ui/components/overlays/Modal/index.tsx@@ -13,12 +13,14 @@ import { PreventEagerPortal } from "metabase/ui";import { useGatedCloseProps } from "metabase/ui/components/overlays/overlay-stack";import { useDisableCommandPalette } from "metabase/ui/hooks/use-disable-command-palette";+import { InModalProvider } from "./InModalContext";import S from "./Modal.module.css";export { useModalsStack } from "@mantine/core";export * from "./Modal.config";export * from "./constants";+export * from "./InModalContext";export const MODAL_LAYOUTS = ["default", "centered"] as const;@@ -103,13 +105,15 @@ export function Modal({closeOnClickOutside={closeProps.closeOnClickOutside}closeOnEscape={closeProps.closeOnEscape}>- {hasCenteredHeading && (- <div className={S.centeredHeading}>- {illustration}- {title && <MantineModal.Title>{title}</MantineModal.Title>}- </div>- )}- {children}+ <InModalProvider value={true}>+ {hasCenteredHeading && (+ <div className={S.centeredHeading}>+ {illustration}+ {title && <MantineModal.Title>{title}</MantineModal.Title>}+ </div>+ )}+ {children}+ </InModalProvider></MantineModal></PreventEagerPortal>);@@ -118,6 +122,7 @@ export function Modal({function ModalRoot({layout = "default",density = "default",+ children,...props}: ModalRootProps) {const closeProps = useGatedCloseProps(props);@@ -133,7 +138,9 @@ function ModalRoot({data-density={density}closeOnClickOutside={closeProps.closeOnClickOutside}closeOnEscape={closeProps.closeOnEscape}- />+ >+ <InModalProvider value={true}>{children}</InModalProvider>+ </MantineModal.Root></PreventEagerPortal>);}