From 0d18674027eb46de65d7247715530e11860e5c4c Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Thu, 1 Aug 2024 21:59:27 +0500 Subject: [PATCH 1/9] Fix i18n (#6222) Signed-off-by: Denis Bykhov --- packages/platform/src/i18n.ts | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/platform/src/i18n.ts b/packages/platform/src/i18n.ts index b59fb3c78a..e70869bde5 100644 --- a/packages/platform/src/i18n.ts +++ b/packages/platform/src/i18n.ts @@ -31,8 +31,8 @@ export type Loader = (locale: string) => Promise> const loaders = new Map() -const translations = new Map() -const cache = new Map() +const translations = new Map>() +const cache = new Map>() const englishTranslationsForMissing = new Map() /** * @public @@ -52,10 +52,14 @@ export async function loadPluginStrings (locale: string, force: boolean = false) cache.clear() } for (const [plugin] of loaders) { - let messages = translations.get(plugin) + const localtTanslations = translations.get(locale) ?? new Map>() + if (!translations.has(locale)) { + translations.set(locale, localtTanslations) + } + let messages = localtTanslations.get(plugin) if (messages === undefined || force) { messages = await loadTranslationsForComponent(plugin, locale) - translations.set(plugin, messages) + localtTanslations.set(plugin, messages) } } } @@ -83,10 +87,14 @@ async function loadTranslationsForComponent (plugin: Plugin, locale: string): Pr async function getTranslation (id: _IdInfo, locale: string): Promise { try { - let messages = translations.get(id.component) + const localtTanslations = translations.get(locale) ?? new Map>() + if (!translations.has(locale)) { + translations.set(locale, localtTanslations) + } + let messages = localtTanslations.get(id.component) if (messages === undefined) { messages = await loadTranslationsForComponent(id.component, locale) - translations.set(id.component, messages) + localtTanslations.set(id.component, messages) } if (messages instanceof Status) { return messages @@ -127,7 +135,11 @@ export async function translate

> ( language?: string ): Promise { const locale = language ?? getMetadata(platform.metadata.locale) ?? 'en' - const compiled = cache.get(message) + const localCache = cache.get(locale) ?? new Map() + if (!cache.has(locale)) { + cache.set(locale, localCache) + } + const compiled = localCache.get(message) if (compiled !== undefined) { if (compiled instanceof Status) { @@ -142,16 +154,16 @@ export async function translate

> ( } const translation = (await getTranslation(id, locale)) ?? message if (translation instanceof Status) { - cache.set(message, translation) + localCache.set(message, translation) return message } const compiled = new IntlMessageFormat(translation, locale, undefined, { ignoreTag: true }) - cache.set(message, compiled) + localCache.set(message, compiled) return compiled.format(params) } catch (err) { const status = unknownError(err) await setPlatformStatus(status) - cache.set(message, status) + localCache.set(message, status) return message } } From 486ef0dc03995c7ee5a3baa8ed7184895339b57d Mon Sep 17 00:00:00 2001 From: Alexander Platov Date: Thu, 1 Aug 2024 20:18:08 +0300 Subject: [PATCH 2/9] Updated planning UI tests (#6211) Signed-off-by: Alexander Platov Co-authored-by: Alexey Zinoviev --- .../profiles/ui/config/rush-project.json | 1 - .../src/components/DocPopup.svelte | 1 + .../src/components/TagsPopup.svelte | 5 +- .../src/components/Header.svelte | 3 + .../components/filter/FilterSection.svelte | 1 + tests/sanity/tests/model/common-page.ts | 147 +++++++++++++++++- .../sanity/tests/model/left-side-menu-page.ts | 10 ++ .../planning/planning-navigation-menu-page.ts | 14 +- .../tests/model/planning/planning-page.ts | 3 + .../model/recruiting/talent-details-page.ts | 1 + tests/sanity/tests/model/team-page.ts | 26 ++++ .../model/tracker/common-tracker-page.ts | 106 +------------ .../sanity/tests/model/tracker/issues-page.ts | 5 +- tests/sanity/tests/model/tracker/types.ts | 6 - tests/sanity/tests/model/types.ts | 5 + tests/sanity/tests/planning/plan.spec.ts | 74 ++++++++- tests/sanity/tests/planning/todos.spec.ts | 8 +- tests/sanity/tests/recruiting/talents.spec.ts | 17 ++ tests/sanity/tests/tracker/filter.spec.ts | 3 +- 19 files changed, 304 insertions(+), 132 deletions(-) create mode 100644 tests/sanity/tests/model/team-page.ts create mode 100644 tests/sanity/tests/model/types.ts diff --git a/packages/platform-rig/profiles/ui/config/rush-project.json b/packages/platform-rig/profiles/ui/config/rush-project.json index 4b6cf6cfde..b1a8f0c8c5 100644 --- a/packages/platform-rig/profiles/ui/config/rush-project.json +++ b/packages/platform-rig/profiles/ui/config/rush-project.json @@ -3,7 +3,6 @@ "temp/**", ".build/**", "coverage/**", - "**/*.svelte", ".build/**", ".validate/**", ".format/**", diff --git a/packages/presentation/src/components/DocPopup.svelte b/packages/presentation/src/components/DocPopup.svelte index 1e79379189..e5799c6bef 100644 --- a/packages/presentation/src/components/DocPopup.svelte +++ b/packages/presentation/src/components/DocPopup.svelte @@ -190,6 +190,7 @@ {size} icon={IconAdd} showTooltip={{ label: create.label }} + dataId={'btnAdd'} on:click={onCreate} disabled={readonly || loading} /> diff --git a/plugins/tags-resources/src/components/TagsPopup.svelte b/plugins/tags-resources/src/components/TagsPopup.svelte index 0dbcef9d13..e9ab6a7ea7 100644 --- a/plugins/tags-resources/src/components/TagsPopup.svelte +++ b/plugins/tags-resources/src/components/TagsPopup.svelte @@ -146,12 +146,15 @@ kind={'ghost'} size={'large'} icon={show ? IconView : IconViewHide} + dataId={`btn${show ? 'Collapse' : 'Expand'}`} on:click={() => { show = !show }} /> {/if} - {#if !hideAdd}