diff --git a/.changeset/light-vans-hide.md b/.changeset/light-vans-hide.md new file mode 100644 index 0000000000..ccc1339959 --- /dev/null +++ b/.changeset/light-vans-hide.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-api-docs': patch +--- + +Add organization name to the API Explorer page title diff --git a/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerLayout.tsx b/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerLayout.tsx index 0720ecf45b..add886fead 100644 --- a/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerLayout.tsx +++ b/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerLayout.tsx @@ -14,20 +14,25 @@ * limitations under the License. */ -import { Header, Page } from '@backstage/core'; +import { Header, Page, useApi, configApiRef } from '@backstage/core'; import React from 'react'; type Props = { children?: React.ReactNode; }; - -export const ApiExplorerLayout = ({ children }: Props) => ( - -
- {children} - -); +export const ApiExplorerLayout = ({ children }: Props) => { + const configApi = useApi(configApiRef); + const generatedSubtitle = `${ + configApi.getOptionalString('organization.name') ?? 'Backstage' + } API Explorer`; + return ( + +
+ {children} + + ); +}; diff --git a/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerPage.test.tsx b/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerPage.test.tsx index 67462b630c..223734504b 100644 --- a/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerPage.test.tsx +++ b/plugins/api-docs/src/components/ApiExplorerPage/ApiExplorerPage.test.tsx @@ -15,7 +15,14 @@ */ import { Entity } from '@backstage/catalog-model'; -import { ApiProvider, ApiRegistry, storageApiRef } from '@backstage/core'; +import { + ApiProvider, + ApiRegistry, + storageApiRef, + ConfigApi, + configApiRef, + ConfigReader, +} from '@backstage/core'; import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react'; import { MockStorageApi, wrapInTestApp } from '@backstage/test-utils'; import { render } from '@testing-library/react'; @@ -50,6 +57,12 @@ describe('ApiCatalogPage', () => { Promise.resolve({ id: 'id', type: 'github', target: 'url' }), }; + const configApi: ConfigApi = new ConfigReader({ + organization: { + name: 'My Company', + }, + }); + const apiDocsConfig = { getApiDefinitionWidget: () => undefined, }; @@ -60,6 +73,7 @@ describe('ApiCatalogPage', () => { { // https://github.com/mbrn/material-table/issues/1293 it('should render', async () => { const { findByText } = renderWrapped(); - expect(await findByText(/Backstage API Explorer/)).toBeInTheDocument(); + expect(await findByText(/My Company API Explorer/)).toBeInTheDocument(); }); });