From f8f8374506c3d0c2ad7cea73bb461b3f64a81be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 13 Apr 2023 14:14:27 +0200 Subject: [PATCH] feat(editor): Add Ask AI preview (#5916) * :sparkles: Add Ask AI preview * :bug: Fire event on mousedown * :zap: Update to use Alex's event bus * :pencil2: Use i18n * :zap: Add telemetry * :recycle: Change trigger from focus to hover * :zap: Ensure focus + hover trigger event --- .../src/components/N8nButton/Button.vue | 2 +- .../editor-ui/src/components/AskAiModal.vue | 52 +++++++++++++++ .../CodeNodeEditor/CodeNodeEditor.vue | 65 ++++++++++++++++++- packages/editor-ui/src/components/Modals.vue | 8 +++ packages/editor-ui/src/constants.ts | 2 + .../src/plugins/i18n/locales/en.json | 4 ++ packages/editor-ui/src/stores/ui.ts | 4 ++ 7 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 packages/editor-ui/src/components/AskAiModal.vue diff --git a/packages/design-system/src/components/N8nButton/Button.vue b/packages/design-system/src/components/N8nButton/Button.vue index e0d6d8334d..127a1abd5f 100644 --- a/packages/design-system/src/components/N8nButton/Button.vue +++ b/packages/design-system/src/components/N8nButton/Button.vue @@ -194,7 +194,7 @@ $loading-overlay-background-color: rgba(255, 255, 255, 0); } .tertiary { - font-weight: var(--font-weight-regular) !important; + font-weight: var(--font-weight-bold) !important; --button-background-color: var(--color-background-xlight); --button-color: var(--color-text-dark); diff --git a/packages/editor-ui/src/components/AskAiModal.vue b/packages/editor-ui/src/components/AskAiModal.vue new file mode 100644 index 0000000000..1a678394a9 --- /dev/null +++ b/packages/editor-ui/src/components/AskAiModal.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/packages/editor-ui/src/components/CodeNodeEditor/CodeNodeEditor.vue b/packages/editor-ui/src/components/CodeNodeEditor/CodeNodeEditor.vue index 55c597bcce..fff8c461fa 100644 --- a/packages/editor-ui/src/components/CodeNodeEditor/CodeNodeEditor.vue +++ b/packages/editor-ui/src/components/CodeNodeEditor/CodeNodeEditor.vue @@ -1,5 +1,21 @@ - + diff --git a/packages/editor-ui/src/components/Modals.vue b/packages/editor-ui/src/components/Modals.vue index 8b26f5dce6..f9866042bd 100644 --- a/packages/editor-ui/src/components/Modals.vue +++ b/packages/editor-ui/src/components/Modals.vue @@ -15,6 +15,10 @@ + + + + @@ -138,10 +142,12 @@ import { WORKFLOW_SHARE_MODAL_KEY, IMPORT_CURL_MODAL_KEY, LOG_STREAM_MODAL_KEY, + ASK_AI_MODAL_KEY, USER_ACTIVATION_SURVEY_MODAL, } from '@/constants'; import AboutModal from './AboutModal.vue'; +import AskAiModal from './AskAiModal.vue'; import CommunityPackageManageConfirmModal from './CommunityPackageManageConfirmModal.vue'; import CommunityPackageInstallModal from './CommunityPackageInstallModal.vue'; import ChangePasswordModal from './ChangePasswordModal.vue'; @@ -169,6 +175,7 @@ export default Vue.extend({ name: 'Modals', components: { AboutModal, + AskAiModal, ActivationModal, CommunityPackageInstallModal, CommunityPackageManageConfirmModal, @@ -199,6 +206,7 @@ export default Vue.extend({ CREDENTIAL_EDIT_MODAL_KEY, CREDENTIAL_SELECT_MODAL_KEY, ABOUT_MODAL_KEY, + ASK_AI_MODAL_KEY, CHANGE_PASSWORD_MODAL_KEY, DELETE_USER_MODAL_KEY, DUPLICATE_MODAL_KEY, diff --git a/packages/editor-ui/src/constants.ts b/packages/editor-ui/src/constants.ts index 7504d6d4e7..1dd90ccbad 100644 --- a/packages/editor-ui/src/constants.ts +++ b/packages/editor-ui/src/constants.ts @@ -26,6 +26,7 @@ export const MAX_TAG_NAME_LENGTH = 24; // modals export const ABOUT_MODAL_KEY = 'about'; +export const ASK_AI_MODAL_KEY = 'askAi'; export const CHANGE_PASSWORD_MODAL_KEY = 'changePassword'; export const CREDENTIAL_EDIT_MODAL_KEY = 'editCredential'; export const CREDENTIAL_SELECT_MODAL_KEY = 'selectCredential'; @@ -193,6 +194,7 @@ export const FLOWS_CONTROL_SUBCATEGORY = 'Flow'; export const HELPERS_SUBCATEGORY = 'Helpers'; export const REQUEST_NODE_FORM_URL = 'https://n8n-community.typeform.com/to/K1fBVTZ3'; +export const ASK_AI_WAITLIST_URL = 'https://n8n-community.typeform.com/to/odKU4oDR'; // General export const INSTANCE_ID_HEADER = 'n8n-instance-id'; diff --git a/packages/editor-ui/src/plugins/i18n/locales/en.json b/packages/editor-ui/src/plugins/i18n/locales/en.json index c20068e321..62bce2e86a 100644 --- a/packages/editor-ui/src/plugins/i18n/locales/en.json +++ b/packages/editor-ui/src/plugins/i18n/locales/en.json @@ -49,6 +49,9 @@ "about.n8nVersion": "n8n Version", "about.sourceCode": "Source Code", "about.instanceID": "Instance ID", + "askAi.dialog.title": "'Ask AI' is almost ready", + "askAi.dialog.body": "We’re still applying the finishing touches. Soon, you will be able to automatically generate code from simple text prompts. Join the waitlist to get early access to this feature.", + "askAi.dialog.signup": "Join Waitlist", "activationModal.butYouCanSeeThem": "but you can see them in the", "activationModal.dontShowAgain": "Don't show again", "activationModal.executionList": "execution list", @@ -110,6 +113,7 @@ "binaryDataDisplay.noDataFoundToDisplay": "No data found to display", "binaryDataDisplay.yourBrowserDoesNotSupport": "Your browser does not support the video element. Kindly update it to latest version.", "codeEdit.edit": "Edit", + "codeNodeEditor.askAi": "✨ Ask AI", "codeNodeEditor.completer.$()": "Output data of the {nodeName} node", "codeNodeEditor.completer.$execution": "Information about the current execution", "codeNodeEditor.completer.$execution.id": "The ID of the current execution", diff --git a/packages/editor-ui/src/stores/ui.ts b/packages/editor-ui/src/stores/ui.ts index 3b8c6d0d08..666dc7af5b 100644 --- a/packages/editor-ui/src/stores/ui.ts +++ b/packages/editor-ui/src/stores/ui.ts @@ -5,6 +5,7 @@ import { } from '@/api/workflow-webhooks'; import { ABOUT_MODAL_KEY, + ASK_AI_MODAL_KEY, CHANGE_PASSWORD_MODAL_KEY, COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY, COMMUNITY_PACKAGE_INSTALL_MODAL_KEY, @@ -56,6 +57,9 @@ export const useUIStore = defineStore(STORES.UI, { [ABOUT_MODAL_KEY]: { open: false, }, + [ASK_AI_MODAL_KEY]: { + open: false, + }, [CHANGE_PASSWORD_MODAL_KEY]: { open: false, },