@backstage/plugin-scaffolder 1.26.0-next.0 → 1.26.0-next.2
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.
- package/CHANGELOG.md +59 -0
- package/alpha/package.json +1 -1
- package/dist/alpha/components/TemplateEditorPage/CustomFieldExplorer.esm.js +61 -29
- package/dist/alpha/components/TemplateEditorPage/CustomFieldExplorer.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/CustomFieldPlaygroud.esm.js +36 -13
- package/dist/alpha/components/TemplateEditorPage/CustomFieldPlaygroud.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/CustomFieldsPage.esm.js +6 -15
- package/dist/alpha/components/TemplateEditorPage/CustomFieldsPage.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/DirectoryEditorContext.esm.js +4 -3
- package/dist/alpha/components/TemplateEditorPage/DirectoryEditorContext.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateEditor.esm.js +35 -80
- package/dist/alpha/components/TemplateEditorPage/TemplateEditor.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorBrowser.esm.js +9 -6
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorBrowser.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorForm.esm.js +5 -2
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorForm.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorIntro.esm.js +108 -89
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorIntro.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorLayout.esm.js +94 -0
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorLayout.esm.js.map +1 -0
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorPage.esm.js +23 -43
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorPage.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorTextArea.esm.js +10 -20
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorTextArea.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbar.esm.js +42 -14
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbar.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarFileMenu.esm.js +73 -0
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarFileMenu.esm.js.map +1 -0
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarTemplatesMenu.esm.js +84 -0
- package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarTemplatesMenu.esm.js.map +1 -0
- package/dist/alpha/components/TemplateEditorPage/TemplateFormPage.esm.js +3 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateFormPage.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateFormPreviewer.esm.js +58 -95
- package/dist/alpha/components/TemplateEditorPage/TemplateFormPreviewer.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/TemplateIntroPage.esm.js +54 -0
- package/dist/alpha/components/TemplateEditorPage/TemplateIntroPage.esm.js.map +1 -0
- package/dist/alpha/components/TemplateEditorPage/useTemplateDirectory.esm.js +33 -0
- package/dist/alpha/components/TemplateEditorPage/useTemplateDirectory.esm.js.map +1 -0
- package/dist/alpha/components/TemplateListPage/RegisterExistingButton.esm.js +1 -1
- package/dist/alpha/components/TemplateListPage/RegisterExistingButton.esm.js.map +1 -1
- package/dist/alpha.d.ts +24 -5
- package/dist/api.esm.js +5 -3
- package/dist/api.esm.js.map +1 -1
- package/dist/components/ActionsPage/ActionsPage.esm.js +42 -8
- package/dist/components/ActionsPage/ActionsPage.esm.js.map +1 -1
- package/dist/components/ListTasksPage/ListTasksPage.esm.js +17 -3
- package/dist/components/ListTasksPage/ListTasksPage.esm.js.map +1 -1
- package/dist/components/Router/Router.esm.js +4 -4
- package/dist/components/Router/Router.esm.js.map +1 -1
- package/dist/components/fields/EntityPicker/EntityPicker.esm.js +1 -1
- package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -1
- package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js +1 -0
- package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/lib/filesystem/WebFileSystemAccess.esm.js +1 -13
- package/dist/lib/filesystem/WebFileSystemAccess.esm.js.map +1 -1
- package/dist/lib/filesystem/WebFileSystemStore.esm.js +15 -0
- package/dist/lib/filesystem/WebFileSystemStore.esm.js.map +1 -0
- package/dist/lib/filesystem/createExampleTemplate.esm.js +1 -0
- package/dist/lib/filesystem/createExampleTemplate.esm.js.map +1 -1
- package/dist/translation.esm.js +39 -4
- package/dist/translation.esm.js.map +1 -1
- package/package.json +33 -24
- package/dist/alpha/components/TemplateEditorPage/TemplatePage.esm.js +0 -52
- package/dist/alpha/components/TemplateEditorPage/TemplatePage.esm.js.map +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
+
import Button from '@material-ui/core/Button';
|
|
4
|
+
import Menu from '@material-ui/core/Menu';
|
|
5
|
+
import MenuItem from '@material-ui/core/MenuItem';
|
|
6
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
7
|
+
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
8
|
+
|
|
9
|
+
const ITEM_HEIGHT = 48;
|
|
10
|
+
const useStyles = makeStyles({
|
|
11
|
+
menu: {
|
|
12
|
+
maxHeight: ITEM_HEIGHT * 5
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
function TemplateEditorToolbarTemplatesMenu(props) {
|
|
16
|
+
const { options, selectedOption, onSelectOption } = props;
|
|
17
|
+
const classes = useStyles();
|
|
18
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
19
|
+
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
20
|
+
const isSelectedOption = useCallback(
|
|
21
|
+
(option) => {
|
|
22
|
+
return !!selectedOption && selectedOption.value === option.value;
|
|
23
|
+
},
|
|
24
|
+
[selectedOption]
|
|
25
|
+
);
|
|
26
|
+
const handleOpenMenu = useCallback(
|
|
27
|
+
(event) => {
|
|
28
|
+
setAnchorEl(event.currentTarget);
|
|
29
|
+
},
|
|
30
|
+
[setAnchorEl]
|
|
31
|
+
);
|
|
32
|
+
const handleCloseMenu = useCallback(() => {
|
|
33
|
+
setAnchorEl(null);
|
|
34
|
+
}, [setAnchorEl]);
|
|
35
|
+
const handleSelectOption = useCallback(
|
|
36
|
+
(option) => {
|
|
37
|
+
handleCloseMenu();
|
|
38
|
+
onSelectOption(option);
|
|
39
|
+
},
|
|
40
|
+
[handleCloseMenu, onSelectOption]
|
|
41
|
+
);
|
|
42
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
43
|
+
Button,
|
|
44
|
+
{
|
|
45
|
+
"aria-controls": "templates-menu",
|
|
46
|
+
"aria-haspopup": "true",
|
|
47
|
+
onClick: handleOpenMenu
|
|
48
|
+
},
|
|
49
|
+
t("templateEditorToolbarTemplatesMenu.button")
|
|
50
|
+
), /* @__PURE__ */ React.createElement(
|
|
51
|
+
Menu,
|
|
52
|
+
{
|
|
53
|
+
id: "templates-menu",
|
|
54
|
+
anchorEl,
|
|
55
|
+
open: Boolean(anchorEl),
|
|
56
|
+
onClose: handleCloseMenu,
|
|
57
|
+
getContentAnchorEl: null,
|
|
58
|
+
anchorOrigin: {
|
|
59
|
+
vertical: "bottom",
|
|
60
|
+
horizontal: "left"
|
|
61
|
+
},
|
|
62
|
+
transformOrigin: {
|
|
63
|
+
vertical: "top",
|
|
64
|
+
horizontal: "left"
|
|
65
|
+
},
|
|
66
|
+
PaperProps: {
|
|
67
|
+
className: classes.menu
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
options.map((option, index) => /* @__PURE__ */ React.createElement(
|
|
71
|
+
MenuItem,
|
|
72
|
+
{
|
|
73
|
+
key: index,
|
|
74
|
+
selected: isSelectedOption(option),
|
|
75
|
+
"aria-selected": isSelectedOption(option),
|
|
76
|
+
onClick: () => handleSelectOption(option)
|
|
77
|
+
},
|
|
78
|
+
option.label
|
|
79
|
+
))
|
|
80
|
+
));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { TemplateEditorToolbarTemplatesMenu };
|
|
84
|
+
//# sourceMappingURL=TemplateEditorToolbarTemplatesMenu.esm.js.map
|
package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarTemplatesMenu.esm.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateEditorToolbarTemplatesMenu.esm.js","sources":["../../../../src/alpha/components/TemplateEditorPage/TemplateEditorToolbarTemplatesMenu.tsx"],"sourcesContent":["/*\n * Copyright 2024 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, { MouseEvent, useCallback, useState } from 'react';\n\nimport { makeStyles } from '@material-ui/core/styles';\nimport Button from '@material-ui/core/Button';\nimport Menu from '@material-ui/core/Menu';\nimport MenuItem from '@material-ui/core/MenuItem';\n\nimport { Entity } from '@backstage/catalog-model';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nconst ITEM_HEIGHT = 48;\n\nconst useStyles = makeStyles({\n menu: {\n maxHeight: ITEM_HEIGHT * 5,\n },\n});\n\nexport type TemplateOption = {\n label: string;\n value: Entity;\n};\n\nexport function TemplateEditorToolbarTemplatesMenu(props: {\n options: TemplateOption[];\n selectedOption?: TemplateOption;\n onSelectOption: (option: TemplateOption) => void;\n}) {\n const { options, selectedOption, onSelectOption } = props;\n const classes = useStyles();\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const isSelectedOption = useCallback(\n (option: TemplateOption) => {\n return !!selectedOption && selectedOption.value === option.value;\n },\n [selectedOption],\n );\n\n const handleOpenMenu = useCallback(\n (event: MouseEvent<HTMLElement>) => {\n setAnchorEl(event.currentTarget);\n },\n [setAnchorEl],\n );\n\n const handleCloseMenu = useCallback(() => {\n setAnchorEl(null);\n }, [setAnchorEl]);\n\n const handleSelectOption = useCallback(\n (option: TemplateOption) => {\n handleCloseMenu();\n onSelectOption(option);\n },\n [handleCloseMenu, onSelectOption],\n );\n\n return (\n <>\n <Button\n aria-controls=\"templates-menu\"\n aria-haspopup=\"true\"\n onClick={handleOpenMenu}\n >\n {t('templateEditorToolbarTemplatesMenu.button')}\n </Button>\n <Menu\n id=\"templates-menu\"\n anchorEl={anchorEl}\n open={Boolean(anchorEl)}\n onClose={handleCloseMenu}\n getContentAnchorEl={null}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'left',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'left',\n }}\n PaperProps={{\n className: classes.menu,\n }}\n >\n {options.map((option, index) => (\n <MenuItem\n key={index}\n selected={isSelectedOption(option)}\n aria-selected={isSelectedOption(option)}\n onClick={() => handleSelectOption(option)}\n >\n {option.label}\n </MenuItem>\n ))}\n </Menu>\n </>\n );\n}\n"],"names":[],"mappings":";;;;;;;;AA2BA,MAAM,WAAc,GAAA,EAAA,CAAA;AAEpB,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA,IACJ,WAAW,WAAc,GAAA,CAAA;AAAA,GAC3B;AACF,CAAC,CAA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c,EAAA,MAAA;AAAA,MACd,OAAS,EAAA,cAAA;AAAA,KAAA;AAAA,IAER,EAAE,2CAA2C,CAAA;AAAA,GAEhD,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,EAAG,EAAA,gBAAA;AAAA,MACH,QAAA;AAAA,MACA,IAAA,EAAM,QAAQ,QAAQ,CAAA;AAAA,MACtB,OAAS,EAAA,eAAA;AAAA,MACT,kBAAoB,EAAA,IAAA;AAAA,MACpB,YAAc,EAAA;AAAA,QACZ,QAAU,EAAA,QAAA;AAAA,QACV,UAAY,EAAA,MAAA;AAAA,OACd;AAAA,MACA,eAAiB,EAAA;AAAA,QACf,QAAU,EAAA,KAAA;AAAA,QACV,UAAY,EAAA,MAAA;AAAA,OACd;AAAA,MACA,UAAY,EAAA;AAAA,QACV,WAAW,OAAQ,CAAA,IAAA;AAAA,OACrB;AAAA,KAAA;AAAA,IAEC,OAAQ,CAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,KACpB,qBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,KAAA;AAAA,QACL,QAAA,EAAU,iBAAiB,MAAM,CAAA;AAAA,QACjC,eAAA,EAAe,iBAAiB,MAAM,CAAA;AAAA,QACtC,OAAA,EAAS,MAAM,kBAAA,CAAmB,MAAM,CAAA;AAAA,OAAA;AAAA,MAEvC,MAAO,CAAA,KAAA;AAAA,KAEX,CAAA;AAAA,GAEL,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -25,7 +25,9 @@ function TemplateFormPage(props) {
|
|
|
25
25
|
Header,
|
|
26
26
|
{
|
|
27
27
|
title: t("templateFormPage.title"),
|
|
28
|
-
subtitle: t("templateFormPage.subtitle")
|
|
28
|
+
subtitle: t("templateFormPage.subtitle"),
|
|
29
|
+
type: t("templateIntroPage.title"),
|
|
30
|
+
typeLink: editLink()
|
|
29
31
|
}
|
|
30
32
|
), /* @__PURE__ */ React.createElement(Content, { className: classes.root }, /* @__PURE__ */ React.createElement(
|
|
31
33
|
TemplateFormPreviewer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateFormPage.esm.js","sources":["../../../../src/alpha/components/TemplateEditorPage/TemplateFormPage.tsx"],"sourcesContent":["/*\n * Copyright 2024 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';\n\nimport { makeStyles } from '@material-ui/core/styles';\n\nimport { Page, Header, Content } from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport {\n FormProps,\n LayoutOptions,\n FieldExtensionOptions,\n} from '@backstage/plugin-scaffolder-react';\n\nimport { editRouteRef } from '../../../routes';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nimport { TemplateFormPreviewer } from './TemplateFormPreviewer';\n\nconst useStyles = makeStyles({\n root: {\n padding: 0,\n },\n});\n\ninterface TemplateFormPageProps {\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n fieldExtensions?: FieldExtensionOptions<any, any>[];\n defaultPreviewTemplate?: string;\n}\n\nexport function TemplateFormPage(props: TemplateFormPageProps) {\n const classes = useStyles();\n const navigate = useNavigate();\n const editLink = useRouteRef(editRouteRef);\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const handleClose = useCallback(() => {\n navigate(editLink());\n }, [navigate, editLink]);\n\n return (\n <Page themeId=\"home\">\n <Header\n title={t('templateFormPage.title')}\n subtitle={t('templateFormPage.subtitle')}\n />\n <Content className={classes.root}>\n <TemplateFormPreviewer\n layouts={props.layouts}\n formProps={props.formProps}\n customFieldExtensions={props.fieldExtensions}\n defaultPreviewTemplate={props.defaultPreviewTemplate}\n onClose={handleClose}\n />\n </Content>\n </Page>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AAmCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA,IACJ,OAAS,EAAA,CAAA;AAAA,GACX;AACF,CAAC,CAAA,CAAA;AASM,SAAS,iBAAiB,KAA8B,EAAA;AAC7D,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAM,MAAA,QAAA,GAAW,YAAY,YAAY,CAAA,CAAA;AACzC,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AAExD,EAAM,MAAA,WAAA,GAAc,YAAY,MAAM;AACpC,IAAA,QAAA,CAAS,UAAU,CAAA,CAAA;AAAA,GAClB,EAAA,CAAC,QAAU,EAAA,QAAQ,CAAC,CAAA,CAAA;AAEvB,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,wBAAwB,CAAA;AAAA,MACjC,QAAA,EAAU,EAAE,2BAA2B,CAAA;AAAA,KAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"TemplateFormPage.esm.js","sources":["../../../../src/alpha/components/TemplateEditorPage/TemplateFormPage.tsx"],"sourcesContent":["/*\n * Copyright 2024 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';\n\nimport { makeStyles } from '@material-ui/core/styles';\n\nimport { Page, Header, Content } from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport {\n FormProps,\n LayoutOptions,\n FieldExtensionOptions,\n} from '@backstage/plugin-scaffolder-react';\n\nimport { editRouteRef } from '../../../routes';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nimport { TemplateFormPreviewer } from './TemplateFormPreviewer';\n\nconst useStyles = makeStyles({\n root: {\n padding: 0,\n },\n});\n\ninterface TemplateFormPageProps {\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n fieldExtensions?: FieldExtensionOptions<any, any>[];\n defaultPreviewTemplate?: string;\n}\n\nexport function TemplateFormPage(props: TemplateFormPageProps) {\n const classes = useStyles();\n const navigate = useNavigate();\n const editLink = useRouteRef(editRouteRef);\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const handleClose = useCallback(() => {\n navigate(editLink());\n }, [navigate, editLink]);\n\n return (\n <Page themeId=\"home\">\n <Header\n title={t('templateFormPage.title')}\n subtitle={t('templateFormPage.subtitle')}\n type={t('templateIntroPage.title')}\n typeLink={editLink()}\n />\n <Content className={classes.root}>\n <TemplateFormPreviewer\n layouts={props.layouts}\n formProps={props.formProps}\n customFieldExtensions={props.fieldExtensions}\n defaultPreviewTemplate={props.defaultPreviewTemplate}\n onClose={handleClose}\n />\n </Content>\n </Page>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AAmCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA,IACJ,OAAS,EAAA,CAAA;AAAA,GACX;AACF,CAAC,CAAA,CAAA;AASM,SAAS,iBAA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
|
-
import Paper from '@material-ui/core/Paper';
|
|
5
|
-
import FormControl from '@material-ui/core/FormControl';
|
|
6
|
-
import Input from '@material-ui/core/Input';
|
|
7
|
-
import Select from '@material-ui/core/Select';
|
|
8
|
-
import Tooltip from '@material-ui/core/Tooltip';
|
|
9
|
-
import IconButton from '@material-ui/core/IconButton';
|
|
10
|
-
import MenuItem from '@material-ui/core/MenuItem';
|
|
11
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
12
|
-
import CloseIcon from '@material-ui/icons/Close';
|
|
1
|
+
import yaml from 'yaml';
|
|
13
2
|
import React, { useState, useCallback } from 'react';
|
|
3
|
+
import { useNavigate } from 'react-router-dom';
|
|
14
4
|
import useAsync from 'react-use/esm/useAsync';
|
|
15
|
-
import
|
|
5
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
6
|
+
import { useApi, alertApiRef, useRouteRef } from '@backstage/core-plugin-api';
|
|
7
|
+
import { catalogApiRef, humanizeEntityRef } from '@backstage/plugin-catalog-react';
|
|
8
|
+
import { editRouteRef } from '../../../routes.esm.js';
|
|
9
|
+
import { TemplateEditorLayout, TemplateEditorLayoutToolbar, TemplateEditorLayoutFiles, TemplateEditorLayoutPreview } from './TemplateEditorLayout.esm.js';
|
|
16
10
|
import { TemplateEditorToolbar } from './TemplateEditorToolbar.esm.js';
|
|
11
|
+
import { TemplateEditorToolbarFileMenu } from './TemplateEditorToolbarFileMenu.esm.js';
|
|
12
|
+
import { TemplateEditorToolbarTemplatesMenu } from './TemplateEditorToolbarTemplatesMenu.esm.js';
|
|
17
13
|
import { TemplateEditorForm } from './TemplateEditorForm.esm.js';
|
|
18
14
|
import { TemplateEditorTextArea } from './TemplateEditorTextArea.esm.js';
|
|
19
|
-
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
20
|
-
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
21
15
|
|
|
22
16
|
const EXAMPLE_TEMPLATE_PARAMS_YAML = `# Edit the template parameters below to see how they will render in the scaffolder form UI
|
|
23
17
|
parameters:
|
|
@@ -64,36 +58,21 @@ const useStyles = makeStyles(
|
|
|
64
58
|
gridArea: "pageContent",
|
|
65
59
|
display: "grid",
|
|
66
60
|
gridTemplateAreas: `
|
|
61
|
+
"toolbar"
|
|
62
|
+
"textArea"
|
|
63
|
+
"preview"
|
|
64
|
+
`,
|
|
65
|
+
[theme.breakpoints.up("md")]: {
|
|
66
|
+
gridTemplateAreas: `
|
|
67
67
|
"toolbar toolbar"
|
|
68
68
|
"textArea preview"
|
|
69
69
|
`,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
toolbar: {
|
|
74
|
-
gridArea: "toolbar"
|
|
75
|
-
},
|
|
76
|
-
textArea: {
|
|
77
|
-
gridArea: "textArea",
|
|
78
|
-
height: "100%"
|
|
79
|
-
},
|
|
80
|
-
preview: {
|
|
81
|
-
gridArea: "preview",
|
|
82
|
-
position: "relative",
|
|
83
|
-
borderLeft: `1px solid ${theme.palette.divider}`,
|
|
84
|
-
backgroundColor: theme.palette.background.default
|
|
85
|
-
},
|
|
86
|
-
scroll: {
|
|
87
|
-
position: "absolute",
|
|
88
|
-
top: 0,
|
|
89
|
-
left: 0,
|
|
90
|
-
right: 0,
|
|
91
|
-
bottom: 0,
|
|
92
|
-
padding: theme.spacing(1)
|
|
70
|
+
gridTemplateRows: "auto 1fr",
|
|
71
|
+
gridTemplateColumns: "1fr 1fr"
|
|
72
|
+
}
|
|
93
73
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
maxWidth: 300
|
|
74
|
+
files: {
|
|
75
|
+
gridArea: "textArea"
|
|
97
76
|
}
|
|
98
77
|
}),
|
|
99
78
|
{ name: "ScaffolderTemplateFormPreviewer" }
|
|
@@ -101,19 +80,22 @@ const useStyles = makeStyles(
|
|
|
101
80
|
const TemplateFormPreviewer = ({
|
|
102
81
|
defaultPreviewTemplate = EXAMPLE_TEMPLATE_PARAMS_YAML,
|
|
103
82
|
customFieldExtensions = [],
|
|
104
|
-
onClose,
|
|
105
83
|
layouts = [],
|
|
106
84
|
formProps
|
|
107
85
|
}) => {
|
|
108
86
|
const classes = useStyles();
|
|
109
|
-
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
110
87
|
const alertApi = useApi(alertApiRef);
|
|
111
88
|
const catalogApi = useApi(catalogApiRef);
|
|
89
|
+
const navigate = useNavigate();
|
|
90
|
+
const editLink = useRouteRef(editRouteRef);
|
|
112
91
|
const [errorText, setErrorText] = useState();
|
|
113
|
-
const [selectedTemplate, setSelectedTemplate] = useState(
|
|
92
|
+
const [selectedTemplate, setSelectedTemplate] = useState();
|
|
114
93
|
const [templateOptions, setTemplateOptions] = useState([]);
|
|
115
94
|
const [templateYaml, setTemplateYaml] = useState(defaultPreviewTemplate);
|
|
116
|
-
const
|
|
95
|
+
const handleCloseDirectory = useCallback(() => {
|
|
96
|
+
navigate(editLink());
|
|
97
|
+
}, [navigate, editLink]);
|
|
98
|
+
useAsync(
|
|
117
99
|
() => catalogApi.getEntities({
|
|
118
100
|
filter: { kind: "template" },
|
|
119
101
|
fields: [
|
|
@@ -144,59 +126,40 @@ const TemplateFormPreviewer = ({
|
|
|
144
126
|
// TODO(Rugvip): Afaik this should be Entity, but didn't want to make runtime changes while fixing types
|
|
145
127
|
(selected) => {
|
|
146
128
|
setSelectedTemplate(selected);
|
|
147
|
-
setTemplateYaml(yaml.stringify(selected.spec));
|
|
129
|
+
setTemplateYaml(yaml.stringify(selected.value.spec));
|
|
148
130
|
},
|
|
149
|
-
[setTemplateYaml]
|
|
131
|
+
[setSelectedTemplate, setTemplateYaml]
|
|
150
132
|
);
|
|
151
|
-
return /* @__PURE__ */ React.createElement(React.
|
|
152
|
-
|
|
133
|
+
return /* @__PURE__ */ React.createElement(TemplateEditorLayout, { classes: { root: classes.root } }, /* @__PURE__ */ React.createElement(TemplateEditorLayoutToolbar, null, /* @__PURE__ */ React.createElement(TemplateEditorToolbar, { fieldExtensions: customFieldExtensions }, /* @__PURE__ */ React.createElement(
|
|
134
|
+
TemplateEditorToolbarFileMenu,
|
|
153
135
|
{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
TemplateEditorTextArea,
|
|
182
|
-
{
|
|
183
|
-
content: templateYaml,
|
|
184
|
-
onUpdate: setTemplateYaml,
|
|
185
|
-
errorText
|
|
186
|
-
}
|
|
187
|
-
)),
|
|
188
|
-
/* @__PURE__ */ React.createElement("div", { className: classes.preview }, /* @__PURE__ */ React.createElement("div", { className: classes.scroll }, /* @__PURE__ */ React.createElement(
|
|
189
|
-
TemplateEditorForm,
|
|
190
|
-
{
|
|
191
|
-
content: templateYaml,
|
|
192
|
-
contentIsSpec: true,
|
|
193
|
-
fieldExtensions: customFieldExtensions,
|
|
194
|
-
setErrorText,
|
|
195
|
-
layouts,
|
|
196
|
-
formProps
|
|
197
|
-
}
|
|
198
|
-
)))
|
|
199
|
-
));
|
|
136
|
+
onCloseDirectory: handleCloseDirectory
|
|
137
|
+
}
|
|
138
|
+
), /* @__PURE__ */ React.createElement(
|
|
139
|
+
TemplateEditorToolbarTemplatesMenu,
|
|
140
|
+
{
|
|
141
|
+
options: templateOptions,
|
|
142
|
+
selectedOption: selectedTemplate,
|
|
143
|
+
onSelectOption: handleSelectChange
|
|
144
|
+
}
|
|
145
|
+
))), /* @__PURE__ */ React.createElement(TemplateEditorLayoutFiles, { classes: { root: classes.files } }, /* @__PURE__ */ React.createElement(
|
|
146
|
+
TemplateEditorTextArea,
|
|
147
|
+
{
|
|
148
|
+
content: templateYaml,
|
|
149
|
+
onUpdate: setTemplateYaml,
|
|
150
|
+
errorText
|
|
151
|
+
}
|
|
152
|
+
)), /* @__PURE__ */ React.createElement(TemplateEditorLayoutPreview, null, /* @__PURE__ */ React.createElement(
|
|
153
|
+
TemplateEditorForm,
|
|
154
|
+
{
|
|
155
|
+
content: templateYaml,
|
|
156
|
+
contentIsSpec: true,
|
|
157
|
+
fieldExtensions: customFieldExtensions,
|
|
158
|
+
setErrorText,
|
|
159
|
+
layouts,
|
|
160
|
+
formProps
|
|
161
|
+
}
|
|
162
|
+
)));
|
|
200
163
|
};
|
|
201
164
|
|
|
202
165
|
export { TemplateFormPreviewer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateFormPreviewer.esm.js","sources":["../../../../src/alpha/components/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 */\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 LinearProgress from '@material-ui/core/LinearProgress';\nimport Paper from '@material-ui/core/Paper';\nimport FormControl from '@material-ui/core/FormControl';\nimport Input from '@material-ui/core/Input';\nimport Select from '@material-ui/core/Select';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport IconButton from '@material-ui/core/IconButton';\nimport MenuItem from '@material-ui/core/MenuItem';\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 FormProps,\n} from '@backstage/plugin-scaffolder-react';\nimport { TemplateEditorToolbar } from './TemplateEditorToolbar';\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\n/** @public */\nexport type ScaffolderTemplateFormPreviewerClassKey =\n | 'root'\n | 'controls'\n | 'textArea'\n | 'preview';\n\nconst useStyles = makeStyles(\n theme => ({\n root: {\n height: '100%',\n gridArea: 'pageContent',\n display: 'grid',\n gridTemplateAreas: `\n \"toolbar toolbar\"\n \"textArea preview\"\n `,\n gridTemplateRows: 'auto 1fr',\n gridTemplateColumns: '1fr 1fr',\n },\n toolbar: {\n gridArea: 'toolbar',\n },\n textArea: {\n gridArea: 'textArea',\n height: '100%',\n },\n preview: {\n gridArea: 'preview',\n position: 'relative',\n borderLeft: `1px solid ${theme.palette.divider}`,\n backgroundColor: theme.palette.background.default,\n },\n scroll: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n padding: theme.spacing(1),\n },\n formControl: {\n minWidth: 120,\n maxWidth: 300,\n },\n }),\n { name: 'ScaffolderTemplateFormPreviewer' },\n);\n\nexport const TemplateFormPreviewer = ({\n defaultPreviewTemplate = EXAMPLE_TEMPLATE_PARAMS_YAML,\n customFieldExtensions = [],\n onClose,\n layouts = [],\n formProps,\n}: {\n defaultPreviewTemplate?: string;\n customFieldExtensions?: FieldExtensionOptions<any, any>[];\n onClose?: () => void;\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n}) => {\n const classes = useStyles();\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const alertApi = useApi(alertApiRef);\n const catalogApi = useApi(catalogApiRef);\n const [errorText, setErrorText] = useState<string>();\n const [selectedTemplate, setSelectedTemplate] =\n useState<TemplateOption | null>(null);\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 <Paper\n className={classes.root}\n component=\"main\"\n variant=\"outlined\"\n square\n >\n <div className={classes.toolbar}>\n <TemplateEditorToolbar fieldExtensions={customFieldExtensions}>\n <Tooltip title=\"Close editor\">\n <IconButton onClick={onClose}>\n <CloseIcon />\n </IconButton>\n </Tooltip>\n <FormControl className={classes.formControl}>\n <Select\n displayEmpty\n value={selectedTemplate}\n onChange={e => handleSelectChange(e.target.value)}\n input={<Input />}\n renderValue={selected => {\n if (!selected) {\n return t('templateEditorPage.templateFormPreviewer.title');\n }\n return (selected as Entity).metadata.title;\n }}\n inputProps={{\n 'aria-label': t(\n 'templateEditorPage.templateFormPreviewer.title',\n ),\n }}\n >\n {templateOptions.map((option, index) => (\n <MenuItem key={index} value={option.value as any}>\n {option.label}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </TemplateEditorToolbar>\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 <div className={classes.scroll}>\n <TemplateEditorForm\n content={templateYaml}\n contentIsSpec\n fieldExtensions={customFieldExtensions}\n setErrorText={setErrorText}\n layouts={layouts}\n formProps={formProps}\n />\n </div>\n </div>\n </Paper>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA,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;AAmDrC,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAU,KAAA,MAAA;AAAA,IACR,IAAM,EAAA;AAAA,MACJ,MAAQ,EAAA,MAAA;AAAA,MACR,QAAU,EAAA,aAAA;AAAA,MACV,OAAS,EAAA,MAAA;AAAA,MACT,iBAAmB,EAAA,CAAA;AAAA;AAAA;AAAA,IAAA,CAAA;AAAA,MAInB,gBAAkB,EAA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
|
1
|
+
{"version":3,"file":"TemplateFormPreviewer.esm.js","sources":["../../../../src/alpha/components/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 */\n\nimport yaml from 'yaml';\nimport React, { useCallback, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport useAsync from 'react-use/esm/useAsync';\n\nimport { makeStyles } from '@material-ui/core/styles';\n\nimport { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport {\n catalogApiRef,\n humanizeEntityRef,\n} from '@backstage/plugin-catalog-react';\nimport {\n LayoutOptions,\n FieldExtensionOptions,\n FormProps,\n} from '@backstage/plugin-scaffolder-react';\n\nimport { editRouteRef } from '../../../routes';\n\nimport {\n TemplateEditorLayout,\n TemplateEditorLayoutToolbar,\n TemplateEditorLayoutFiles,\n TemplateEditorLayoutPreview,\n} from './TemplateEditorLayout';\nimport { TemplateEditorToolbar } from './TemplateEditorToolbar';\nimport { TemplateEditorToolbarFileMenu } from './TemplateEditorToolbarFileMenu';\nimport {\n TemplateOption,\n TemplateEditorToolbarTemplatesMenu,\n} from './TemplateEditorToolbarTemplatesMenu';\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\n/** @public */\nexport type ScaffolderTemplateFormPreviewerClassKey =\n | 'root'\n | 'toolbar'\n | 'controls'\n | 'textArea'\n | 'preview';\n\nconst useStyles = makeStyles(\n theme => ({\n root: {\n height: '100%',\n gridArea: 'pageContent',\n display: 'grid',\n gridTemplateAreas: `\n \"toolbar\"\n \"textArea\"\n \"preview\"\n `,\n [theme.breakpoints.up('md')]: {\n gridTemplateAreas: `\n \"toolbar toolbar\"\n \"textArea preview\"\n `,\n gridTemplateRows: 'auto 1fr',\n gridTemplateColumns: '1fr 1fr',\n },\n },\n files: {\n gridArea: 'textArea',\n },\n }),\n { name: 'ScaffolderTemplateFormPreviewer' },\n);\n\nexport const TemplateFormPreviewer = ({\n defaultPreviewTemplate = EXAMPLE_TEMPLATE_PARAMS_YAML,\n customFieldExtensions = [],\n layouts = [],\n formProps,\n}: {\n defaultPreviewTemplate?: string;\n customFieldExtensions?: FieldExtensionOptions<any, any>[];\n onClose?: () => void;\n layouts?: LayoutOptions[];\n formProps?: FormProps;\n}) => {\n const classes = useStyles();\n const alertApi = useApi(alertApiRef);\n const catalogApi = useApi(catalogApiRef);\n const navigate = useNavigate();\n const editLink = useRouteRef(editRouteRef);\n\n const [errorText, setErrorText] = useState<string>();\n const [selectedTemplate, setSelectedTemplate] = useState<TemplateOption>();\n const [templateOptions, setTemplateOptions] = useState<TemplateOption[]>([]);\n const [templateYaml, setTemplateYaml] = useState(defaultPreviewTemplate);\n\n const handleCloseDirectory = useCallback(() => {\n navigate(editLink());\n }, [navigate, editLink]);\n\n 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: TemplateOption) => {\n setSelectedTemplate(selected);\n setTemplateYaml(yaml.stringify(selected.value.spec));\n },\n [setSelectedTemplate, setTemplateYaml],\n );\n\n return (\n <TemplateEditorLayout classes={{ root: classes.root }}>\n <TemplateEditorLayoutToolbar>\n <TemplateEditorToolbar fieldExtensions={customFieldExtensions}>\n <TemplateEditorToolbarFileMenu\n onCloseDirectory={handleCloseDirectory}\n />\n <TemplateEditorToolbarTemplatesMenu\n options={templateOptions}\n selectedOption={selectedTemplate}\n onSelectOption={handleSelectChange}\n />\n </TemplateEditorToolbar>\n </TemplateEditorLayoutToolbar>\n <TemplateEditorLayoutFiles classes={{ root: classes.files }}>\n <TemplateEditorTextArea\n content={templateYaml}\n onUpdate={setTemplateYaml}\n errorText={errorText}\n />\n </TemplateEditorLayoutFiles>\n <TemplateEditorLayoutPreview>\n <TemplateEditorForm\n content={templateYaml}\n contentIsSpec\n fieldExtensions={customFieldExtensions}\n setErrorText={setErrorText}\n layouts={layouts}\n formProps={formProps}\n />\n </TemplateEditorLayoutPreview>\n </TemplateEditorLayout>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmDA,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;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AAA;AAAA,MACA,OAAA;AAAA,MACA,SAAA;AAAA,KAAA;AAAA,GAEJ,CACF,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { Page, Header, Content } from '@backstage/core-components';
|
|
3
|
+
import { TemplateEditorIntro } from './TemplateEditorIntro.esm.js';
|
|
4
|
+
import { useNavigate } from 'react-router-dom';
|
|
5
|
+
import { useRouteRef } from '@backstage/core-plugin-api';
|
|
6
|
+
import { rootRouteRef, editorRouteRef, templateFormRouteRef, customFieldsRouteRef } from '../../../routes.esm.js';
|
|
7
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
8
|
+
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
9
|
+
import { useTemplateDirectory } from './useTemplateDirectory.esm.js';
|
|
10
|
+
|
|
11
|
+
function TemplateIntroPage() {
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
const createLink = useRouteRef(rootRouteRef);
|
|
14
|
+
const editorLink = useRouteRef(editorRouteRef);
|
|
15
|
+
const templateFormLink = useRouteRef(templateFormRouteRef);
|
|
16
|
+
const customFieldsLink = useRouteRef(customFieldsRouteRef);
|
|
17
|
+
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
18
|
+
const { openDirectory, createDirectory } = useTemplateDirectory();
|
|
19
|
+
const handleSelect = useCallback(
|
|
20
|
+
(option) => {
|
|
21
|
+
if (option === "local") {
|
|
22
|
+
openDirectory().then(() => navigate(editorLink())).catch(() => {
|
|
23
|
+
});
|
|
24
|
+
} else if (option === "create-template") {
|
|
25
|
+
createDirectory().then(() => navigate(editorLink())).catch(() => {
|
|
26
|
+
});
|
|
27
|
+
} else if (option === "form") {
|
|
28
|
+
navigate(templateFormLink());
|
|
29
|
+
} else if (option === "field-explorer") {
|
|
30
|
+
navigate(customFieldsLink());
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
[
|
|
34
|
+
openDirectory,
|
|
35
|
+
createDirectory,
|
|
36
|
+
navigate,
|
|
37
|
+
editorLink,
|
|
38
|
+
templateFormLink,
|
|
39
|
+
customFieldsLink
|
|
40
|
+
]
|
|
41
|
+
);
|
|
42
|
+
return /* @__PURE__ */ React.createElement(Page, { themeId: "home" }, /* @__PURE__ */ React.createElement(
|
|
43
|
+
Header,
|
|
44
|
+
{
|
|
45
|
+
title: t("templateIntroPage.title"),
|
|
46
|
+
type: "Scaffolder",
|
|
47
|
+
typeLink: createLink(),
|
|
48
|
+
subtitle: t("templateIntroPage.subtitle")
|
|
49
|
+
}
|
|
50
|
+
), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(TemplateEditorIntro, { onSelect: handleSelect })));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { TemplateIntroPage };
|
|
54
|
+
//# sourceMappingURL=TemplateIntroPage.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateIntroPage.esm.js","sources":["../../../../src/alpha/components/TemplateEditorPage/TemplateIntroPage.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, { useCallback } from 'react';\nimport { Content, Header, Page } from '@backstage/core-components';\n\nimport { TemplateEditorIntro } from './TemplateEditorIntro';\nimport { useNavigate } from 'react-router-dom';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport {\n rootRouteRef,\n editorRouteRef,\n templateFormRouteRef,\n customFieldsRouteRef,\n} from '../../../routes';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\nimport { useTemplateDirectory } from './useTemplateDirectory';\n\nexport function TemplateIntroPage() {\n const navigate = useNavigate();\n const createLink = useRouteRef(rootRouteRef);\n const editorLink = useRouteRef(editorRouteRef);\n const templateFormLink = useRouteRef(templateFormRouteRef);\n const customFieldsLink = useRouteRef(customFieldsRouteRef);\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const { openDirectory, createDirectory } = useTemplateDirectory();\n\n const handleSelect = useCallback(\n (option: 'create-template' | 'local' | 'form' | 'field-explorer') => {\n if (option === 'local') {\n openDirectory()\n .then(() => navigate(editorLink()))\n .catch(() => {});\n } else if (option === 'create-template') {\n createDirectory()\n .then(() => navigate(editorLink()))\n .catch(() => {});\n } else if (option === 'form') {\n navigate(templateFormLink());\n } else if (option === 'field-explorer') {\n navigate(customFieldsLink());\n }\n },\n [\n openDirectory,\n createDirectory,\n navigate,\n editorLink,\n templateFormLink,\n customFieldsLink,\n ],\n );\n\n return (\n <Page themeId=\"home\">\n <Header\n title={t('templateIntroPage.title')}\n type=\"Scaffolder\"\n typeLink={createLink()}\n subtitle={t('templateIntroPage.subtitle')}\n />\n <Content>\n <TemplateEditorIntro onSelect={handleSelect} />\n </Content>\n </Page>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AA+BO,SAAS,iBAAoB,GAAA;AAClC,EAAA,MAAM,WAAW,WAAY,EAAA,CAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,YAAY,YAAY,CAAA,CAAA;AAC3C,EAAM,MAAA,UAAA,GAAa,YAAY,cAAc,CAAA,CAAA;AAC7C,EAAM,MAAA,gBAAA,GAAmB,YAAY,oBAAoB,CAAA,CAAA;AACzD,EAAM,MAAA,gBAAA,GAAmB,YAAY,oBAAoB,CAAA,CAAA;AACzD,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA,CAAA;AACxD,EAAA,MAAM,EAAE,aAAA,EAAe,eAAgB,EAA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1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import useAsyncRetry from 'react-use/esm/useAsyncRetry';
|
|
3
|
+
import { createExampleTemplate } from '../../../lib/filesystem/createExampleTemplate.esm.js';
|
|
4
|
+
import { WebFileSystemStore } from '../../../lib/filesystem/WebFileSystemStore.esm.js';
|
|
5
|
+
import { WebFileSystemAccess } from '../../../lib/filesystem/WebFileSystemAccess.esm.js';
|
|
6
|
+
|
|
7
|
+
function useTemplateDirectory() {
|
|
8
|
+
const { value, loading, error, retry } = useAsyncRetry(async () => {
|
|
9
|
+
const directory = await WebFileSystemStore.getDirectory();
|
|
10
|
+
if (!directory) return void 0;
|
|
11
|
+
return WebFileSystemAccess.fromHandle(directory);
|
|
12
|
+
}, []);
|
|
13
|
+
const openDirectory = useCallback(() => {
|
|
14
|
+
return WebFileSystemAccess.requestDirectoryAccess().then(WebFileSystemStore.setDirectory).then(retry);
|
|
15
|
+
}, [retry]);
|
|
16
|
+
const createDirectory = useCallback(() => {
|
|
17
|
+
return WebFileSystemAccess.requestDirectoryAccess().then(createExampleTemplate).then(WebFileSystemStore.setDirectory).then(retry);
|
|
18
|
+
}, [retry]);
|
|
19
|
+
const closeDirectory = useCallback(() => {
|
|
20
|
+
return WebFileSystemStore.setDirectory(void 0).then(retry);
|
|
21
|
+
}, [retry]);
|
|
22
|
+
return {
|
|
23
|
+
directory: value,
|
|
24
|
+
loading,
|
|
25
|
+
error,
|
|
26
|
+
openDirectory,
|
|
27
|
+
createDirectory,
|
|
28
|
+
closeDirectory
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { useTemplateDirectory };
|
|
33
|
+
//# sourceMappingURL=useTemplateDirectory.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTemplateDirectory.esm.js","sources":["../../../../src/alpha/components/TemplateEditorPage/useTemplateDirectory.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { useCallback } from 'react';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\n\nimport {\n WebFileSystemStore,\n WebFileSystemAccess,\n WebDirectoryAccess,\n createExampleTemplate,\n} from '../../../lib/filesystem';\n\nexport function useTemplateDirectory(): {\n directory?: WebDirectoryAccess;\n loading: boolean;\n error?: Error;\n openDirectory: () => Promise<void>;\n createDirectory: () => Promise<void>;\n closeDirectory: () => Promise<void>;\n} {\n const { value, loading, error, retry } = useAsyncRetry(async () => {\n const directory = await WebFileSystemStore.getDirectory();\n if (!directory) return undefined;\n return WebFileSystemAccess.fromHandle(directory);\n }, []);\n\n const openDirectory = useCallback(() => {\n return WebFileSystemAccess.requestDirectoryAccess()\n .then(WebFileSystemStore.setDirectory)\n .then(retry);\n }, [retry]);\n\n const createDirectory = useCallback(() => {\n return WebFileSystemAccess.requestDirectoryAccess()\n .then(createExampleTemplate)\n .then(WebFileSystemStore.setDirectory)\n .then(retry);\n }, [retry]);\n\n const closeDirectory = useCallback(() => {\n return WebFileSystemStore.setDirectory(undefined).then(retry);\n }, [retry]);\n\n return {\n directory: value,\n loading,\n error,\n openDirectory,\n createDirectory,\n closeDirectory,\n };\n}\n"],"names":[],"mappings":";;;;;;AA0BO,SAAS,oBAOd,GAAA;AACA,EAAA,MAAM,EAAE,KAAO,EAAA,OAAA,EAAS,OAAO,KAAM,EAAA,GAAI,cAAc,YAAY;AACjE,IAAM,MAAA,SAAA,GAAY,MAAM,kBAAA,CAAmB,YAAa,EAAA,CAAA;AACxD,IAAI,IAAA,CAAC,WAAkB,OAAA,KAAA,CAAA,CAAA;AACvB,IAAO,OAAA,mBAAA,CAAoB,WAAW,SAAS,CAAA,CAAA;AAAA,GACjD,EAAG,EAAE,CAAA,CAAA;AAEL,EAAM,MAAA,aAAA,GAAgB,YAAY,MAAM;AACtC,IAAO,OAAA,mBAAA,CAAoB,wBACxB,CAAA,IAAA,CAAK,mBAAmB,YAAY,CAAA,CACpC,KAAK,KAAK,CAAA,CAAA;AAAA,GACf,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA;AAEV,EAAM,MAAA,eAAA,GAAkB,YAAY,MAAM;AACxC,IAAO,OAAA,mBAAA,CAAoB,sBAAuB,EAAA,CAC/C,IAAK,CAAA,qBAAqB,CAC1B,CAAA,IAAA,CAAK,kBAAmB,CAAA,YAAY,CACpC,CAAA,IAAA,CAAK,KAAK,CAAA,CAAA;AAAA,GACf,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA;AAEV,EAAM,MAAA,cAAA,GAAiB,YAAY,MAAM;AACvC,IAAA,OAAO,kBAAmB,CAAA,YAAA,CAAa,KAAS,CAAA,CAAA,CAAE,KAAK,KAAK,CAAA,CAAA;AAAA,GAC9D,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA;AAEV,EAAO,OAAA;AAAA,IACL,SAAW,EAAA,KAAA;AAAA,IACX,OAAA;AAAA,IACA,KAAA;AAAA,IACA,aAAA;AAAA,IACA,eAAA;AAAA,IACA,cAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -28,7 +28,7 @@ const RegisterExistingButton = (props) => {
|
|
|
28
28
|
to
|
|
29
29
|
},
|
|
30
30
|
/* @__PURE__ */ React.createElement(CreateComponentIcon, null)
|
|
31
|
-
) : /* @__PURE__ */ React.createElement(Button, { component: Link, variant: "
|
|
31
|
+
) : /* @__PURE__ */ React.createElement(Button, { component: Link, variant: "outlined", color: "primary", to }, title);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export { RegisterExistingButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisterExistingButton.esm.js","sources":["../../../../src/alpha/components/TemplateListPage/RegisterExistingButton.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 Button from '@material-ui/core/Button';\nimport IconButton from '@material-ui/core/IconButton';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport React from 'react';\nimport { Link as RouterLink, LinkProps } from 'react-router-dom';\nimport AddCircleOutline from '@material-ui/icons/AddCircleOutline';\nimport { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { Theme } from '@material-ui/core/styles';\n\n/**\n * Properties for {@link RegisterExistingButton}\n *\n * @alpha\n */\nexport type RegisterExistingButtonProps = {\n title: string;\n} & Partial<Pick<LinkProps, 'to'>>;\n\n/**\n * A button that helps users to register an existing component.\n * @alpha\n */\nexport const RegisterExistingButton = (props: RegisterExistingButtonProps) => {\n const { title, to } = props;\n const { allowed } = usePermission({\n permission: catalogEntityCreatePermission,\n });\n const isXSScreen = useMediaQuery<Theme>(theme =>\n theme.breakpoints.down('xs'),\n );\n\n if (!to || !allowed) {\n return null;\n }\n\n return isXSScreen ? (\n <IconButton\n component={RouterLink}\n color=\"primary\"\n title={title}\n size=\"small\"\n to={to}\n >\n <AddCircleOutline />\n </IconButton>\n ) : (\n <Button component={RouterLink} variant=\"
|
|
1
|
+
{"version":3,"file":"RegisterExistingButton.esm.js","sources":["../../../../src/alpha/components/TemplateListPage/RegisterExistingButton.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 Button from '@material-ui/core/Button';\nimport IconButton from '@material-ui/core/IconButton';\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport React from 'react';\nimport { Link as RouterLink, LinkProps } from 'react-router-dom';\nimport AddCircleOutline from '@material-ui/icons/AddCircleOutline';\nimport { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { Theme } from '@material-ui/core/styles';\n\n/**\n * Properties for {@link RegisterExistingButton}\n *\n * @alpha\n */\nexport type RegisterExistingButtonProps = {\n title: string;\n} & Partial<Pick<LinkProps, 'to'>>;\n\n/**\n * A button that helps users to register an existing component.\n * @alpha\n */\nexport const RegisterExistingButton = (props: RegisterExistingButtonProps) => {\n const { title, to } = props;\n const { allowed } = usePermission({\n permission: catalogEntityCreatePermission,\n });\n const isXSScreen = useMediaQuery<Theme>(theme =>\n theme.breakpoints.down('xs'),\n );\n\n if (!to || !allowed) {\n return null;\n }\n\n return isXSScreen ? (\n <IconButton\n component={RouterLink}\n color=\"primary\"\n title={title}\n size=\"small\"\n to={to}\n >\n <AddCircleOutline />\n </IconButton>\n ) : (\n <Button component={RouterLink} variant=\"outlined\" color=\"primary\" to={to}>\n {title}\n </Button>\n );\n};\n"],"names":["RouterLink","AddCircleOutline"],"mappings":";;;;;;;;;AAuCa,MAAA,sBAAA,GAAyB,CAAC,KAAuC,KAAA;AAC5E,EAAM,MAAA,EAAE,KAAO,EAAA,EAAA,EAAO,GAAA,KAAA,CAAA;AACtB,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,aAAc,CAAA;AAAA,IAChC,UAAY,EAAA,6BAAA;AAAA,GACb,CAAA,CAAA;AACD,EAAA,MAAM,UAAa,GAAA,aAAA;AAAA,IAAqB,CACtC,KAAA,KAAA,KAAA,CAAM,WAAY,CAAA,IAAA,CAAK,IAAI,CAAA;AAAA,GAC7B,CAAA;AAEA,EAAI,IAAA,CAAC,EAAM,IAAA,CAAC,OAAS,EAAA;AACnB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,OAAO,UACL,mBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAAA,IAAA;AAAA,MACX,KAAM,EAAA,SAAA;AAAA,MACN,KAAA;AAAA,MACA,IAAK,EAAA,OAAA;AAAA,MACL,EAAA;AAAA,KAAA;AAAA,wCAECC,mBAAiB,EAAA,IAAA,CAAA;AAAA,GACpB,mBAEC,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAO,SAAW,EAAAD,IAAA,EAAY,SAAQ,UAAW,EAAA,KAAA,EAAM,SAAU,EAAA,EAAA,EAAA,EAC/D,KACH,CAAA,CAAA;AAEJ;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api'
|
|
|
12
12
|
type ScaffolderCustomFieldExplorerClassKey = 'root' | 'controls' | 'fieldForm' | 'preview';
|
|
13
13
|
|
|
14
14
|
/** @public */
|
|
15
|
-
type ScaffolderTemplateEditorClassKey = 'root' | 'browser' | 'editor' | 'preview' | 'results';
|
|
15
|
+
type ScaffolderTemplateEditorClassKey = 'root' | 'toolbar' | 'browser' | 'editor' | 'preview' | 'results';
|
|
16
16
|
|
|
17
17
|
/** @public */
|
|
18
|
-
type ScaffolderTemplateFormPreviewerClassKey = 'root' | 'controls' | 'textArea' | 'preview';
|
|
18
|
+
type ScaffolderTemplateFormPreviewerClassKey = 'root' | 'toolbar' | 'controls' | 'textArea' | 'preview';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @alpha
|
|
@@ -117,6 +117,7 @@ declare const scaffolderTranslationRef: _backstage_core_plugin_api_alpha.Transla
|
|
|
117
117
|
readonly "actionsPage.content.tableCell.name": "Name";
|
|
118
118
|
readonly "actionsPage.content.tableCell.title": "Title";
|
|
119
119
|
readonly "actionsPage.content.tableCell.description": "Description";
|
|
120
|
+
readonly "actionsPage.content.searchFieldPlaceholder": "Search for an action";
|
|
120
121
|
readonly "actionsPage.content.noRowsDescription": "No schema defined";
|
|
121
122
|
readonly "actionsPage.title": "Installed actions";
|
|
122
123
|
readonly "actionsPage.action.input": "Input";
|
|
@@ -156,8 +157,12 @@ declare const scaffolderTranslationRef: _backstage_core_plugin_api_alpha.Transla
|
|
|
156
157
|
readonly "ongoingTask.showLogsButtonTitle": "Show Logs";
|
|
157
158
|
readonly "templateEditorForm.stepper.emptyText": "There are no spec parameters in the template to preview.";
|
|
158
159
|
readonly "templateTypePicker.title": "Categories";
|
|
159
|
-
readonly "
|
|
160
|
-
readonly "
|
|
160
|
+
readonly "templateIntroPage.title": "Manage Templates";
|
|
161
|
+
readonly "templateIntroPage.subtitle": "Edit, preview, and try out templates, forms, and custom fields";
|
|
162
|
+
readonly "templateFormPage.title": "Template Editor";
|
|
163
|
+
readonly "templateFormPage.subtitle": "Edit, preview, and try out templates forms";
|
|
164
|
+
readonly "templateCustomFieldPage.title": "Custom Field Explorer";
|
|
165
|
+
readonly "templateCustomFieldPage.subtitle": "Edit, preview, and try out custom fields";
|
|
161
166
|
readonly "templateEditorPage.title": "Template Editor";
|
|
162
167
|
readonly "templateEditorPage.subtitle": "Edit, preview, and try out templates and template forms";
|
|
163
168
|
readonly "templateEditorPage.dryRunResults.title": "Dry-run results";
|
|
@@ -184,12 +189,13 @@ declare const scaffolderTranslationRef: _backstage_core_plugin_api_alpha.Transla
|
|
|
184
189
|
readonly "templateEditorPage.templateEditorIntro.createLocal.title": "Create New Template";
|
|
185
190
|
readonly "templateEditorPage.templateEditorIntro.createLocal.description": "Create a local template directory, allowing you to both edit and try executing your own template.";
|
|
186
191
|
readonly "templateEditorPage.templateEditorIntro.createLocal.unsupportedTooltip": "Only supported in some Chromium-based browsers";
|
|
187
|
-
readonly "templateEditorPage.templateEditorIntro.formEditor.title": "
|
|
192
|
+
readonly "templateEditorPage.templateEditorIntro.formEditor.title": "Template Form Playground";
|
|
188
193
|
readonly "templateEditorPage.templateEditorIntro.formEditor.description": "Preview and edit a template form, either using a sample template or by loading a template from the catalog.";
|
|
189
194
|
readonly "templateEditorPage.templateEditorIntro.fieldExplorer.title": "Custom Field Explorer";
|
|
190
195
|
readonly "templateEditorPage.templateEditorIntro.fieldExplorer.description": "View and play around with available installed custom field extensions.";
|
|
191
196
|
readonly "templateEditorPage.templateEditorTextArea.saveIconTooltip": "Save file";
|
|
192
197
|
readonly "templateEditorPage.templateEditorTextArea.refreshIconTooltip": "Reload file";
|
|
198
|
+
readonly "templateEditorPage.templateEditorTextArea.emptyStateParagraph": "Please select an action on the file menu.";
|
|
193
199
|
readonly "templateEditorPage.templateFormPreviewer.title": "Load Existing Template";
|
|
194
200
|
readonly "templateListPage.title": "Create a new component";
|
|
195
201
|
readonly "templateListPage.subtitle": "Create new software components using standard templates in your organization";
|
|
@@ -203,6 +209,19 @@ declare const scaffolderTranslationRef: _backstage_core_plugin_api_alpha.Transla
|
|
|
203
209
|
readonly "templateWizardPage.subtitle": "Create new software components using standard templates in your organization";
|
|
204
210
|
readonly "templateWizardPage.pageTitle": "Create a new component";
|
|
205
211
|
readonly "templateWizardPage.pageContextMenu.editConfigurationTitle": "Edit Configuration";
|
|
212
|
+
readonly "templateEditorToolbar.customFieldExplorerTooltip": "Custom Fields Explorer";
|
|
213
|
+
readonly "templateEditorToolbar.installedActionsDocumentationTooltip": "Installed Actions Documentation";
|
|
214
|
+
readonly "templateEditorToolbar.addToCatalogButton": "Publish";
|
|
215
|
+
readonly "templateEditorToolbar.addToCatalogDialogTitle": "Publish changes";
|
|
216
|
+
readonly "templateEditorToolbar.addToCatalogDialogContent.stepsIntroduction": "Follow the instructions below to create or update a template:";
|
|
217
|
+
readonly "templateEditorToolbar.addToCatalogDialogContent.stepsListItems": "Save the template files in a local directory\nCreate a pull request to a new or existing git repository\nIf the template already exists, the changes will be reflected in the software catalog once the pull request gets merged\nBut if you are creating a new template, follow the documentation linked below to register the new template repository in software catalog";
|
|
218
|
+
readonly "templateEditorToolbar.addToCatalogDialogActions.documentationUrl": "https://backstage.io/docs/features/software-templates/adding-templates/";
|
|
219
|
+
readonly "templateEditorToolbar.addToCatalogDialogActions.documentationButton": "Go to the documentation";
|
|
220
|
+
readonly "templateEditorToolbarFileMenu.button": "File";
|
|
221
|
+
readonly "templateEditorToolbarFileMenu.options.openDirectory": "Open template directory";
|
|
222
|
+
readonly "templateEditorToolbarFileMenu.options.createDirectory": "Create template directory";
|
|
223
|
+
readonly "templateEditorToolbarFileMenu.options.closeEditor": "Close template editor";
|
|
224
|
+
readonly "templateEditorToolbarTemplatesMenu.button": "Templates";
|
|
206
225
|
}>;
|
|
207
226
|
|
|
208
227
|
/*
|
package/dist/api.esm.js
CHANGED
|
@@ -25,9 +25,11 @@ class ScaffolderClient {
|
|
|
25
25
|
}
|
|
26
26
|
const baseUrl = await this.discoveryApi.getBaseUrl("scaffolder");
|
|
27
27
|
const { userEntityRef } = await this.identityApi.getBackstageIdentity();
|
|
28
|
-
const query = qs.stringify(
|
|
29
|
-
options.filterByOwnership === "owned" ?
|
|
30
|
-
|
|
28
|
+
const query = qs.stringify({
|
|
29
|
+
createdBy: options.filterByOwnership === "owned" ? userEntityRef : void 0,
|
|
30
|
+
limit: options.limit,
|
|
31
|
+
offset: options.offset
|
|
32
|
+
});
|
|
31
33
|
const response = await this.fetchApi.fetch(`${baseUrl}/v2/tasks?${query}`);
|
|
32
34
|
if (!response.ok) {
|
|
33
35
|
throw await ResponseError.fromResponse(response);
|