fix: Stop showing mapping hint after mapping (#5586)

* fix: Stop showing mapping hint after mapping

* fix: set value correctly

* chore: clean up mapping hint code
This commit is contained in:
Mutasem Aldmour 2023-03-01 14:02:34 +03:00 committed by GitHub
parent aa2beaa800
commit eac4275a7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 46 deletions

View file

@ -1119,6 +1119,7 @@ export interface NDVState {
canDrop: boolean; canDrop: boolean;
stickyPosition: null | XYPosition; stickyPosition: null | XYPosition;
}; };
isMappingOnboarded: boolean;
} }
export interface UIState { export interface UIState {

View file

@ -11,7 +11,6 @@
:sessionId="sessionId" :sessionId="sessionId"
:overrideOutputs="connectedCurrentNodeOutputs" :overrideOutputs="connectedCurrentNodeOutputs"
:mappingEnabled="!readOnly" :mappingEnabled="!readOnly"
:showMappingHint="draggableHintShown"
:distanceFromActive="currentNodeDepth" :distanceFromActive="currentNodeDepth"
:isProductionExecutionPreview="isProductionExecutionPreview" :isProductionExecutionPreview="isProductionExecutionPreview"
paneType="input" paneType="input"
@ -142,9 +141,7 @@ import WireMeUp from './WireMeUp.vue';
import { import {
CRON_NODE_TYPE, CRON_NODE_TYPE,
INTERVAL_NODE_TYPE, INTERVAL_NODE_TYPE,
LOCAL_STORAGE_MAPPING_FLAG,
MANUAL_TRIGGER_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE,
SCHEDULE_TRIGGER_NODE_TYPE,
START_NODE_TYPE, START_NODE_TYPE,
} from '@/constants'; } from '@/constants';
import { mapStores } from 'pinia'; import { mapStores } from 'pinia';
@ -192,7 +189,7 @@ export default mixins(workflowHelpers).extend({
return this.ndvStore.focusedMappableInput; return this.ndvStore.focusedMappableInput;
}, },
isUserOnboarded(): boolean { isUserOnboarded(): boolean {
return window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) === 'true'; return this.ndvStore.isMappingOnboarded;
}, },
showDraggableHint(): boolean { showDraggableHint(): boolean {
const toIgnore = [ const toIgnore = [

View file

@ -77,7 +77,6 @@ import ParameterOptions from '@/components/ParameterOptions.vue';
import DraggableTarget from '@/components/DraggableTarget.vue'; import DraggableTarget from '@/components/DraggableTarget.vue';
import mixins from 'vue-typed-mixins'; import mixins from 'vue-typed-mixins';
import { showMessage } from '@/mixins/showMessage'; import { showMessage } from '@/mixins/showMessage';
import { LOCAL_STORAGE_MAPPING_FLAG } from '@/constants';
import { import {
hasExpressionMapping, hasExpressionMapping,
isResourceLocatorValue, isResourceLocatorValue,
@ -106,7 +105,6 @@ export default mixins(showMessage, externalHooks).extend({
forceShowExpression: false, forceShowExpression: false,
dataMappingTooltipButtons: [] as IN8nButton[], dataMappingTooltipButtons: [] as IN8nButton[],
mappingTooltipEnabled: false, mappingTooltipEnabled: false,
localStorageMappingFlag: window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) === 'true',
}; };
}, },
props: { props: {
@ -187,10 +185,10 @@ export default mixins(showMessage, externalHooks).extend({
showMappingTooltip(): boolean { showMappingTooltip(): boolean {
return ( return (
this.mappingTooltipEnabled && this.mappingTooltipEnabled &&
!this.ndvStore.isMappingOnboarded &&
this.focused && this.focused &&
this.isInputTypeString && this.isInputTypeString &&
!this.isInputDataEmpty && !this.isInputDataEmpty
!this.localStorageMappingFlag
); );
}, },
}, },
@ -306,14 +304,14 @@ export default mixins(showMessage, externalHooks).extend({
this.$emit('valueChanged', parameterData); this.$emit('valueChanged', parameterData);
if (window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) !== 'true') { if (!this.ndvStore.isMappingOnboarded) {
this.$showMessage({ this.$showMessage({
title: this.$locale.baseText('dataMapping.success.title'), title: this.$locale.baseText('dataMapping.success.title'),
message: this.$locale.baseText('dataMapping.success.moreInfo'), message: this.$locale.baseText('dataMapping.success.moreInfo'),
type: 'success', type: 'success',
}); });
window.localStorage.setItem(LOCAL_STORAGE_MAPPING_FLAG, 'true'); this.ndvStore.disableMappingHint();
} }
this.ndvStore.setMappingTelemetry({ this.ndvStore.setMappingTelemetry({

View file

@ -295,7 +295,6 @@
:inputData="inputData" :inputData="inputData"
:mappingEnabled="mappingEnabled" :mappingEnabled="mappingEnabled"
:distanceFromActive="distanceFromActive" :distanceFromActive="distanceFromActive"
:showMappingHint="showMappingHint"
:runIndex="runIndex" :runIndex="runIndex"
:pageOffset="currentPageOffset" :pageOffset="currentPageOffset"
:totalRuns="maxRunIndex" :totalRuns="maxRunIndex"
@ -315,7 +314,6 @@
:inputData="inputData" :inputData="inputData"
:mappingEnabled="mappingEnabled" :mappingEnabled="mappingEnabled"
:distanceFromActive="distanceFromActive" :distanceFromActive="distanceFromActive"
:showMappingHint="showMappingHint"
:runIndex="runIndex" :runIndex="runIndex"
:totalRuns="maxRunIndex" :totalRuns="maxRunIndex"
/> />
@ -565,9 +563,6 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
distanceFromActive: { distanceFromActive: {
type: Number, type: Number,
}, },
showMappingHint: {
type: Boolean,
},
blockUI: { blockUI: {
type: Boolean, type: Boolean,
default: false, default: false,

View file

@ -70,7 +70,6 @@
import { PropType } from 'vue'; import { PropType } from 'vue';
import mixins from 'vue-typed-mixins'; import mixins from 'vue-typed-mixins';
import VueJsonPretty from 'vue-json-pretty'; import VueJsonPretty from 'vue-json-pretty';
import { LOCAL_STORAGE_MAPPING_FLAG } from '@/constants';
import { IDataObject, INodeExecutionData } from 'n8n-workflow'; import { IDataObject, INodeExecutionData } from 'n8n-workflow';
import Draggable from '@/components/Draggable.vue'; import Draggable from '@/components/Draggable.vue';
import { executionDataToJson, isString, shorten } from '@/utils'; import { executionDataToJson, isString, shorten } from '@/utils';
@ -114,9 +113,6 @@ export default mixins(externalHooks).extend({
distanceFromActive: { distanceFromActive: {
type: Number, type: Number,
}, },
showMappingHint: {
type: Boolean,
},
runIndex: { runIndex: {
type: Number, type: Number,
}, },
@ -127,40 +123,15 @@ export default mixins(externalHooks).extend({
data() { data() {
return { return {
selectedJsonPath: null as null | string, selectedJsonPath: null as null | string,
mappingHintVisible: false,
showHintWithDelay: false,
draggingPath: null as null | string, draggingPath: null as null | string,
displayMode: 'json', displayMode: 'json',
}; };
}, },
mounted() {
if (this.showMappingHint) {
this.mappingHintVisible = true;
setTimeout(() => {
this.mappingHintVisible = false;
}, 6000);
}
if (this.showMappingHint && this.showHint) {
setTimeout(() => {
this.showHintWithDelay = this.showHint;
this.$telemetry.track('User viewed JSON mapping tooltip', { type: 'param focus' });
}, 500);
}
},
computed: { computed: {
...mapStores(useNDVStore, useWorkflowsStore), ...mapStores(useNDVStore, useWorkflowsStore),
jsonData(): IDataObject[] { jsonData(): IDataObject[] {
return executionDataToJson(this.inputData); return executionDataToJson(this.inputData);
}, },
showHint(): boolean {
return (
!this.draggingPath &&
((this.showMappingHint && this.mappingHintVisible) ||
window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) !== 'true')
);
},
}, },
methods: { methods: {
getShortKey(el: HTMLElement): string { getShortKey(el: HTMLElement): string {

View file

@ -306,7 +306,7 @@ export const VALID_EMAIL_REGEX =
export const LOCAL_STORAGE_ACTIVATION_FLAG = 'N8N_HIDE_ACTIVATION_ALERT'; export const LOCAL_STORAGE_ACTIVATION_FLAG = 'N8N_HIDE_ACTIVATION_ALERT';
export const LOCAL_STORAGE_PIN_DATA_DISCOVERY_NDV_FLAG = 'N8N_PIN_DATA_DISCOVERY_NDV'; export const LOCAL_STORAGE_PIN_DATA_DISCOVERY_NDV_FLAG = 'N8N_PIN_DATA_DISCOVERY_NDV';
export const LOCAL_STORAGE_PIN_DATA_DISCOVERY_CANVAS_FLAG = 'N8N_PIN_DATA_DISCOVERY_CANVAS'; export const LOCAL_STORAGE_PIN_DATA_DISCOVERY_CANVAS_FLAG = 'N8N_PIN_DATA_DISCOVERY_CANVAS';
export const LOCAL_STORAGE_MAPPING_FLAG = 'N8N_MAPPING_ONBOARDED'; export const LOCAL_STORAGE_MAPPING_IS_ONBOARDED = 'N8N_MAPPING_ONBOARDED';
export const LOCAL_STORAGE_MAIN_PANEL_RELATIVE_WIDTH = 'N8N_MAIN_PANEL_RELATIVE_WIDTH'; export const LOCAL_STORAGE_MAIN_PANEL_RELATIVE_WIDTH = 'N8N_MAIN_PANEL_RELATIVE_WIDTH';
export const LOCAL_STORAGE_THEME = 'N8N_THEME'; export const LOCAL_STORAGE_THEME = 'N8N_THEME';
export const BASE_NODE_SURVEY_URL = 'https://n8n-community.typeform.com/to/BvmzxqYv#nodename='; export const BASE_NODE_SURVEY_URL = 'https://n8n-community.typeform.com/to/BvmzxqYv#nodename=';

View file

@ -1,4 +1,4 @@
import { STORES } from '@/constants'; import { LOCAL_STORAGE_MAPPING_IS_ONBOARDED, STORES } from '@/constants';
import { INodeUi, IRunDataDisplayMode, NDVState, NodePanelType, XYPosition } from '@/Interface'; import { INodeUi, IRunDataDisplayMode, NDVState, NodePanelType, XYPosition } from '@/Interface';
import { IRunData } from 'n8n-workflow'; import { IRunData } from 'n8n-workflow';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
@ -40,6 +40,7 @@ export const useNDVStore = defineStore(STORES.NDV, {
canDrop: false, canDrop: false,
stickyPosition: null, stickyPosition: null,
}, },
isMappingOnboarded: window.localStorage.getItem(LOCAL_STORAGE_MAPPING_IS_ONBOARDED) === 'true',
}), }),
getters: { getters: {
activeNode(): INodeUi | null { activeNode(): INodeUi | null {
@ -184,5 +185,9 @@ export const useNDVStore = defineStore(STORES.NDV, {
setNDVPanelDataIsEmpty(payload: { panel: 'input' | 'output'; isEmpty: boolean }): void { setNDVPanelDataIsEmpty(payload: { panel: 'input' | 'output'; isEmpty: boolean }): void {
Vue.set(this[payload.panel].data, 'isEmpty', payload.isEmpty); Vue.set(this[payload.panel].data, 'isEmpty', payload.isEmpty);
}, },
disableMappingHint() {
this.isMappingOnboarded = true;
window.localStorage.setItem(LOCAL_STORAGE_MAPPING_IS_ONBOARDED, 'true');
},
}, },
}); });