diff --git a/plugins/scaffolder/report-alpha.api.md b/plugins/scaffolder/report-alpha.api.md index 4319362ef9..cb939c2e84 100644 --- a/plugins/scaffolder/report-alpha.api.md +++ b/plugins/scaffolder/report-alpha.api.md @@ -274,9 +274,13 @@ export const scaffolderTranslationRef: TranslationRef< readonly 'ongoingTask.showLogsButtonTitle': 'Show Logs'; readonly 'templateEditorForm.stepper.emptyText': 'There are no spec parameters in the template to preview.'; readonly 'templateTypePicker.title': 'Categories'; +<<<<<<< HEAD:plugins/scaffolder/report-alpha.api.md readonly 'templateFormPage.title': 'Template Form Playground'; readonly 'templateFormPage.subtitle': 'Edit, preview, and try out templates and template forms'; readonly 'templateEditorPage.title': 'Template Editor'; +======= + readonly 'templateEditorPage.title': 'Manage Templates'; +>>>>>>> 0d22ec434749 (scaffolder: Rework manage templates page):plugins/scaffolder/api-report-alpha.md readonly 'templateEditorPage.subtitle': 'Edit, preview, and try out templates and template forms'; readonly 'templateEditorPage.dryRunResults.title': 'Dry-run results'; readonly 'templateEditorPage.dryRunResultsList.title': 'Result {{resultId}}'; @@ -302,7 +306,7 @@ export const scaffolderTranslationRef: TranslationRef< readonly 'templateEditorPage.templateEditorIntro.createLocal.title': 'Create New Template'; readonly 'templateEditorPage.templateEditorIntro.createLocal.description': 'Create a local template directory, allowing you to both edit and try executing your own template.'; readonly 'templateEditorPage.templateEditorIntro.createLocal.unsupportedTooltip': 'Only supported in some Chromium-based browsers'; - readonly 'templateEditorPage.templateEditorIntro.formEditor.title': 'Edit Template Form'; + readonly 'templateEditorPage.templateEditorIntro.formEditor.title': 'Template playground'; readonly 'templateEditorPage.templateEditorIntro.formEditor.description': 'Preview and edit a template form, either using a sample template or by loading a template from the catalog.'; readonly 'templateEditorPage.templateEditorIntro.fieldExplorer.title': 'Custom Field Explorer'; readonly 'templateEditorPage.templateEditorIntro.fieldExplorer.description': 'View and play around with available installed custom field extensions.'; diff --git a/plugins/scaffolder/src/alpha/components/TemplateEditorPage/TemplateEditorIntro.tsx b/plugins/scaffolder/src/alpha/components/TemplateEditorPage/TemplateEditorIntro.tsx index c65ef569a6..e5edd2cbd5 100644 --- a/plugins/scaffolder/src/alpha/components/TemplateEditorPage/TemplateEditorIntro.tsx +++ b/plugins/scaffolder/src/alpha/components/TemplateEditorPage/TemplateEditorIntro.tsx @@ -18,30 +18,63 @@ import React from 'react'; import Card from '@material-ui/core/Card'; import CardActionArea from '@material-ui/core/CardActionArea'; import CardContent from '@material-ui/core/CardContent'; -import Tooltip from '@material-ui/core/Tooltip'; import Typography from '@material-ui/core/Typography'; -import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined'; import { makeStyles } from '@material-ui/core/styles'; import { WebFileSystemAccess } from '../../../lib/filesystem'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; import { scaffolderTranslationRef } from '../../../translation'; +import CreateNewFolderIcon from '@material-ui/icons/CreateNewFolder'; +import ListAltIcon from '@material-ui/icons/ListAlt'; +import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted'; +import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined'; +import CardMedia from '@material-ui/core/CardMedia'; +import PublishIcon from '@material-ui/icons/Publish'; +import SvgIcon from '@material-ui/core/SvgIcon'; +import Tooltip from '@material-ui/core/Tooltip'; const useStyles = makeStyles(theme => ({ + gridRoot: { + display: 'flex', + flex: 1, + alignItems: 'center', + justifyContent: 'center', + }, + cardGrid: { + display: 'grid', + maxWidth: 1000, + gridTemplateColumns: '1fr 1fr', + gridAutoRows: '1fr 1fr', + gap: '1rem', + [theme.breakpoints.down('sm')]: { + gridAutoFlow: 'row', + }, + }, + card: { + display: 'grid', + gridTemplateColumns: 'auto 1fr', + gridTemplateRows: '1fr', + alignItems: 'center', + margin: theme.spacing(0, 1), + marginTop: theme.spacing(2), + padding: theme.spacing(2), + }, + icon: { + justifySelf: 'center', + paddingTop: theme.spacing(1), + fontSize: 48, + }, introText: { textAlign: 'center', marginTop: theme.spacing(2), }, - card: { - position: 'relative', - maxWidth: 340, - marginTop: theme.spacing(4), - margin: theme.spacing(0, 2), - }, infoIcon: { position: 'absolute', top: theme.spacing(1), right: theme.spacing(1), }, + cardContent: { + padding: theme.spacing(1), + }, })); interface EditorIntroProps { @@ -51,142 +84,109 @@ interface EditorIntroProps { ) => void; } -export function TemplateEditorIntro(props: EditorIntroProps) { - const classes = useStyles(); - const supportsLoad = WebFileSystemAccess.isSupported(); +function ActionCard(props: { + title: string; + description: string; + Icon: typeof SvgIcon; + action?: React.MouseEventHandler; + requireLoad?: boolean; +}) { + const supportsLoad = props.requireLoad + ? WebFileSystemAccess.isSupported() + : true; const { t } = useTranslationRef(scaffolderTranslationRef); - const cardLoadLocal = ( - - props.onSelect?.('local')} - > - - - {t('templateEditorPage.templateEditorIntro.loadLocal.title')} - - - {t('templateEditorPage.templateEditorIntro.loadLocal.description')} - - - + const classes = useStyles(); + const { Icon, title, description, action } = props; + return ( + {!supportsLoad && ( -
- - - -
+ + + )} -
- ); - const cardCreateLocal = ( - - props.onSelect?.('create-template')} - > - + + + + + - {t('templateEditorPage.templateEditorIntro.createLocal.title')} - - - {t( - 'templateEditorPage.templateEditorIntro.createLocal.description', - )} + {title} - - - {!supportsLoad && ( -
- - - -
- )} -
- ); - - const cardFormEditor = ( - - props.onSelect?.('form')}> - - - {t('templateEditorPage.templateEditorIntro.formEditor.title')} - - - {t('templateEditorPage.templateEditorIntro.formEditor.description')} - - - - - ); - - const cardFieldExplorer = ( - - props.onSelect?.('field-explorer')}> - - - {t('templateEditorPage.templateEditorIntro.fieldExplorer.title')} - - - {t( - 'templateEditorPage.templateEditorIntro.fieldExplorer.description', - )} + + {description} ); +} +export function TemplateEditorIntro(props: EditorIntroProps) { + const classes = useStyles(); + const { t } = useTranslationRef(scaffolderTranslationRef); return (
{t('templateEditorPage.templateEditorIntro.title')} -
- {supportsLoad && cardLoadLocal} - {supportsLoad && cardCreateLocal} - {cardFormEditor} - {!supportsLoad && cardLoadLocal} - {cardFieldExplorer} +
+
+ props.onSelect?.('local')} + /> + props.onSelect?.('create-template')} + Icon={CreateNewFolderIcon} + /> + + props.onSelect?.('field-explorer')} + /> + + props.onSelect?.('form')} + /> +
); diff --git a/plugins/scaffolder/src/alpha/components/TemplateEditorPage/TemplateEditorPage.tsx b/plugins/scaffolder/src/alpha/components/TemplateEditorPage/TemplateEditorPage.tsx index 8d71db2551..90737393f9 100644 --- a/plugins/scaffolder/src/alpha/components/TemplateEditorPage/TemplateEditorPage.tsx +++ b/plugins/scaffolder/src/alpha/components/TemplateEditorPage/TemplateEditorPage.tsx @@ -19,15 +19,12 @@ import { Content, Header, Page } from '@backstage/core-components'; import { WebFileSystemAccess } from '../../../lib/filesystem'; import { TemplateEditorIntro } from './TemplateEditorIntro'; -import { ScaffolderPageContextMenu } from '@backstage/plugin-scaffolder-react/alpha'; import { useNavigate } from 'react-router-dom'; import { useRouteRef } from '@backstage/core-plugin-api'; import { - actionsRouteRef, editorRouteRef, customFieldsRouteRef, rootRouteRef, - scaffolderListTaskRouteRef, templateFormRouteRef, } from '../../../routes'; import { useTranslationRef } from '@backstage/core-plugin-api/alpha'; @@ -37,29 +34,20 @@ import { createExampleTemplate } from '../../../lib/filesystem/createExampleTemp export function TemplateEditorPage() { const navigate = useNavigate(); - const actionsLink = useRouteRef(actionsRouteRef); - const tasksLink = useRouteRef(scaffolderListTaskRouteRef); const createLink = useRouteRef(rootRouteRef); const editorLink = useRouteRef(editorRouteRef); const customFieldsLink = useRouteRef(customFieldsRouteRef); const templateFormLink = useRouteRef(templateFormRouteRef); const { t } = useTranslationRef(scaffolderTranslationRef); - const scaffolderPageContextMenuProps = { - onEditorClicked: undefined, - onActionsClicked: () => navigate(actionsLink()), - onTasksClicked: () => navigate(tasksLink()), - onCreateClicked: () => navigate(createLink()), - }; - return (
- -
+ /> { diff --git a/plugins/scaffolder/src/translation.ts b/plugins/scaffolder/src/translation.ts index ba39c80b7c..11c13194ce 100644 --- a/plugins/scaffolder/src/translation.ts +++ b/plugins/scaffolder/src/translation.ts @@ -199,7 +199,7 @@ export const scaffolderTranslationRef = createTranslationRef({ subtitle: 'Edit, preview, and try out templates and template forms', }, templateEditorPage: { - title: 'Template Editor', + title: 'Manage Templates', subtitle: 'Edit, preview, and try out templates and template forms', dryRunResults: { title: 'Dry-run results', @@ -253,7 +253,7 @@ export const scaffolderTranslationRef = createTranslationRef({ unsupportedTooltip: 'Only supported in some Chromium-based browsers', }, formEditor: { - title: 'Edit Template Form', + title: 'Template playground', description: 'Preview and edit a template form, either using a sample template or by loading a template from the catalog.', },