From aa03110f2e71885026949d8a7df46f1e14ed8f81 Mon Sep 17 00:00:00 2001 From: Suguru Inoue Date: Tue, 10 Jun 2025 17:25:22 +0200 Subject: [PATCH] fix(editor): Adjust time format for negative numbers (no-changelog) (#16194) --- packages/frontend/@n8n/i18n/src/index.test.ts | 1 + packages/frontend/@n8n/i18n/src/index.ts | 6 ++---- .../frontend/@n8n/rest-api-client/src/api/ldap.ts | 3 ++- .../frontend/@n8n/rest-api-client/src/utils.ts | 2 +- .../global/GlobalExecutionsListItem.test.ts | 2 +- turbo.json | 14 ++++++++++++++ 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/frontend/@n8n/i18n/src/index.test.ts b/packages/frontend/@n8n/i18n/src/index.test.ts index 7503d138d4..82b2eabfd9 100644 --- a/packages/frontend/@n8n/i18n/src/index.test.ts +++ b/packages/frontend/@n8n/i18n/src/index.test.ts @@ -3,6 +3,7 @@ import { I18nClass } from './index'; describe(I18nClass, () => { describe('displayTimer', () => { it('should format duration with hours, minutes and seconds', () => { + expect(new I18nClass().displayTimer(-1)).toBe('-1s'); expect(new I18nClass().displayTimer(0)).toBe('0s'); expect(new I18nClass().displayTimer(12)).toBe('0s'); expect(new I18nClass().displayTimer(123)).toBe('0s'); diff --git a/packages/frontend/@n8n/i18n/src/index.ts b/packages/frontend/@n8n/i18n/src/index.ts index 6d87495612..5c25b1d1d1 100644 --- a/packages/frontend/@n8n/i18n/src/index.ts +++ b/packages/frontend/@n8n/i18n/src/index.ts @@ -107,11 +107,9 @@ export class I18nClass { remainingMs = remainingMs % minute; } - if (!showMs) { - remainingMs -= remainingMs % second; - } + const remainingSec = showMs ? remainingMs / second : Math.floor(remainingMs / second); - parts.push(`${remainingMs / second}${this.baseText('genericHelpers.secShort')}`); + parts.push(`${remainingSec}${this.baseText('genericHelpers.secShort')}`); return parts.join(' '); } diff --git a/packages/frontend/@n8n/rest-api-client/src/api/ldap.ts b/packages/frontend/@n8n/rest-api-client/src/api/ldap.ts index 187c84cdeb..96aff331a5 100644 --- a/packages/frontend/@n8n/rest-api-client/src/api/ldap.ts +++ b/packages/frontend/@n8n/rest-api-client/src/api/ldap.ts @@ -1,6 +1,7 @@ +import type { IDataObject } from 'n8n-workflow'; + import type { IRestApiContext } from '../types'; import { makeRestApiRequest } from '../utils'; -import type { IDataObject } from 'n8n-workflow'; export interface LdapSyncData { id: number; diff --git a/packages/frontend/@n8n/rest-api-client/src/utils.ts b/packages/frontend/@n8n/rest-api-client/src/utils.ts index 9f7668011d..39437dde91 100644 --- a/packages/frontend/@n8n/rest-api-client/src/utils.ts +++ b/packages/frontend/@n8n/rest-api-client/src/utils.ts @@ -284,6 +284,6 @@ export async function streamRequest( } } catch (e: unknown) { assert(e instanceof Error); - onError?.(e as Error); + onError?.(e); } } diff --git a/packages/frontend/editor-ui/src/components/executions/global/GlobalExecutionsListItem.test.ts b/packages/frontend/editor-ui/src/components/executions/global/GlobalExecutionsListItem.test.ts index c718c527b1..e7a97e1873 100644 --- a/packages/frontend/editor-ui/src/components/executions/global/GlobalExecutionsListItem.test.ts +++ b/packages/frontend/editor-ui/src/components/executions/global/GlobalExecutionsListItem.test.ts @@ -199,6 +199,6 @@ describe('GlobalExecutionsListItem', () => { const executionTimeElement = getByTestId('execution-time'); expect(executionTimeElement).toBeVisible(); - expect(executionTimeElement.textContent).toBe('30:00m'); + expect(executionTimeElement.textContent).toBe('30m 0s'); }); }); diff --git a/turbo.json b/turbo.json index 671f9def19..022752cbf3 100644 --- a/turbo.json +++ b/turbo.json @@ -53,6 +53,13 @@ "lint:frontend": { "dependsOn": [ "^build", + "@n8n/rest-api-client#lint", + "@n8n/api-types#lint", + "@n8n/constants#lint", + "@n8n/i18n#lint", + "@n8n/permissions#lint", + "@n8n/stores#lint", + "@n8n/utils#lint", "@n8n/chat#lint", "@n8n/codemirror-lang#lint", "@n8n/storybook#lint", @@ -94,6 +101,13 @@ }, "test:frontend": { "dependsOn": [ + "@n8n/rest-api-client#test", + "@n8n/api-types#test", + "@n8n/constants#test", + "@n8n/i18n#test", + "@n8n/permissions#test", + "@n8n/stores#test", + "@n8n/utils#test", "@n8n/chat#test", "@n8n/codemirror-lang#test", "@n8n/composables#build",