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
Move the metabot slash command slot into metabot (#82307)
Fraser99f918928c98
diff --git a/enterprise/frontend/src/metabase-enterprise/audit_app/index.tsx b/enterprise/frontend/src/metabase-enterprise/audit_app/index.tsxindex 63a285d2a5e..2f9f459a02d 100644--- a/enterprise/frontend/src/metabase-enterprise/audit_app/index.tsx+++ b/enterprise/frontend/src/metabase-enterprise/audit_app/index.tsx@@ -1,6 +1,7 @@import { t } from "ttag";import { ForwardRefLink } from "metabase/common/components/Link";+import { PLUGIN_METABOT_SLASH_COMMANDS } from "metabase/metabot";import {PLUGIN_ADMIN_USER_MENU_ITEMS,PLUGIN_ADMIN_USER_MENU_ROUTES,@@ -54,6 +55,7 @@ export function initializePlugin() {PLUGIN_AUDIT.getAiAuditingRoutes = hasPremiumFeature("ai_controls")? getAiAuditingRoutes: getAiAuditingUpsellRoutes;- PLUGIN_AUDIT.handleMetabotSlashCommand = handleMetabotSlashCommand;+ PLUGIN_METABOT_SLASH_COMMANDS.handleSlashCommand =+ handleMetabotSlashCommand;}}diff --git a/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/metabot-analytics/slash-commands.ts b/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/metabot-analytics/slash-commands.tsindex 7eb52ac9479..183db08762a 100644--- a/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/metabot-analytics/slash-commands.ts+++ b/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/metabot-analytics/slash-commands.ts@@ -1,6 +1,6 @@import { getUserIsAdmin } from "metabase/current-user";+import type { MetabotSlashCommandHandler } from "metabase/metabot";import { getIsConversationEmpty } from "metabase/metabot/state";-import type { MetabotSlashCommandHandler } from "metabase/plugins/oss/audit";import { addUndo } from "metabase/redux/undo";import { navigate } from "metabase/router";import * as Urls from "metabase/urls";diff --git a/frontend/src/metabase/metabot/index.tsx b/frontend/src/metabase/metabot/index.tsxindex eb8f56dbb1c..158be2b4b05 100644--- a/frontend/src/metabase/metabot/index.tsx+++ b/frontend/src/metabase/metabot/index.tsx@@ -12,3 +12,7 @@ export {AIProviderSetup,LlmModelPicker,} from "./components/AIProviderConfigurationForm";+export {+ PLUGIN_METABOT_SLASH_COMMANDS,+ type MetabotSlashCommandHandler,+} from "./plugins";diff --git a/frontend/src/metabase/metabot/plugins.ts b/frontend/src/metabase/metabot/plugins.tsnew file mode 100644index 00000000000..47cadca5309--- /dev/null+++ b/frontend/src/metabase/metabot/plugins.ts@@ -0,0 +1,21 @@+import { definePluginSlot } from "metabase/plugins";+import type { Dispatch, GetState } from "metabase/redux/store";++import type { SlashCommand } from "./state/types";++export type MetabotSlashCommandHandler = (args: {+ command: SlashCommand;+ conversationId: string;+ dispatch: Dispatch;+ getState: GetState;+}) => boolean;++type MetabotSlashCommandsPlugin = {+ handleSlashCommand: MetabotSlashCommandHandler;+};++export const PLUGIN_METABOT_SLASH_COMMANDS = definePluginSlot(+ (): MetabotSlashCommandsPlugin => ({+ handleSlashCommand: () => false,+ }),+);diff --git a/frontend/src/metabase/metabot/state/actions.ts b/frontend/src/metabase/metabot/state/actions.tsindex 1c798ce9b0c..ffe22671cc0 100644--- a/frontend/src/metabase/metabot/state/actions.ts+++ b/frontend/src/metabase/metabot/state/actions.ts@@ -16,7 +16,6 @@ import type { ProcessedChatResponse } from "metabase/api/ai-streaming/process-stimport { listTag } from "metabase/api/tags";import { getUser } from "metabase/current-user";import { isEmbeddingSdk } from "metabase/embedding-sdk/config";-import { PLUGIN_AUDIT } from "metabase/plugins";import { setIsNativeEditorOpen } from "metabase/redux/query-builder";import type { Dispatch, State } from "metabase/redux/store";import { addUndo } from "metabase/redux/undo";@@ -42,6 +41,7 @@ import {type MetabotProfileId,isHistoryEnabledProfile,} from "../constants";+import { PLUGIN_METABOT_SLASH_COMMANDS } from "../plugins";import { metabot } from "./reducer";import {@@ -285,7 +285,7 @@ export const executeSlashCommand = createAsyncThunk<);}).otherwise(() => {- const handled = PLUGIN_AUDIT.handleMetabotSlashCommand({+ const handled = PLUGIN_METABOT_SLASH_COMMANDS.handleSlashCommand({command,conversationId,dispatch,diff --git a/frontend/src/metabase/plugins/oss/audit.ts b/frontend/src/metabase/plugins/oss/audit.tsindex 902395e7de3..ca3bb02a155 100644--- a/frontend/src/metabase/plugins/oss/audit.ts+++ b/frontend/src/metabase/plugins/oss/audit.ts@@ -1,9 +1,7 @@import type { ComponentType, ReactNode } from "react";import type { LinkProps } from "metabase/common/components/Link";-import type { SlashCommand } from "metabase/metabot/state/types";import { PluginPlaceholder } from "metabase/plugins/components/PluginPlaceholder";-import type { Dispatch, GetState } from "metabase/redux/store";import type Question from "metabase-lib/v1/Question";import type {Card,@@ -14,13 +12,6 @@ import type {import { definePluginSlot } from "../slot";-export type MetabotSlashCommandHandler = (args: {- command: SlashCommand;- conversationId: string;- dispatch: Dispatch;- getState: GetState;-}) => boolean;-export type InsightsLinkProps = (| {question: Pick<Question, "id" | "collection">;@@ -49,7 +40,6 @@ type AuditPlugin = {CollectionExportAnalytics: ComponentType;isAiAuditingEnabled: boolean;getAiAuditingRoutes: () => ReactNode;- handleMetabotSlashCommand: MetabotSlashCommandHandler;};const getDefaultPluginAudit = (): AuditPlugin => ({@@ -61,7 +51,6 @@ const getDefaultPluginAudit = (): AuditPlugin => ({CollectionExportAnalytics: PluginPlaceholder,isAiAuditingEnabled: false,getAiAuditingRoutes: () => null,- handleMetabotSlashCommand: (_args) => false,});export const PLUGIN_AUDIT = definePluginSlot(getDefaultPluginAudit);