From 2363a5011dda083bd2da14fb67a2b5fb30e8c06b Mon Sep 17 00:00:00 2001 From: arunvjn <32433245+arunvjn@users.noreply.github.com> Date: Fri, 16 Jun 2023 07:30:22 +0530 Subject: [PATCH] chore: use separate feature flags for JS expressions and SQL query AI (#24498) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description CE changes to support https://github.com/appsmithorg/appsmith-ee/pull/1644 > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change - Chore (housekeeping or task changes that don't impact user perception) > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- .../editorComponents/GPT/trigger.tsx | 10 +++++---- .../editorComponents/CodeEditor/index.tsx | 21 +++++++------------ app/client/src/entities/FeatureFlags.ts | 2 ++ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/client/src/ce/components/editorComponents/GPT/trigger.tsx b/app/client/src/ce/components/editorComponents/GPT/trigger.tsx index 0745032668..31fca72688 100644 --- a/app/client/src/ce/components/editorComponents/GPT/trigger.tsx +++ b/app/client/src/ce/components/editorComponents/GPT/trigger.tsx @@ -1,6 +1,8 @@ -export const askAIEnabled = false; -export const APPSMITH_AI = "Ask AI"; +import type { TEditorModes } from "components/editorComponents/CodeEditor/EditorConfig"; +import type FeatureFlags from "entities/FeatureFlags"; +export const APPSMITH_AI = "AI"; -export function GPTTrigger() { - return null; +/* eslint-disable-next-line */ +export function isAIEnabled(ff: FeatureFlags, mode: TEditorModes) { + return false; } diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index d3c2acb964..bc2bd9095a 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -147,7 +147,7 @@ import { AIWindow } from "@appsmith/components/editorComponents/GPT"; import classNames from "classnames"; import { APPSMITH_AI, - askAIEnabled, + isAIEnabled, } from "@appsmith/components/editorComponents/GPT/trigger"; import { getAllDatasourceTableKeys, @@ -157,13 +157,10 @@ import { debug } from "loglevel"; import { PeekOverlayExpressionIdentifier, SourceType } from "@shared/ast"; import type { MultiplexingModeConfig } from "components/editorComponents/CodeEditor/modes"; import { MULTIPLEXING_MODE_CONFIGS } from "components/editorComponents/CodeEditor/modes"; -import { getAppsmithConfigs } from "@appsmith/configs"; type ReduxStateProps = ReturnType; type ReduxDispatchProps = ReturnType; -const { cloudHosting } = getAppsmithConfigs(); - export type CodeEditorExpected = { type: string; example: ExpectedValueExample; @@ -317,6 +314,12 @@ class CodeEditor extends Component { props.input.value, ); this.multiplexConfig = MULTIPLEXING_MODE_CONFIGS[this.props.mode]; + /** + * Decides if AI is enabled by looking at repo, feature flags, props and environment + */ + this.AIEnabled = + isAIEnabled(this.props.featureFlags, this.props.mode) && + Boolean(this.props.AIAssisted); } componentDidMount(): void { @@ -1475,16 +1478,6 @@ class CodeEditor extends Component { } const entityInformation = this.getEntityInformation(); - /** - * Decides if AI is enabled by looking at repo, feature flags, props and environment - */ - this.AIEnabled = Boolean( - askAIEnabled && - this.props.featureFlags.ask_ai && - this.props.AIAssisted && - cloudHosting, - ); - /** * AI button is to be shown when following conditions are satisfied * Enabled by feature flag and repo permissions diff --git a/app/client/src/entities/FeatureFlags.ts b/app/client/src/entities/FeatureFlags.ts index 3c83fa92d0..3f25e07285 100644 --- a/app/client/src/entities/FeatureFlags.ts +++ b/app/client/src/entities/FeatureFlags.ts @@ -4,6 +4,8 @@ type FeatureFlags = { AUTO_LAYOUT?: boolean; ask_ai?: boolean; APP_NAVIGATION_LOGO_UPLOAD?: boolean; + ask_ai_sql?: boolean; + ask_ai_js?: boolean; }; export default FeatureFlags;