fix(editor): Handle localStorage being blocked/unavailable (#7348)
This commit is contained in:
committed by
GitHub
parent
739a4d4ecf
commit
c05bc6728d
@@ -41,6 +41,7 @@ import { defineComponent } from 'vue';
|
||||
import type { PropType } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { get } from 'lodash-es';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
|
||||
import type { INodeTypeDescription } from 'n8n-workflow';
|
||||
import PanelDragButton from './PanelDragButton.vue';
|
||||
@@ -345,9 +346,10 @@ export default defineComponent({
|
||||
);
|
||||
},
|
||||
restorePositionData() {
|
||||
const storedPanelWidthData = window.localStorage.getItem(
|
||||
const storedPanelWidthData = useStorage(
|
||||
`${LOCAL_STORAGE_MAIN_PANEL_RELATIVE_WIDTH}_${this.currentNodePaneType}`,
|
||||
);
|
||||
undefined,
|
||||
).value;
|
||||
|
||||
if (storedPanelWidthData) {
|
||||
const parsedWidth = parseFloat(storedPanelWidthData);
|
||||
|
||||
@@ -170,6 +170,7 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import {
|
||||
CUSTOM_API_CALL_KEY,
|
||||
LOCAL_STORAGE_PIN_DATA_DISCOVERY_CANVAS_FLAG,
|
||||
@@ -579,9 +580,10 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
created() {
|
||||
const hasSeenPinDataTooltip = localStorage.getItem(
|
||||
const hasSeenPinDataTooltip = useStorage(
|
||||
LOCAL_STORAGE_PIN_DATA_DISCOVERY_CANVAS_FLAG,
|
||||
);
|
||||
undefined,
|
||||
).value;
|
||||
if (!hasSeenPinDataTooltip) {
|
||||
this.unwatchWorkflowDataItems = this.$watch('workflowDataItems', (dataItemsCount: number) => {
|
||||
this.showPinDataDiscoveryTooltip(dataItemsCount);
|
||||
|
||||
@@ -495,6 +495,7 @@
|
||||
import { defineAsyncComponent, defineComponent } from 'vue';
|
||||
import type { PropType } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { saveAs } from 'file-saver';
|
||||
import type {
|
||||
ConnectionTypes,
|
||||
@@ -975,12 +976,12 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
value &&
|
||||
value.length > 0 &&
|
||||
!this.isReadOnlyRoute &&
|
||||
!localStorage.getItem(LOCAL_STORAGE_PIN_DATA_DISCOVERY_NDV_FLAG)
|
||||
) {
|
||||
const pinDataDiscoveryFlag = useStorage(
|
||||
LOCAL_STORAGE_PIN_DATA_DISCOVERY_NDV_FLAG,
|
||||
undefined,
|
||||
).value;
|
||||
|
||||
if (value && value.length > 0 && !this.isReadOnlyRoute && !pinDataDiscoveryFlag) {
|
||||
this.pinDataDiscoveryComplete();
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user