From 16be6f94733953c0f9e4d067fb9260dab21ec603 Mon Sep 17 00:00:00 2001 From: Federico Morreale Date: Thu, 5 Oct 2023 17:18:10 +0200 Subject: [PATCH 01/13] fix: add default limit to search query Signed-off-by: Federico Morreale --- .changeset/twelve-snakes-sell.md | 5 +++++ plugins/search-backend/src/service/router.ts | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/twelve-snakes-sell.md diff --git a/.changeset/twelve-snakes-sell.md b/.changeset/twelve-snakes-sell.md new file mode 100644 index 0000000000..7f91b2910f --- /dev/null +++ b/.changeset/twelve-snakes-sell.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search-backend': patch +--- + +Set the default length limit to search query to 100. To override it, define `search.maxTermLength` in the config file. diff --git a/plugins/search-backend/src/service/router.ts b/plugins/search-backend/src/service/router.ts index dca632dfaf..54ac49f724 100644 --- a/plugins/search-backend/src/service/router.ts +++ b/plugins/search-backend/src/service/router.ts @@ -63,6 +63,7 @@ export type RouterOptions = { }; const defaultMaxPageLimit = 100; +const defaultMaxTermLength = 100; const allowedLocationProtocols = ['http:', 'https:']; /** @@ -77,8 +78,11 @@ export async function createRouter( const maxPageLimit = config.getOptionalNumber('search.maxPageLimit') ?? defaultMaxPageLimit; + const maxTermLength = + config.getOptionalNumber('search.maxTermLength') ?? defaultMaxTermLength; + const requestSchema = z.object({ - term: z.string().default(''), + term: z.string().max(maxTermLength).default(''), filters: jsonObjectSchema.optional(), types: z .array(z.string().refine(type => Object.keys(types).includes(type))) From 8be6c23b6c4fe11bb42bf671840ce0ae89731112 Mon Sep 17 00:00:00 2001 From: Federico Morreale Date: Thu, 5 Oct 2023 17:22:19 +0200 Subject: [PATCH 02/13] fix: add maxTermLength to config.d.ts Signed-off-by: Federico Morreale --- plugins/search-backend/config.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/search-backend/config.d.ts b/plugins/search-backend/config.d.ts index 3dbdf78dfe..25ae59d273 100644 --- a/plugins/search-backend/config.d.ts +++ b/plugins/search-backend/config.d.ts @@ -22,6 +22,11 @@ export interface Config { */ maxPageLimit?: number; + /** + * Sets the maximum term length for the search string. Defaults to 100. + */ + maxTermLength?: number; + /** * Options related to the search integration with the Backstage permissions system */ From d2e8e10f3a44c4d16a05082e293dd73aab8f6cac Mon Sep 17 00:00:00 2001 From: Federico Morreale Date: Thu, 5 Oct 2023 17:42:02 +0200 Subject: [PATCH 03/13] add tests Signed-off-by: Federico Morreale --- plugins/search-backend/src/service/router.test.ts | 15 ++++++++++++++- plugins/search-backend/src/service/router.ts | 10 +++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/plugins/search-backend/src/service/router.test.ts b/plugins/search-backend/src/service/router.test.ts index 7ec8603307..73523f2b62 100644 --- a/plugins/search-backend/src/service/router.test.ts +++ b/plugins/search-backend/src/service/router.test.ts @@ -60,7 +60,7 @@ describe('createRouter', () => { }, config: new ConfigReader({ permissions: { enabled: false }, - search: { maxPageLimit: 200 }, + search: { maxPageLimit: 200, maxTermLength: 20 }, }), permissions: mockPermissionEvaluator, logger, @@ -162,6 +162,19 @@ describe('createRouter', () => { }); }); + it('should reject term length over configured max', async () => { + const response = await request(app).get( + `/query?term=HelloWorld1234567890!`, + ); + + expect(response.status).toEqual(400); + expect(response.body).toMatchObject({ + error: { + message: /The term length "21" is greater than "20"/i, + }, + }); + }); + it('removes backend-only properties from search documents', async () => { mockSearchEngine.query.mockResolvedValue({ results: [ diff --git a/plugins/search-backend/src/service/router.ts b/plugins/search-backend/src/service/router.ts index 54ac49f724..876cb5d103 100644 --- a/plugins/search-backend/src/service/router.ts +++ b/plugins/search-backend/src/service/router.ts @@ -82,7 +82,15 @@ export async function createRouter( config.getOptionalNumber('search.maxTermLength') ?? defaultMaxTermLength; const requestSchema = z.object({ - term: z.string().max(maxTermLength).default(''), + term: z + .string() + .refine( + term => term.length <= maxTermLength, + term => ({ + message: `The term length "${term.length}" is greater than "${maxTermLength}"`, + }), + ) + .default(''), filters: jsonObjectSchema.optional(), types: z .array(z.string().refine(type => Object.keys(types).includes(type))) From 790fe3c4c117ea3da0044424eab40eaba94faa3e Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Tue, 19 Sep 2023 15:52:27 +0200 Subject: [PATCH 04/13] Initial setup for alpha TechDocs FE DI Co-authored-by: Johan Haals Signed-off-by: Philipp Hugenroth --- plugins/techdocs/src/alpha.tsx | 98 +++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx index bea4b7ab34..864780afff 100644 --- a/plugins/techdocs/src/alpha.tsx +++ b/plugins/techdocs/src/alpha.tsx @@ -18,8 +18,23 @@ import React from 'react'; import { createPlugin, createSchemaFromZod, + createApiExtension, + createPageExtension, } from '@backstage/frontend-plugin-api'; import { createSearchResultListItemExtension } from '@backstage/plugin-search-react/alpha'; +import { + configApiRef, + createApiFactory, + discoveryApiRef, + fetchApiRef, + identityApiRef, +} from '@backstage/core-plugin-api'; +import { + techdocsApiRef, + techdocsStorageApiRef, +} from '@backstage/plugin-techdocs-react'; +import { TechDocsClient, TechDocsStorageClient } from './client'; +import { rootDocsRouteRef, rootRouteRef } from './routes'; /** @alpha */ export const TechDocsSearchResultListItemExtension = @@ -44,8 +59,89 @@ export const TechDocsSearchResultListItemExtension = }, }); +/** + * Responsible for rendering the provided router element + * + * @alpha + */ +const TechDocsIndexPage = createPageExtension({ + id: 'plugin.techdocs.indexPage', + defaultPath: '/docs', + routeRef: rootRouteRef, + loader: () => + import('./home/components/TechDocsIndexPage').then(m => ( + + )), +}); + +/** + * Component responsible for composing a TechDocs reader page experience + * + * @alpha + */ +const TechDocsReaderPage = createPageExtension({ + id: 'plugin.techdocs.readerPage', + loader: () => + import('./reader/components/TechDocsReaderPage').then(m => ( + + )), + routeRef: rootDocsRouteRef, + defaultPath: '/docs/:namespace/:kind/:name/*', +}); + +/** @alpha */ +const techDocsStorage = createApiExtension({ + api: techdocsStorageApiRef, + + factory() { + return createApiFactory({ + api: techdocsStorageApiRef, + deps: { + configApi: configApiRef, + discoveryApi: discoveryApiRef, + identityApi: identityApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ configApi, discoveryApi, identityApi, fetchApi }) => + new TechDocsStorageClient({ + configApi, + discoveryApi, + identityApi, + fetchApi, + }), + }); + }, +}); + +/** @alpha */ +const techDocsClient = createApiExtension({ + api: techdocsApiRef, + factory() { + return createApiFactory({ + api: techdocsApiRef, + deps: { + configApi: configApiRef, + discoveryApi: discoveryApiRef, + fetchApi: fetchApiRef, + }, + factory: ({ configApi, discoveryApi, fetchApi }) => + new TechDocsClient({ + configApi, + discoveryApi, + fetchApi, + }), + }); + }, +}); + /** @alpha */ export default createPlugin({ id: 'techdocs', - extensions: [TechDocsSearchResultListItemExtension], + extensions: [ + TechDocsIndexPage, + TechDocsReaderPage, + techDocsClient, + techDocsStorage, + TechDocsSearchResultListItemExtension, + ], }); From 27740caa2df15f499ebab45106eca3b194628b98 Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Wed, 27 Sep 2023 14:18:42 +0200 Subject: [PATCH 05/13] Add changeset & add to app-next Signed-off-by: Philipp Hugenroth --- .changeset/modern-owls-mate.md | 5 +++++ packages/app-next/src/App.tsx | 2 ++ plugins/techdocs/src/alpha.tsx | 11 ++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .changeset/modern-owls-mate.md diff --git a/.changeset/modern-owls-mate.md b/.changeset/modern-owls-mate.md new file mode 100644 index 0000000000..73d98f426c --- /dev/null +++ b/.changeset/modern-owls-mate.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs': minor +--- + +Added experimental support for declarative integration. diff --git a/packages/app-next/src/App.tsx b/packages/app-next/src/App.tsx index 2ab447c68f..f19fb1c109 100644 --- a/packages/app-next/src/App.tsx +++ b/packages/app-next/src/App.tsx @@ -25,6 +25,7 @@ import { createPageExtension, } from '@backstage/frontend-plugin-api'; import { entityRouteRef } from '@backstage/plugin-catalog-react'; +import techdocsPlugin from '@backstage/plugin-techdocs/alpha'; /* @@ -67,6 +68,7 @@ const app = createApp({ graphiqlPlugin, pagesPlugin, techRadarPlugin, + techdocsPlugin, userSettingsPlugin, createExtensionOverrides({ extensions: [entityPageExtension], diff --git a/plugins/techdocs/src/alpha.tsx b/plugins/techdocs/src/alpha.tsx index 864780afff..2f991f2fcc 100644 --- a/plugins/techdocs/src/alpha.tsx +++ b/plugins/techdocs/src/alpha.tsx @@ -25,6 +25,7 @@ import { createSearchResultListItemExtension } from '@backstage/plugin-search-re import { configApiRef, createApiFactory, + createRouteRef, discoveryApiRef, fetchApiRef, identityApiRef, @@ -34,7 +35,15 @@ import { techdocsStorageApiRef, } from '@backstage/plugin-techdocs-react'; import { TechDocsClient, TechDocsStorageClient } from './client'; -import { rootDocsRouteRef, rootRouteRef } from './routes'; + +const rootRouteRef = createRouteRef({ + id: 'plugin.techdocs.indexPage', +}); + +const rootDocsRouteRef = createRouteRef({ + id: 'plugin.techdocs.readerPage', + params: ['namespace', 'kind', 'name'], +}); /** @alpha */ export const TechDocsSearchResultListItemExtension = From 080d1beb2a51da17f2153b9615aff359287a148a Mon Sep 17 00:00:00 2001 From: Axel Hecht Date: Wed, 11 Oct 2023 19:42:39 +0200 Subject: [PATCH 06/13] Make dev dependencies just devDependencies Signed-off-by: Axel Hecht --- .changeset/red-baboons-warn.md | 5 +++++ packages/dev-utils/package.json | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .changeset/red-baboons-warn.md diff --git a/.changeset/red-baboons-warn.md b/.changeset/red-baboons-warn.md new file mode 100644 index 0000000000..bf32c613ee --- /dev/null +++ b/.changeset/red-baboons-warn.md @@ -0,0 +1,5 @@ +--- +'@backstage/dev-utils': patch +--- + +Moving dev dependencies to devDependencies diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index d61c21dd88..5ec49ded70 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -40,17 +40,11 @@ "@backstage/core-plugin-api": "workspace:^", "@backstage/integration-react": "workspace:^", "@backstage/plugin-catalog-react": "workspace:^", - "@backstage/test-utils": "workspace:^", "@backstage/theme": "workspace:^", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", - "@testing-library/dom": "^9.0.0", - "@testing-library/jest-dom": "^6.0.0", - "@testing-library/react": "^12.1.3", - "@testing-library/user-event": "^14.0.0", "@types/react": "^16.13.1 || ^17.0.0", - "react-use": "^17.2.4", - "zen-observable": "^0.10.0" + "react-use": "^17.2.4" }, "peerDependencies": { "react": "^16.13.1 || ^17.0.0", @@ -58,7 +52,13 @@ "react-router-dom": "6.0.0-beta.0 || ^6.3.0" }, "devDependencies": { - "@backstage/cli": "workspace:^" + "@backstage/cli": "workspace:^", + "@backstage/test-utils": "workspace:^", + "@testing-library/dom": "^9.0.0", + "@testing-library/jest-dom": "^6.0.0", + "@testing-library/react": "^12.1.3", + "@testing-library/user-event": "^14.0.0", + "zen-observable": "^0.10.0" }, "files": [ "dist" From ae8812c151c009b5cb02fef9e0fe223bee4b7d06 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 12 Oct 2023 11:13:12 +0200 Subject: [PATCH 07/13] changesets: tweak changeset for backend start change Signed-off-by: Patrik Oldsberg --- .changeset/itchy-rabbits-exist.md | 2 +- docs/releases/v1.19.0-next.0-changelog.md | 2 +- packages/cli/CHANGELOG.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/itchy-rabbits-exist.md b/.changeset/itchy-rabbits-exist.md index acac771a97..6a16ac5648 100644 --- a/.changeset/itchy-rabbits-exist.md +++ b/.changeset/itchy-rabbits-exist.md @@ -2,6 +2,6 @@ '@backstage/cli': minor --- -The new backend start command that used to be enabled by setting `EXPERIMENTAL_BACKEND_START` is now the default. To revert to the old behavior, set `LEGACY_BACKEND_START` instead. +**BREAKING** The new backend start command that used to be enabled by setting `EXPERIMENTAL_BACKEND_START` is now the default. To revert to the old behavior set `LEGACY_BACKEND_START`, which is recommended if you haven't migrated to the new backend system. This new command is no longer based on Webpack, but instead uses Node.js loaders to transpile on the fly. Rather than hot reloading modules the entire backend is now restarted on change, but the SQLite database state is still maintained across restarts via a parent process. diff --git a/docs/releases/v1.19.0-next.0-changelog.md b/docs/releases/v1.19.0-next.0-changelog.md index d1861165b9..b1c85e238e 100644 --- a/docs/releases/v1.19.0-next.0-changelog.md +++ b/docs/releases/v1.19.0-next.0-changelog.md @@ -4,7 +4,7 @@ ### Minor Changes -- 7077dbf131: The new backend start command that used to be enabled by setting `EXPERIMENTAL_BACKEND_START` is now the default. To revert to the old behavior, set `LEGACY_BACKEND_START` instead. +- 7077dbf131: **BREAKING** The new backend start command that used to be enabled by setting `EXPERIMENTAL_BACKEND_START` is now the default. To revert to the old behavior set `LEGACY_BACKEND_START`, which is recommended if you haven't migrated to the new backend system. This new command is no longer based on Webpack, but instead uses Node.js loaders to transpile on the fly. Rather than hot reloading modules the entire backend is now restarted on change, but the SQLite database state is still maintained across restarts via a parent process. diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index da412a58a1..a3a6b005c0 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -61,7 +61,7 @@ ### Minor Changes -- 7077dbf131: The new backend start command that used to be enabled by setting `EXPERIMENTAL_BACKEND_START` is now the default. To revert to the old behavior, set `LEGACY_BACKEND_START` instead. +- 7077dbf131: **BREAKING** The new backend start command that used to be enabled by setting `EXPERIMENTAL_BACKEND_START` is now the default. To revert to the old behavior set `LEGACY_BACKEND_START`, which is recommended if you haven't migrated to the new backend system. This new command is no longer based on Webpack, but instead uses Node.js loaders to transpile on the fly. Rather than hot reloading modules the entire backend is now restarted on change, but the SQLite database state is still maintained across restarts via a parent process. From 41381ddf1bbe81273a89362180f7b617b5726325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 12 Oct 2023 12:04:39 +0200 Subject: [PATCH 08/13] Update .changeset/red-baboons-warn.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Philipp Hugenroth Signed-off-by: Fredrik Adelöw --- .changeset/red-baboons-warn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/red-baboons-warn.md b/.changeset/red-baboons-warn.md index bf32c613ee..80b7cd3cad 100644 --- a/.changeset/red-baboons-warn.md +++ b/.changeset/red-baboons-warn.md @@ -2,4 +2,4 @@ '@backstage/dev-utils': patch --- -Moving dev dependencies to devDependencies +Moving development `dependencies` to `devDependencies` From cb0da264671aa8ea8370cfe1954b01c81535c94a Mon Sep 17 00:00:00 2001 From: Philipp Hugenroth Date: Thu, 12 Oct 2023 12:09:43 +0200 Subject: [PATCH 09/13] Update .changeset/modern-owls-mate.md Co-authored-by: Patrik Oldsberg Signed-off-by: Philipp Hugenroth --- .changeset/modern-owls-mate.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/modern-owls-mate.md b/.changeset/modern-owls-mate.md index 73d98f426c..bed33c6bbc 100644 --- a/.changeset/modern-owls-mate.md +++ b/.changeset/modern-owls-mate.md @@ -2,4 +2,4 @@ '@backstage/plugin-techdocs': minor --- -Added experimental support for declarative integration. +Added experimental support for declarative integration via the `/alpha` subpath. From 4f16e60e6dee7c7db3d2247dc4332d8d4719fcac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 12 Oct 2023 15:00:06 +0200 Subject: [PATCH 10/13] Request slightly smaller pages from GitHub MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/olive-islands-sneeze.md | 6 ++++++ .../discovery/providers/github/GithubDiscoveryProvider.ts | 2 +- plugins/catalog-backend-module-github/src/lib/github.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/olive-islands-sneeze.md diff --git a/.changeset/olive-islands-sneeze.md b/.changeset/olive-islands-sneeze.md new file mode 100644 index 0000000000..b44f071acc --- /dev/null +++ b/.changeset/olive-islands-sneeze.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog-backend-module-github': patch +'@backstage/cli': patch +--- + +Request slightly smaller pages of data from GitHub diff --git a/packages/cli/src/commands/onboard/discovery/providers/github/GithubDiscoveryProvider.ts b/packages/cli/src/commands/onboard/discovery/providers/github/GithubDiscoveryProvider.ts index d5a3dc4a77..a24756edd7 100644 --- a/packages/cli/src/commands/onboard/discovery/providers/github/GithubDiscoveryProvider.ts +++ b/packages/cli/src/commands/onboard/discovery/providers/github/GithubDiscoveryProvider.ts @@ -113,7 +113,7 @@ export class GithubDiscoveryProvider implements Provider { const query = `query repositories($org: String!, $cursor: String) { repositoryOwner(login: $org) { login - repositories(first: 100, after: $cursor) { + repositories(first: 50, after: $cursor) { nodes { name url diff --git a/plugins/catalog-backend-module-github/src/lib/github.ts b/plugins/catalog-backend-module-github/src/lib/github.ts index 073e6c1587..cf6b400443 100644 --- a/plugins/catalog-backend-module-github/src/lib/github.ts +++ b/plugins/catalog-backend-module-github/src/lib/github.ts @@ -462,7 +462,7 @@ export async function getOrganizationRepositories( query repositories($org: String!, $catalogPathRef: String!, $cursor: String) { repositoryOwner(login: $org) { login - repositories(first: 100, after: $cursor) { + repositories(first: 50, after: $cursor) { nodes { name catalogInfoFile: object(expression: $catalogPathRef) { From f1b349cfbaf3c5d43653a0651d15624756b6b47f Mon Sep 17 00:00:00 2001 From: Stan Lewis Date: Thu, 12 Oct 2023 08:08:45 -0400 Subject: [PATCH 11/13] fix: Tidy up i18nextTranslationApi change handling This change removes some extra logic in i18NextTranslationApi's change handling to ensure it always updates subscribers when a language change is handled. The relevant test was updated so it doesn't expect snapshots that aren't loaded. Fixes #20381 Signed-off-by: Stan Lewis --- .changeset/shiny-birds-melt.md | 5 +++++ .../TranslationApi/I18nextTranslationApi.test.ts | 3 +-- .../TranslationApi/I18nextTranslationApi.ts | 11 +++-------- 3 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 .changeset/shiny-birds-melt.md diff --git a/.changeset/shiny-birds-melt.md b/.changeset/shiny-birds-melt.md new file mode 100644 index 0000000000..4e37404c09 --- /dev/null +++ b/.changeset/shiny-birds-melt.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-app-api': patch +--- + +Fixed a bug in i18nextTranslationApi where in some cases it wouldn't notify subscribers of language changes diff --git a/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.test.ts b/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.test.ts index 224430752c..d5b812c5d7 100644 --- a/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.test.ts +++ b/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.test.ts @@ -377,8 +377,7 @@ describe('I18nextTranslationApi', () => { }, }); }); - - expect(translations).toEqual(['foo', null, 'Föö', null, 'Føø']); + expect(translations).toEqual(['foo', 'Föö', 'Føø']); }); describe('formatting', () => { diff --git a/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.ts b/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.ts index 01e75d6df2..d0ef35568f 100644 --- a/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.ts +++ b/packages/core-app-api/src/apis/implementations/TranslationApi/I18nextTranslationApi.ts @@ -241,7 +241,6 @@ export class I18nextTranslationApi implements TranslationApi { return new ObservableImpl>(subscriber => { let loadTicket = {}; // To check for stale loads - let lastSnapshotWasReady = false; const loadResource = () => { loadTicket = {}; @@ -250,8 +249,7 @@ export class I18nextTranslationApi implements TranslationApi { () => { if (ticket === loadTicket) { const snapshot = this.#createSnapshot(internalRef); - if (snapshot.ready || lastSnapshotWasReady) { - lastSnapshotWasReady = snapshot.ready; + if (snapshot.ready) { subscriber.next(snapshot); } } @@ -266,12 +264,9 @@ export class I18nextTranslationApi implements TranslationApi { const onChange = () => { const snapshot = this.#createSnapshot(internalRef); - if (lastSnapshotWasReady && !snapshot.ready) { - lastSnapshotWasReady = snapshot.ready; + if (snapshot.ready) { subscriber.next(snapshot); - } - - if (!snapshot.ready) { + } else { loadResource(); } }; From b535298539a670864a4dc2032c7c3cc7f660bacf Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 12 Oct 2023 16:10:13 +0200 Subject: [PATCH 12/13] Update .changeset/shiny-birds-melt.md Signed-off-by: Patrik Oldsberg --- .changeset/shiny-birds-melt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/shiny-birds-melt.md b/.changeset/shiny-birds-melt.md index 4e37404c09..16591b6d2f 100644 --- a/.changeset/shiny-birds-melt.md +++ b/.changeset/shiny-birds-melt.md @@ -2,4 +2,4 @@ '@backstage/core-app-api': patch --- -Fixed a bug in i18nextTranslationApi where in some cases it wouldn't notify subscribers of language changes +Fixed a bug in `TranslationApi` implementation where in some cases it wouldn't notify subscribers of language changes. From 29f2e76b5184fd260bad730ae4d1d05cab210b7a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 13 Oct 2023 11:05:52 +0200 Subject: [PATCH 13/13] create-app: fix for test not restoring cwd Signed-off-by: Patrik Oldsberg --- packages/create-app/src/lib/tasks.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/create-app/src/lib/tasks.test.ts b/packages/create-app/src/lib/tasks.test.ts index e122374004..c436bf5ad2 100644 --- a/packages/create-app/src/lib/tasks.test.ts +++ b/packages/create-app/src/lib/tasks.test.ts @@ -103,6 +103,7 @@ describe('tasks', () => { const mockDir = createMockDirectory(); + const origCwd = process.cwd(); const realChdir = process.chdir; // If anyone calls chdir then make it resolve within the tmpdir const mockChdir = jest.spyOn(process, 'chdir'); @@ -130,6 +131,10 @@ describe('tasks', () => { mockChdir.mockReset(); }); + afterAll(() => { + realChdir(origCwd); + }); + describe('checkAppExistsTask', () => { it('should do nothing if the directory does not exist', async () => { const dir = 'projects/';