fix(editor): Hide pin data in production executions (#4595)

*  Passing an execution mode to the preview iframe so UI can be adjusted based on it
*  Handling production execution mode to hide the pin data in node details view
This commit is contained in:
Milorad FIlipović
2022-11-14 13:28:26 +01:00
committed by GitHub
parent 96b5e4a329
commit edebad1a89
8 changed files with 50 additions and 6 deletions

View File

@@ -55,7 +55,7 @@
<n8n-icon-button :title="$locale.baseText('executionDetails.deleteExecution')" icon="trash" size="large" type="tertiary" @click="onDeleteExecution" /> <n8n-icon-button :title="$locale.baseText('executionDetails.deleteExecution')" icon="trash" size="large" type="tertiary" @click="onDeleteExecution" />
</div> </div>
</div> </div>
<workflow-preview mode="execution" loaderType="spinner" :executionId="executionId"/> <workflow-preview mode="execution" loaderType="spinner" :executionId="executionId" :executionMode="executionMode"/>
</div> </div>
</template> </template>
@@ -90,6 +90,9 @@ export default mixins(restApi, showMessage, executionHelpers).extend({
sidebarCollapsed(): boolean { sidebarCollapsed(): boolean {
return this.uiStore.sidebarMenuCollapsed; return this.uiStore.sidebarMenuCollapsed;
}, },
executionMode(): string {
return this.activeExecution?.mode || '';
},
}, },
methods: { methods: {
async onDeleteExecution(): Promise<void> { async onDeleteExecution(): Promise<void> {

View File

@@ -13,6 +13,7 @@
:mappingEnabled="!readOnly" :mappingEnabled="!readOnly"
:showMappingHint="draggableHintShown" :showMappingHint="draggableHintShown"
:distanceFromActive="currentNodeDepth" :distanceFromActive="currentNodeDepth"
:isProductionExecutionPreview="isProductionExecutionPreview"
paneType="input" paneType="input"
@itemHover="$emit('itemHover', $event)" @itemHover="$emit('itemHover', $event)"
@linkRun="onLinkRun" @linkRun="onLinkRun"
@@ -107,6 +108,10 @@ export default mixins(
readOnly: { readOnly: {
type: Boolean, type: Boolean,
}, },
isProductionExecutionPreview: {
type: Boolean,
default: false,
},
}, },
data() { data() {
return { return {

View File

@@ -16,7 +16,7 @@
<font-awesome-icon icon="clock" /> <font-awesome-icon icon="clock" />
</n8n-tooltip> </n8n-tooltip>
</div> </div>
<span v-else-if="hasPinData" class="node-pin-data-icon"> <span v-else-if="showPinnedDataInfo" class="node-pin-data-icon">
<font-awesome-icon icon="thumbtack" /> <font-awesome-icon icon="thumbtack" />
<span v-if="workflowDataItems > 1" class="items-count"> {{ workflowDataItems }}</span> <span v-if="workflowDataItems > 1" class="items-count"> {{ workflowDataItems }}</span>
</span> </span>
@@ -132,6 +132,12 @@ export default mixins(
TitledList, TitledList,
NodeIcon, NodeIcon,
}, },
props: {
isProductionExecutionPreview: {
type: Boolean,
default: false,
},
},
computed: { computed: {
...mapStores( ...mapStores(
useNodeTypesStore, useNodeTypesStore,
@@ -139,6 +145,9 @@ export default mixins(
useUIStore, useUIStore,
useWorkflowsStore, useWorkflowsStore,
), ),
showPinnedDataInfo(): boolean {
return this.hasPinData && !this.isProductionExecutionPreview;
},
isDuplicatable(): boolean { isDuplicatable(): boolean {
if(!this.nodeType) return true; if(!this.nodeType) return true;
return this.nodeType.maxNodes === undefined || this.sameTypeNodes.length < this.nodeType.maxNodes; return this.nodeType.maxNodes === undefined || this.sameTypeNodes.length < this.nodeType.maxNodes;
@@ -307,7 +316,7 @@ export default mixins(
else if (!this.isExecuting) { else if (!this.isExecuting) {
if (this.hasIssues) { if (this.hasIssues) {
borderColor = getStyleTokenValue('--color-danger'); borderColor = getStyleTokenValue('--color-danger');
} else if (this.waiting || this.hasPinData) { } else if (this.waiting || this.showPinnedDataInfo) {
borderColor = getStyleTokenValue('--color-secondary'); borderColor = getStyleTokenValue('--color-secondary');
} else if (this.workflowDataItems) { } else if (this.workflowDataItems) {
borderColor = getStyleTokenValue('--color-success'); borderColor = getStyleTokenValue('--color-success');

View File

@@ -55,6 +55,7 @@
:currentNodeName="inputNodeName" :currentNodeName="inputNodeName"
:sessionId="sessionId" :sessionId="sessionId"
:readOnly="readOnly || hasForeignCredential" :readOnly="readOnly || hasForeignCredential"
:isProductionExecutionPreview="isProductionExecutionPreview"
@linkRun="onLinkRunToInput" @linkRun="onLinkRunToInput"
@unlinkRun="() => onUnlinkRun('input')" @unlinkRun="() => onUnlinkRun('input')"
@runChange="onRunInputIndexChange" @runChange="onRunInputIndexChange"
@@ -73,6 +74,7 @@
:sessionId="sessionId" :sessionId="sessionId"
:isReadOnly="readOnly || hasForeignCredential" :isReadOnly="readOnly || hasForeignCredential"
:blockUI="blockUi && isTriggerNode" :blockUI="blockUi && isTriggerNode"
:isProductionExecutionPreview="isProductionExecutionPreview"
@linkRun="onLinkRunToOutput" @linkRun="onLinkRunToOutput"
@unlinkRun="() => onUnlinkRun('output')" @unlinkRun="() => onUnlinkRun('output')"
@runChange="onRunOutputIndexChange" @runChange="onRunOutputIndexChange"
@@ -168,6 +170,10 @@ export default mixins(
renaming: { renaming: {
type: Boolean, type: Boolean,
}, },
isProductionExecutionPreview: {
type: Boolean,
default: false,
},
}, },
data() { data() {
return { return {

View File

@@ -11,6 +11,7 @@
:sessionId="sessionId" :sessionId="sessionId"
:isReadOnly="isReadOnly" :isReadOnly="isReadOnly"
:blockUI="blockUI" :blockUI="blockUI"
:isProductionExecutionPreview="isProductionExecutionPreview"
paneType="output" paneType="output"
@runChange="onRunIndexChange" @runChange="onRunIndexChange"
@linkRun="onLinkRun" @linkRun="onLinkRun"
@@ -119,6 +120,10 @@ export default mixins(
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isProductionExecutionPreview: {
type: Boolean,
default: false,
},
}, },
computed: { computed: {
...mapStores( ...mapStores(

View File

@@ -1,7 +1,7 @@
<template> <template>
<div :class="$style.container"> <div :class="$style.container">
<n8n-callout <n8n-callout
v-if="canPinData && hasPinData && !editMode.enabled" v-if="canPinData && hasPinData && !editMode.enabled && !isProductionExecutionPreview"
theme="secondary" theme="secondary"
icon="thumbtack" icon="thumbtack"
:class="$style['pinned-data-callout']" :class="$style['pinned-data-callout']"
@@ -448,6 +448,10 @@ export default mixins(
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isProductionExecutionPreview: {
type: Boolean,
default: false,
},
}, },
data () { data () {
return { return {
@@ -630,7 +634,7 @@ export default mixins(
inputData (): INodeExecutionData[] { inputData (): INodeExecutionData[] {
let inputData = this.rawInputData; let inputData = this.rawInputData;
if (this.node && this.pinData) { if (this.node && this.pinData && !this.isProductionExecutionPreview) {
inputData = Array.isArray(this.pinData) inputData = Array.isArray(this.pinData)
? this.pinData.map((value) => ({ ? this.pinData.map((value) => ({
json: value, json: value,

View File

@@ -39,7 +39,7 @@ export default mixins(showMessage).extend({
type: String, type: String,
default: 'workflow', default: 'workflow',
validator: (value: string): boolean => validator: (value: string): boolean =>
['workflow', 'execution', 'medium'].includes(value), ['workflow', 'execution'].includes(value),
}, },
workflow: { workflow: {
type: Object as () => IWorkflowDb, type: Object as () => IWorkflowDb,
@@ -49,6 +49,10 @@ export default mixins(showMessage).extend({
type: String, type: String,
required: false, required: false,
}, },
executionMode: {
type: String,
required: false,
},
loaderType: { loaderType: {
type: String, type: String,
default: 'image', default: 'image',
@@ -125,6 +129,7 @@ export default mixins(showMessage).extend({
JSON.stringify({ JSON.stringify({
command: 'openExecution', command: 'openExecution',
executionId: this.executionId, executionId: this.executionId,
executionMode: this.executionMode || '',
}), }),
'*', '*',
); );

View File

@@ -49,6 +49,7 @@
:instance="instance" :instance="instance"
:isActive="!!activeNode && activeNode.name === nodeData.name" :isActive="!!activeNode && activeNode.name === nodeData.name"
:hideActions="pullConnActive" :hideActions="pullConnActive"
:isProductionExecutionPreview="isProductionExecutionPreview"
> >
<span <span
slot="custom-tooltip" slot="custom-tooltip"
@@ -76,6 +77,7 @@
<node-details-view <node-details-view
:readOnly="isReadOnly" :readOnly="isReadOnly"
:renaming="renamingActive" :renaming="renamingActive"
:isProductionExecutionPreview="isProductionExecutionPreview"
@valueChanged="valueChanged" @valueChanged="valueChanged"
@stopExecution="stopExecution" @stopExecution="stopExecution"
/> />
@@ -530,6 +532,7 @@ export default mixins(
isExecutionPreview: false, isExecutionPreview: false,
showTriggerMissingTooltip: false, showTriggerMissingTooltip: false,
workflowData: null as INewWorkflowData | null, workflowData: null as INewWorkflowData | null,
isProductionExecutionPreview: false,
}; };
}, },
beforeDestroy() { beforeDestroy() {
@@ -3135,6 +3138,10 @@ export default mixins(
} }
} else if (json && json.command === 'openExecution') { } else if (json && json.command === 'openExecution') {
try { try {
// If this NodeView is used in preview mode (in iframe) it will not have access to the main app store
// so everything it needs has to be sent using post messages and passed down to child components
this.isProductionExecutionPreview = json.executionMode !== 'manual';
await this.openExecution(json.executionId); await this.openExecution(json.executionId);
this.isExecutionPreview = true; this.isExecutionPreview = true;
} catch (e) { } catch (e) {