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', + }, +});