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
Show Metabot illustration preview next to the visibility toggle (#73346)
Andrei Chernykh06d543abe57e
diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotCustomizationPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotCustomizationPage.unit.spec.tsxindex dce9aea356d..61e8af09a83 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotCustomizationPage.unit.spec.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotCustomizationPage.unit.spec.tsx@@ -46,6 +46,9 @@ describe("MetabotCustomizationPage", () => {screen.queryByRole("button", { name: /Remove custom icon/ }),).not.toBeInTheDocument();expect(screen.queryByText("Metabot illustrations")).not.toBeInTheDocument();+ expect(+ screen.queryByAltText("Metabot illustration preview"),+ ).not.toBeInTheDocument();});it("shows the remove button and illustrations toggle when a custom icon is set", async () => {@@ -56,6 +59,9 @@ describe("MetabotCustomizationPage", () => {screen.getByRole("button", { name: /Remove custom icon/ }),).toBeInTheDocument();expect(screen.getByText("Metabot illustrations")).toBeInTheDocument();+ expect(+ screen.getByAltText("Metabot illustration preview"),+ ).toBeInTheDocument();});it("shows the custom icon preview image when a custom icon is set", async () => {diff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotIconField.tsx b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotIconField.tsxindex 06f6fe3dd04..ce8ea00b343 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotIconField.tsx+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotCustomizationPage/MetabotIconField.tsx@@ -2,6 +2,7 @@ import cx from "classnames";import { type ChangeEvent, useRef, useState } from "react";import { t } from "ttag";+import EmptyDashboardBot from "assets/img/dashboard-empty.svg";import { useAdminSetting } from "metabase/api/utils";import CS from "metabase/css/core/index.css";import {@@ -97,26 +98,30 @@ export function MetabotIconField() {my="sm"py="sm"px="md"+ maw="100%"+ wrap="wrap">- <Box+ <FlexclassName={cx(CS.bgLight, CS.bordered, CS.rounded)}- p="sm"- flex="0 0 2.25rem"+ align="center"+ justify="center"+ w="2.25rem"+ h="2.25rem"+ flex="0 0 auto">{iconPreviewSrc ? (- <img+ <Box+ component="img"src={iconPreviewSrc}alt={t`Metabot icon`}- style={{- width: "1.5rem",- height: "1.5rem",- objectFit: "contain",- }}+ w="1.5rem"+ h="1.5rem"+ style={{ objectFit: "contain" }}/>) : (<Icon name="metabot" />)}- </Box>+ </Flex><inputref={fileInputRef}hidden@@ -125,23 +130,38 @@ export function MetabotIconField() {multiple={false}onChange={handleIconUpload}/>- <Button size="sm" onClick={() => fileInputRef.current?.click()}>+ <Button+ size="sm"+ onClick={() => fileInputRef.current?.click()}+ flex="0 0 auto"+ >{t`Upload a custom icon`}</Button>- {iconFileName && (- <Text fz="sm" c="text-secondary" truncate="end">- {iconFileName}- </Text>- )}- {!isDefaultIcon && (- <Tooltip label={t`Remove custom icon`}>- <ActionIcon- onClick={handleIconRemove}- aria-label={t`Remove custom icon`}- >- <Icon name="close" />- </ActionIcon>- </Tooltip>+ {(iconFileName || !isDefaultIcon) && (+ <Flex align="center" gap="md" flex="1 1 0" miw="2rem">+ {iconFileName && (+ <Text+ fz="sm"+ c="text-secondary"+ truncate="end"+ miw={0}+ title={iconFileName}+ flex="1 1 0"+ >+ {iconFileName}+ </Text>+ )}+ {!isDefaultIcon && (+ <Tooltip label={t`Remove custom icon`}>+ <ActionIcon+ onClick={handleIconRemove}+ aria-label={t`Remove custom icon`}+ >+ <Icon name="close" />+ </ActionIcon>+ </Tooltip>+ )}+ </Flex>)}</Flex>{!isDefaultIcon && (@@ -149,10 +169,20 @@ export function MetabotIconField() {<Text fz="md" fw="bold">{t`Metabot illustrations`}</Text>- <Group gap="lg">- <Text fz="md" c="text-secondary">- {t`Show Metabot illustrations in chat sidebar and AI exploration page`}- </Text>+ <Group gap="lg" align="center" wrap="nowrap">+ <Flex align="center" gap="sm" flex="1" miw={0}>+ <Box+ component="img"+ src={EmptyDashboardBot}+ alt={t`Metabot illustration preview`}+ w="3rem"+ h="3rem"+ flex="0 0 auto"+ />+ <Text fz="md" c="text-secondary" flex="1">+ {t`Show Metabot illustrations in chat sidebar and AI exploration page`}+ </Text>+ </Flex><Switcharia-label={t`Show Metabot illustrations`}checked={!!showIllustrations}