@backstage/plugin-scaffolder 1.10.0-next.1 → 1.10.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.
@@ -0,0 +1,251 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Link, useNavigate, useOutlet, Routes, Route } from 'react-router-dom';
3
+ import { Progress, Link as Link$1, DocsIcon, Page, Header, Content, ContentHeader, SupportButton } from '@backstage/core-components';
4
+ import { useEntityTypeFilter, useEntityList, EntityListProvider, CatalogFilterLayout, EntitySearchBar, EntityKindPicker, UserListPicker, EntityTagPicker } from '@backstage/plugin-catalog-react';
5
+ import capitalize from 'lodash/capitalize';
6
+ import { Box, Typography, FormControlLabel, Checkbox, TextField } from '@material-ui/core';
7
+ import CheckBoxIcon from '@material-ui/icons/CheckBox';
8
+ import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';
9
+ import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
10
+ import { Autocomplete } from '@material-ui/lab';
11
+ import { useApi, alertApiRef, errorApiRef, useApp, useRouteRef } from '@backstage/core-plugin-api';
12
+ import Button from '@material-ui/core/Button';
13
+ import IconButton from '@material-ui/core/IconButton';
14
+ import useMediaQuery from '@material-ui/core/useMediaQuery';
15
+ import AddCircleOutline from '@material-ui/icons/AddCircleOutline';
16
+ import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common';
17
+ import { usePermission } from '@backstage/plugin-permission-react';
18
+ import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';
19
+ import { TemplateGroup, useCustomFieldExtensions, SecretsContextProvider } from '@backstage/plugin-scaffolder-react';
20
+ import { v as viewTechDocRouteRef, y as nextSelectedTemplateRouteRef, r as registerComponentRouteRef, z as TemplateWizardPage } from './index-618869a2.esm.js';
21
+ import { D as DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from './default-b0a9b946.esm.js';
22
+ import '@backstage/errors';
23
+ import 'qs';
24
+ import 'zen-observable';
25
+ import '@backstage/integration-react';
26
+ import '@material-ui/core/FormControl';
27
+ import '@material-ui/lab/Autocomplete';
28
+ import 'react-use/lib/useAsync';
29
+ import 'zod';
30
+ import 'zod-to-json-schema';
31
+ import '@material-ui/core/FormHelperText';
32
+ import '@material-ui/core/Input';
33
+ import '@material-ui/core/InputLabel';
34
+ import 'react-use/lib/useDebounce';
35
+ import 'react-use/lib/useEffectOnce';
36
+ import '@material-ui/core/Grid';
37
+ import '@material-ui/core/Step';
38
+ import '@material-ui/core/StepLabel';
39
+ import '@material-ui/core/Stepper';
40
+ import '@material-ui/core/styles';
41
+ import '@material-ui/core/Typography';
42
+ import '@material-ui/icons/Cancel';
43
+ import '@material-ui/icons/Check';
44
+ import '@material-ui/icons/FiberManualRecord';
45
+ import 'classnames';
46
+ import 'luxon';
47
+ import 'react-use/lib/useInterval';
48
+ import 'use-immer';
49
+ import '@material-ui/icons/Language';
50
+
51
+ const icon = /* @__PURE__ */ React.createElement(CheckBoxOutlineBlankIcon, { fontSize: "small" });
52
+ const checkedIcon = /* @__PURE__ */ React.createElement(CheckBoxIcon, { fontSize: "small" });
53
+ const CategoryPicker = () => {
54
+ const alertApi = useApi(alertApiRef);
55
+ const { error, loading, availableTypes, selectedTypes, setSelectedTypes } = useEntityTypeFilter();
56
+ if (loading)
57
+ return /* @__PURE__ */ React.createElement(Progress, null);
58
+ if (error) {
59
+ alertApi.post({
60
+ message: `Failed to load entity types with error: ${error}`,
61
+ severity: "error"
62
+ });
63
+ return null;
64
+ }
65
+ if (!availableTypes)
66
+ return null;
67
+ return /* @__PURE__ */ React.createElement(Box, { pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(Typography, { variant: "button" }, "Categories"), /* @__PURE__ */ React.createElement(
68
+ Autocomplete,
69
+ {
70
+ multiple: true,
71
+ "aria-label": "Categories",
72
+ options: availableTypes,
73
+ value: selectedTypes,
74
+ onChange: (_, value) => setSelectedTypes(value),
75
+ renderOption: (option, { selected }) => /* @__PURE__ */ React.createElement(
76
+ FormControlLabel,
77
+ {
78
+ control: /* @__PURE__ */ React.createElement(
79
+ Checkbox,
80
+ {
81
+ icon,
82
+ checkedIcon,
83
+ checked: selected
84
+ }
85
+ ),
86
+ label: capitalize(option)
87
+ }
88
+ ),
89
+ size: "small",
90
+ popupIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, null),
91
+ renderInput: (params) => /* @__PURE__ */ React.createElement(TextField, { ...params, variant: "outlined" })
92
+ }
93
+ ));
94
+ };
95
+
96
+ const RegisterExistingButton = (props) => {
97
+ const { title, to } = props;
98
+ const { allowed } = usePermission({
99
+ permission: catalogEntityCreatePermission
100
+ });
101
+ const isXSScreen = useMediaQuery(
102
+ (theme) => theme.breakpoints.down("xs")
103
+ );
104
+ if (!to || !allowed) {
105
+ return null;
106
+ }
107
+ return isXSScreen ? /* @__PURE__ */ React.createElement(
108
+ IconButton,
109
+ {
110
+ component: Link,
111
+ color: "primary",
112
+ title,
113
+ size: "small",
114
+ to
115
+ },
116
+ /* @__PURE__ */ React.createElement(AddCircleOutline, null)
117
+ ) : /* @__PURE__ */ React.createElement(Button, { component: Link, variant: "contained", color: "primary", to }, title);
118
+ };
119
+
120
+ const TemplateGroups = (props) => {
121
+ const { loading, error, entities } = useEntityList();
122
+ const { groups, TemplateCardComponent } = props;
123
+ const errorApi = useApi(errorApiRef);
124
+ const app = useApp();
125
+ const viewTechDocsLink = useRouteRef(viewTechDocRouteRef);
126
+ const templateRoute = useRouteRef(nextSelectedTemplateRouteRef);
127
+ const navigate = useNavigate();
128
+ const onSelected = useCallback(
129
+ (template) => {
130
+ const { namespace, name } = parseEntityRef(stringifyEntityRef(template));
131
+ navigate(templateRoute({ namespace, templateName: name }));
132
+ },
133
+ [navigate, templateRoute]
134
+ );
135
+ if (loading) {
136
+ return /* @__PURE__ */ React.createElement(Progress, null);
137
+ }
138
+ if (error) {
139
+ errorApi.post(error);
140
+ return null;
141
+ }
142
+ if (!entities || !entities.length) {
143
+ return /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "No templates found that match your filter. Learn more about", " ", /* @__PURE__ */ React.createElement(Link$1, { to: "https://backstage.io/docs/features/software-templates/adding-templates" }, "adding templates"), ".");
144
+ }
145
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, groups.map(({ title, filter }, index) => {
146
+ const templates = entities.filter((e) => filter(e)).map((template) => {
147
+ var _a, _b;
148
+ const { kind, namespace, name } = parseEntityRef(
149
+ stringifyEntityRef(template)
150
+ );
151
+ const additionalLinks = ((_a = template.metadata.annotations) == null ? void 0 : _a["backstage.io/techdocs-ref"]) && viewTechDocsLink ? [
152
+ {
153
+ icon: (_b = app.getSystemIcon("docs")) != null ? _b : DocsIcon,
154
+ text: "View TechDocs",
155
+ url: viewTechDocsLink({ kind, namespace, name })
156
+ }
157
+ ] : [];
158
+ return {
159
+ template,
160
+ additionalLinks
161
+ };
162
+ });
163
+ return /* @__PURE__ */ React.createElement(
164
+ TemplateGroup,
165
+ {
166
+ key: index,
167
+ templates,
168
+ title,
169
+ components: { CardComponent: TemplateCardComponent },
170
+ onSelected
171
+ }
172
+ );
173
+ }));
174
+ };
175
+
176
+ const defaultGroup = {
177
+ title: "All Templates",
178
+ filter: () => true
179
+ };
180
+ const TemplateListPage = (props) => {
181
+ const registerComponentLink = useRouteRef(registerComponentRouteRef);
182
+ const { TemplateCardComponent, groups = [] } = props;
183
+ return /* @__PURE__ */ React.createElement(EntityListProvider, null, /* @__PURE__ */ React.createElement(Page, { themeId: "website" }, /* @__PURE__ */ React.createElement(
184
+ Header,
185
+ {
186
+ pageTitleOverride: "Create a new component",
187
+ title: "Create a new component",
188
+ subtitle: "Create new software components using standard templates in your organization"
189
+ }
190
+ ), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(ContentHeader, { title: "Available Templates" }, /* @__PURE__ */ React.createElement(
191
+ RegisterExistingButton,
192
+ {
193
+ title: "Register Existing Component",
194
+ to: registerComponentLink && registerComponentLink()
195
+ }
196
+ ), /* @__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(
197
+ UserListPicker,
198
+ {
199
+ initialFilter: "all",
200
+ availableFilters: ["all", "starred"]
201
+ }
202
+ ), /* @__PURE__ */ React.createElement(CategoryPicker, null), /* @__PURE__ */ React.createElement(EntityTagPicker, null)), /* @__PURE__ */ React.createElement(CatalogFilterLayout.Content, null, /* @__PURE__ */ React.createElement(
203
+ TemplateGroups,
204
+ {
205
+ groups: [...groups, defaultGroup],
206
+ TemplateCardComponent
207
+ }
208
+ ))))));
209
+ };
210
+
211
+ const Router = (props) => {
212
+ const { components: { TemplateCardComponent } = {} } = props;
213
+ const outlet = useOutlet() || props.children;
214
+ const customFieldExtensions = useCustomFieldExtensions(outlet);
215
+ const fieldExtensions = [
216
+ ...customFieldExtensions,
217
+ ...DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS.filter(
218
+ ({ name }) => !customFieldExtensions.some(
219
+ (customFieldExtension) => customFieldExtension.name === name
220
+ )
221
+ )
222
+ ];
223
+ return /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(
224
+ Route,
225
+ {
226
+ path: "/",
227
+ element: /* @__PURE__ */ React.createElement(
228
+ TemplateListPage,
229
+ {
230
+ TemplateCardComponent,
231
+ groups: props.groups
232
+ }
233
+ )
234
+ }
235
+ ), /* @__PURE__ */ React.createElement(
236
+ Route,
237
+ {
238
+ path: nextSelectedTemplateRouteRef.path,
239
+ element: /* @__PURE__ */ React.createElement(SecretsContextProvider, null, /* @__PURE__ */ React.createElement(
240
+ TemplateWizardPage,
241
+ {
242
+ customFieldExtensions: fieldExtensions,
243
+ FormProps: props.FormProps
244
+ }
245
+ ))
246
+ }
247
+ ));
248
+ };
249
+
250
+ export { Router };
251
+ //# sourceMappingURL=index-6aee5f45.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-6aee5f45.esm.js","sources":["../../src/next/TemplateListPage/CategoryPicker.tsx","../../src/next/TemplateListPage/RegisterExistingButton.tsx","../../src/next/TemplateListPage/TemplateGroups.tsx","../../src/next/TemplateListPage/TemplateListPage.tsx","../../src/next/Router/Router.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 React from 'react';\nimport capitalize from 'lodash/capitalize';\nimport { Progress } from '@backstage/core-components';\nimport {\n Box,\n Checkbox,\n FormControlLabel,\n TextField,\n Typography,\n} from '@material-ui/core';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { Autocomplete } from '@material-ui/lab';\nimport { useEntityTypeFilter } from '@backstage/plugin-catalog-react';\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\n\nconst icon = <CheckBoxOutlineBlankIcon fontSize=\"small\" />;\nconst checkedIcon = <CheckBoxIcon fontSize=\"small\" />;\n\n/**\n * The Category Picker that is rendered on the left side for picking\n * categories and filtering the template list.\n */\nexport const CategoryPicker = () => {\n const alertApi = useApi(alertApiRef);\n const { error, loading, availableTypes, selectedTypes, setSelectedTypes } =\n useEntityTypeFilter();\n\n if (loading) return <Progress />;\n\n if (error) {\n alertApi.post({\n message: `Failed to load entity types with error: ${error}`,\n severity: 'error',\n });\n return null;\n }\n\n if (!availableTypes) return null;\n\n return (\n <Box pb={1} pt={1}>\n <Typography variant=\"button\">Categories</Typography>\n <Autocomplete\n multiple\n aria-label=\"Categories\"\n options={availableTypes}\n value={selectedTypes}\n onChange={(_: object, value: string[]) => setSelectedTypes(value)}\n renderOption={(option, { selected }) => (\n <FormControlLabel\n control={\n <Checkbox\n icon={icon}\n checkedIcon={checkedIcon}\n checked={selected}\n />\n }\n label={capitalize(option)}\n />\n )}\n size=\"small\"\n popupIcon={<ExpandMoreIcon />}\n renderInput={params => <TextField {...params} variant=\"outlined\" />}\n />\n </Box>\n );\n};\n","/*\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 { BackstageTheme } from '@backstage/theme';\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';\nimport { usePermission } from '@backstage/plugin-permission-react';\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<BackstageTheme>(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=\"contained\" color=\"primary\" to={to}>\n {title}\n </Button>\n );\n};\n","/*\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';\n\nimport {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useEntityList } from '@backstage/plugin-catalog-react';\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { Progress, Link, DocsIcon } from '@backstage/core-components';\nimport { Typography } from '@material-ui/core';\nimport {\n errorApiRef,\n useApi,\n useApp,\n useRouteRef,\n} from '@backstage/core-plugin-api';\nimport { TemplateGroup } from '@backstage/plugin-scaffolder-react';\nimport { viewTechDocRouteRef } from '../../routes';\nimport { nextSelectedTemplateRouteRef } from '../routes';\nimport { useNavigate } from 'react-router-dom';\n\n/**\n * @alpha\n */\nexport type TemplateGroupFilter = {\n title?: React.ReactNode;\n filter: (entity: Entity) => boolean;\n};\n\nexport interface TemplateGroupsProps {\n groups: TemplateGroupFilter[];\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n}\n\nexport const TemplateGroups = (props: TemplateGroupsProps) => {\n const { loading, error, entities } = useEntityList();\n const { groups, TemplateCardComponent } = props;\n const errorApi = useApi(errorApiRef);\n const app = useApp();\n const viewTechDocsLink = useRouteRef(viewTechDocRouteRef);\n const templateRoute = useRouteRef(nextSelectedTemplateRouteRef);\n const navigate = useNavigate();\n const onSelected = useCallback(\n (template: TemplateEntityV1beta3) => {\n const { namespace, name } = parseEntityRef(stringifyEntityRef(template));\n navigate(templateRoute({ namespace, templateName: name }));\n },\n [navigate, templateRoute],\n );\n\n if (loading) {\n return <Progress />;\n }\n\n if (error) {\n errorApi.post(error);\n return null;\n }\n\n if (!entities || !entities.length) {\n return (\n <Typography variant=\"body2\">\n No templates found that match your filter. Learn more about{' '}\n <Link to=\"https://backstage.io/docs/features/software-templates/adding-templates\">\n adding templates\n </Link>\n .\n </Typography>\n );\n }\n\n return (\n <>\n {groups.map(({ title, filter }, index) => {\n const templates = entities\n .filter((e): e is TemplateEntityV1beta3 => filter(e))\n .map(template => {\n const { kind, namespace, name } = parseEntityRef(\n stringifyEntityRef(template),\n );\n const additionalLinks =\n 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 return {\n template,\n additionalLinks,\n };\n });\n\n return (\n <TemplateGroup\n key={index}\n templates={templates}\n title={title}\n components={{ CardComponent: TemplateCardComponent }}\n onSelected={onSelected}\n />\n );\n })}\n </>\n );\n};\n","/*\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 { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\n\nimport {\n Content,\n ContentHeader,\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 { CategoryPicker } from './CategoryPicker';\nimport { RegisterExistingButton } from './RegisterExistingButton';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport { TemplateGroupFilter, TemplateGroups } from './TemplateGroups';\nimport { registerComponentRouteRef } from '../../routes';\n\nexport type TemplateListPageProps = {\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n groups?: TemplateGroupFilter[];\n};\n\nconst defaultGroup: TemplateGroupFilter = {\n title: 'All Templates',\n filter: () => true,\n};\n\nexport const TemplateListPage = (props: TemplateListPageProps) => {\n const registerComponentLink = useRouteRef(registerComponentRouteRef);\n const { TemplateCardComponent, groups = [] } = props;\n\n return (\n <EntityListProvider>\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 />\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 <CategoryPicker />\n <EntityTagPicker />\n </CatalogFilterLayout.Filters>\n <CatalogFilterLayout.Content>\n <TemplateGroups\n groups={[...groups, defaultGroup]}\n TemplateCardComponent={TemplateCardComponent}\n />\n </CatalogFilterLayout.Content>\n </CatalogFilterLayout>\n </Content>\n </Page>\n </EntityListProvider>\n );\n};\n","/*\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, { PropsWithChildren } from 'react';\nimport { Routes, Route, useOutlet } from 'react-router-dom';\nimport { TemplateListPage } from '../TemplateListPage';\nimport { TemplateWizardPage } from '../TemplateWizardPage';\nimport {\n NextFieldExtensionOptions,\n SecretsContextProvider,\n useCustomFieldExtensions,\n} from '@backstage/plugin-scaffolder-react';\n\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { TemplateGroupFilter } from '../TemplateListPage/TemplateGroups';\nimport { DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from '../../extensions/default';\nimport { FormProps } from '../types';\nimport { nextSelectedTemplateRouteRef } from '../routes';\n\n/**\n * The Props for the Scaffolder Router\n *\n * @alpha\n */\nexport type NextRouterProps = {\n components?: {\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n TaskPageComponent?: React.ComponentType<{}>;\n };\n groups?: TemplateGroupFilter[];\n FormProps?: FormProps;\n};\n\n/**\n * The Scaffolder Router\n *\n * @alpha\n */\nexport const Router = (props: PropsWithChildren<NextRouterProps>) => {\n const { components: { TemplateCardComponent } = {} } = props;\n const outlet = useOutlet() || props.children;\n const customFieldExtensions =\n useCustomFieldExtensions<NextFieldExtensionOptions>(outlet);\n const fieldExtensions = [\n ...customFieldExtensions,\n ...DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS.filter(\n ({ name }) =>\n !customFieldExtensions.some(\n customFieldExtension => customFieldExtension.name === name,\n ),\n ),\n ] as NextFieldExtensionOptions[];\n\n return (\n <Routes>\n <Route\n path=\"/\"\n element={\n <TemplateListPage\n TemplateCardComponent={TemplateCardComponent}\n groups={props.groups}\n />\n }\n />\n <Route\n path={nextSelectedTemplateRouteRef.path}\n element={\n <SecretsContextProvider>\n <TemplateWizardPage\n customFieldExtensions={fieldExtensions}\n FormProps={props.FormProps}\n />\n </SecretsContextProvider>\n }\n />\n </Routes>\n );\n};\n"],"names":["RouterLink","Link"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,IAAO,mBAAA,KAAA,CAAA,aAAA,CAAC,wBAAyB,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA,CAAA,CAAA;AACxD,MAAM,WAAc,mBAAA,KAAA,CAAA,aAAA,CAAC,YAAa,EAAA,EAAA,QAAA,EAAS,OAAQ,EAAA,CAAA,CAAA;AAM5C,MAAM,iBAAiB,MAAM;AAClC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAA,MAAM,EAAE,KAAO,EAAA,OAAA,EAAS,gBAAgB,aAAe,EAAA,gBAAA,KACrD,mBAAoB,EAAA,CAAA;AAEtB,EAAI,IAAA,OAAA;AAAS,IAAA,2CAAQ,QAAS,EAAA,IAAA,CAAA,CAAA;AAE9B,EAAA,IAAI,KAAO,EAAA;AACT,IAAA,QAAA,CAAS,IAAK,CAAA;AAAA,MACZ,SAAS,CAA2C,wCAAA,EAAA,KAAA,CAAA,CAAA;AAAA,MACpD,QAAU,EAAA,OAAA;AAAA,KACX,CAAA,CAAA;AACD,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,IAAI,CAAC,cAAA;AAAgB,IAAO,OAAA,IAAA,CAAA;AAE5B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,GAAI,EAAA,EAAA,EAAA,EAAI,CAAG,EAAA,EAAA,EAAI,CACd,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EA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