Skip to content
Snippets Groups Projects
Unverified Commit d7efdd90 authored by Aleksandr Lesnenko's avatar Aleksandr Lesnenko Committed by GitHub
Browse files

Hide metabot (#31750)

parent 54a4d223
No related branches found
No related tags found
No related merge requests found
......@@ -238,7 +238,7 @@ describe("scenarios > admin > settings", () => {
"should display the order of the settings items consistently between OSS/EE versions (metabase#15441)",
{ tags: "@OSS" },
() => {
const lastItem = isEE ? "Appearance" : "Metabot";
const lastItem = isEE ? "Appearance" : "Caching";
cy.visit("/admin/settings/setup");
cy.get(".AdminList .AdminList-item")
......
......@@ -8,6 +8,7 @@ import {
openQuestionActions,
resetSnowplow,
restore,
sidebar,
visitModel,
} from "e2e/support/helpers";
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
......@@ -64,6 +65,17 @@ describe("scenarios > metabot", () => {
});
});
it("should not show metabot if it is disabled", () => {
cy.visit("/admin");
sidebar().findByText("Metabot").should("not.exist");
cy.visit("/metabot/database/1");
cy.url().should("eq", `${location.origin}/`);
cy.visit("/metabot/model/1");
cy.url().should("eq", `${location.origin}/`);
});
it("should allow to submit prompts based on the database", () => {
cy.createQuestion(MODEL_DETAILS);
enableMetabot();
......
......@@ -248,11 +248,11 @@ class SettingsEditorApp extends Component {
);
return (
<div className="MetadataEditor-table-list AdminList flex-no-shrink">
<aside className="MetadataEditor-table-list AdminList flex-no-shrink">
<ul className="AdminList-items pt1">
<ErrorBoundary>{renderedSections}</ErrorBoundary>
</ul>
</div>
</aside>
);
}
......
......@@ -661,13 +661,8 @@ const SECTIONS = updateSectionsWithPlugins({
metabot: {
name: t`Metabot`,
order: 130,
getHidden: settings => !settings["is-metabot-enabled"],
settings: [
{
key: "is-metabot-enabled",
display_name: t`Enable Metabot`,
description: t`Metabot is in alpha, and in general you should always examine SQL queries generated by large language models (LLMs) before using their results in critical applications. By using Metabot, you agree to share your prompts and their resultant queries with Metabase to help us improve Metabot’s performance.`,
type: "boolean",
},
{
key: "openai-api-key",
display_name: t`OpenAI API Key`,
......@@ -741,7 +736,9 @@ export const getSections = createSelector(
const settingsByKey = _.groupBy(settings, "key");
const sectionsWithAPISettings = {};
for (const [slug, section] of Object.entries(SECTIONS)) {
if (section.adminOnly && !isAdmin) {
const isHidden = section.getHidden?.(derivedSettingValues);
if (isHidden || (section.adminOnly && !isAdmin)) {
continue;
}
......
......@@ -2,6 +2,7 @@ import { routerActions } from "react-router-redux";
import { UserAuthWrapper } from "redux-auth-wrapper";
import MetabaseSettings from "metabase/lib/settings";
import { getAdminPaths } from "metabase/admin/app/selectors";
import { getIsMetabotEnabled } from "metabase/home/selectors";
const MetabaseIsSetup = UserAuthWrapper({
predicate: authData => authData.hasUserSetup,
......@@ -48,9 +49,9 @@ const UserCanAccessSettings = UserAuthWrapper({
});
export const UserCanAccessMetabot = UserAuthWrapper({
predicate: isMetabotEnabled => true, // FIXME [AL]: fix this guard
predicate: isMetabotEnabled => isMetabotEnabled,
failureRedirectPath: "/",
authSelector: () => MetabaseSettings.isMetabotEnabled(),
authSelector: state => getIsMetabotEnabled(state),
allowRedirectBack: false,
wrapperDisplayName: "UserCanAccessMetabot",
redirectAction: routerActions.replace,
......
......@@ -38,7 +38,7 @@
(defsetting is-metabot-enabled
(deferred-tru "Is Metabot enabled?")
:type :boolean
:visibility :authenticated
:visibility :public
:default false)
(defsetting num-metabot-choices
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment