mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(editor): Fix unexpected date rendering on front-end (#5528)
🔥 Remove front-end date rendering logic that changes date timezone to workflow TZ
This commit is contained in:
parent
510855d958
commit
684d717520
|
@ -73,7 +73,7 @@ import VueJsonPretty from 'vue-json-pretty';
|
||||||
import { LOCAL_STORAGE_MAPPING_FLAG } from '@/constants';
|
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 { parseDate, executionDataToJson, isString, shorten } from '@/utils';
|
import { executionDataToJson, isString, shorten } from '@/utils';
|
||||||
import { INodeUi } from '@/Interface';
|
import { INodeUi } from '@/Interface';
|
||||||
import { externalHooks } from '@/mixins/externalHooks';
|
import { externalHooks } from '@/mixins/externalHooks';
|
||||||
import { mapStores } from 'pinia';
|
import { mapStores } from 'pinia';
|
||||||
|
@ -210,11 +210,7 @@ export default mixins(externalHooks).extend({
|
||||||
}, 1000); // ensure dest data gets set if drop
|
}, 1000); // ensure dest data gets set if drop
|
||||||
},
|
},
|
||||||
getContent(value: unknown): string {
|
getContent(value: unknown): string {
|
||||||
if (isString(value)) {
|
return isString(value) ? `"${value}"` : JSON.stringify(value);
|
||||||
const parsedDate = parseDate(value, this.workflowsStore.workflow.settings?.timezone);
|
|
||||||
return parsedDate ? parsedDate.toString() : `"${value}"`;
|
|
||||||
}
|
|
||||||
return JSON.stringify(value);
|
|
||||||
},
|
},
|
||||||
getListItemName(path: string): string {
|
getListItemName(path: string): string {
|
||||||
return path.replace(/^(\["?\d"?]\.?)/g, '');
|
return path.replace(/^(\["?\d"?]\.?)/g, '');
|
||||||
|
|
|
@ -159,7 +159,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
/* eslint-disable prefer-spread */
|
/* eslint-disable prefer-spread */
|
||||||
import { INodeUi, ITableData, NDVState } from '@/Interface';
|
import { INodeUi, ITableData, NDVState } from '@/Interface';
|
||||||
import { getPairedItemId, parseDate } from '@/utils';
|
import { getPairedItemId } from '@/utils';
|
||||||
import Vue, { PropType } from 'vue';
|
import Vue, { PropType } from 'vue';
|
||||||
import mixins from 'vue-typed-mixins';
|
import mixins from 'vue-typed-mixins';
|
||||||
import { GenericValue, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
import { GenericValue, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||||
|
@ -171,7 +171,6 @@ import { useWorkflowsStore } from '@/stores/workflows';
|
||||||
import { useNDVStore } from '@/stores/ndv';
|
import { useNDVStore } from '@/stores/ndv';
|
||||||
import MappingPill from './MappingPill.vue';
|
import MappingPill from './MappingPill.vue';
|
||||||
import { getMappedExpression } from '@/utils/mappingUtils';
|
import { getMappedExpression } from '@/utils/mappingUtils';
|
||||||
import { DateTime } from 'luxon';
|
|
||||||
|
|
||||||
const MAX_COLUMNS_LIMIT = 40;
|
const MAX_COLUMNS_LIMIT = 40;
|
||||||
|
|
||||||
|
@ -366,25 +365,17 @@ export default mixins(externalHooks).extend({
|
||||||
return this.$locale.baseText('runData.emptyString');
|
return this.$locale.baseText('runData.emptyString');
|
||||||
}
|
}
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
const parsedDate = parseDate(value, this.workflowsStore.workflow.settings?.timezone);
|
|
||||||
if (parsedDate) {
|
|
||||||
return parsedDate.toString();
|
|
||||||
}
|
|
||||||
return value.replaceAll('\n', '\\n');
|
return value.replaceAll('\n', '\\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(value) && value.length === 0) {
|
if (Array.isArray(value) && value.length === 0) {
|
||||||
return this.$locale.baseText('runData.emptyArray');
|
return this.$locale.baseText('runData.emptyArray');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === 'object' && value !== null && Object.keys(value).length === 0) {
|
if (typeof value === 'object' && value !== null && Object.keys(value).length === 0) {
|
||||||
return this.$locale.baseText('runData.emptyObject');
|
return this.$locale.baseText('runData.emptyObject');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value === null || value === undefined) {
|
if (value === null || value === undefined) {
|
||||||
return `[${value}]`;
|
return `[${value}]`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
onDragStart() {
|
onDragStart() {
|
||||||
|
|
|
@ -249,17 +249,3 @@ export const getSchema = (input: Optional<Primitives | object>, path = ''): Sche
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert UTC dates that come from back-end to workflow timezone
|
|
||||||
export const parseDate = (input: string, timezone: string | undefined): DateTime | null => {
|
|
||||||
const isUTCDate = /\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/.test(
|
|
||||||
input,
|
|
||||||
);
|
|
||||||
if (isUTCDate) {
|
|
||||||
const date = new Date(Date.parse(input));
|
|
||||||
if (date.toString() !== 'Invalid Date') {
|
|
||||||
return DateTime.fromJSDate(date, { zone: timezone });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in a new issue