Skip to content

Commit

Permalink
Only show AI tab if feature flag exists
Browse files Browse the repository at this point in the history
  • Loading branch information
hetunandu committed Nov 11, 2024
1 parent a824609 commit cffb595
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions app/client/src/pages/Editor/CustomWidgetBuilder/Editor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext } from "react";
import React, { useContext, useMemo } from "react";
import styles from "./styles.module.css";
import Layout from "./Layouts";
import Header from "./Header";
Expand All @@ -9,37 +9,49 @@ import JSEditor from "./CodeEditors/JSEditor";
import type { ContentProps } from "./CodeEditors/types";
import References from "./References";
import { ChatBot } from "./ChatBot/ChatBot";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import { FEATURE_FLAG } from "ee/entities/FeatureFlag";

export default function Editor() {
const { isReferenceOpen } = useContext(CustomWidgetBuilderContext);
const isAIEnabled = useFeatureFlag(
FEATURE_FLAG.release_custom_widget_ai_builder,
);

const tabs = useMemo(() => {
const defaultTabs = [
{
title: "HTML",
children: (props: ContentProps) => <HTMLEditor {...props} />,
},
{
title: "Style",
titleControls: <TitleControls />,
children: (props: ContentProps) => <StyleEditor {...props} />,
},
{
title: "Javascript",
children: (props: ContentProps) => <JSEditor {...props} />,
},
];

if (isAIEnabled) {
defaultTabs.push({
title: "AI",
children: (props: ContentProps) => <ChatBot {...props} />,
});
}

return defaultTabs;
}, [isAIEnabled]);

return (
<div>
<div className={styles.headerControls}>
<Header />
</div>
<div className={styles.contentRightBody}>
<Layout
content={[
{
title: "HTML",
children: (props: ContentProps) => <HTMLEditor {...props} />,
},
{
title: "Style",
titleControls: <TitleControls />,
children: (props: ContentProps) => <StyleEditor {...props} />,
},
{
title: "Javascript",
children: (props: ContentProps) => <JSEditor {...props} />,
},
{
title: "AI",
children: (props: ContentProps) => <ChatBot {...props} />,
},
]}
/>
<Layout content={tabs} />
{isReferenceOpen && <References />}
</div>
</div>
Expand Down

0 comments on commit cffb595

Please sign in to comment.