From aa844e704a326cc0b546285839129a0997b3e519 Mon Sep 17 00:00:00 2001 From: Axel Koehler Date: Tue, 5 Sep 2023 15:27:59 +0200 Subject: [PATCH 1/3] feat(plugins/adr): configurable component header title Signed-off-by: Axel Koehler --- .changeset/plenty-lamps-pump.md | 5 +++++ .../adr/src/components/EntityAdrContent/EntityAdrContent.tsx | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/plenty-lamps-pump.md diff --git a/.changeset/plenty-lamps-pump.md b/.changeset/plenty-lamps-pump.md new file mode 100644 index 0000000000..4ba45ce7ef --- /dev/null +++ b/.changeset/plenty-lamps-pump.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-adr': minor +--- + +configurable component header title diff --git a/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx b/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx index 32e353eba9..027da2aa67 100644 --- a/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx +++ b/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx @@ -160,8 +160,9 @@ const AdrListContainer = (props: { export const EntityAdrContent = (props: { contentDecorators?: AdrContentDecorator[]; filePathFilterFn?: AdrFilePathFilterFn; + headerTitle?: string; }) => { - const { contentDecorators, filePathFilterFn } = props; + const { contentDecorators, filePathFilterFn, headerTitle } = props; const classes = useStyles(); const { entity } = useEntity(); const [adrList, setAdrList] = useState([]); @@ -214,7 +215,7 @@ export const EntityAdrContent = (props: { return ( - + {appSupportConfigured && } From 2a64789f0cdb8a35440333ee5d9c0532b227ed30 Mon Sep 17 00:00:00 2001 From: Axel Koehler Date: Wed, 6 Sep 2023 08:53:57 +0200 Subject: [PATCH 2/3] support for i18n feature Signed-off-by: Axel Koehler --- .changeset/plenty-lamps-pump.md | 4 +-- .../EntityAdrContent/EntityAdrContent.tsx | 12 +++++---- plugins/adr/src/translations.ts | 26 +++++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 plugins/adr/src/translations.ts diff --git a/.changeset/plenty-lamps-pump.md b/.changeset/plenty-lamps-pump.md index 4ba45ce7ef..04d0f2f4f0 100644 --- a/.changeset/plenty-lamps-pump.md +++ b/.changeset/plenty-lamps-pump.md @@ -1,5 +1,5 @@ --- -'@backstage/plugin-adr': minor +'@backstage/plugin-adr': patch --- -configurable component header title +support for i18n feature diff --git a/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx b/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx index 027da2aa67..8081043a9f 100644 --- a/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx +++ b/plugins/adr/src/components/EntityAdrContent/EntityAdrContent.tsx @@ -59,6 +59,8 @@ import FolderIcon from '@material-ui/icons/Folder'; import { adrApiRef, AdrFileInfo } from '../../api'; import { rootRouteRef } from '../../routes'; import { AdrContentDecorator, AdrReader } from '../AdrReader'; +import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; +import { adrTranslationRef } from '../../translations'; const useStyles = makeStyles((theme: Theme) => ({ adrMenu: { @@ -160,9 +162,8 @@ const AdrListContainer = (props: { export const EntityAdrContent = (props: { contentDecorators?: AdrContentDecorator[]; filePathFilterFn?: AdrFilePathFilterFn; - headerTitle?: string; }) => { - const { contentDecorators, filePathFilterFn, headerTitle } = props; + const { contentDecorators, filePathFilterFn } = props; const classes = useStyles(); const { entity } = useEntity(); const [adrList, setAdrList] = useState([]); @@ -170,6 +171,7 @@ export const EntityAdrContent = (props: { const scmIntegrations = useApi(scmIntegrationsApiRef); const adrApi = useApi(adrApiRef); const entityHasAdrs = isAdrAvailable(entity); + const t = useTranslationRef(adrTranslationRef); const config = useApi(configApiRef); const appSupportConfigured = config?.getOptionalConfig('app.support'); @@ -215,7 +217,7 @@ export const EntityAdrContent = (props: { return ( - + {appSupportConfigured && } @@ -226,7 +228,7 @@ export const EntityAdrContent = (props: { {loading && } {entityHasAdrs && !loading && error && ( - + )} {entityHasAdrs && @@ -253,7 +255,7 @@ export const EntityAdrContent = (props: { ) : ( - No ADRs found + {t('no_adrs')} ))} ); diff --git a/plugins/adr/src/translations.ts b/plugins/adr/src/translations.ts new file mode 100644 index 0000000000..cc0995f597 --- /dev/null +++ b/plugins/adr/src/translations.ts @@ -0,0 +1,26 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { createTranslationRef } from '@backstage/core-plugin-api/alpha'; + +/** @alpha */ +export const adrTranslationRef = createTranslationRef({ + id: 'adr', + messages: { + content_header_title: 'Architecture Decision Records', + failed_to_fetch: 'Failed to fetch ADRs', + no_adrs: 'No ADRs found', + }, +}); From 88c6850a11cad95b5e39f3f5e900228d9fdd4f39 Mon Sep 17 00:00:00 2001 From: Axel Koehler Date: Tue, 12 Sep 2023 07:44:15 +0200 Subject: [PATCH 3/3] Apply review comments - export alpha symbols Signed-off-by: Axel Koehler --- plugins/adr/alpha-api-report.md | 16 ++++++++++++++++ plugins/adr/package.json | 19 ++++++++++++++++--- plugins/adr/src/alpha.ts | 16 ++++++++++++++++ plugins/adr/src/translations.ts | 2 +- 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 plugins/adr/alpha-api-report.md create mode 100644 plugins/adr/src/alpha.ts diff --git a/plugins/adr/alpha-api-report.md b/plugins/adr/alpha-api-report.md new file mode 100644 index 0000000000..1d2b3f313d --- /dev/null +++ b/plugins/adr/alpha-api-report.md @@ -0,0 +1,16 @@ +## API Report File for "@backstage/plugin-adr" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { TranslationRef } from '@backstage/core-plugin-api/alpha'; + +// @alpha (undocumented) +export const adrTranslationRef: TranslationRef<{ + readonly content_header_title: 'Architecture Decision Records'; + readonly failed_to_fetch: 'Failed to fetch ADRs'; + readonly no_adrs: 'No ADRs found'; +}>; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/adr/package.json b/plugins/adr/package.json index 4cefeef71e..eb55663c1a 100644 --- a/plugins/adr/package.json +++ b/plugins/adr/package.json @@ -4,10 +4,23 @@ "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" + }, + "typesVersions": { + "*": { + "alpha": [ + "src/alpha.ts" + ], + "package.json": [ + "package.json" + ] + } + }, "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts" + "access": "public" }, "backstage": { "role": "frontend-plugin" diff --git a/plugins/adr/src/alpha.ts b/plugins/adr/src/alpha.ts new file mode 100644 index 0000000000..587cfce3d6 --- /dev/null +++ b/plugins/adr/src/alpha.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export * from './translations'; diff --git a/plugins/adr/src/translations.ts b/plugins/adr/src/translations.ts index cc0995f597..5cef279e66 100644 --- a/plugins/adr/src/translations.ts +++ b/plugins/adr/src/translations.ts @@ -22,5 +22,5 @@ export const adrTranslationRef = createTranslationRef({ content_header_title: 'Architecture Decision Records', failed_to_fetch: 'Failed to fetch ADRs', no_adrs: 'No ADRs found', - }, + } as const, });