Skip to content

Commit

Permalink
fix: Show Ask AI only on Code Node (#6336)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed May 30, 2023
1 parent 792b1c1 commit da856d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Expand Up @@ -7,7 +7,7 @@
>
<div ref="codeNodeEditor" class="code-node-editor-input ph-no-capture"></div>
<n8n-button
v-if="isCloud && (isEditorHovered || isEditorFocused)"
v-if="aiButtonEnabled && (isEditorHovered || isEditorFocused)"
size="small"
type="tertiary"
:class="$style['ask-ai-button']"
Expand Down Expand Up @@ -38,7 +38,6 @@ import { workflowHelpers } from '@/mixins/workflowHelpers'; // for json field co
import { ASK_AI_MODAL_KEY, CODE_NODE_TYPE } from '@/constants';
import { codeNodeEditorEventBus } from '@/event-bus';
import { useRootStore } from '@/stores/n8nRoot.store';
import { useSettingsStore } from '@/stores/settings.store';
import { readOnlyEditorExtensions, writableEditorExtensions } from './baseExtensions';
import { CODE_PLACEHOLDERS } from './constants';
Expand All @@ -50,6 +49,10 @@ export default defineComponent({
name: 'code-node-editor',
mixins: [linterExtension, completerExtension, workflowHelpers],
props: {
aiButtonEnabled: {
type: Boolean,
default: false,
},
mode: {
type: String as PropType<CodeExecutionMode>,
validator: (value: CodeExecutionMode): boolean => CODE_EXECUTION_MODES.includes(value),
Expand Down Expand Up @@ -97,9 +100,6 @@ export default defineComponent({
},
computed: {
...mapStores(useRootStore),
isCloud() {
return useSettingsStore().deploymentType === 'cloud';
},
content(): string {
if (!this.editor) return '';
Expand Down
10 changes: 9 additions & 1 deletion packages/editor-ui/src/components/ParameterInput.vue
Expand Up @@ -91,6 +91,7 @@
:defaultValue="parameter.default"
:language="editorLanguage"
:isReadOnly="isReadOnly"
:aiButtonEnabled="settingsStore.isCloudDeployment"
@valueChanged="valueChangedDebounced"
/>

Expand Down Expand Up @@ -387,6 +388,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store';
import { useNDVStore } from '@/stores/ndv.store';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useCredentialsStore } from '@/stores/credentials.store';
import { useSettingsStore } from '@/stores/settings.store';
import { htmlEditorEventBus } from '@/event-bus';
import Vue from 'vue';
Expand Down Expand Up @@ -519,7 +521,13 @@ export default defineComponent({
},
},
computed: {
...mapStores(useCredentialsStore, useNodeTypesStore, useNDVStore, useWorkflowsStore),
...mapStores(
useCredentialsStore,
useNodeTypesStore,
useNDVStore,
useWorkflowsStore,
useSettingsStore,
),
expressionDisplayValue(): string {
if (this.forceShowExpression) {
return '';
Expand Down

0 comments on commit da856d1

Please sign in to comment.