Skip to content

Commit

Permalink
feat: add translation to editor toolbar
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Belo <[email protected]>
  • Loading branch information
camilaibs committed Oct 1, 2024
1 parent 8376e12 commit f989c47
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-dodos-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---

Add translation to the editor toolbar component.
10 changes: 10 additions & 0 deletions plugins/scaffolder/report-alpha.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ export const scaffolderTranslationRef: TranslationRef<
readonly 'templateWizardPage.subtitle': 'Create new software components using standard templates in your organization';
readonly 'templateWizardPage.pageTitle': 'Create a new component';
readonly 'templateWizardPage.pageContextMenu.editConfigurationTitle': 'Edit Configuration';
readonly 'templateEditorToolbar.customFieldExplorerTooltip': 'Custom Fields Explorer';
readonly 'templateEditorToolbar.installedActionsDocumentationTooltip': 'Installed Actions Documentation';
readonly 'templateEditorToolbar.addToCatalogButton': 'Publish';
readonly 'templateEditorToolbar.addToCatalogDialogTitle': 'Publish changes';
readonly 'templateEditorToolbar.addToCatalogDialogContent.introduction': 'Follow the instructions below to create or update a template:';
readonly 'templateEditorToolbar.addToCatalogDialogContent.step1': 'Save the template files in a local directory';
readonly 'templateEditorToolbar.addToCatalogDialogContent.step2': 'Create a pull request to a new or existing git repository';
readonly 'templateEditorToolbar.addToCatalogDialogContent.step3': 'If the template already exists, the changes will be reflected in the software catalog once the pull request gets merged';
readonly 'templateEditorToolbar.addToCatalogDialogContent.step4': 'But if you are creating a new template, follow the documentation linked below to register the new template repository in software catalog';
readonly 'templateEditorToolbar.addToCatalogDialogActions.closeButton': 'Close';
}
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import { FieldExtensionOptions } from '@backstage/plugin-scaffolder-react';

import { ActionPageContent } from '../../../components/ActionsPage/ActionsPage';
import { CustomFieldPlaygroud } from './CustomFieldPlaygroud';
import { useTranslationRef } from '@backstage/frontend-plugin-api';
import { scaffolderTranslationRef } from '../../../translation';

const useStyles = makeStyles(
theme => ({
Expand Down Expand Up @@ -73,6 +75,7 @@ export function TemplateEditorToolbar(props: {
}) {
const { children, fieldExtensions } = props;
const classes = useStyles();
const { t } = useTranslationRef(scaffolderTranslationRef);
const [showFieldsDrawer, setShowFieldsDrawer] = useState(false);
const [showActionsDrawer, setShowActionsDrawer] = useState(false);
const [showPublishModal, setShowPublishModal] = useState(false);
Expand All @@ -86,17 +89,25 @@ export function TemplateEditorToolbar(props: {
variant="outlined"
color="primary"
>
<Tooltip title="Custom Fields Explorer">
<Tooltip
title={t('templateEditorToolbar.customFieldExplorerTooltip')}
>
<Button onClick={() => setShowFieldsDrawer(true)}>
<ExtensionIcon />
</Button>
</Tooltip>
<Tooltip title="Installed Actions Documentation">
<Tooltip
title={t(
'templateEditorToolbar.installedActionsDocumentationTooltip',
)}
>
<Button onClick={() => setShowActionsDrawer(true)}>
<DescriptionIcon />
</Button>
</Tooltip>
<Button onClick={() => setShowPublishModal(true)}>Publish</Button>
<Button onClick={() => setShowPublishModal(true)}>
{t('templateEditorToolbar.addToCatalogButton')}
</Button>
</ButtonGroup>
<Drawer
classes={{ paper: classes.paper }}
Expand All @@ -120,32 +131,37 @@ export function TemplateEditorToolbar(props: {
aria-labelledby="publish-dialog-title"
aria-describedby="publish-dialog-description"
>
<DialogTitle id="publish-dialog-title">Publish changes</DialogTitle>
<DialogTitle id="publish-dialog-title">
{t('templateEditorToolbar.addToCatalogDialogTitle')}
</DialogTitle>
<DialogContent dividers>
<DialogContentText id="publish-dialog-slide-description">
Follow the instructions below to create or update a template:
{t(
'templateEditorToolbar.addToCatalogDialogContent.introduction',
)}
<ol>
<li>Save the template files in a local directory</li>
<li>
Create a pull request to a new or existing git repository
{t('templateEditorToolbar.addToCatalogDialogContent.step1')}
</li>
<li>
If the template already exists, the changes will be reflected
in the software catalog once the pull request gets merged
{t('templateEditorToolbar.addToCatalogDialogContent.step2')}
</li>
<li>
But if you are creating a new template, follow this{' '}
{t('templateEditorToolbar.addToCatalogDialogContent.step3')}
</li>
<li>
{t('templateEditorToolbar.addToCatalogDialogContent.step4')}
<br />
<Link to="https://backstage.io/docs/features/software-templates/adding-templates/">
documentation
</Link>{' '}
to register the new template repository in software catalog
https://backstage.io/docs/features/software-templates/adding-templates/
</Link>
</li>
</ol>
</DialogContentText>
</DialogContent>
<DialogActions>
<Button color="primary" onClick={() => setShowPublishModal(false)}>
Close
{t('templateEditorToolbar.addToCatalogDialogActions.closeButton')}
</Button>
</DialogActions>
</Dialog>
Expand Down
19 changes: 19 additions & 0 deletions plugins/scaffolder/src/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,24 @@ export const scaffolderTranslationRef = createTranslationRef({
editConfigurationTitle: 'Edit Configuration',
},
},
templateEditorToolbar: {
customFieldExplorerTooltip: 'Custom Fields Explorer',
installedActionsDocumentationTooltip: 'Installed Actions Documentation',
addToCatalogButton: 'Publish',
addToCatalogDialogTitle: 'Publish changes',
addToCatalogDialogContent: {
introduction:
'Follow the instructions below to create or update a template:',
step1: 'Save the template files in a local directory',
step2: 'Create a pull request to a new or existing git repository',
step3:
'If the template already exists, the changes will be reflected in the software catalog once the pull request gets merged',
step4:
'But if you are creating a new template, follow the documentation linked below to register the new template repository in software catalog',
},
addToCatalogDialogActions: {
closeButton: 'Close',
},
},
},
});

0 comments on commit f989c47

Please sign in to comment.