Merge pull request #19786 from axdotl/adr-title

feat(plugins/adr): support for i18n feature
This commit is contained in:
Patrik Oldsberg
2023-09-12 12:48:33 +02:00
committed by GitHub
6 changed files with 85 additions and 6 deletions
+16
View File
@@ -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)
```
+16 -3
View File
@@ -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"
+16
View File
@@ -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';
@@ -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: {
@@ -169,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');
@@ -214,7 +217,7 @@ export const EntityAdrContent = (props: {
return (
<Content>
<ContentHeader title="Architecture Decision Records">
<ContentHeader title={t('content_header_title')}>
{appSupportConfigured && <SupportButton />}
</ContentHeader>
@@ -225,7 +228,7 @@ export const EntityAdrContent = (props: {
{loading && <Progress />}
{entityHasAdrs && !loading && error && (
<WarningPanel title="Failed to fetch ADRs" message={error?.message} />
<WarningPanel title={t('failed_to_fetch')} message={error?.message} />
)}
{entityHasAdrs &&
@@ -252,7 +255,7 @@ export const EntityAdrContent = (props: {
</Grid>
</Grid>
) : (
<Typography>No ADRs found</Typography>
<Typography>{t('no_adrs')}</Typography>
))}
</Content>
);
+26
View File
@@ -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',
} as const,
});