Skip to content

Commit

Permalink
fix: Stop showing mapping hint after mapping (#5586)
Browse files Browse the repository at this point in the history
* fix: Stop showing mapping hint after mapping

* fix: set value correctly

* chore: clean up mapping hint code
  • Loading branch information
mutdmour committed Mar 1, 2023
1 parent aa2beaa commit eac4275
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 46 deletions.
1 change: 1 addition & 0 deletions packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ export interface NDVState {
canDrop: boolean;
stickyPosition: null | XYPosition;
};
isMappingOnboarded: boolean;
}

export interface UIState {
Expand Down
5 changes: 1 addition & 4 deletions packages/editor-ui/src/components/InputPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
:sessionId="sessionId"
:overrideOutputs="connectedCurrentNodeOutputs"
:mappingEnabled="!readOnly"
:showMappingHint="draggableHintShown"
:distanceFromActive="currentNodeDepth"
:isProductionExecutionPreview="isProductionExecutionPreview"
paneType="input"
Expand Down Expand Up @@ -142,9 +141,7 @@ import WireMeUp from './WireMeUp.vue';
import {
CRON_NODE_TYPE,
INTERVAL_NODE_TYPE,
LOCAL_STORAGE_MAPPING_FLAG,
MANUAL_TRIGGER_NODE_TYPE,
SCHEDULE_TRIGGER_NODE_TYPE,
START_NODE_TYPE,
} from '@/constants';
import { mapStores } from 'pinia';
Expand Down Expand Up @@ -192,7 +189,7 @@ export default mixins(workflowHelpers).extend({
return this.ndvStore.focusedMappableInput;
},
isUserOnboarded(): boolean {
return window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) === 'true';
return this.ndvStore.isMappingOnboarded;
},
showDraggableHint(): boolean {
const toIgnore = [
Expand Down
10 changes: 4 additions & 6 deletions packages/editor-ui/src/components/ParameterInputFull.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ import ParameterOptions from '@/components/ParameterOptions.vue';
import DraggableTarget from '@/components/DraggableTarget.vue';
import mixins from 'vue-typed-mixins';
import { showMessage } from '@/mixins/showMessage';
import { LOCAL_STORAGE_MAPPING_FLAG } from '@/constants';
import {
hasExpressionMapping,
isResourceLocatorValue,
Expand Down Expand Up @@ -106,7 +105,6 @@ export default mixins(showMessage, externalHooks).extend({
forceShowExpression: false,
dataMappingTooltipButtons: [] as IN8nButton[],
mappingTooltipEnabled: false,
localStorageMappingFlag: window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) === 'true',
};
},
props: {
Expand Down Expand Up @@ -187,10 +185,10 @@ export default mixins(showMessage, externalHooks).extend({
showMappingTooltip(): boolean {
return (
this.mappingTooltipEnabled &&
!this.ndvStore.isMappingOnboarded &&
this.focused &&
this.isInputTypeString &&
!this.isInputDataEmpty &&
!this.localStorageMappingFlag
!this.isInputDataEmpty
);
},
},
Expand Down Expand Up @@ -306,14 +304,14 @@ export default mixins(showMessage, externalHooks).extend({
this.$emit('valueChanged', parameterData);
if (window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) !== 'true') {
if (!this.ndvStore.isMappingOnboarded) {
this.$showMessage({
title: this.$locale.baseText('dataMapping.success.title'),
message: this.$locale.baseText('dataMapping.success.moreInfo'),
type: 'success',
});
window.localStorage.setItem(LOCAL_STORAGE_MAPPING_FLAG, 'true');
this.ndvStore.disableMappingHint();
}
this.ndvStore.setMappingTelemetry({
Expand Down
5 changes: 0 additions & 5 deletions packages/editor-ui/src/components/RunData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@
:inputData="inputData"
:mappingEnabled="mappingEnabled"
:distanceFromActive="distanceFromActive"
:showMappingHint="showMappingHint"
:runIndex="runIndex"
:pageOffset="currentPageOffset"
:totalRuns="maxRunIndex"
Expand All @@ -315,7 +314,6 @@
:inputData="inputData"
:mappingEnabled="mappingEnabled"
:distanceFromActive="distanceFromActive"
:showMappingHint="showMappingHint"
:runIndex="runIndex"
:totalRuns="maxRunIndex"
/>
Expand Down Expand Up @@ -565,9 +563,6 @@ export default mixins(externalHooks, genericHelpers, nodeHelpers, pinData).exten
distanceFromActive: {
type: Number,
},
showMappingHint: {
type: Boolean,
},
blockUI: {
type: Boolean,
default: false,
Expand Down
29 changes: 0 additions & 29 deletions packages/editor-ui/src/components/RunDataJson.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import { PropType } from 'vue';
import mixins from 'vue-typed-mixins';
import VueJsonPretty from 'vue-json-pretty';
import { LOCAL_STORAGE_MAPPING_FLAG } from '@/constants';
import { IDataObject, INodeExecutionData } from 'n8n-workflow';
import Draggable from '@/components/Draggable.vue';
import { executionDataToJson, isString, shorten } from '@/utils';
Expand Down Expand Up @@ -114,9 +113,6 @@ export default mixins(externalHooks).extend({
distanceFromActive: {
type: Number,
},
showMappingHint: {
type: Boolean,
},
runIndex: {
type: Number,
},
Expand All @@ -127,40 +123,15 @@ export default mixins(externalHooks).extend({
data() {
return {
selectedJsonPath: null as null | string,
mappingHintVisible: false,
showHintWithDelay: false,
draggingPath: null as null | string,
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: {
...mapStores(useNDVStore, useWorkflowsStore),
jsonData(): IDataObject[] {
return executionDataToJson(this.inputData);
},
showHint(): boolean {
return (
!this.draggingPath &&
((this.showMappingHint && this.mappingHintVisible) ||
window.localStorage.getItem(LOCAL_STORAGE_MAPPING_FLAG) !== 'true')
);
},
},
methods: {
getShortKey(el: HTMLElement): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export const VALID_EMAIL_REGEX =
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_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_THEME = 'N8N_THEME';
export const BASE_NODE_SURVEY_URL = 'https://n8n-community.typeform.com/to/BvmzxqYv#nodename=';
Expand Down
7 changes: 6 additions & 1 deletion packages/editor-ui/src/stores/ndv.ts
Original file line number Diff line number Diff line change
@@ -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 { IRunData } from 'n8n-workflow';
import { defineStore } from 'pinia';
Expand Down Expand Up @@ -40,6 +40,7 @@ export const useNDVStore = defineStore(STORES.NDV, {
canDrop: false,
stickyPosition: null,
},
isMappingOnboarded: window.localStorage.getItem(LOCAL_STORAGE_MAPPING_IS_ONBOARDED) === 'true',
}),
getters: {
activeNode(): INodeUi | null {
Expand Down Expand Up @@ -184,5 +185,9 @@ export const useNDVStore = defineStore(STORES.NDV, {
setNDVPanelDataIsEmpty(payload: { panel: 'input' | 'output'; isEmpty: boolean }): void {
Vue.set(this[payload.panel].data, 'isEmpty', payload.isEmpty);
},
disableMappingHint() {
this.isMappingOnboarded = true;
window.localStorage.setItem(LOCAL_STORAGE_MAPPING_IS_ONBOARDED, 'true');
},
},
});

0 comments on commit eac4275

Please sign in to comment.