@backstage/plugin-scaffolder 1.24.0-next.2 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/alpha/package.json +1 -1
  3. package/dist/alpha.d.ts +156 -1
  4. package/dist/alpha.esm.js +32 -25
  5. package/dist/alpha.esm.js.map +1 -1
  6. package/dist/components/ActionsPage/ActionsPage.esm.js +14 -10
  7. package/dist/components/ActionsPage/ActionsPage.esm.js.map +1 -1
  8. package/dist/components/ListTasksPage/ListTasksPage.esm.js +15 -11
  9. package/dist/components/ListTasksPage/ListTasksPage.esm.js.map +1 -1
  10. package/dist/components/ListTasksPage/OwnerListPicker.esm.js +8 -5
  11. package/dist/components/ListTasksPage/OwnerListPicker.esm.js.map +1 -1
  12. package/dist/components/OngoingTask/ContextMenu.esm.js +12 -4
  13. package/dist/components/OngoingTask/ContextMenu.esm.js.map +1 -1
  14. package/dist/components/OngoingTask/OngoingTask.esm.js +10 -7
  15. package/dist/components/OngoingTask/OngoingTask.esm.js.map +1 -1
  16. package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js +4 -1
  17. package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js.map +1 -1
  18. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js +7 -1
  19. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js.map +1 -1
  20. package/dist/components/fields/EntityPicker/EntityPicker.esm.js +7 -1
  21. package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -1
  22. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js +5 -2
  23. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js.map +1 -1
  24. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js +43 -18
  25. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js.map +1 -1
  26. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js +7 -1
  27. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js.map +1 -1
  28. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js +7 -1
  29. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js.map +1 -1
  30. package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js +3 -4
  31. package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js.map +1 -1
  32. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js +19 -15
  33. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js.map +1 -1
  34. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +23 -6
  35. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -1
  36. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js +14 -11
  37. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js.map +1 -1
  38. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js +14 -9
  39. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js.map +1 -1
  40. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js +11 -8
  41. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js.map +1 -1
  42. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +14 -9
  43. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -1
  44. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js +5 -2
  45. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js.map +1 -1
  46. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +13 -3
  47. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -1
  48. package/dist/components/fields/VirtualizedListbox.esm.js +14 -5
  49. package/dist/components/fields/VirtualizedListbox.esm.js.map +1 -1
  50. package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js +20 -5
  51. package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js.map +1 -1
  52. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResults.esm.js +4 -1
  53. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResults.esm.js.map +1 -1
  54. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js +17 -3
  55. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js.map +1 -1
  56. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js +22 -1
  57. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js.map +1 -1
  58. package/dist/next/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js +6 -1
  59. package/dist/next/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js.map +1 -1
  60. package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js +36 -13
  61. package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js.map +1 -1
  62. package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js +13 -6
  63. package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js.map +1 -1
  64. package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js +5 -2
  65. package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js.map +1 -1
  66. package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js +30 -11
  67. package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js.map +1 -1
  68. package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js +5 -2
  69. package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js.map +1 -1
  70. package/dist/next/TemplateListPage/TemplateListPage.esm.js +23 -15
  71. package/dist/next/TemplateListPage/TemplateListPage.esm.js.map +1 -1
  72. package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js +6 -3
  73. package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js.map +1 -1
  74. package/dist/next/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js +11 -1
  75. package/dist/next/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js.map +1 -1
  76. package/dist/translation.esm.js +258 -0
  77. package/dist/translation.esm.js.map +1 -0
  78. package/package.json +19 -19
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateEditorIntro.esm.js","sources":["../../../src/next/TemplateEditorPage/TemplateEditorIntro.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Card from '@material-ui/core/Card';\nimport CardActionArea from '@material-ui/core/CardActionArea';\nimport CardContent from '@material-ui/core/CardContent';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\nimport InfoOutlinedIcon from '@material-ui/icons/InfoOutlined';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { WebFileSystemAccess } from '../../lib/filesystem';\n\nconst useStyles = makeStyles(theme => ({\n introText: {\n textAlign: 'center',\n marginTop: theme.spacing(2),\n },\n card: {\n position: 'relative',\n maxWidth: 340,\n marginTop: theme.spacing(4),\n margin: theme.spacing(0, 2),\n },\n infoIcon: {\n position: 'absolute',\n top: theme.spacing(1),\n right: theme.spacing(1),\n },\n}));\n\ninterface EditorIntroProps {\n style?: JSX.IntrinsicElements['div']['style'];\n onSelect?: (option: 'local' | 'form' | 'field-explorer') => void;\n}\n\nexport function TemplateEditorIntro(props: EditorIntroProps) {\n const classes = useStyles();\n const supportsLoad = WebFileSystemAccess.isSupported();\n\n const cardLoadLocal = (\n <Card className={classes.card} elevation={4}>\n <CardActionArea\n disabled={!supportsLoad}\n onClick={() => props.onSelect?.('local')}\n >\n <CardContent>\n <Typography\n variant=\"h4\"\n component=\"h3\"\n gutterBottom\n color={supportsLoad ? undefined : 'textSecondary'}\n style={{ display: 'flex', flexFlow: 'row nowrap' }}\n >\n Load Template Directory\n </Typography>\n <Typography\n variant=\"body1\"\n color={supportsLoad ? undefined : 'textSecondary'}\n >\n Load a local template directory, allowing you to both edit and try\n executing your own template.\n </Typography>\n </CardContent>\n </CardActionArea>\n {!supportsLoad && (\n <div className={classes.infoIcon}>\n <Tooltip\n placement=\"top\"\n title=\"Only supported in some Chromium-based browsers\"\n >\n <InfoOutlinedIcon />\n </Tooltip>\n </div>\n )}\n </Card>\n );\n\n const cardFormEditor = (\n <Card className={classes.card} elevation={4}>\n <CardActionArea onClick={() => props.onSelect?.('form')}>\n <CardContent>\n <Typography variant=\"h4\" component=\"h3\" gutterBottom>\n Edit Template Form\n </Typography>\n <Typography variant=\"body1\">\n Preview and edit a template form, either using a sample template or\n by loading a template from the catalog.\n </Typography>\n </CardContent>\n </CardActionArea>\n </Card>\n );\n\n const cardFieldExplorer = (\n <Card className={classes.card} elevation={4}>\n <CardActionArea onClick={() => props.onSelect?.('field-explorer')}>\n <CardContent>\n <Typography variant=\"h4\" component=\"h3\" gutterBottom>\n Custom Field Explorer\n </Typography>\n <Typography variant=\"body1\">\n View and play around with available installed custom field\n extensions.\n </Typography>\n </CardContent>\n </CardActionArea>\n </Card>\n );\n\n return (\n <div style={props.style}>\n <Typography variant=\"h4\" component=\"h2\" className={classes.introText}>\n Get started by choosing one of the options below\n </Typography>\n <div\n style={{\n display: 'flex',\n flexFlow: 'row wrap',\n alignItems: 'flex-start',\n justifyContent: 'center',\n alignContent: 'flex-start',\n }}\n >\n {supportsLoad && cardLoadLocal}\n {cardFormEditor}\n {!supportsLoad && cardLoadLocal}\n {cardFieldExplorer}\n </div>\n </div>\n );\n}\n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,IAAM,EAAA,SAAA,EAAW,CACxC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,kBAAe,OAAS,EAAA,MAAM,KAAM,CAAA,QAAA,GAAW,gBAAgB,CAC9D,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,WACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,IAAA,EAAK,SAAU,EAAA,IAAA,EAAK,cAAY,IAAC,EAAA,EAAA,uBAErD,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,OAAA,EAAA,EAAQ,wEAG5B,CACF,CACF,CACF,CAAA,CAAA;AAGF,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,KAAO,EAAA,KAAA,CAAM,yBACf,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,IAAA,EAAK,WAAU,IAAK,EAAA,SAAA,EAAW,OAAQ,CAAA,SAAA,EAAA,EAAW,kDAEtE,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA;AAAA,QACL,OAAS,EAAA,MAAA;AAAA,QACT,QAAU,EAAA,UAAA;AAAA,QACV,UAAY,EAAA,YAAA;AAAA,QACZ,cAAgB,EAAA,QAAA;AAAA,QAChB,YAAc,EAAA,YAAA;AAAA,OAChB;AAAA,KAAA;AAAA,IAEC,YAAgB,IAAA,aAAA;AAAA,IAChB,cAAA;AAAA,IACA,CAAC,YAAgB,IAAA,aAAA;AAAA,IACjB,iBAAA;AAAA,GAEL,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TemplateEditorIntro.esm.js","sources":["../../../src/next/TemplateEditorPage/TemplateEditorIntro.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Card from '@material-ui/core/Card';\nimport CardActionArea from '@material-ui/core/CardActionArea';\nimport CardContent from '@material-ui/core/CardContent';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Typography from '@material-ui/core/Typography';\nimport InfoOutlinedIcon from '@material-ui/icons/InfoOutlined';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { WebFileSystemAccess } from '../../lib/filesystem';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../translation';\n\nconst useStyles = makeStyles(theme => ({\n introText: {\n textAlign: 'center',\n marginTop: theme.spacing(2),\n },\n card: {\n position: 'relative',\n maxWidth: 340,\n marginTop: theme.spacing(4),\n margin: theme.spacing(0, 2),\n },\n infoIcon: {\n position: 'absolute',\n top: theme.spacing(1),\n right: theme.spacing(1),\n },\n}));\n\ninterface EditorIntroProps {\n style?: JSX.IntrinsicElements['div']['style'];\n onSelect?: (option: 'local' | 'form' | 'field-explorer') => void;\n}\n\nexport function TemplateEditorIntro(props: EditorIntroProps) {\n const classes = useStyles();\n const supportsLoad = WebFileSystemAccess.isSupported();\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const cardLoadLocal = (\n <Card className={classes.card} elevation={4}>\n <CardActionArea\n disabled={!supportsLoad}\n onClick={() => props.onSelect?.('local')}\n >\n <CardContent>\n <Typography\n variant=\"h4\"\n component=\"h3\"\n gutterBottom\n color={supportsLoad ? undefined : 'textSecondary'}\n style={{ display: 'flex', flexFlow: 'row nowrap' }}\n >\n {t('templateEditorPage.templateEditorIntro.loadLocal.title')}\n </Typography>\n <Typography\n variant=\"body1\"\n color={supportsLoad ? undefined : 'textSecondary'}\n >\n {t('templateEditorPage.templateEditorIntro.loadLocal.description')}\n </Typography>\n </CardContent>\n </CardActionArea>\n {!supportsLoad && (\n <div className={classes.infoIcon}>\n <Tooltip\n placement=\"top\"\n title={t(\n 'templateEditorPage.templateEditorIntro.loadLocal.unsupportedTooltip',\n )}\n >\n <InfoOutlinedIcon />\n </Tooltip>\n </div>\n )}\n </Card>\n );\n\n const cardFormEditor = (\n <Card className={classes.card} elevation={4}>\n <CardActionArea onClick={() => props.onSelect?.('form')}>\n <CardContent>\n <Typography variant=\"h4\" component=\"h3\" gutterBottom>\n {t('templateEditorPage.templateEditorIntro.formEditor.title')}\n </Typography>\n <Typography variant=\"body1\">\n {t('templateEditorPage.templateEditorIntro.formEditor.description')}\n </Typography>\n </CardContent>\n </CardActionArea>\n </Card>\n );\n\n const cardFieldExplorer = (\n <Card className={classes.card} elevation={4}>\n <CardActionArea onClick={() => props.onSelect?.('field-explorer')}>\n <CardContent>\n <Typography variant=\"h4\" component=\"h3\" gutterBottom>\n {t('templateEditorPage.templateEditorIntro.fieldExplorer.title')}\n </Typography>\n <Typography variant=\"body1\">\n {t(\n 'templateEditorPage.templateEditorIntro.fieldExplorer.description',\n )}\n </Typography>\n </CardContent>\n </CardActionArea>\n </Card>\n );\n\n return (\n <div style={props.style}>\n <Typography variant=\"h4\" component=\"h2\" className={classes.introText}>\n {t('templateEditorPage.templateEditorIntro.title')}\n </Typography>\n <div\n style={{\n display: 'flex',\n flexFlow: 'row wrap',\n alignItems: 'flex-start',\n justifyContent: 'center',\n alignContent: 'flex-start',\n }}\n >\n {supportsLoad && cardLoadLocal}\n {cardFormEditor}\n {!supportsLoad && cardLoadLocal}\n {cardFieldExplorer}\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AA4BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,SAAW,EAAA;AAAA,IACT,SAAW,EAAA,QAAA;AAAA,IACX,SAAA,EAAW,KAAM,CAAA,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,SAAA,EAAW,CACxC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,EAAA,OAAA,EAAS,MAAM,KAAA,CAAM,WAAW,gBAAgB,CAAA,EAAA,kBAC7D,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,IAAA,EAAK,WAAU,IAAK,EAAA,YAAA,EAAY,IACjD,EAAA,EAAA,CAAA,CAAE,4DAA4D,CACjE,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,SAAQ,OACjB,EAAA,EAAA,CAAA;AAAA,IACC,kEAAA;AAAA,GAEJ,CACF,CACF,CACF,CAAA,CAAA;AAGF,EAAA,2CACG,KAAI,EAAA,EAAA,KAAA,EAAO,KAAM,CAAA,KAAA,EAAA,sCACf,UAAW,EAAA,EAAA,OAAA,EAAQ,IAAK,EAAA,SAAA,EAAU,MAAK,SAAW,EAAA,OAAA,CAAQ,aACxD,CAAE,CAAA,8CAA8C,CACnD,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA;AAAA,QACL,OAAS,EAAA,MAAA;AAAA,QACT,QAAU,EAAA,UAAA;AAAA,QACV,UAAY,EAAA,YAAA;AAAA,QACZ,cAAgB,EAAA,QAAA;AAAA,QAChB,YAAc,EAAA,YAAA;AAAA,OAChB;AAAA,KAAA;AAAA,IAEC,YAAgB,IAAA,aAAA;AAAA,IAChB,cAAA;AAAA,IACA,CAAC,YAAgB,IAAA,aAAA;AAAA,IACjB,iBAAA;AAAA,GAEL,CAAA,CAAA;AAEJ;;;;"}
@@ -9,6 +9,8 @@ import { ScaffolderPageContextMenu } from '@backstage/plugin-scaffolder-react/al
9
9
  import { useNavigate } from 'react-router-dom';
10
10
  import { useRouteRef } from '@backstage/core-plugin-api';
11
11
  import { actionsRouteRef, scaffolderListTaskRouteRef, rootRouteRef } from '../../routes.esm.js';
12
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
13
+ import { scaffolderTranslationRef } from '../../translation.esm.js';
12
14
 
13
15
  function TemplateEditorPage(props) {
14
16
  const [selection, setSelection] = useState();
@@ -16,6 +18,7 @@ function TemplateEditorPage(props) {
16
18
  const actionsLink = useRouteRef(actionsRouteRef);
17
19
  const tasksLink = useRouteRef(scaffolderListTaskRouteRef);
18
20
  const createLink = useRouteRef(rootRouteRef);
21
+ const { t } = useTranslationRef(scaffolderTranslationRef);
19
22
  const scaffolderPageContextMenuProps = {
20
23
  onEditorClicked: void 0,
21
24
  onActionsClicked: () => navigate(actionsLink()),
@@ -71,8 +74,8 @@ function TemplateEditorPage(props) {
71
74
  return /* @__PURE__ */ React.createElement(Page, { themeId: "home" }, /* @__PURE__ */ React.createElement(
72
75
  Header,
73
76
  {
74
- title: "Template Editor",
75
- subtitle: "Edit, preview, and try out templates and template forms"
77
+ title: t("templateEditorPage.title"),
78
+ subtitle: t("templateEditorPage.subtitle")
76
79
  },
77
80
  /* @__PURE__ */ React.createElement(ScaffolderPageContextMenu, { ...scaffolderPageContextMenuProps })
78
81
  ), content);
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateEditorPage.esm.js","sources":["../../../src/next/TemplateEditorPage/TemplateEditorPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useState } from 'react';\nimport { Content, Header, Page } from '@backstage/core-components';\nimport {\n TemplateDirectoryAccess,\n WebFileSystemAccess,\n} from '../../lib/filesystem';\nimport { CustomFieldExplorer } from './CustomFieldExplorer';\nimport { TemplateEditor } from './TemplateEditor';\nimport { TemplateFormPreviewer } from './TemplateFormPreviewer';\nimport {\n FieldExtensionOptions,\n type LayoutOptions,\n} from '@backstage/plugin-scaffolder-react';\nimport { TemplateEditorIntro } from './TemplateEditorIntro';\nimport { ScaffolderPageContextMenu } from '@backstage/plugin-scaffolder-react/alpha';\nimport { useNavigate } from 'react-router-dom';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport {\n actionsRouteRef,\n rootRouteRef,\n scaffolderListTaskRouteRef,\n} from '../../routes';\n\ntype Selection =\n | {\n type: 'local';\n directory: TemplateDirectoryAccess;\n }\n | {\n type: 'form';\n }\n | {\n type: 'field-explorer';\n };\n\ninterface TemplateEditorPageProps {\n defaultPreviewTemplate?: string;\n customFieldExtensions?: FieldExtensionOptions<any, any>[];\n layouts?: LayoutOptions[];\n}\n\nexport function TemplateEditorPage(props: TemplateEditorPageProps) {\n const [selection, setSelection] = useState<Selection>();\n const navigate = useNavigate();\n const actionsLink = useRouteRef(actionsRouteRef);\n const tasksLink = useRouteRef(scaffolderListTaskRouteRef);\n const createLink = useRouteRef(rootRouteRef);\n\n const scaffolderPageContextMenuProps = {\n onEditorClicked: undefined,\n onActionsClicked: () => navigate(actionsLink()),\n onTasksClicked: () => navigate(tasksLink()),\n onCreateClicked: () => navigate(createLink()),\n };\n\n let content: JSX.Element | null = null;\n if (selection?.type === 'local') {\n content = (\n <TemplateEditor\n directory={selection.directory}\n fieldExtensions={props.customFieldExtensions}\n onClose={() => setSelection(undefined)}\n layouts={props.layouts}\n />\n );\n } else if (selection?.type === 'form') {\n content = (\n <TemplateFormPreviewer\n defaultPreviewTemplate={props.defaultPreviewTemplate}\n customFieldExtensions={props.customFieldExtensions}\n onClose={() => setSelection(undefined)}\n layouts={props.layouts}\n />\n );\n } else if (selection?.type === 'field-explorer') {\n content = (\n <CustomFieldExplorer\n customFieldExtensions={props.customFieldExtensions}\n onClose={() => setSelection(undefined)}\n />\n );\n } else {\n content = (\n <Content>\n <TemplateEditorIntro\n onSelect={option => {\n if (option === 'local') {\n WebFileSystemAccess.requestDirectoryAccess()\n .then(directory => setSelection({ type: 'local', directory }))\n .catch(() => {});\n } else if (option === 'form') {\n setSelection({ type: 'form' });\n } else if (option === 'field-explorer') {\n setSelection({ type: 'field-explorer' });\n }\n }}\n />\n </Content>\n );\n }\n\n return (\n <Page themeId=\"home\">\n <Header\n title=\"Template Editor\"\n subtitle=\"Edit, preview, and try out templates and template forms\"\n >\n <ScaffolderPageContextMenu {...scaffolderPageContextMenuProps} />\n </Header>\n {content}\n </Page>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAwDO,SAAS,mBAAmB,KAAgC,EAAA;AACjE,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,QAAoB,EAAA,CAAA;AACtD,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAM,MAAA,WAAA,GAAc,YAAY,eAAe,CAAA,CAAA;AAC/C,EAAM,MAAA,SAAA,GAAY,YAAY,0BAA0B,CAAA,CAAA;AACxD,EAAM,MAAA,UAAA,GAAa,YAAY,YAAY,CAAA,CAAA;AAE3C,EAAA,MAAM,8BAAiC,GAAA;AAAA,IACrC,eAAiB,EAAA,KAAA,CAAA;AAAA,IACjB,gBAAkB,EAAA,MAAM,QAAS,CAAA,WAAA,EAAa,CAAA;AAAA,IAC9C,cAAgB,EAAA,MAAM,QAAS,CAAA,SAAA,EAAW,CAAA;AAAA,IAC1C,eAAiB,EAAA,MAAM,QAAS,CAAA,UAAA,EAAY,CAAA;AAAA,GAC9C,CAAA;AAEA,EAAA,IAAI,OAA8B,GAAA,IAAA,CAAA;AAClC,EAAI,IAAA,SAAA,EAAW,SAAS,OAAS,EAAA;AAC/B,IACE,OAAA,mBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,WAAW,SAAU,CAAA,SAAA;AAAA,QAC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,EAAQ,CAAA,CAAA;AAAA,WAC/B,MAAA,IAAW,WAAW,gBAAkB,EAAA;AACtC,YAAa,YAAA,CAAA,EAAE,IAAM,EAAA,gBAAA,EAAkB,CAAA,CAAA;AAAA,WACzC;AAAA,SACF;AAAA,OAAA;AAAA,KAEJ,CAAA,CAAA;AAAA,GAEJ;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,OAAA,EAAQ,MACZ,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,KAAM,EAAA,iBAAA;AAAA,MACN,QAAS,EAAA,yDAAA;AAAA,KAAA;AAAA,oBAET,KAAA,CAAA,aAAA,CAAC,yBAA2B,EAAA,EAAA,GAAG,8BAAgC,EAAA,CAAA;AAAA,KAEhE,OACH,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TemplateEditorPage.esm.js","sources":["../../../src/next/TemplateEditorPage/TemplateEditorPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useState } from 'react';\nimport { Content, Header, Page } from '@backstage/core-components';\nimport {\n TemplateDirectoryAccess,\n WebFileSystemAccess,\n} from '../../lib/filesystem';\nimport { CustomFieldExplorer } from './CustomFieldExplorer';\nimport { TemplateEditor } from './TemplateEditor';\nimport { TemplateFormPreviewer } from './TemplateFormPreviewer';\nimport {\n FieldExtensionOptions,\n type LayoutOptions,\n} from '@backstage/plugin-scaffolder-react';\nimport { TemplateEditorIntro } from './TemplateEditorIntro';\nimport { ScaffolderPageContextMenu } from '@backstage/plugin-scaffolder-react/alpha';\nimport { useNavigate } from 'react-router-dom';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport {\n actionsRouteRef,\n rootRouteRef,\n scaffolderListTaskRouteRef,\n} from '../../routes';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../translation';\n\ntype Selection =\n | {\n type: 'local';\n directory: TemplateDirectoryAccess;\n }\n | {\n type: 'form';\n }\n | {\n type: 'field-explorer';\n };\n\ninterface TemplateEditorPageProps {\n defaultPreviewTemplate?: string;\n customFieldExtensions?: FieldExtensionOptions<any, any>[];\n layouts?: LayoutOptions[];\n}\n\nexport function TemplateEditorPage(props: TemplateEditorPageProps) {\n const [selection, setSelection] = useState<Selection>();\n const navigate = useNavigate();\n const actionsLink = useRouteRef(actionsRouteRef);\n const tasksLink = useRouteRef(scaffolderListTaskRouteRef);\n const createLink = useRouteRef(rootRouteRef);\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const scaffolderPageContextMenuProps = {\n onEditorClicked: undefined,\n onActionsClicked: () => navigate(actionsLink()),\n onTasksClicked: () => navigate(tasksLink()),\n onCreateClicked: () => navigate(createLink()),\n };\n\n let content: JSX.Element | null = null;\n if (selection?.type === 'local') {\n content = (\n <TemplateEditor\n directory={selection.directory}\n fieldExtensions={props.customFieldExtensions}\n onClose={() => setSelection(undefined)}\n layouts={props.layouts}\n />\n );\n } else if (selection?.type === 'form') {\n content = (\n <TemplateFormPreviewer\n defaultPreviewTemplate={props.defaultPreviewTemplate}\n customFieldExtensions={props.customFieldExtensions}\n onClose={() => setSelection(undefined)}\n layouts={props.layouts}\n />\n );\n } else if (selection?.type === 'field-explorer') {\n content = (\n <CustomFieldExplorer\n customFieldExtensions={props.customFieldExtensions}\n onClose={() => setSelection(undefined)}\n />\n );\n } else {\n content = (\n <Content>\n <TemplateEditorIntro\n onSelect={option => {\n if (option === 'local') {\n WebFileSystemAccess.requestDirectoryAccess()\n .then(directory => setSelection({ type: 'local', directory }))\n .catch(() => {});\n } else if (option === 'form') {\n setSelection({ type: 'form' });\n } else if (option === 'field-explorer') {\n setSelection({ type: 'field-explorer' });\n }\n }}\n />\n </Content>\n );\n }\n\n return (\n <Page themeId=\"home\">\n <Header\n title={t('templateEditorPage.title')}\n subtitle={t('templateEditorPage.subtitle')}\n >\n <ScaffolderPageContextMenu {...scaffolderPageContextMenuProps} />\n </Header>\n {content}\n </Page>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA0DO,SAAS,mBAAmB,KAAgC,EAAA;AACjE,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,QAAoB,EAAA,CAAA;AACtD,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAM,MAAA,WAAA,GAAc,YAAY,eAAe,CAAA,CAAA;AAC/C,EAAM,MAAA,SAAA,GAAY,YAAY,0BAA0B,CAAA,CAAA;AACxD,EAAM,MAAA,UAAA,GAAa,YAAY,YAAY,CAAA,CAAA;AAC3C,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AAExD,EAAA,MAAM,8BAAiC,GAAA;AAAA,IACrC,eAAiB,EAAA,KAAA,CAAA;AAAA,IACjB,gBAAkB,EAAA,MAAM,QAAS,CAAA,WAAA,EAAa,CAAA;AAAA,IAC9C,cAAgB,EAAA,MAAM,QAAS,CAAA,SAAA,EAAW,CAAA;AAAA,IAC1C,eAAiB,EAAA,MAAM,QAAS,CAAA,UAAA,EAAY,CAAA;AAAA,GAC9C,CAAA;AAEA,EAAA,IAAI,OAA8B,GAAA,IAAA,CAAA;AAClC,EAAI,IAAA,SAAA,EAAW,SAAS,OAAS,EAAA;AAC/B,IACE,OAAA,mBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,WAAW,SAAU,CAAA,SAAA;AAAA,QACrB,iBAAiB,KAAM,CA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AAAA,WAC/B,MAAA,IAAW,WAAW,gBAAkB,EAAA;AACtC,YAAa,YAAA,CAAA,EAAE,IAAM,EAAA,gBAAA,EAAkB,CAAA,CAAA;AAAA,WACzC;AAAA,SACF;AAAA,OAAA;AAAA,KAEJ,CAAA,CAAA;AAAA,GAEJ;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,OAAA,EAAQ,MACZ,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,0BAA0B,CAAA;AAAA,MACnC,QAAA,EAAU,EAAE,6BAA6B,CAAA;AAAA,KAAA;AAAA,oBAEzC,KAAA,CAAA,aAAA,CAAC,yBAA2B,EAAA,EAAA,GAAG,8BAAgC,EAAA,CAAA;AAAA,KAEhE,OACH,CAAA,CAAA;AAEJ;;;;"}
@@ -11,6 +11,8 @@ import { useKeyboardEvent } from '@react-hookz/web';
11
11
  import CodeMirror from '@uiw/react-codemirror';
12
12
  import React, { useMemo } from 'react';
13
13
  import { useDirectoryEditor } from './DirectoryEditorContext.esm.js';
14
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
15
+ import { scaffolderTranslationRef } from '../../translation.esm.js';
14
16
 
15
17
  const useStyles = makeStyles((theme) => ({
16
18
  container: {
@@ -42,6 +44,7 @@ const useStyles = makeStyles((theme) => ({
42
44
  function TemplateEditorTextArea(props) {
43
45
  const { errorText } = props;
44
46
  const classes = useStyles();
47
+ const { t } = useTranslationRef(scaffolderTranslationRef);
45
48
  const panelExtension = useMemo(() => {
46
49
  if (!errorText) {
47
50
  return showPanel.of(null);
@@ -70,21 +73,37 @@ function TemplateEditorTextArea(props) {
70
73
  value: props.content,
71
74
  onChange: props.onUpdate
72
75
  }
73
- ), (props.onSave || props.onReload) && /* @__PURE__ */ React.createElement("div", { className: classes.floatingButtons }, /* @__PURE__ */ React.createElement(Paper, null, props.onSave && /* @__PURE__ */ React.createElement(Tooltip, { title: "Save file" }, /* @__PURE__ */ React.createElement(
74
- IconButton,
76
+ ), (props.onSave || props.onReload) && /* @__PURE__ */ React.createElement("div", { className: classes.floatingButtons }, /* @__PURE__ */ React.createElement(Paper, null, props.onSave && /* @__PURE__ */ React.createElement(
77
+ Tooltip,
75
78
  {
76
- className: classes.floatingButton,
77
- onClick: () => props.onSave?.()
79
+ title: t(
80
+ "templateEditorPage.templateEditorTextArea.saveIconTooltip"
81
+ )
78
82
  },
79
- /* @__PURE__ */ React.createElement(SaveIcon, null)
80
- )), props.onReload && /* @__PURE__ */ React.createElement(Tooltip, { title: "Reload file" }, /* @__PURE__ */ React.createElement(
81
- IconButton,
83
+ /* @__PURE__ */ React.createElement(
84
+ IconButton,
85
+ {
86
+ className: classes.floatingButton,
87
+ onClick: () => props.onSave?.()
88
+ },
89
+ /* @__PURE__ */ React.createElement(SaveIcon, null)
90
+ )
91
+ ), props.onReload && /* @__PURE__ */ React.createElement(
92
+ Tooltip,
82
93
  {
83
- className: classes.floatingButton,
84
- onClick: () => props.onReload?.()
94
+ title: t(
95
+ "templateEditorPage.templateEditorTextArea.refreshIconTooltip"
96
+ )
85
97
  },
86
- /* @__PURE__ */ React.createElement(RefreshIcon, null)
87
- )))));
98
+ /* @__PURE__ */ React.createElement(
99
+ IconButton,
100
+ {
101
+ className: classes.floatingButton,
102
+ onClick: () => props.onReload?.()
103
+ },
104
+ /* @__PURE__ */ React.createElement(RefreshIcon, null)
105
+ )
106
+ ))));
88
107
  }
89
108
  function TemplateEditorDirectoryEditorTextArea(props) {
90
109
  const directoryEditor = useDirectoryEditor();
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateEditorTextArea.esm.js","sources":["../../../src/next/TemplateEditorPage/TemplateEditorTextArea.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { StreamLanguage } from '@codemirror/language';\nimport { yaml as yamlSupport } from '@codemirror/legacy-modes/mode/yaml';\nimport { showPanel } from '@codemirror/view';\nimport IconButton from '@material-ui/core/IconButton';\nimport Paper from '@material-ui/core/Paper';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { makeStyles } from '@material-ui/core/styles';\nimport RefreshIcon from '@material-ui/icons/Refresh';\nimport SaveIcon from '@material-ui/icons/Save';\nimport { useKeyboardEvent } from '@react-hookz/web';\nimport CodeMirror from '@uiw/react-codemirror';\nimport React, { useMemo } from 'react';\nimport { useDirectoryEditor } from './DirectoryEditorContext';\n\nconst useStyles = makeStyles(theme => ({\n container: {\n position: 'relative',\n width: '100%',\n height: '100%',\n },\n codeMirror: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n errorPanel: {\n color: theme.palette.error.main,\n lineHeight: 2,\n margin: theme.spacing(0, 1),\n },\n floatingButtons: {\n position: 'absolute',\n top: theme.spacing(1),\n right: theme.spacing(3),\n },\n floatingButton: {\n padding: theme.spacing(1),\n },\n}));\n\n/** A wrapper around CodeMirror with an error panel and extra actions available */\nexport function TemplateEditorTextArea(props: {\n content?: string;\n onUpdate?: (content: string) => void;\n errorText?: string;\n onSave?: () => void;\n onReload?: () => void;\n}) {\n const { errorText } = props;\n const classes = useStyles();\n\n const panelExtension = useMemo(() => {\n if (!errorText) {\n return showPanel.of(null);\n }\n\n const dom = document.createElement('div');\n dom.classList.add(classes.errorPanel);\n dom.textContent = errorText;\n return showPanel.of(() => ({ dom, bottom: true }));\n }, [classes, errorText]);\n\n useKeyboardEvent(\n e => e.key === 's' && (e.ctrlKey || e.metaKey),\n e => {\n e.preventDefault();\n if (props.onSave) {\n props.onSave();\n }\n },\n );\n\n return (\n <div className={classes.container}>\n <CodeMirror\n className={classes.codeMirror}\n theme=\"dark\"\n height=\"100%\"\n extensions={[StreamLanguage.define(yamlSupport), panelExtension]}\n value={props.content}\n onChange={props.onUpdate}\n />\n {(props.onSave || props.onReload) && (\n <div className={classes.floatingButtons}>\n <Paper>\n {props.onSave && (\n <Tooltip title=\"Save file\">\n <IconButton\n className={classes.floatingButton}\n onClick={() => props.onSave?.()}\n >\n <SaveIcon />\n </IconButton>\n </Tooltip>\n )}\n {props.onReload && (\n <Tooltip title=\"Reload file\">\n <IconButton\n className={classes.floatingButton}\n onClick={() => props.onReload?.()}\n >\n <RefreshIcon />\n </IconButton>\n </Tooltip>\n )}\n </Paper>\n </div>\n )}\n </div>\n );\n}\n\n/** A version of the TemplateEditorTextArea that is connected to the DirectoryEditor context */\nexport function TemplateEditorDirectoryEditorTextArea(props: {\n errorText?: string;\n}) {\n const directoryEditor = useDirectoryEditor();\n\n const actions = directoryEditor.selectedFile?.dirty\n ? {\n onSave: () => directoryEditor.save(),\n onReload: () => directoryEditor.reload(),\n }\n : {\n onReload: () => directoryEditor.reload(),\n };\n\n return (\n <TemplateEditorTextArea\n errorText={props.errorText}\n content={directoryEditor.selectedFile?.content}\n onUpdate={content => directoryEditor.selectedFile?.updateContent(content)}\n {...actions}\n />\n );\n}\n\nTemplateEditorTextArea.DirectoryEditor = TemplateEditorDirectoryEditorTextArea;\n"],"names":["yamlSupport"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,SAAW,EAAA;AAAA,IACT,QAAU,EAAA,UAAA;AAAA,IACV,KAAO,EAAA,MAAA;AAAA,IACP,MAAQ,EAAA,MAAA;AAAA,GACV;AAAA,EACA,UAAY,EAAA;AAAA,IACV,QAAU,EAAA,UAAA;AAAA,IACV,GAAK,EAAA,CAAA;AAAA,IACL,MAAQ,EAAA,CAAA;AAAA,IACR,IAAM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AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,WAAW,OAAQ,CAAA,cAAA;AAAA,MACnB,OAAA,EAAS,MAAM,KAAA,CAAM,QAAW,IAAA;AAAA,KAAA;AAAA,wCAE/B,WAAY,EAAA,IAAA,CAAA;AAAA,GAEjB,CAEJ,CACF,CAEJ,CAAA,CAAA;AAEJ,CAAA;AAGO,SAAS,sCAAsC,KAEnD,EAAA;AACD,EAAA,MAAM,kBAAkB,kBAAmB,EAAA,CAAA;AAE3C,EAAM,MAAA,OAAA,GAAU,eAAgB,CAAA,YAAA,EAAc,KAC1C,GAAA;AAAA,IACE,MAAA,EAAQ,MAAM,eAAA,CAAgB,IAAK,EAAA;AAAA,IACnC,QAAA,EAAU,MAAM,eAAA,CAAgB,MAAO,EAAA;AAAA,GAEzC,GAAA;AAAA,IACE,QAAA,EAAU,MAAM,eAAA,CAAgB,MAAO,EAAA;AAAA,GACzC,CAAA;AAEJ,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,sBAAA;AAAA,IAAA;AAAA,MACC,WAAW,KAAM,CAAA,SAAA;AAAA,MACjB,OAAA,EAAS,gBAAgB,YAAc,EAAA,OAAA;AAAA,MACvC,QAAU,EAAA,CAAA,OAAA,KAAW,eAAgB,CAAA,YAAA,EAAc,cAAc,OAAO,CAAA;AAAA,MACvE,GAAG,OAAA;AAAA,KAAA;AAAA,GACN,CAAA;AAEJ,CAAA;AAEA,sBAAA,CAAuB,eAAkB,GAAA,qCAAA;;;;"}
1
+ {"version":3,"file":"TemplateEditorTextArea.esm.js","sources":["../../../src/next/TemplateEditorPage/TemplateEditorTextArea.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { StreamLanguage } from '@codemirror/language';\nimport { yaml as yamlSupport } from '@codemirror/legacy-modes/mode/yaml';\nimport { showPanel } from '@codemirror/view';\nimport IconButton from '@material-ui/core/IconButton';\nimport Paper from '@material-ui/core/Paper';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { makeStyles } from '@material-ui/core/styles';\nimport RefreshIcon from '@material-ui/icons/Refresh';\nimport SaveIcon from '@material-ui/icons/Save';\nimport { useKeyboardEvent } from '@react-hookz/web';\nimport CodeMirror from '@uiw/react-codemirror';\nimport React, { useMemo } from 'react';\nimport { useDirectoryEditor } from './DirectoryEditorContext';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../translation';\n\nconst useStyles = makeStyles(theme => ({\n container: {\n position: 'relative',\n width: '100%',\n height: '100%',\n },\n codeMirror: {\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n },\n errorPanel: {\n color: theme.palette.error.main,\n lineHeight: 2,\n margin: theme.spacing(0, 1),\n },\n floatingButtons: {\n position: 'absolute',\n top: theme.spacing(1),\n right: theme.spacing(3),\n },\n floatingButton: {\n padding: theme.spacing(1),\n },\n}));\n\n/** A wrapper around CodeMirror with an error panel and extra actions available */\nexport function TemplateEditorTextArea(props: {\n content?: string;\n onUpdate?: (content: string) => void;\n errorText?: string;\n onSave?: () => void;\n onReload?: () => void;\n}) {\n const { errorText } = props;\n const classes = useStyles();\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const panelExtension = useMemo(() => {\n if (!errorText) {\n return showPanel.of(null);\n }\n\n const dom = document.createElement('div');\n dom.classList.add(classes.errorPanel);\n dom.textContent = errorText;\n return showPanel.of(() => ({ dom, bottom: true }));\n }, [classes, errorText]);\n\n useKeyboardEvent(\n e => e.key === 's' && (e.ctrlKey || e.metaKey),\n e => {\n e.preventDefault();\n if (props.onSave) {\n props.onSave();\n }\n },\n );\n\n return (\n <div className={classes.container}>\n <CodeMirror\n className={classes.codeMirror}\n theme=\"dark\"\n height=\"100%\"\n extensions={[StreamLanguage.define(yamlSupport), panelExtension]}\n value={props.content}\n onChange={props.onUpdate}\n />\n {(props.onSave || props.onReload) && (\n <div className={classes.floatingButtons}>\n <Paper>\n {props.onSave && (\n <Tooltip\n title={t(\n 'templateEditorPage.templateEditorTextArea.saveIconTooltip',\n )}\n >\n <IconButton\n className={classes.floatingButton}\n onClick={() => props.onSave?.()}\n >\n <SaveIcon />\n </IconButton>\n </Tooltip>\n )}\n {props.onReload && (\n <Tooltip\n title={t(\n 'templateEditorPage.templateEditorTextArea.refreshIconTooltip',\n )}\n >\n <IconButton\n className={classes.floatingButton}\n onClick={() => props.onReload?.()}\n >\n <RefreshIcon />\n </IconButton>\n </Tooltip>\n )}\n </Paper>\n </div>\n )}\n </div>\n );\n}\n\n/** A version of the TemplateEditorTextArea that is connected to the DirectoryEditor context */\nexport function TemplateEditorDirectoryEditorTextArea(props: {\n errorText?: string;\n}) {\n const directoryEditor = useDirectoryEditor();\n\n const actions = directoryEditor.selectedFile?.dirty\n ? {\n onSave: () => directoryEditor.save(),\n onReload: () => directoryEditor.reload(),\n }\n : {\n onReload: () => directoryEditor.reload(),\n };\n\n return (\n <TemplateEditorTextArea\n errorText={props.errorText}\n content={directoryEditor.selectedFile?.content}\n onUpdate={content => directoryEditor.selectedFile?.updateContent(content)}\n {...actions}\n />\n );\n}\n\nTemplateEditorTextArea.DirectoryEditor = TemplateEditorDirectoryEditorTextArea;\n"],"names":["yamlSupport"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,SAAW,EAAA;AAAA,IACT,QAAU,EAAA,UAAA;AAAA,IACV,KAAO,EAAA,MAAA;AAAA,IACP,MAAQ,EAAA,MAAA;AAAA,GACV;AAAA,EACA,UAAY,E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;AAAA,GACN,CAAA;AAEJ,CAAA;AAEA,sBAAA,CAAuB,eAAkB,GAAA,qCAAA;;;;"}
@@ -13,6 +13,8 @@ import useAsync from 'react-use/esm/useAsync';
13
13
  import yaml from 'yaml';
14
14
  import { TemplateEditorForm } from './TemplateEditorForm.esm.js';
15
15
  import { TemplateEditorTextArea } from './TemplateEditorTextArea.esm.js';
16
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
17
+ import { scaffolderTranslationRef } from '../../translation.esm.js';
16
18
 
17
19
  const EXAMPLE_TEMPLATE_PARAMS_YAML = `# Edit the template parameters below to see how they will render in the scaffolder form UI
18
20
  parameters:
@@ -84,6 +86,7 @@ const TemplateFormPreviewer = ({
84
86
  layouts = []
85
87
  }) => {
86
88
  const classes = useStyles();
89
+ const { t } = useTranslationRef(scaffolderTranslationRef);
87
90
  const alertApi = useApi(alertApiRef);
88
91
  const catalogApi = useApi(catalogApiRef);
89
92
  const [selectedTemplate, setSelectedTemplate] = useState("");
@@ -125,11 +128,11 @@ const TemplateFormPreviewer = ({
125
128
  },
126
129
  [setTemplateYaml]
127
130
  );
128
- return /* @__PURE__ */ React.createElement(React.Fragment, null, loading && /* @__PURE__ */ React.createElement(LinearProgress, null), /* @__PURE__ */ React.createElement("main", { className: classes.root }, /* @__PURE__ */ React.createElement("div", { className: classes.controls }, /* @__PURE__ */ React.createElement(FormControl, { variant: "outlined", size: "small", fullWidth: true }, /* @__PURE__ */ React.createElement(InputLabel, { id: "select-template-label" }, "Load Existing Template"), /* @__PURE__ */ React.createElement(
131
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, loading && /* @__PURE__ */ React.createElement(LinearProgress, null), /* @__PURE__ */ React.createElement("main", { className: classes.root }, /* @__PURE__ */ React.createElement("div", { className: classes.controls }, /* @__PURE__ */ React.createElement(FormControl, { variant: "outlined", size: "small", fullWidth: true }, /* @__PURE__ */ React.createElement(InputLabel, { id: "select-template-label" }, t("templateEditorPage.templateFormPreviewer.title")), /* @__PURE__ */ React.createElement(
129
132
  Select,
130
133
  {
131
134
  value: selectedTemplate,
132
- label: "Load Existing Template",
135
+ label: t("templateEditorPage.templateFormPreviewer.title"),
133
136
  labelId: "select-template-label",
134
137
  onChange: (e) => handleSelectChange(e.target.value)
135
138
  },
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateFormPreviewer.esm.js","sources":["../../../src/next/TemplateEditorPage/TemplateFormPreviewer.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Entity } from '@backstage/catalog-model';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n catalogApiRef,\n humanizeEntityRef,\n} from '@backstage/plugin-catalog-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport IconButton from '@material-ui/core/IconButton';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport LinearProgress from '@material-ui/core/LinearProgress';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { makeStyles } from '@material-ui/core/styles';\nimport CloseIcon from '@material-ui/icons/Close';\nimport React, { useCallback, useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport yaml from 'yaml';\nimport {\n LayoutOptions,\n FieldExtensionOptions,\n} from '@backstage/plugin-scaffolder-react';\nimport { TemplateEditorForm } from './TemplateEditorForm';\nimport { TemplateEditorTextArea } from './TemplateEditorTextArea';\n\nconst EXAMPLE_TEMPLATE_PARAMS_YAML = `# Edit the template parameters below to see how they will render in the scaffolder form UI\nparameters:\n - title: Fill in some steps\n required:\n - name\n properties:\n name:\n title: Name\n type: string\n description: Unique name of the component\n owner:\n title: Owner\n type: string\n description: Owner of the component\n ui:field: OwnerPicker\n ui:options:\n catalogFilter:\n kind: Group\n - title: Choose a location\n required:\n - repoUrl\n properties:\n repoUrl:\n title: Repository Location\n type: string\n ui:field: RepoUrlPicker\n ui:options:\n allowedHosts:\n - github.com\nsteps:\n - id: fetch-base\n name: Fetch Base\n action: fetch:template\n input:\n url: ./template\n values:\n name: \\${{parameters.name}}\n`;\n\ntype TemplateOption = {\n label: string;\n value: Entity;\n};\n\nconst useStyles = makeStyles(theme => ({\n root: {\n gridArea: 'pageContent',\n display: 'grid',\n gridTemplateAreas: `\n \"controls controls\"\n \"textArea preview\"\n `,\n gridTemplateRows: 'auto 1fr',\n gridTemplateColumns: '1fr 1fr',\n },\n controls: {\n gridArea: 'controls',\n display: 'flex',\n flexFlow: 'row nowrap',\n alignItems: 'center',\n margin: theme.spacing(1),\n },\n textArea: {\n gridArea: 'textArea',\n },\n preview: {\n gridArea: 'preview',\n },\n}));\n\nexport const TemplateFormPreviewer = ({\n defaultPreviewTemplate = EXAMPLE_TEMPLATE_PARAMS_YAML,\n customFieldExtensions = [],\n onClose,\n layouts = [],\n}: {\n defaultPreviewTemplate?: string;\n customFieldExtensions?: FieldExtensionOptions<any, any>[];\n onClose?: () => void;\n layouts?: LayoutOptions[];\n}) => {\n const classes = useStyles();\n const alertApi = useApi(alertApiRef);\n const catalogApi = useApi(catalogApiRef);\n const [selectedTemplate, setSelectedTemplate] = useState('');\n const [errorText, setErrorText] = useState<string>();\n const [templateOptions, setTemplateOptions] = useState<TemplateOption[]>([]);\n const [templateYaml, setTemplateYaml] = useState(defaultPreviewTemplate);\n\n const { loading } = useAsync(\n () =>\n catalogApi\n .getEntities({\n filter: { kind: 'template' },\n fields: [\n 'kind',\n 'metadata.namespace',\n 'metadata.name',\n 'metadata.title',\n 'spec.parameters',\n 'spec.steps',\n 'spec.output',\n ],\n })\n .then(({ items }) =>\n setTemplateOptions(\n items.map(template => ({\n label:\n template.metadata.title ??\n humanizeEntityRef(template, { defaultKind: 'template' }),\n value: template,\n })),\n ),\n )\n .catch(e =>\n alertApi.post({\n message: `Error loading exisiting templates: ${e.message}`,\n severity: 'error',\n }),\n ),\n [catalogApi],\n );\n\n const handleSelectChange = useCallback(\n // TODO(Rugvip): Afaik this should be Entity, but didn't want to make runtime changes while fixing types\n (selected: any) => {\n setSelectedTemplate(selected);\n setTemplateYaml(yaml.stringify(selected.spec));\n },\n [setTemplateYaml],\n );\n\n return (\n <>\n {loading && <LinearProgress />}\n <main className={classes.root}>\n <div className={classes.controls}>\n <FormControl variant=\"outlined\" size=\"small\" fullWidth>\n <InputLabel id=\"select-template-label\">\n Load Existing Template\n </InputLabel>\n <Select\n value={selectedTemplate}\n label=\"Load Existing Template\"\n labelId=\"select-template-label\"\n onChange={e => handleSelectChange(e.target.value)}\n >\n {templateOptions.map((option, idx) => (\n <MenuItem key={idx} value={option.value as any}>\n {option.label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n <IconButton size=\"medium\" onClick={onClose}>\n <CloseIcon />\n </IconButton>\n </div>\n <div className={classes.textArea}>\n <TemplateEditorTextArea\n content={templateYaml}\n onUpdate={setTemplateYaml}\n errorText={errorText}\n />\n </div>\n <div className={classes.preview}>\n <TemplateEditorForm\n content={templateYaml}\n contentIsSpec\n fieldExtensions={customFieldExtensions}\n setErrorText={setErrorText}\n layouts={layouts}\n />\n </div>\n </main>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAM,4BAA+B,GAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA,CAAA;AA4CrC,MAAM,SAAA,GAAY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AAA;AAAA,GAEJ,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAW,QAAQ,OACtB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,YAAA;AAAA,MACT,aAAa,EAAA,IAAA;AAAA,MACb,eAAiB,EAAA,qBAAA;AAAA,MACjB,YAAA;AAAA,MACA,OAAA;AAAA,KAAA;AAAA,GAEJ,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TemplateFormPreviewer.esm.js","sources":["../../../src/next/TemplateEditorPage/TemplateFormPreviewer.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Entity } from '@backstage/catalog-model';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport {\n catalogApiRef,\n humanizeEntityRef,\n} from '@backstage/plugin-catalog-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport IconButton from '@material-ui/core/IconButton';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport LinearProgress from '@material-ui/core/LinearProgress';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { makeStyles } from '@material-ui/core/styles';\nimport CloseIcon from '@material-ui/icons/Close';\nimport React, { useCallback, useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport yaml from 'yaml';\nimport {\n LayoutOptions,\n FieldExtensionOptions,\n} from '@backstage/plugin-scaffolder-react';\nimport { TemplateEditorForm } from './TemplateEditorForm';\nimport { TemplateEditorTextArea } from './TemplateEditorTextArea';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../translation';\n\nconst EXAMPLE_TEMPLATE_PARAMS_YAML = `# Edit the template parameters below to see how they will render in the scaffolder form UI\nparameters:\n - title: Fill in some steps\n required:\n - name\n properties:\n name:\n title: Name\n type: string\n description: Unique name of the component\n owner:\n title: Owner\n type: string\n description: Owner of the component\n ui:field: OwnerPicker\n ui:options:\n catalogFilter:\n kind: Group\n - title: Choose a location\n required:\n - repoUrl\n properties:\n repoUrl:\n title: Repository Location\n type: string\n ui:field: RepoUrlPicker\n ui:options:\n allowedHosts:\n - github.com\nsteps:\n - id: fetch-base\n name: Fetch Base\n action: fetch:template\n input:\n url: ./template\n values:\n name: \\${{parameters.name}}\n`;\n\ntype TemplateOption = {\n label: string;\n value: Entity;\n};\n\nconst useStyles = makeStyles(theme => ({\n root: {\n gridArea: 'pageContent',\n display: 'grid',\n gridTemplateAreas: `\n \"controls controls\"\n \"textArea preview\"\n `,\n gridTemplateRows: 'auto 1fr',\n gridTemplateColumns: '1fr 1fr',\n },\n controls: {\n gridArea: 'controls',\n display: 'flex',\n flexFlow: 'row nowrap',\n alignItems: 'center',\n margin: theme.spacing(1),\n },\n textArea: {\n gridArea: 'textArea',\n },\n preview: {\n gridArea: 'preview',\n },\n}));\n\nexport const TemplateFormPreviewer = ({\n defaultPreviewTemplate = EXAMPLE_TEMPLATE_PARAMS_YAML,\n customFieldExtensions = [],\n onClose,\n layouts = [],\n}: {\n defaultPreviewTemplate?: string;\n customFieldExtensions?: FieldExtensionOptions<any, any>[];\n onClose?: () => void;\n layouts?: LayoutOptions[];\n}) => {\n const classes = useStyles();\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const alertApi = useApi(alertApiRef);\n const catalogApi = useApi(catalogApiRef);\n const [selectedTemplate, setSelectedTemplate] = useState('');\n const [errorText, setErrorText] = useState<string>();\n const [templateOptions, setTemplateOptions] = useState<TemplateOption[]>([]);\n const [templateYaml, setTemplateYaml] = useState(defaultPreviewTemplate);\n\n const { loading } = useAsync(\n () =>\n catalogApi\n .getEntities({\n filter: { kind: 'template' },\n fields: [\n 'kind',\n 'metadata.namespace',\n 'metadata.name',\n 'metadata.title',\n 'spec.parameters',\n 'spec.steps',\n 'spec.output',\n ],\n })\n .then(({ items }) =>\n setTemplateOptions(\n items.map(template => ({\n label:\n template.metadata.title ??\n humanizeEntityRef(template, { defaultKind: 'template' }),\n value: template,\n })),\n ),\n )\n .catch(e =>\n alertApi.post({\n message: `Error loading exisiting templates: ${e.message}`,\n severity: 'error',\n }),\n ),\n [catalogApi],\n );\n\n const handleSelectChange = useCallback(\n // TODO(Rugvip): Afaik this should be Entity, but didn't want to make runtime changes while fixing types\n (selected: any) => {\n setSelectedTemplate(selected);\n setTemplateYaml(yaml.stringify(selected.spec));\n },\n [setTemplateYaml],\n );\n\n return (\n <>\n {loading && <LinearProgress />}\n <main className={classes.root}>\n <div className={classes.controls}>\n <FormControl variant=\"outlined\" size=\"small\" fullWidth>\n <InputLabel id=\"select-template-label\">\n {t('templateEditorPage.templateFormPreviewer.title')}\n </InputLabel>\n <Select\n value={selectedTemplate}\n label={t('templateEditorPage.templateFormPreviewer.title')}\n labelId=\"select-template-label\"\n onChange={e => handleSelectChange(e.target.value)}\n >\n {templateOptions.map((option, idx) => (\n <MenuItem key={idx} value={option.value as any}>\n {option.label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n\n <IconButton size=\"medium\" onClick={onClose}>\n <CloseIcon />\n </IconButton>\n </div>\n <div className={classes.textArea}>\n <TemplateEditorTextArea\n content={templateYaml}\n onUpdate={setTemplateYaml}\n errorText={errorText}\n />\n </div>\n <div className={classes.preview}>\n <TemplateEditorForm\n content={templateYaml}\n contentIsSpec\n fieldExtensions={customFieldExtensions}\n setErrorText={setErrorText}\n layouts={layouts}\n />\n </div>\n </main>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;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EAAA,MAAA,CAAO,KACV,CACD,CAAA;AAAA,GAEL,CAEA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,IAAA,EAAK,UAAS,OAAS,EAAA,OAAA,EAAA,kBAChC,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,IAAU,CACb,CACF,CAAA,sCACC,KAAI,EAAA,EAAA,SAAA,EAAW,QAAQ,QACtB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,sBAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,YAAA;AAAA,MACT,QAAU,EAAA,eAAA;AAAA,MACV,SAAA;AAAA,KAAA;AAAA,GAEJ,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAW,QAAQ,OACtB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,kBAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,YAAA;AAAA,MACT,aAAa,EAAA,IAAA;AAAA,MACb,eAAiB,EAAA,qBAAA;AAAA,MACjB,YAAA;AAAA,MACA,OAAA;AAAA,KAAA;AAAA,GAEJ,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -7,15 +7,13 @@ import { ScaffolderPageContextMenu, TemplateCategoryPicker, TemplateGroups } fro
7
7
  import { RegisterExistingButton } from './RegisterExistingButton.esm.js';
8
8
  import { registerComponentRouteRef, editRouteRef, actionsRouteRef, scaffolderListTaskRouteRef, viewTechDocRouteRef, selectedTemplateRouteRef } from '../../routes.esm.js';
9
9
  import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';
10
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
11
+ import { scaffolderTranslationRef } from '../../translation.esm.js';
10
12
 
11
- const defaultGroup = {
12
- title: "Templates",
13
- filter: () => true
14
- };
15
- const createGroupsWithOther = (groups) => [
13
+ const createGroupsWithOther = (groups, t) => [
16
14
  ...groups,
17
15
  {
18
- title: "Other Templates",
16
+ title: t("templateListPage.templateGroups.otherTitle"),
19
17
  filter: (e) => ![...groups].some(({ filter }) => filter(e))
20
18
  }
21
19
  ];
@@ -34,7 +32,13 @@ const TemplateListPage = (props) => {
34
32
  const viewTechDocsLink = useRouteRef(viewTechDocRouteRef);
35
33
  const templateRoute = useRouteRef(selectedTemplateRouteRef);
36
34
  const app = useApp();
37
- const groups = givenGroups.length ? createGroupsWithOther(givenGroups) : [defaultGroup];
35
+ const { t } = useTranslationRef(scaffolderTranslationRef);
36
+ const groups = givenGroups.length ? createGroupsWithOther(givenGroups, t) : [
37
+ {
38
+ title: t("templateListPage.templateGroups.defaultTitle"),
39
+ filter: () => true
40
+ }
41
+ ];
38
42
  const scaffolderPageContextMenuProps = {
39
43
  onEditorClicked: props?.contextMenu?.editor !== false ? () => navigate(editorLink()) : void 0,
40
44
  onActionsClicked: props?.contextMenu?.actions !== false ? () => navigate(actionsLink()) : void 0,
@@ -48,12 +52,14 @@ const TemplateListPage = (props) => {
48
52
  return template.metadata.annotations?.["backstage.io/techdocs-ref"] && viewTechDocsLink ? [
49
53
  {
50
54
  icon: app.getSystemIcon("docs") ?? DocsIcon,
51
- text: "View TechDocs",
55
+ text: t(
56
+ "templateListPage.additionalLinksForEntity.viewTechDocsTitle"
57
+ ),
52
58
  url: viewTechDocsLink({ kind, namespace, name })
53
59
  }
54
60
  ] : [];
55
61
  },
56
- [app, viewTechDocsLink]
62
+ [app, viewTechDocsLink, t]
57
63
  );
58
64
  const onTemplateSelected = useCallback(
59
65
  (template) => {
@@ -65,19 +71,21 @@ const TemplateListPage = (props) => {
65
71
  return /* @__PURE__ */ React.createElement(EntityListProvider, null, /* @__PURE__ */ React.createElement(Page, { themeId: "home" }, /* @__PURE__ */ React.createElement(
66
72
  Header,
67
73
  {
68
- pageTitleOverride: "Create a new component",
69
- title: "Create a new component",
70
- subtitle: "Create new software components using standard templates in your organization",
74
+ pageTitleOverride: t("templateListPage.pageTitle"),
75
+ title: t("templateListPage.title"),
76
+ subtitle: t("templateListPage.subtitle"),
71
77
  ...headerOptions
72
78
  },
73
79
  /* @__PURE__ */ React.createElement(ScaffolderPageContextMenu, { ...scaffolderPageContextMenuProps })
74
- ), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(ContentHeader, { title: "Available Templates" }, /* @__PURE__ */ React.createElement(
80
+ ), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(ContentHeader, { title: t("templateListPage.contentHeader.title") }, /* @__PURE__ */ React.createElement(
75
81
  RegisterExistingButton,
76
82
  {
77
- title: "Register Existing Component",
83
+ title: t(
84
+ "templateListPage.contentHeader.registerExistingButtonTitle"
85
+ ),
78
86
  to: registerComponentLink && registerComponentLink()
79
87
  }
80
- ), /* @__PURE__ */ React.createElement(SupportButton, null, "Create new software components using standard templates. Different templates create different kinds of components (services, websites, documentation, ...).")), /* @__PURE__ */ React.createElement(CatalogFilterLayout, null, /* @__PURE__ */ React.createElement(CatalogFilterLayout.Filters, null, /* @__PURE__ */ React.createElement(EntitySearchBar, null), /* @__PURE__ */ React.createElement(EntityKindPicker, { initialFilter: "template", hidden: true }), /* @__PURE__ */ React.createElement(
88
+ ), /* @__PURE__ */ React.createElement(SupportButton, null, t("templateListPage.contentHeader.supportButtonTitle"))), /* @__PURE__ */ React.createElement(CatalogFilterLayout, null, /* @__PURE__ */ React.createElement(CatalogFilterLayout.Filters, null, /* @__PURE__ */ React.createElement(EntitySearchBar, null), /* @__PURE__ */ React.createElement(EntityKindPicker, { initialFilter: "template", hidden: true }), /* @__PURE__ */ React.createElement(
81
89
  UserListPicker,
82
90
  {
83
91
  initialFilter: "all",
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateListPage.esm.js","sources":["../../../src/next/TemplateListPage/TemplateListPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { useApp, useRouteRef } from '@backstage/core-plugin-api';\n\nimport {\n Content,\n ContentHeader,\n DocsIcon,\n Header,\n Page,\n SupportButton,\n} from '@backstage/core-components';\nimport {\n EntityKindPicker,\n EntityListProvider,\n EntitySearchBar,\n EntityTagPicker,\n CatalogFilterLayout,\n UserListPicker,\n} from '@backstage/plugin-catalog-react';\nimport {\n ScaffolderPageContextMenu,\n TemplateCategoryPicker,\n TemplateGroups,\n} from '@backstage/plugin-scaffolder-react/alpha';\n\nimport { RegisterExistingButton } from './RegisterExistingButton';\nimport {\n actionsRouteRef,\n editRouteRef,\n registerComponentRouteRef,\n scaffolderListTaskRouteRef,\n selectedTemplateRouteRef,\n viewTechDocRouteRef,\n} from '../../routes';\nimport { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { TemplateGroupFilter } from '@backstage/plugin-scaffolder-react';\n\n/**\n * @alpha\n */\nexport type TemplateListPageProps = {\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n groups?: TemplateGroupFilter[];\n templateFilter?: (entity: TemplateEntityV1beta3) => boolean;\n contextMenu?: {\n editor?: boolean;\n actions?: boolean;\n tasks?: boolean;\n };\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n};\n\nconst defaultGroup: TemplateGroupFilter = {\n title: 'Templates',\n filter: () => true,\n};\n\nconst createGroupsWithOther = (\n groups: TemplateGroupFilter[],\n): TemplateGroupFilter[] => [\n ...groups,\n {\n title: 'Other Templates',\n filter: e => ![...groups].some(({ filter }) => filter(e)),\n },\n];\n\n/**\n * @alpha\n */\nexport const TemplateListPage = (props: TemplateListPageProps) => {\n const registerComponentLink = useRouteRef(registerComponentRouteRef);\n const {\n TemplateCardComponent,\n groups: givenGroups = [],\n templateFilter,\n headerOptions,\n } = props;\n const navigate = useNavigate();\n const editorLink = useRouteRef(editRouteRef);\n const actionsLink = useRouteRef(actionsRouteRef);\n const tasksLink = useRouteRef(scaffolderListTaskRouteRef);\n const viewTechDocsLink = useRouteRef(viewTechDocRouteRef);\n const templateRoute = useRouteRef(selectedTemplateRouteRef);\n const app = useApp();\n\n const groups = givenGroups.length\n ? createGroupsWithOther(givenGroups)\n : [defaultGroup];\n\n const scaffolderPageContextMenuProps = {\n onEditorClicked:\n props?.contextMenu?.editor !== false\n ? () => navigate(editorLink())\n : undefined,\n onActionsClicked:\n props?.contextMenu?.actions !== false\n ? () => navigate(actionsLink())\n : undefined,\n onTasksClicked:\n props?.contextMenu?.tasks !== false\n ? () => navigate(tasksLink())\n : undefined,\n };\n\n const additionalLinksForEntity = useCallback(\n (template: TemplateEntityV1beta3) => {\n const { kind, namespace, name } = parseEntityRef(\n stringifyEntityRef(template),\n );\n return template.metadata.annotations?.['backstage.io/techdocs-ref'] &&\n viewTechDocsLink\n ? [\n {\n icon: app.getSystemIcon('docs') ?? DocsIcon,\n text: 'View TechDocs',\n url: viewTechDocsLink({ kind, namespace, name }),\n },\n ]\n : [];\n },\n [app, viewTechDocsLink],\n );\n\n const onTemplateSelected = useCallback(\n (template: TemplateEntityV1beta3) => {\n const { namespace, name } = parseEntityRef(stringifyEntityRef(template));\n\n navigate(templateRoute({ namespace, templateName: name }));\n },\n [navigate, templateRoute],\n );\n\n return (\n <EntityListProvider>\n <Page themeId=\"home\">\n <Header\n pageTitleOverride=\"Create a new component\"\n title=\"Create a new component\"\n subtitle=\"Create new software components using standard templates in your organization\"\n {...headerOptions}\n >\n <ScaffolderPageContextMenu {...scaffolderPageContextMenuProps} />\n </Header>\n <Content>\n <ContentHeader title=\"Available Templates\">\n <RegisterExistingButton\n title=\"Register Existing Component\"\n to={registerComponentLink && registerComponentLink()}\n />\n <SupportButton>\n Create new software components using standard templates. Different\n templates create different kinds of components (services,\n websites, documentation, ...).\n </SupportButton>\n </ContentHeader>\n\n <CatalogFilterLayout>\n <CatalogFilterLayout.Filters>\n <EntitySearchBar />\n <EntityKindPicker initialFilter=\"template\" hidden />\n <UserListPicker\n initialFilter=\"all\"\n availableFilters={['all', 'starred']}\n />\n <TemplateCategoryPicker />\n <EntityTagPicker />\n </CatalogFilterLayout.Filters>\n <CatalogFilterLayout.Content>\n <TemplateGroups\n groups={groups}\n templateFilter={templateFilter}\n TemplateCardComponent={TemplateCardComponent}\n onTemplateSelected={onTemplateSelected}\n additionalLinksForEntity={additionalLinksForEntity}\n />\n </CatalogFilterLayout.Content>\n </CatalogFilterLayout>\n </Content>\n </Page>\n </EntityListProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA4EA,MAAM,YAAoC,GAAA;AAAA,EACxC,KAAO,EAAA,WAAA;AAAA,EACP,QAAQ,MAAM,IAAA;AAChB,CAAA,CAAA;AAEA,MAAM,qBAAA,GAAwB,CAC5B,MAC0B,KAAA;AAAA,EAC1B,GAAG,MAAA;AAAA,EACH;AAAA,IACE,KAAO,EAAA,iBAAA;AAAA,IACP,MAAQ,EAAA,CAAA,CAAA,KAAK,CAAC,CAAC,GAAG,MAAM,CAAA,CAAE,IAAK,CAAA,CAAC,EAAE,MAAA,EAAa,KAAA,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,GAC1D;AACF,CAAA,CAAA;AAKa,MAAA,gBAAA,GAAmB,CAAC,KAAiC,KAAA;AAChE,EAAM,MAAA,qBAAA,GAAwB,YAAY,yBAAyB,CAAA,CAAA;AACnE,EAAM,MAAA;AAAA,IACJ,qBAAA;AAAA,IACA,MAAA,EAAQ,cAAc,EAAC;AAAA,IACvB,cAAA;AAAA,IACA,aAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAC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6JAIf,CACF,CAEA,kBAAA,KAAA,CAAA,aAAA,CAAC,2CACE,KAAA,CAAA,aAAA,CAAA,mBAAA,CAAoB,SAApB,IACC,kBAAA,KAAA,CAAA,aAAA,CAAC,qBAAgB,CACjB,kBAAA,KAAA,CAAA,aAAA,CAAC,oBAAiB,aAAc,EAAA,UAAA,EAAW,MAAM,EAAA,IAAA,EAAC,CAClD,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,aAAc,EAAA,KAAA;AAAA,MACd,gBAAA,EAAkB,CAAC,KAAA,EAAO,SAAS,CAAA;AAAA,KAAA;AAAA,GACrC,kBACC,KAAA,CAAA,aAAA,CAAA,sBAAA,EAAA,IAAuB,CACxB,kBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,EAAA,IAAA,CACnB,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,mBAAoB,CAAA,OAAA,EAApB,IACC,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,cAAA;AAAA,MACA,qBAAA;AAAA,MACA,kBAAA;AAAA,MACA,wBAAA;AAAA,KAAA;AAAA,GAEJ,CACF,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TemplateListPage.esm.js","sources":["../../../src/next/TemplateListPage/TemplateListPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useCallback } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { useApp, useRouteRef } from '@backstage/core-plugin-api';\n\nimport {\n Content,\n ContentHeader,\n DocsIcon,\n Header,\n Page,\n SupportButton,\n} from '@backstage/core-components';\nimport {\n EntityKindPicker,\n EntityListProvider,\n EntitySearchBar,\n EntityTagPicker,\n CatalogFilterLayout,\n UserListPicker,\n} from '@backstage/plugin-catalog-react';\nimport {\n ScaffolderPageContextMenu,\n TemplateCategoryPicker,\n TemplateGroups,\n} from '@backstage/plugin-scaffolder-react/alpha';\n\nimport { RegisterExistingButton } from './RegisterExistingButton';\nimport {\n actionsRouteRef,\n editRouteRef,\n registerComponentRouteRef,\n scaffolderListTaskRouteRef,\n selectedTemplateRouteRef,\n viewTechDocRouteRef,\n} from '../../routes';\nimport { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';\nimport { TemplateGroupFilter } from '@backstage/plugin-scaffolder-react';\nimport {\n TranslationFunction,\n useTranslationRef,\n} from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../translation';\n\n/**\n * @alpha\n */\nexport type TemplateListPageProps = {\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n groups?: TemplateGroupFilter[];\n templateFilter?: (entity: TemplateEntityV1beta3) => boolean;\n contextMenu?: {\n editor?: boolean;\n actions?: boolean;\n tasks?: boolean;\n };\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n};\n\nconst createGroupsWithOther = (\n groups: TemplateGroupFilter[],\n t: TranslationFunction<typeof scaffolderTranslationRef.T>,\n): TemplateGroupFilter[] => [\n ...groups,\n {\n title: t('templateListPage.templateGroups.otherTitle'),\n filter: e => ![...groups].some(({ filter }) => filter(e)),\n },\n];\n\n/**\n * @alpha\n */\nexport const TemplateListPage = (props: TemplateListPageProps) => {\n const registerComponentLink = useRouteRef(registerComponentRouteRef);\n const {\n TemplateCardComponent,\n groups: givenGroups = [],\n templateFilter,\n headerOptions,\n } = props;\n const navigate = useNavigate();\n const editorLink = useRouteRef(editRouteRef);\n const actionsLink = useRouteRef(actionsRouteRef);\n const tasksLink = useRouteRef(scaffolderListTaskRouteRef);\n const viewTechDocsLink = useRouteRef(viewTechDocRouteRef);\n const templateRoute = useRouteRef(selectedTemplateRouteRef);\n const app = useApp();\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const groups = givenGroups.length\n ? createGroupsWithOther(givenGroups, t)\n : [\n {\n title: t('templateListPage.templateGroups.defaultTitle'),\n filter: () => true,\n },\n ];\n\n const scaffolderPageContextMenuProps = {\n onEditorClicked:\n props?.contextMenu?.editor !== false\n ? () => navigate(editorLink())\n : undefined,\n onActionsClicked:\n props?.contextMenu?.actions !== false\n ? () => navigate(actionsLink())\n : undefined,\n onTasksClicked:\n props?.contextMenu?.tasks !== false\n ? () => navigate(tasksLink())\n : undefined,\n };\n\n const additionalLinksForEntity = useCallback(\n (template: TemplateEntityV1beta3) => {\n const { kind, namespace, name } = parseEntityRef(\n stringifyEntityRef(template),\n );\n return template.metadata.annotations?.['backstage.io/techdocs-ref'] &&\n viewTechDocsLink\n ? [\n {\n icon: app.getSystemIcon('docs') ?? DocsIcon,\n text: t(\n 'templateListPage.additionalLinksForEntity.viewTechDocsTitle',\n ),\n url: viewTechDocsLink({ kind, namespace, name }),\n },\n ]\n : [];\n },\n [app, viewTechDocsLink, t],\n );\n\n const onTemplateSelected = useCallback(\n (template: TemplateEntityV1beta3) => {\n const { namespace, name } = parseEntityRef(stringifyEntityRef(template));\n\n navigate(templateRoute({ namespace, templateName: name }));\n },\n [navigate, templateRoute],\n );\n\n return (\n <EntityListProvider>\n <Page themeId=\"home\">\n <Header\n pageTitleOverride={t('templateListPage.pageTitle')}\n title={t('templateListPage.title')}\n subtitle={t('templateListPage.subtitle')}\n {...headerOptions}\n >\n <ScaffolderPageContextMenu {...scaffolderPageContextMenuProps} />\n </Header>\n <Content>\n <ContentHeader title={t('templateListPage.contentHeader.title')}>\n <RegisterExistingButton\n title={t(\n 'templateListPage.contentHeader.registerExistingButtonTitle',\n )}\n to={registerComponentLink && registerComponentLink()}\n />\n <SupportButton>\n {t('templateListPage.contentHeader.supportButtonTitle')}\n </SupportButton>\n </ContentHeader>\n\n <CatalogFilterLayout>\n <CatalogFilterLayout.Filters>\n <EntitySearchBar />\n <EntityKindPicker initialFilter=\"template\" hidden />\n <UserListPicker\n initialFilter=\"all\"\n availableFilters={['all', 'starred']}\n />\n <TemplateCategoryPicker />\n <EntityTagPicker />\n </CatalogFilterLayout.Filters>\n <CatalogFilterLayout.Content>\n <TemplateGroups\n groups={groups}\n templateFilter={templateFilter}\n TemplateCardComponent={TemplateCardComponent}\n onTemplateSelected={onTemplateSelected}\n additionalLinksForEntity={additionalLinksForEntity}\n />\n </CatalogFilterLayout.Content>\n </CatalogFilterLayout>\n </Content>\n </Page>\n </EntityListProvider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAiFA,MAAM,qBAAA,GAAwB,CAC5B,MAAA,EACA,CAC0B,KAAA;AAAA,EAC1B,GAAG,MAAA;AAAA,EACH;AAAA,IACE,KAAA,EAAO,EAAE,4CAA4C,CAAA;AAAA,IACrD,MAAQ,EAAA,CAAA,CAAA,KAAK,CAAC,CAAC,GAAG,MAAM,CAAA,CAAE,IAAK,CAAA,CAAC,EAAE,MAAA,EAAa,KAAA,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,GAC1D;AACF,CAAA,CAAA;AAKa,MAAA,gBAAA,GAAmB,CAAC,KAAiC,KAAA;AAChE,EAAM,MAAA,qBAAA,GAAwB,YAAY,yBAAyB,CAAA,CAAA;AACnE,EAAM,MAAA;AAAA,IACJ,qBAAA;AAAA,IACA,MAAA,EAAQ,cAAc,EAAC;AAAA,IACvB,cAAA;AAAA,IACA,aAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,YAAY,YAA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AA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,sBAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA,CAAA;AAAA,QACL,4DAAA;AAAA,OACF;AAAA,MACA,EAAA,EAAI,yBAAyB,qBAAsB,EAAA;AAAA,KAAA;AAAA,GACrD,sCACC,aACE,EAAA,IAAA,EAAA,CAAA,CAAE,mDAAmD,CACxD,CACF,CAEA,kBAAA,KAAA,CAAA,aAAA,CAAC,mBACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,oBAAoB,OAApB,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,IAAgB,CACjB,kBAAA,KAAA,CAAA,aAAA,CAAC,oBAAiB,aAAc,EAAA,UAAA,EAAW,MAAM,EAAA,IAAA,EAAC,CAClD,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,aAAc,EAAA,KAAA;AAAA,MACd,gBAAA,EAAkB,CAAC,KAAA,EAAO,SAAS,CAAA;AAAA,KAAA;AAAA,GACrC,kBACC,KAAA,CAAA,aAAA,CAAA,sBAAA,EAAA,IAAuB,CACxB,kBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,EAAA,IAAA,CACnB,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,mBAAoB,CAAA,OAAA,EAApB,IACC,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,cAAA;AAAA,MACA,qBAAA;AAAA,MACA,kBAAA;AAAA,MACA,wBAAA;AAAA,KAAA;AAAA,GAEJ,CACF,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -8,6 +8,8 @@ import { catalogApiRef } from '@backstage/plugin-catalog-react';
8
8
  import { Workflow } from '@backstage/plugin-scaffolder-react/alpha';
9
9
  import { Page, Header } from '@backstage/core-components';
10
10
  import { rootRouteRef, scaffolderTaskRouteRef, selectedTemplateRouteRef } from '../../routes.esm.js';
11
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
12
+ import { scaffolderTranslationRef } from '../../translation.esm.js';
11
13
  import { TemplateWizardPageContextMenu } from './TemplateWizardPageContextMenu.esm.js';
12
14
 
13
15
  const TemplateWizardPage = (props) => {
@@ -20,6 +22,7 @@ const TemplateWizardPage = (props) => {
20
22
  const { templateName, namespace } = useRouteRefParams(
21
23
  selectedTemplateRouteRef
22
24
  );
25
+ const { t } = useTranslationRef(scaffolderTranslationRef);
23
26
  const templateRef = stringifyEntityRef({
24
27
  kind: "Template",
25
28
  namespace,
@@ -41,9 +44,9 @@ const TemplateWizardPage = (props) => {
41
44
  return /* @__PURE__ */ React.createElement(AnalyticsContext, { attributes: { entityRef: templateRef } }, /* @__PURE__ */ React.createElement(Page, { themeId: "website" }, /* @__PURE__ */ React.createElement(
42
45
  Header,
43
46
  {
44
- pageTitleOverride: "Create a new component",
45
- title: "Create a new component",
46
- subtitle: "Create new software components using standard templates in your organization",
47
+ pageTitleOverride: t("templateWizardPage.pageTitle"),
48
+ title: t("templateWizardPage.title"),
49
+ subtitle: t("templateWizardPage.subtitle"),
47
50
  ...props.headerOptions
48
51
  },
49
52
  /* @__PURE__ */ React.createElement(TemplateWizardPageContextMenu, { editUrl })
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateWizardPage.esm.js","sources":["../../../src/next/TemplateWizardPage/TemplateWizardPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { Navigate, useNavigate } from 'react-router-dom';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n stringifyEntityRef,\n ANNOTATION_EDIT_URL,\n} from '@backstage/catalog-model';\nimport {\n AnalyticsContext,\n useApi,\n useRouteRef,\n useRouteRefParams,\n} from '@backstage/core-plugin-api';\nimport {\n scaffolderApiRef,\n useTemplateSecrets,\n type LayoutOptions,\n FormProps,\n FieldExtensionOptions,\n ReviewStepProps,\n} from '@backstage/plugin-scaffolder-react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport { Workflow } from '@backstage/plugin-scaffolder-react/alpha';\nimport { JsonValue } from '@backstage/types';\nimport { Header, Page } from '@backstage/core-components';\n\nimport {\n rootRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n} from '../../routes';\n\nimport { TemplateWizardPageContextMenu } from './TemplateWizardPageContextMenu';\n\n/**\n * @alpha\n */\nexport type TemplateWizardPageProps = {\n customFieldExtensions: FieldExtensionOptions<any, any>[];\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n };\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n};\n\nexport const TemplateWizardPage = (props: TemplateWizardPageProps) => {\n const rootRef = useRouteRef(rootRouteRef);\n const taskRoute = useRouteRef(scaffolderTaskRouteRef);\n const { secrets } = useTemplateSecrets();\n const scaffolderApi = useApi(scaffolderApiRef);\n const catalogApi = useApi(catalogApiRef);\n const navigate = useNavigate();\n const { templateName, namespace } = useRouteRefParams(\n selectedTemplateRouteRef,\n );\n\n const templateRef = stringifyEntityRef({\n kind: 'Template',\n namespace,\n name: templateName,\n });\n\n const { value: editUrl } = useAsync(async () => {\n const data = await catalogApi.getEntityByRef(templateRef);\n return data?.metadata.annotations?.[ANNOTATION_EDIT_URL];\n }, [templateRef, catalogApi]);\n\n const onCreate = async (values: Record<string, JsonValue>) => {\n const { taskId } = await scaffolderApi.scaffold({\n templateRef,\n values,\n secrets,\n });\n\n navigate(taskRoute({ taskId }));\n };\n\n const onError = () => <Navigate to={rootRef()} />;\n\n return (\n <AnalyticsContext attributes={{ entityRef: templateRef }}>\n <Page themeId=\"website\">\n <Header\n pageTitleOverride=\"Create a new component\"\n title=\"Create a new component\"\n subtitle=\"Create new software components using standard templates in your organization\"\n {...props.headerOptions}\n >\n <TemplateWizardPageContextMenu editUrl={editUrl} />\n </Header>\n <Workflow\n namespace={namespace}\n templateName={templateName}\n onCreate={onCreate}\n components={props.components}\n onError={onError}\n extensions={props.customFieldExtensions}\n formProps={props.formProps}\n layouts={props.layouts}\n />\n </Page>\n </AnalyticsContext>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAmEa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAM,MAAA,OAAA,GAAU,YAAY,YAAY,CAAA,CAAA;AACxC,EAAM,MAAA,SAAA,GAAY,YAAY,sBAAsB,CAAA,CAAA;AACpD,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,kBAAmB,EAAA,CAAA;AACvC,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA,CAAA;AAC7C,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AACvC,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAM,MAAA,EAAE,YAAc,EAAA,SAAA,EAAc,GAAA,iBAAA;AAAA,IAClC,wBAAA;AAAA,GACF,CAAA;AAEA,EAAA,MAAM,cAAc,kBAAmB,CAAA;AAAA,IACrC,IAAM,EAAA,UAAA;AAAA,IACN,SAAA;AAAA,IACA,IAAM,EAAA,YAAA;AAAA,GACP,CAAA,CAAA;AAED,EAAA,MAAM,EAAE,KAAA,EAAO,OAAQ,EAAA,GAAI,SAAS,YAAY;AAC9C,IAAA,MAAM,IAAO,GAAA,MAAM,UAAW,CAAA,cAAA,CAAe,WAAW,CAAA,CAAA;AACxD,IAAO,OAAA,IAAA,EAAM,QAAS,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AEnB,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TemplateWizardPage.esm.js","sources":["../../../src/next/TemplateWizardPage/TemplateWizardPage.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { Navigate, useNavigate } from 'react-router-dom';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n stringifyEntityRef,\n ANNOTATION_EDIT_URL,\n} from '@backstage/catalog-model';\nimport {\n AnalyticsContext,\n useApi,\n useRouteRef,\n useRouteRefParams,\n} from '@backstage/core-plugin-api';\nimport {\n scaffolderApiRef,\n useTemplateSecrets,\n type LayoutOptions,\n FormProps,\n FieldExtensionOptions,\n ReviewStepProps,\n} from '@backstage/plugin-scaffolder-react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport { Workflow } from '@backstage/plugin-scaffolder-react/alpha';\nimport { JsonValue } from '@backstage/types';\nimport { Header, Page } from '@backstage/core-components';\n\nimport {\n rootRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n} from '../../routes';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../translation';\n\nimport { TemplateWizardPageContextMenu } from './TemplateWizardPageContextMenu';\n\n/**\n * @alpha\n */\nexport type TemplateWizardPageProps = {\n customFieldExtensions: FieldExtensionOptions<any, any>[];\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n };\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n};\n\nexport const TemplateWizardPage = (props: TemplateWizardPageProps) => {\n const rootRef = useRouteRef(rootRouteRef);\n const taskRoute = useRouteRef(scaffolderTaskRouteRef);\n const { secrets } = useTemplateSecrets();\n const scaffolderApi = useApi(scaffolderApiRef);\n const catalogApi = useApi(catalogApiRef);\n const navigate = useNavigate();\n const { templateName, namespace } = useRouteRefParams(\n selectedTemplateRouteRef,\n );\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const templateRef = stringifyEntityRef({\n kind: 'Template',\n namespace,\n name: templateName,\n });\n\n const { value: editUrl } = useAsync(async () => {\n const data = await catalogApi.getEntityByRef(templateRef);\n return data?.metadata.annotations?.[ANNOTATION_EDIT_URL];\n }, [templateRef, catalogApi]);\n\n const onCreate = async (values: Record<string, JsonValue>) => {\n const { taskId } = await scaffolderApi.scaffold({\n templateRef,\n values,\n secrets,\n });\n\n navigate(taskRoute({ taskId }));\n };\n\n const onError = () => <Navigate to={rootRef()} />;\n\n return (\n <AnalyticsContext attributes={{ entityRef: templateRef }}>\n <Page themeId=\"website\">\n <Header\n pageTitleOverride={t('templateWizardPage.pageTitle')}\n title={t('templateWizardPage.title')}\n subtitle={t('templateWizardPage.subtitle')}\n {...props.headerOptions}\n >\n <TemplateWizardPageContextMenu editUrl={editUrl} />\n </Header>\n <Workflow\n namespace={namespace}\n templateName={templateName}\n onCreate={onCreate}\n components={props.components}\n onError={onError}\n extensions={props.customFieldExtensions}\n formProps={props.formProps}\n layouts={props.layouts}\n />\n </Page>\n </AnalyticsContext>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAqEa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAM,MAAA,OAAA,GAAU,YAAY,YAAY,CAAA,CAAA;AACxC,EAAM,MAAA,SAAA,GAAY,YAAY,sBAAsB,CAAA,CAAA;AACpD,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,kBAAmB,EAAA,CAAA;AACvC,E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EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,OAAA,EAAQ,SACZ,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,iBAAA,EAAmB,EAAE,8BAA8B,CAAA;AAAA,MACnD,KAAA,EAAO,EAAE,0BAA0B,CAAA;AAAA,MACnC,QAAA,EAAU,EAAE,6BAA6B,CAAA;AAAA,MACxC,GAAG,KAAM,CAAA,aAAA;AAAA,KAAA;AAAA,oBAEV,KAAA,CAAA,aAAA,CAAC,iCAA8B,OAAkB,EAAA,CAAA;AAAA,GAEnD,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,YAAA;AAAA,MACA,QAAA;AAAA,MACA,YAAY,KAAM,CAAA,UAAA;AAAA,MAClB,OAAA;AAAA,MACA,YAAY,KAAM,CAAA,qBAAA;AAAA,MAClB,WAAW,KAAM,CAAA,SAAA;AAAA,MACjB,SAAS,KAAM,CAAA,OAAA;AAAA,KAAA;AAAA,GAEnB,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -8,6 +8,8 @@ import { makeStyles } from '@material-ui/core/styles';
8
8
  import Edit from '@material-ui/icons/Edit';
9
9
  import MoreVert from '@material-ui/icons/MoreVert';
10
10
  import React, { useState } from 'react';
11
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
12
+ import { scaffolderTranslationRef } from '../../translation.esm.js';
11
13
 
12
14
  const useStyles = makeStyles((theme) => ({
13
15
  button: {
@@ -18,6 +20,7 @@ function TemplateWizardPageContextMenu(props) {
18
20
  const { editUrl } = props;
19
21
  const classes = useStyles();
20
22
  const [anchorEl, setAnchorEl] = useState();
23
+ const { t } = useTranslationRef(scaffolderTranslationRef);
21
24
  if (!editUrl) {
22
25
  return null;
23
26
  }
@@ -52,7 +55,14 @@ function TemplateWizardPageContextMenu(props) {
52
55
  anchorOrigin: { vertical: "bottom", horizontal: "right" },
53
56
  transformOrigin: { vertical: "top", horizontal: "right" }
54
57
  },
55
- /* @__PURE__ */ React.createElement(MenuList, null, /* @__PURE__ */ React.createElement(MenuItem, { onClick: () => window.open(editUrl, "_blank") }, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(Edit, { fontSize: "small" })), /* @__PURE__ */ React.createElement(ListItemText, { primary: "Edit Configuration" })))
58
+ /* @__PURE__ */ React.createElement(MenuList, null, /* @__PURE__ */ React.createElement(MenuItem, { onClick: () => window.open(editUrl, "_blank") }, /* @__PURE__ */ React.createElement(ListItemIcon, null, /* @__PURE__ */ React.createElement(Edit, { fontSize: "small" })), /* @__PURE__ */ React.createElement(
59
+ ListItemText,
60
+ {
61
+ primary: t(
62
+ "templateWizardPage.pageContextMenu.editConfigurationTitle"
63
+ )
64
+ }
65
+ )))
56
66
  ));
57
67
  }
58
68
 
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateWizardPageContextMenu.esm.js","sources":["../../../src/next/TemplateWizardPage/TemplateWizardPageContextMenu.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport IconButton from '@material-ui/core/IconButton';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport MenuList from '@material-ui/core/MenuList';\nimport Popover from '@material-ui/core/Popover';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Edit from '@material-ui/icons/Edit';\nimport MoreVert from '@material-ui/icons/MoreVert';\nimport React, { useState } from 'react';\n\nconst useStyles = makeStyles(theme => ({\n button: {\n color: theme.page.fontColor,\n },\n}));\n\nexport type TemplateWizardPageContextMenuProps = {\n editUrl?: string;\n};\n\nexport function TemplateWizardPageContextMenu(\n props: TemplateWizardPageContextMenuProps,\n) {\n const { editUrl } = props;\n const classes = useStyles();\n const [anchorEl, setAnchorEl] = useState<HTMLButtonElement>();\n\n if (!editUrl) {\n return null;\n }\n\n const onOpen = (event: React.SyntheticEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const onClose = () => {\n setAnchorEl(undefined);\n };\n\n return (\n <>\n <IconButton\n id=\"long-menu\"\n aria-label=\"more\"\n aria-controls=\"long-menu\"\n aria-expanded={!!anchorEl}\n aria-haspopup=\"true\"\n role=\"button\"\n onClick={onOpen}\n data-testid=\"menu-button\"\n color=\"inherit\"\n className={classes.button}\n >\n <MoreVert />\n </IconButton>\n <Popover\n aria-labelledby=\"long-menu\"\n open={Boolean(anchorEl)}\n onClose={onClose}\n anchorEl={anchorEl}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}\n transformOrigin={{ vertical: 'top', horizontal: 'right' }}\n >\n <MenuList>\n <MenuItem onClick={() => window.open(editUrl, '_blank')}>\n <ListItemIcon>\n <Edit fontSize=\"small\" />\n </ListItemIcon>\n <ListItemText primary=\"Edit Configuration\" />\n </MenuItem>\n </MenuList>\n </Popover>\n </>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA2BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACN,KAAA,EAAO,MAAM,IAAK,CAAA,SAAA;AAAA,GACpB;AACF,CAAE,CAAA,CAAA,CAAA;AAMK,SAAS,8BACd,KACA,EAAA;AACA,EAAM,MAAA,EAAE,SAAY,GAAA,KAAA,CAAA;AACpB,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,CAAC,QAAA,EAA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AA,CAAC,QAAS,EAAA,EAAA,OAAA,EAAS,MAAM,MAAO,CAAA,IAAA,CAAK,OAAS,EAAA,QAAQ,CACpD,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,oCACE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,QAAS,EAAA,OAAA,EAAQ,CACzB,CAAA,sCACC,YAAa,EAAA,EAAA,OAAA,EAAQ,oBAAqB,EAAA,CAC7C,CACF,CAAA;AAAA,GAEJ,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TemplateWizardPageContextMenu.esm.js","sources":["../../../src/next/TemplateWizardPage/TemplateWizardPageContextMenu.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport IconButton from '@material-ui/core/IconButton';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport MenuList from '@material-ui/core/MenuList';\nimport Popover from '@material-ui/core/Popover';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Edit from '@material-ui/icons/Edit';\nimport MoreVert from '@material-ui/icons/MoreVert';\nimport React, { useState } from 'react';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../translation';\n\nconst useStyles = makeStyles(theme => ({\n button: {\n color: theme.page.fontColor,\n },\n}));\n\nexport type TemplateWizardPageContextMenuProps = {\n editUrl?: string;\n};\n\nexport function TemplateWizardPageContextMenu(\n props: TemplateWizardPageContextMenuProps,\n) {\n const { editUrl } = props;\n const classes = useStyles();\n const [anchorEl, setAnchorEl] = useState<HTMLButtonElement>();\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n if (!editUrl) {\n return null;\n }\n\n const onOpen = (event: React.SyntheticEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const onClose = () => {\n setAnchorEl(undefined);\n };\n\n return (\n <>\n <IconButton\n id=\"long-menu\"\n aria-label=\"more\"\n aria-controls=\"long-menu\"\n aria-expanded={!!anchorEl}\n aria-haspopup=\"true\"\n role=\"button\"\n onClick={onOpen}\n data-testid=\"menu-button\"\n color=\"inherit\"\n className={classes.button}\n >\n <MoreVert />\n </IconButton>\n <Popover\n aria-labelledby=\"long-menu\"\n open={Boolean(anchorEl)}\n onClose={onClose}\n anchorEl={anchorEl}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}\n transformOrigin={{ vertical: 'top', horizontal: 'right' }}\n >\n <MenuList>\n <MenuItem onClick={() => window.open(editUrl, '_blank')}>\n <ListItemIcon>\n <Edit fontSize=\"small\" />\n </ListItemIcon>\n <ListItemText\n primary={t(\n 'templateWizardPage.pageContextMenu.editConfigurationTitle',\n )}\n />\n </MenuItem>\n </MenuList>\n </Popover>\n </>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA6BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACN,KAAA,EAAO,MAAM,IAAK,CAAA,SAAA;AAAA,GACpB;AACF,CAAE,CAAA,CAAA,CAAA;AAMK,SAAS,8BACd,KACA,EAAA;AACA,EAAM,MAAA,EAAE,SAAY,GAAA,KAAA,CAAA;AACpB,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,QAA4B,EAAA,CAAA;AAC5D,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CA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