@backstage/plugin-scaffolder 1.19.3 → 1.19.4-next.1

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 (152) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/alpha/package.json +1 -1
  3. package/dist/alpha.esm.js +3 -8
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/{esm/routes-BvToNy4N.esm.js → api.esm.js} +2 -46
  6. package/dist/api.esm.js.map +1 -0
  7. package/dist/components/ActionsPage/ActionsPage.esm.js +186 -0
  8. package/dist/components/ActionsPage/ActionsPage.esm.js.map +1 -0
  9. package/dist/components/FileBrowser/FileBrowser.esm.js +90 -0
  10. package/dist/components/FileBrowser/FileBrowser.esm.js.map +1 -0
  11. package/dist/components/ListTasksPage/ListTasksPage.esm.js +120 -0
  12. package/dist/components/ListTasksPage/ListTasksPage.esm.js.map +1 -0
  13. package/dist/components/ListTasksPage/OwnerListPicker.esm.js +88 -0
  14. package/dist/components/ListTasksPage/OwnerListPicker.esm.js.map +1 -0
  15. package/dist/components/ListTasksPage/columns/CreatedAtColumn.esm.js +13 -0
  16. package/dist/components/ListTasksPage/columns/CreatedAtColumn.esm.js.map +1 -0
  17. package/dist/components/ListTasksPage/columns/OwnerEntityColumn.esm.js +31 -0
  18. package/dist/components/ListTasksPage/columns/OwnerEntityColumn.esm.js.map +1 -0
  19. package/dist/components/ListTasksPage/columns/TaskStatusColumn.esm.js +17 -0
  20. package/dist/components/ListTasksPage/columns/TaskStatusColumn.esm.js.map +1 -0
  21. package/dist/components/ListTasksPage/columns/TemplateTitleColumn.esm.js +21 -0
  22. package/dist/components/ListTasksPage/columns/TemplateTitleColumn.esm.js.map +1 -0
  23. package/dist/components/OngoingTask/ContextMenu.esm.js +86 -0
  24. package/dist/components/OngoingTask/ContextMenu.esm.js.map +1 -0
  25. package/dist/components/OngoingTask/OngoingTask.esm.js +173 -0
  26. package/dist/components/OngoingTask/OngoingTask.esm.js.map +1 -0
  27. package/dist/components/Router/Router.esm.js +105 -0
  28. package/dist/components/Router/Router.esm.js.map +1 -0
  29. package/dist/components/Router/index.esm.js +2 -0
  30. package/dist/components/Router/index.esm.js.map +1 -0
  31. package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js +70 -0
  32. package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js.map +1 -0
  33. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js +34 -0
  34. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js.map +1 -0
  35. package/dist/components/fields/EntityNamePicker/schema.esm.js +8 -0
  36. package/dist/components/fields/EntityNamePicker/schema.esm.js.map +1 -0
  37. package/dist/components/fields/EntityNamePicker/validation.esm.js +12 -0
  38. package/dist/components/fields/EntityNamePicker/validation.esm.js.map +1 -0
  39. package/dist/components/fields/EntityPicker/EntityPicker.esm.js +151 -0
  40. package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -0
  41. package/dist/components/fields/EntityPicker/schema.esm.js +29 -0
  42. package/dist/components/fields/EntityPicker/schema.esm.js.map +1 -0
  43. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js +84 -0
  44. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js.map +1 -0
  45. package/dist/components/fields/EntityTagsPicker/schema.esm.js +15 -0
  46. package/dist/components/fields/EntityTagsPicker/schema.esm.js.map +1 -0
  47. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js +168 -0
  48. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js.map +1 -0
  49. package/dist/components/fields/MultiEntityPicker/schema.esm.js +23 -0
  50. package/dist/components/fields/MultiEntityPicker/schema.esm.js.map +1 -0
  51. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js +83 -0
  52. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js.map +1 -0
  53. package/dist/components/fields/MyGroupsPicker/schema.esm.js +14 -0
  54. package/dist/components/fields/MyGroupsPicker/schema.esm.js.map +1 -0
  55. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js +68 -0
  56. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js.map +1 -0
  57. package/dist/components/fields/OwnedEntityPicker/schema.esm.js +24 -0
  58. package/dist/components/fields/OwnedEntityPicker/schema.esm.js.map +1 -0
  59. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js +37 -0
  60. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js.map +1 -0
  61. package/dist/components/fields/OwnerPicker/schema.esm.js +24 -0
  62. package/dist/components/fields/OwnerPicker/schema.esm.js.map +1 -0
  63. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js +75 -0
  64. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js.map +1 -0
  65. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +80 -0
  66. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -0
  67. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js +38 -0
  68. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js.map +1 -0
  69. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js +44 -0
  70. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js.map +1 -0
  71. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js +42 -0
  72. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js.map +1 -0
  73. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +44 -0
  74. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -0
  75. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js +200 -0
  76. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js.map +1 -0
  77. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js +56 -0
  78. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js.map +1 -0
  79. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +48 -0
  80. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -0
  81. package/dist/components/fields/RepoUrlPicker/schema.esm.js +32 -0
  82. package/dist/components/fields/RepoUrlPicker/schema.esm.js.map +1 -0
  83. package/dist/components/fields/RepoUrlPicker/utils.esm.js +46 -0
  84. package/dist/components/fields/RepoUrlPicker/utils.esm.js.map +1 -0
  85. package/dist/components/fields/RepoUrlPicker/validation.esm.js +43 -0
  86. package/dist/components/fields/RepoUrlPicker/validation.esm.js.map +1 -0
  87. package/dist/components/fields/SecretInput/SecretInput.esm.js +48 -0
  88. package/dist/components/fields/SecretInput/SecretInput.esm.js.map +1 -0
  89. package/dist/components/fields/utils.esm.js +15 -0
  90. package/dist/components/fields/utils.esm.js.map +1 -0
  91. package/dist/deprecated.esm.js +13 -0
  92. package/dist/deprecated.esm.js.map +1 -0
  93. package/dist/extensions/default.esm.js +72 -0
  94. package/dist/extensions/default.esm.js.map +1 -0
  95. package/dist/index.esm.js +13 -214
  96. package/dist/index.esm.js.map +1 -1
  97. package/dist/lib/download/helpers.esm.js +11 -0
  98. package/dist/lib/download/helpers.esm.js.map +1 -0
  99. package/dist/lib/filesystem/WebFileSystemAccess.esm.js +56 -0
  100. package/dist/lib/filesystem/WebFileSystemAccess.esm.js.map +1 -0
  101. package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js +151 -0
  102. package/dist/next/TemplateEditorPage/CustomFieldExplorer.esm.js.map +1 -0
  103. package/dist/next/TemplateEditorPage/DirectoryEditorContext.esm.js +186 -0
  104. package/dist/next/TemplateEditorPage/DirectoryEditorContext.esm.js.map +1 -0
  105. package/dist/next/TemplateEditorPage/DryRunContext.esm.js +110 -0
  106. package/dist/next/TemplateEditorPage/DryRunContext.esm.js.map +1 -0
  107. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResults.esm.js +70 -0
  108. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResults.esm.js.map +1 -0
  109. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js +98 -0
  110. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js.map +1 -0
  111. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsSplitView.esm.js +31 -0
  112. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsSplitView.esm.js.map +1 -0
  113. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js +145 -0
  114. package/dist/next/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js.map +1 -0
  115. package/dist/next/TemplateEditorPage/DryRunResults/IconLink.esm.js +25 -0
  116. package/dist/next/TemplateEditorPage/DryRunResults/IconLink.esm.js.map +1 -0
  117. package/dist/next/TemplateEditorPage/DryRunResults/TaskPageLinks.esm.js +40 -0
  118. package/dist/next/TemplateEditorPage/DryRunResults/TaskPageLinks.esm.js.map +1 -0
  119. package/dist/next/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js +135 -0
  120. package/dist/next/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js.map +1 -0
  121. package/dist/next/TemplateEditorPage/TemplateEditor.esm.js +52 -0
  122. package/dist/next/TemplateEditorPage/TemplateEditor.esm.js.map +1 -0
  123. package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js +74 -0
  124. package/dist/next/TemplateEditorPage/TemplateEditorBrowser.esm.js.map +1 -0
  125. package/dist/next/TemplateEditorPage/TemplateEditorForm.esm.js +174 -0
  126. package/dist/next/TemplateEditorPage/TemplateEditorForm.esm.js.map +1 -0
  127. package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js +93 -0
  128. package/dist/next/TemplateEditorPage/TemplateEditorIntro.esm.js.map +1 -0
  129. package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js +82 -0
  130. package/dist/next/TemplateEditorPage/TemplateEditorPage.esm.js.map +1 -0
  131. package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js +120 -0
  132. package/dist/next/TemplateEditorPage/TemplateEditorTextArea.esm.js.map +1 -0
  133. package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js +160 -0
  134. package/dist/next/TemplateEditorPage/TemplateFormPreviewer.esm.js.map +1 -0
  135. package/dist/next/TemplateListPage/RegisterExistingButton.esm.js +35 -0
  136. package/dist/next/TemplateListPage/RegisterExistingButton.esm.js.map +1 -0
  137. package/dist/next/TemplateListPage/TemplateListPage.esm.js +101 -0
  138. package/dist/next/TemplateListPage/TemplateListPage.esm.js.map +1 -0
  139. package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js +67 -0
  140. package/dist/next/TemplateWizardPage/TemplateWizardPage.esm.js.map +1 -0
  141. package/dist/next/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js +60 -0
  142. package/dist/next/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js.map +1 -0
  143. package/dist/plugin.esm.js +125 -0
  144. package/dist/plugin.esm.js.map +1 -0
  145. package/dist/routes.esm.js +47 -0
  146. package/dist/routes.esm.js.map +1 -0
  147. package/package.json +18 -18
  148. package/dist/esm/OngoingTask-ClfJCJcE.esm.js +0 -1575
  149. package/dist/esm/OngoingTask-ClfJCJcE.esm.js.map +0 -1
  150. package/dist/esm/index-UcPid-q1.esm.js +0 -2553
  151. package/dist/esm/index-UcPid-q1.esm.js.map +0 -1
  152. package/dist/esm/routes-BvToNy4N.esm.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OngoingTask.esm.js","sources":["../../../src/components/OngoingTask/OngoingTask.tsx"],"sourcesContent":["/*\n * Copyright 2023 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, useEffect, useMemo, useState } from 'react';\nimport { Content, ErrorPanel, Header, Page } from '@backstage/core-components';\nimport { useNavigate, useParams } from 'react-router-dom';\nimport Box from '@material-ui/core/Box';\nimport Button from '@material-ui/core/Button';\nimport Paper from '@material-ui/core/Paper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport {\n ScaffolderTaskOutput,\n scaffolderApiRef,\n useTaskEventStream,\n} from '@backstage/plugin-scaffolder-react';\nimport { selectedTemplateRouteRef } from '../../routes';\nimport { useAnalytics, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport qs from 'qs';\nimport { ContextMenu } from './ContextMenu';\nimport {\n DefaultTemplateOutputs,\n TaskLogStream,\n TaskSteps,\n} from '@backstage/plugin-scaffolder-react/alpha';\nimport { useAsync } from '@react-hookz/web';\n\nconst useStyles = makeStyles(theme => ({\n contentWrapper: {\n display: 'flex',\n flexDirection: 'column',\n },\n buttonBar: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'right',\n },\n cancelButton: {\n marginRight: theme.spacing(1),\n },\n logsVisibilityButton: {\n marginRight: theme.spacing(1),\n },\n}));\n\n/**\n * @public\n */\nexport const OngoingTask = (props: {\n TemplateOutputsComponent?: React.ComponentType<{\n output?: ScaffolderTaskOutput;\n }>;\n}) => {\n // todo(blam): check that task Id actually exists, and that it's valid. otherwise redirect to something more useful.\n const { taskId } = useParams();\n const templateRouteRef = useRouteRef(selectedTemplateRouteRef);\n const navigate = useNavigate();\n const analytics = useAnalytics();\n const scaffolderApi = useApi(scaffolderApiRef);\n const taskStream = useTaskEventStream(taskId!);\n const classes = useStyles();\n const steps = useMemo(\n () =>\n taskStream.task?.spec.steps.map(step => ({\n ...step,\n ...taskStream?.steps?.[step.id],\n })) ?? [],\n [taskStream],\n );\n\n const [logsVisible, setLogVisibleState] = useState(false);\n const [buttonBarVisible, setButtonBarVisibleState] = useState(true);\n\n useEffect(() => {\n if (taskStream.error) {\n setLogVisibleState(true);\n }\n }, [taskStream.error]);\n\n useEffect(() => {\n if (taskStream.completed && !taskStream.error) {\n setButtonBarVisibleState(false);\n }\n }, [taskStream.error, taskStream.completed]);\n\n const activeStep = useMemo(() => {\n for (let i = steps.length - 1; i >= 0; i--) {\n if (steps[i].status !== 'open') {\n return i;\n }\n }\n\n return 0;\n }, [steps]);\n\n const startOver = useCallback(() => {\n const { namespace, name } =\n taskStream.task?.spec.templateInfo?.entity?.metadata ?? {};\n\n const formData = taskStream.task?.spec.parameters ?? {};\n\n if (!namespace || !name) {\n return;\n }\n\n analytics.captureEvent('click', `Task has been started over`);\n\n navigate({\n pathname: templateRouteRef({\n namespace,\n templateName: name,\n }),\n search: `?${qs.stringify({ formData: JSON.stringify(formData) })}`,\n });\n }, [\n analytics,\n navigate,\n taskStream.task?.spec.parameters,\n taskStream.task?.spec.templateInfo?.entity?.metadata,\n templateRouteRef,\n ]);\n\n const [{ status: cancelStatus }, { execute: triggerCancel }] = useAsync(\n async () => {\n if (taskId) {\n analytics.captureEvent('cancelled', 'Template has been cancelled');\n await scaffolderApi.cancelTask(taskId);\n }\n },\n );\n\n const Outputs = props.TemplateOutputsComponent ?? DefaultTemplateOutputs;\n\n const templateName =\n taskStream.task?.spec.templateInfo?.entity?.metadata.name;\n\n const cancelEnabled = !(taskStream.cancelled || taskStream.completed);\n\n return (\n <Page themeId=\"website\">\n <Header\n pageTitleOverride={`Run of ${templateName}`}\n title={\n <div>\n Run of <code>{templateName}</code>\n </div>\n }\n subtitle={`Task ${taskId}`}\n >\n <ContextMenu\n cancelEnabled={cancelEnabled}\n logsVisible={logsVisible}\n buttonBarVisible={buttonBarVisible}\n onStartOver={startOver}\n onToggleLogs={setLogVisibleState}\n onToggleButtonBar={setButtonBarVisibleState}\n taskId={taskId}\n />\n </Header>\n <Content className={classes.contentWrapper}>\n {taskStream.error ? (\n <Box paddingBottom={2}>\n <ErrorPanel\n error={taskStream.error}\n titleFormat=\"markdown\"\n title={taskStream.error.message}\n />\n </Box>\n ) : null}\n\n <Box paddingBottom={2}>\n <TaskSteps\n steps={steps}\n activeStep={activeStep}\n isComplete={taskStream.completed}\n isError={Boolean(taskStream.error)}\n />\n </Box>\n\n <Outputs output={taskStream.output} />\n\n {buttonBarVisible ? (\n <Box paddingBottom={2}>\n <Paper>\n <Box padding={2}>\n <div className={classes.buttonBar}>\n <Button\n className={classes.cancelButton}\n disabled={!cancelEnabled || cancelStatus !== 'not-executed'}\n onClick={triggerCancel}\n data-testid=\"cancel-button\"\n >\n Cancel\n </Button>\n <Button\n className={classes.logsVisibilityButton}\n color=\"primary\"\n variant=\"outlined\"\n onClick={() => setLogVisibleState(!logsVisible)}\n >\n {logsVisible ? 'Hide Logs' : 'Show Logs'}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={cancelEnabled}\n onClick={startOver}\n >\n Start Over\n </Button>\n </div>\n </Box>\n </Paper>\n </Box>\n ) : null}\n\n {logsVisible ? (\n <Box paddingBottom={2} height=\"100%\">\n <Paper style={{ height: '100%' }}>\n <Box padding={2} height=\"100%\">\n <TaskLogStream logs={taskStream.stepLogs} />\n </Box>\n </Paper>\n </Box>\n ) : null}\n </Content>\n </Page>\n );\n};\n"],"names":["_a","_b","_c","_d","_e","_f"],"mappings":";;;;;;;;;;;;;;;AAsCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,cAAgB,EAAA;AAAA,IACd,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,QAAA;AAAA,GACjB;AAAA,EACA,SAAW,EAAA;AAAA,IACT,OAAS,EAAA,MAAA;AAAA,IACT,aAAe,EAAA,KAAA;AAAA,IACf,cAAgB,EAAA,OAAA;AAAA,GAClB;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC,C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,0 +1,105 @@
1
+ import React from 'react';
2
+ import { useOutlet, Routes, Route } from 'react-router-dom';
3
+ import { useCustomFieldExtensions, useCustomLayouts, SecretsContextProvider } from '@backstage/plugin-scaffolder-react';
4
+ import { DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from '../../extensions/default.esm.js';
5
+ import { selectedTemplateRouteRef, scaffolderTaskRouteRef, editRouteRef, actionsRouteRef, scaffolderListTaskRouteRef } from '../../routes.esm.js';
6
+ import { ErrorPage } from '@backstage/core-components';
7
+ import { ActionsPage } from '../ActionsPage/ActionsPage.esm.js';
8
+ import { ListTasksPage } from '../ListTasksPage/ListTasksPage.esm.js';
9
+ import { TemplateListPage } from '../../next/TemplateListPage/TemplateListPage.esm.js';
10
+ import { TemplateWizardPage } from '../../next/TemplateWizardPage/TemplateWizardPage.esm.js';
11
+ import { OngoingTask } from '../OngoingTask/OngoingTask.esm.js';
12
+ import { TemplateEditorPage } from '../../next/TemplateEditorPage/TemplateEditorPage.esm.js';
13
+
14
+ const Router = (props) => {
15
+ const {
16
+ components: {
17
+ TemplateCardComponent,
18
+ TaskPageComponent = OngoingTask,
19
+ ReviewStepComponent,
20
+ EXPERIMENTAL_TemplateOutputsComponent: TemplateOutputsComponent,
21
+ EXPERIMENTAL_TemplateListPageComponent: TemplateListPageComponent = TemplateListPage,
22
+ EXPERIMENTAL_TemplateWizardPageComponent: TemplateWizardPageComponent = TemplateWizardPage
23
+ } = {}
24
+ } = props;
25
+ const outlet = useOutlet() || props.children;
26
+ const customFieldExtensions = useCustomFieldExtensions(outlet);
27
+ const fieldExtensions = [
28
+ ...customFieldExtensions,
29
+ ...DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS.filter(
30
+ ({ name }) => !customFieldExtensions.some(
31
+ (customFieldExtension) => customFieldExtension.name === name
32
+ )
33
+ )
34
+ ];
35
+ const customLayouts = useCustomLayouts(outlet);
36
+ return /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(
37
+ Route,
38
+ {
39
+ path: "/",
40
+ element: /* @__PURE__ */ React.createElement(
41
+ TemplateListPageComponent,
42
+ {
43
+ TemplateCardComponent,
44
+ contextMenu: props.contextMenu,
45
+ groups: props.groups,
46
+ templateFilter: props.templateFilter,
47
+ headerOptions: props.headerOptions
48
+ }
49
+ )
50
+ }
51
+ ), /* @__PURE__ */ React.createElement(
52
+ Route,
53
+ {
54
+ path: selectedTemplateRouteRef.path,
55
+ element: /* @__PURE__ */ React.createElement(SecretsContextProvider, null, /* @__PURE__ */ React.createElement(
56
+ TemplateWizardPageComponent,
57
+ {
58
+ headerOptions: props.headerOptions,
59
+ customFieldExtensions: fieldExtensions,
60
+ layouts: customLayouts,
61
+ components: { ReviewStepComponent },
62
+ formProps: props.formProps
63
+ }
64
+ ))
65
+ }
66
+ ), /* @__PURE__ */ React.createElement(
67
+ Route,
68
+ {
69
+ path: scaffolderTaskRouteRef.path,
70
+ element: /* @__PURE__ */ React.createElement(
71
+ TaskPageComponent,
72
+ {
73
+ TemplateOutputsComponent
74
+ }
75
+ )
76
+ }
77
+ ), /* @__PURE__ */ React.createElement(
78
+ Route,
79
+ {
80
+ path: editRouteRef.path,
81
+ element: /* @__PURE__ */ React.createElement(SecretsContextProvider, null, /* @__PURE__ */ React.createElement(
82
+ TemplateEditorPage,
83
+ {
84
+ customFieldExtensions: fieldExtensions,
85
+ layouts: customLayouts
86
+ }
87
+ ))
88
+ }
89
+ ), /* @__PURE__ */ React.createElement(Route, { path: actionsRouteRef.path, element: /* @__PURE__ */ React.createElement(ActionsPage, null) }), /* @__PURE__ */ React.createElement(
90
+ Route,
91
+ {
92
+ path: scaffolderListTaskRouteRef.path,
93
+ element: /* @__PURE__ */ React.createElement(ListTasksPage, null)
94
+ }
95
+ ), /* @__PURE__ */ React.createElement(
96
+ Route,
97
+ {
98
+ path: "*",
99
+ element: /* @__PURE__ */ React.createElement(ErrorPage, { status: "404", statusMessage: "Page not found" })
100
+ }
101
+ ));
102
+ };
103
+
104
+ export { Router };
105
+ //# sourceMappingURL=Router.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Router.esm.js","sources":["../../../src/components/Router/Router.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, { PropsWithChildren } from 'react';\nimport { Routes, Route, useOutlet } from 'react-router-dom';\n\nimport {\n FieldExtensionOptions,\n FormProps,\n ReviewStepProps,\n TemplateGroupFilter,\n} from '@backstage/plugin-scaffolder-react';\nimport {\n ScaffolderTaskOutput,\n SecretsContextProvider,\n useCustomFieldExtensions,\n useCustomLayouts,\n} from '@backstage/plugin-scaffolder-react';\n\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from '../../extensions/default';\n\nimport {\n actionsRouteRef,\n editRouteRef,\n scaffolderListTaskRouteRef,\n scaffolderTaskRouteRef,\n selectedTemplateRouteRef,\n} from '../../routes';\nimport { ErrorPage } from '@backstage/core-components';\n\nimport { ActionsPage } from '../../components/ActionsPage';\nimport { ListTasksPage } from '../../components/ListTasksPage';\n\nimport {\n TemplateListPageProps,\n TemplateWizardPageProps,\n} from '@backstage/plugin-scaffolder/alpha';\nimport { TemplateListPage, TemplateWizardPage } from '../../next';\nimport { OngoingTask } from '../OngoingTask';\nimport { TemplateEditorPage } from '../../next/TemplateEditorPage';\n\n/**\n * The Props for the Scaffolder Router\n *\n * @public\n */\nexport type RouterProps = {\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n TaskPageComponent?: React.ComponentType<PropsWithChildren<{}>>;\n EXPERIMENTAL_TemplateOutputsComponent?: React.ComponentType<{\n output?: ScaffolderTaskOutput;\n }>;\n EXPERIMENTAL_TemplateListPageComponent?: React.ComponentType<TemplateListPageProps>;\n EXPERIMENTAL_TemplateWizardPageComponent?: React.ComponentType<TemplateWizardPageProps>;\n };\n groups?: TemplateGroupFilter[];\n templateFilter?: (entity: TemplateEntityV1beta3) => boolean;\n headerOptions?: {\n pageTitleOverride?: string;\n title?: string;\n subtitle?: string;\n };\n defaultPreviewTemplate?: string;\n formProps?: FormProps;\n contextMenu?: {\n /** Whether to show a link to the template editor */\n editor?: boolean;\n /** Whether to show a link to the actions documentation */\n actions?: boolean;\n /** Whether to show a link to the tasks page */\n tasks?: boolean;\n };\n};\n\n/**\n * The Scaffolder Router\n *\n * @public\n */\nexport const Router = (props: PropsWithChildren<RouterProps>) => {\n const {\n components: {\n TemplateCardComponent,\n TaskPageComponent = OngoingTask,\n ReviewStepComponent,\n EXPERIMENTAL_TemplateOutputsComponent: TemplateOutputsComponent,\n EXPERIMENTAL_TemplateListPageComponent:\n TemplateListPageComponent = TemplateListPage,\n EXPERIMENTAL_TemplateWizardPageComponent:\n TemplateWizardPageComponent = TemplateWizardPage,\n } = {},\n } = props;\n const outlet = useOutlet() || props.children;\n const customFieldExtensions =\n useCustomFieldExtensions<FieldExtensionOptions>(outlet);\n\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 FieldExtensionOptions[];\n\n const customLayouts = useCustomLayouts(outlet);\n\n return (\n <Routes>\n <Route\n path=\"/\"\n element={\n <TemplateListPageComponent\n TemplateCardComponent={TemplateCardComponent}\n contextMenu={props.contextMenu}\n groups={props.groups}\n templateFilter={props.templateFilter}\n headerOptions={props.headerOptions}\n />\n }\n />\n <Route\n path={selectedTemplateRouteRef.path}\n element={\n <SecretsContextProvider>\n <TemplateWizardPageComponent\n headerOptions={props.headerOptions}\n customFieldExtensions={fieldExtensions}\n layouts={customLayouts}\n components={{ ReviewStepComponent }}\n formProps={props.formProps}\n />\n </SecretsContextProvider>\n }\n />\n <Route\n path={scaffolderTaskRouteRef.path}\n element={\n <TaskPageComponent\n TemplateOutputsComponent={TemplateOutputsComponent}\n />\n }\n />\n <Route\n path={editRouteRef.path}\n element={\n <SecretsContextProvider>\n <TemplateEditorPage\n customFieldExtensions={fieldExtensions}\n layouts={customLayouts}\n />\n </SecretsContextProvider>\n }\n />\n\n <Route path={actionsRouteRef.path} element={<ActionsPage />} />\n <Route\n path={scaffolderListTaskRouteRef.path}\n element={<ListTasksPage />}\n />\n <Route\n path=\"*\"\n element={<ErrorPage status=\"404\" statusMessage=\"Page not found\" />}\n />\n </Routes>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgGa,MAAA,MAAA,GAAS,CAAC,KAA0C,KAAA;AAC/D,EAAM,MAAA;AAAA,IACJ,UAAY,EAAA;AAAA,MACV,qBAAA;AAAA,MACA,iBAAoB,GAAA,WAAA;AAAA,MACpB,mBAAA;AAAA,MACA,qCAAuC,EAAA,wBAAA;AAAA,MACvC,wCACE,yBAA4B,GAAA,gBAAA;AAAA,MAC9B,0CACE,2BAA8B,GAAA,kBAAA;AAAA,QAC9B,EAAC;AAAA,GACH,GAAA,KAAA,CAAA;AACJ,EAAM,MAAA,MAAA,GAAS,SAAU,EAAA,IAAK,KAAM,CAAA,QAAA,CAAA;AACpC,EAAM,MAAA,qBAAA,GACJ,yBAAgD,MAAM,CAAA,CAAA;AAExD,EAAA,MAAM,eAAkB,GAAA;AAAA,IACtB,GAAG,qBAAA;AAAA,IACH,GAAG,mCAAoC,CAAA,MAAA;AAAA,MACrC,CAAC,EAAE,IAAK,EAAA,KACN,CAAC,qBAAsB,CAAA,IAAA;AAAA,QACr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AAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,MAAM,YAAa,CAAA,IAAA;AAAA,MACnB,OAAA,sCACG,sBACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,kBAAA;AAAA,QAAA;AAAA,UACC,qBAAuB,EAAA,eAAA;AAAA,UACvB,OAAS,EAAA,aAAA;AAAA,SAAA;AAAA,OAEb,CAAA;AAAA,KAAA;AAAA,GAEJ,kBAEC,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAM,IAAM,EAAA,eAAA,CAAgB,MAAM,OAAS,kBAAA,KAAA,CAAA,aAAA,CAAC,WAAY,EAAA,IAAA,CAAA,EAAI,CAC7D,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,MAAM,0BAA2B,CAAA,IAAA;AAAA,MACjC,OAAA,sCAAU,aAAc,EAAA,IAAA,CAAA;AAAA,KAAA;AAAA,GAE1B,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IAAK,EAAA,GAAA;AAAA,MACL,yBAAU,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,EAAU,MAAO,EAAA,KAAA,EAAM,eAAc,gBAAiB,EAAA,CAAA;AAAA,KAAA;AAAA,GAEpE,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,2 @@
1
+ export { Router } from './Router.esm.js';
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import capitalize from 'lodash/capitalize';
3
+ import { Progress } from '@backstage/core-components';
4
+ import Box from '@material-ui/core/Box';
5
+ import Checkbox from '@material-ui/core/Checkbox';
6
+ import FormControlLabel from '@material-ui/core/FormControlLabel';
7
+ import TextField from '@material-ui/core/TextField';
8
+ import Typography from '@material-ui/core/Typography';
9
+ import CheckBoxIcon from '@material-ui/icons/CheckBox';
10
+ import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';
11
+ import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
12
+ import Autocomplete from '@material-ui/lab/Autocomplete';
13
+ import { useEntityTypeFilter } from '@backstage/plugin-catalog-react';
14
+ import { useApi, alertApiRef } from '@backstage/core-plugin-api';
15
+
16
+ const icon = /* @__PURE__ */ React.createElement(CheckBoxOutlineBlankIcon, { fontSize: "small" });
17
+ const checkedIcon = /* @__PURE__ */ React.createElement(CheckBoxIcon, { fontSize: "small" });
18
+ const TemplateTypePicker = () => {
19
+ const alertApi = useApi(alertApiRef);
20
+ const { error, loading, availableTypes, selectedTypes, setSelectedTypes } = useEntityTypeFilter();
21
+ if (loading)
22
+ return /* @__PURE__ */ React.createElement(Progress, null);
23
+ if (!availableTypes)
24
+ return null;
25
+ if (error) {
26
+ alertApi.post({
27
+ message: `Failed to load entity types`,
28
+ severity: "error"
29
+ });
30
+ return null;
31
+ }
32
+ return /* @__PURE__ */ React.createElement(Box, { pb: 1, pt: 1 }, /* @__PURE__ */ React.createElement(
33
+ Typography,
34
+ {
35
+ variant: "button",
36
+ component: "label",
37
+ htmlFor: "categories-picker"
38
+ },
39
+ "Categories"
40
+ ), /* @__PURE__ */ React.createElement(
41
+ Autocomplete,
42
+ {
43
+ id: "categories-picker",
44
+ multiple: true,
45
+ options: availableTypes,
46
+ value: selectedTypes,
47
+ onChange: (_, value) => setSelectedTypes(value),
48
+ renderOption: (option, { selected }) => /* @__PURE__ */ React.createElement(
49
+ FormControlLabel,
50
+ {
51
+ control: /* @__PURE__ */ React.createElement(
52
+ Checkbox,
53
+ {
54
+ icon,
55
+ checkedIcon,
56
+ checked: selected
57
+ }
58
+ ),
59
+ label: capitalize(option)
60
+ }
61
+ ),
62
+ size: "small",
63
+ popupIcon: /* @__PURE__ */ React.createElement(ExpandMoreIcon, { "data-testid": "categories-picker-expand" }),
64
+ renderInput: (params) => /* @__PURE__ */ React.createElement(TextField, { ...params, variant: "outlined" })
65
+ }
66
+ ));
67
+ };
68
+
69
+ export { TemplateTypePicker };
70
+ //# sourceMappingURL=TemplateTypePicker.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateTypePicker.esm.js","sources":["../../../src/components/TemplateTypePicker/TemplateTypePicker.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 Box from '@material-ui/core/Box';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport FormControlLabel from '@material-ui/core/FormControlLabel';\nimport TextField from '@material-ui/core/TextField';\nimport Typography from '@material-ui/core/Typography';\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/Autocomplete';\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 component to select the `type` of `Template` that you will see in the table.\n *\n * @public\n */\nexport const TemplateTypePicker = () => {\n const alertApi = useApi(alertApiRef);\n const { error, loading, availableTypes, selectedTypes, setSelectedTypes } =\n useEntityTypeFilter();\n\n if (loading) return <Progress />;\n\n if (!availableTypes) return null;\n\n if (error) {\n alertApi.post({\n message: `Failed to load entity types`,\n severity: 'error',\n });\n return null;\n }\n\n return (\n <Box pb={1} pt={1}>\n <Typography\n variant=\"button\"\n component=\"label\"\n htmlFor=\"categories-picker\"\n >\n Categories\n </Typography>\n <Autocomplete<string, true>\n id=\"categories-picker\"\n multiple\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 data-testid=\"categories-picker-expand\" />}\n renderInput={params => <TextField {...params} variant=\"outlined\" />}\n />\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA+BA,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;AAO5C,MAAM,qBAAqB,MAAM;AACtC,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,CAAC,cAAA;AAAgB,IAAO,OAAA,IAAA,CAAA;AAE5B,EAAA,IAAI,KAAO,EAAA;AACT,IAAA,QAAA,CAAS,IAAK,CAAA;AAAA,MACZ,OAAS,EAAA,CAAA,2BAAA,CAAA;AAAA,MACT,QAAU,EAAA,OAAA;AAAA,KACX,CAAA,CAAA;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react';
2
+ import TextField from '@material-ui/core/TextField';
3
+ export { EntityNamePickerSchema } from './schema.esm.js';
4
+
5
+ const EntityNamePicker = (props) => {
6
+ const {
7
+ onChange,
8
+ required,
9
+ schema: { title = "Name", description = "Unique name of the component" },
10
+ rawErrors,
11
+ formData,
12
+ uiSchema: { "ui:autofocus": autoFocus },
13
+ idSchema,
14
+ placeholder
15
+ } = props;
16
+ return /* @__PURE__ */ React.createElement(
17
+ TextField,
18
+ {
19
+ id: idSchema == null ? void 0 : idSchema.$id,
20
+ label: title,
21
+ placeholder,
22
+ helperText: description,
23
+ required,
24
+ value: formData != null ? formData : "",
25
+ onChange: ({ target: { value } }) => onChange(value),
26
+ margin: "normal",
27
+ error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !formData,
28
+ inputProps: { autoFocus }
29
+ }
30
+ );
31
+ };
32
+
33
+ export { EntityNamePicker };
34
+ //# sourceMappingURL=EntityNamePicker.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityNamePicker.esm.js","sources":["../../../../src/components/fields/EntityNamePicker/EntityNamePicker.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 */\nimport React from 'react';\nimport { EntityNamePickerProps } from './schema';\nimport TextField from '@material-ui/core/TextField';\n\nexport { EntityNamePickerSchema } from './schema';\n\n/**\n * EntityName Picker\n */\nexport const EntityNamePicker = (props: EntityNamePickerProps) => {\n const {\n onChange,\n required,\n schema: { title = 'Name', description = 'Unique name of the component' },\n rawErrors,\n formData,\n uiSchema: { 'ui:autofocus': autoFocus },\n idSchema,\n placeholder,\n } = props;\n\n return (\n <TextField\n id={idSchema?.$id}\n label={title}\n placeholder={placeholder}\n helperText={description}\n required={required}\n value={formData ?? ''}\n onChange={({ target: { value } }) => onChange(value)}\n margin=\"normal\"\n error={rawErrors?.length > 0 && !formData}\n inputProps={{ autoFocus }}\n />\n );\n};\n"],"names":[],"mappings":";;;;AAwBa,MAAA,gBAAA,GAAmB,CAAC,KAAiC,KAAA;AAChE,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAQ,EAAA,EAAE,KAAQ,GAAA,MAAA,EAAQ,cAAc,8BAA+B,EAAA;AAAA,IACvE,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA,EAAU,EAAE,cAAA,EAAgB,SAAU,EAAA;AAAA,IACtC,QAAA;AAAA,IACA,WAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,IAAI,QAAU,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAA,GAAA;AAAA,MACd,KAAO,EAAA,KAAA;AAAA,MACP,WAAA;AAAA,MACA,UAAY,EAAA,WAAA;AAAA,MACZ,QAAA;AAAA,MACA,OAAO,QAAY,IAAA,IAAA,GAAA,QAAA,GAAA,EAAA;AAAA,MACnB,QAAA,EAAU,CAAC,EAAE,MAAA,EAAQ,EAAE,KAAM,EAAA,EAAQ,KAAA,QAAA,CAAS,KAAK,CAAA;AAAA,MACnD,MAAO,EAAA,QAAA;AAAA,MACP,KAAO,EAAA,CAAA,SAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,SAAA,CAAW,MAAS,IAAA,CAAA,IAAK,CAAC,QAAA;AAAA,MACjC,UAAA,EAAY,EAAE,SAAU,EAAA;AAAA,KAAA;AAAA,GAC1B,CAAA;AAEJ;;;;"}
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { makeFieldSchemaFromZod } from '../utils.esm.js';
3
+
4
+ const EntityNamePickerFieldSchema = makeFieldSchemaFromZod(z.string());
5
+ const EntityNamePickerSchema = EntityNamePickerFieldSchema.schema;
6
+
7
+ export { EntityNamePickerSchema };
8
+ //# sourceMappingURL=schema.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.esm.js","sources":["../../../../src/components/fields/EntityNamePicker/schema.ts"],"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 { z } from 'zod';\nimport { makeFieldSchemaFromZod } from '../utils';\n\nconst EntityNamePickerFieldSchema = makeFieldSchemaFromZod(z.string());\n\nexport const EntityNamePickerSchema = EntityNamePickerFieldSchema.schema;\n\nexport type EntityNamePickerProps = typeof EntityNamePickerFieldSchema.type;\n"],"names":[],"mappings":";;;AAkBA,MAAM,2BAA8B,GAAA,sBAAA,CAAuB,CAAE,CAAA,MAAA,EAAQ,CAAA,CAAA;AAE9D,MAAM,yBAAyB,2BAA4B,CAAA;;;;"}
@@ -0,0 +1,12 @@
1
+ import { KubernetesValidatorFunctions } from '@backstage/catalog-model';
2
+
3
+ const entityNamePickerValidation = (value, validation) => {
4
+ if (!KubernetesValidatorFunctions.isValidObjectName(value)) {
5
+ validation.addError(
6
+ "Must start and end with an alphanumeric character, and contain only alphanumeric characters, hyphens, underscores, and periods. Maximum length is 63 characters."
7
+ );
8
+ }
9
+ };
10
+
11
+ export { entityNamePickerValidation };
12
+ //# sourceMappingURL=validation.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.esm.js","sources":["../../../../src/components/fields/EntityNamePicker/validation.ts"],"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 { FieldValidation } from '@rjsf/utils';\nimport { KubernetesValidatorFunctions } from '@backstage/catalog-model';\n\nexport const entityNamePickerValidation = (\n value: string,\n validation: FieldValidation,\n) => {\n if (!KubernetesValidatorFunctions.isValidObjectName(value)) {\n validation.addError(\n 'Must start and end with an alphanumeric character, and contain only alphanumeric characters, hyphens, underscores, and periods. Maximum length is 63 characters.',\n );\n }\n};\n"],"names":[],"mappings":";;AAmBa,MAAA,0BAAA,GAA6B,CACxC,KAAA,EACA,UACG,KAAA;AACH,EAAA,IAAI,CAAC,4BAAA,CAA6B,iBAAkB,CAAA,KAAK,CAAG,EAAA;AAC1D,IAAW,UAAA,CAAA,QAAA;AAAA,MACT,kKAAA;AAAA,KACF,CAAA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,151 @@
1
+ import { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';
2
+ import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';
3
+ import { useApi } from '@backstage/core-plugin-api';
4
+ import { catalogApiRef, humanizeEntityRef } from '@backstage/plugin-catalog-react';
5
+ import TextField from '@material-ui/core/TextField';
6
+ import FormControl from '@material-ui/core/FormControl';
7
+ import Autocomplete from '@material-ui/lab/Autocomplete';
8
+ import React, { useCallback, useEffect } from 'react';
9
+ import useAsync from 'react-use/esm/useAsync';
10
+ export { EntityPickerSchema } from './schema.esm.js';
11
+
12
+ const EntityPicker = (props) => {
13
+ var _a, _b, _c, _d, _e;
14
+ const {
15
+ onChange,
16
+ schema: { title = "Entity", description = "An entity from the catalog" },
17
+ required,
18
+ uiSchema,
19
+ rawErrors,
20
+ formData,
21
+ idSchema
22
+ } = props;
23
+ const catalogFilter = buildCatalogFilter(uiSchema);
24
+ const defaultKind = (_a = uiSchema["ui:options"]) == null ? void 0 : _a.defaultKind;
25
+ const defaultNamespace = ((_b = uiSchema["ui:options"]) == null ? void 0 : _b.defaultNamespace) || void 0;
26
+ const catalogApi = useApi(catalogApiRef);
27
+ const { value: entities, loading } = useAsync(async () => {
28
+ const fields = ["metadata.name", "metadata.namespace", "kind"];
29
+ const { items } = await catalogApi.getEntities(
30
+ catalogFilter ? { filter: catalogFilter, fields } : { filter: void 0, fields }
31
+ );
32
+ return items;
33
+ });
34
+ const allowArbitraryValues = (_d = (_c = uiSchema["ui:options"]) == null ? void 0 : _c.allowArbitraryValues) != null ? _d : true;
35
+ const getLabel = useCallback(
36
+ (ref) => {
37
+ try {
38
+ return humanizeEntityRef(
39
+ parseEntityRef(ref, { defaultKind, defaultNamespace }),
40
+ {
41
+ defaultKind,
42
+ defaultNamespace
43
+ }
44
+ );
45
+ } catch (err) {
46
+ return ref;
47
+ }
48
+ },
49
+ [defaultKind, defaultNamespace]
50
+ );
51
+ const onSelect = useCallback(
52
+ (_, ref, reason) => {
53
+ if (typeof ref !== "string") {
54
+ onChange(ref ? stringifyEntityRef(ref) : void 0);
55
+ } else {
56
+ if (reason === "blur" || reason === "create-option") {
57
+ let entityRef = ref;
58
+ try {
59
+ entityRef = stringifyEntityRef(
60
+ parseEntityRef(ref, {
61
+ defaultKind,
62
+ defaultNamespace
63
+ })
64
+ );
65
+ } catch (err) {
66
+ }
67
+ if (formData !== ref || allowArbitraryValues) {
68
+ onChange(entityRef);
69
+ }
70
+ }
71
+ }
72
+ },
73
+ [onChange, formData, defaultKind, defaultNamespace, allowArbitraryValues]
74
+ );
75
+ const selectedEntity = (_e = entities == null ? void 0 : entities.find((e) => stringifyEntityRef(e) === formData)) != null ? _e : allowArbitraryValues && formData ? getLabel(formData) : "";
76
+ useEffect(() => {
77
+ if ((entities == null ? void 0 : entities.length) === 1 && selectedEntity === "") {
78
+ onChange(stringifyEntityRef(entities[0]));
79
+ }
80
+ }, [entities, onChange, selectedEntity]);
81
+ return /* @__PURE__ */ React.createElement(
82
+ FormControl,
83
+ {
84
+ margin: "normal",
85
+ required,
86
+ error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !formData
87
+ },
88
+ /* @__PURE__ */ React.createElement(
89
+ Autocomplete,
90
+ {
91
+ disabled: (entities == null ? void 0 : entities.length) === 1,
92
+ id: idSchema == null ? void 0 : idSchema.$id,
93
+ value: selectedEntity,
94
+ loading,
95
+ onChange: onSelect,
96
+ options: entities || [],
97
+ getOptionLabel: (option) => (
98
+ // option can be a string due to freeSolo.
99
+ typeof option === "string" ? option : humanizeEntityRef(option, { defaultKind, defaultNamespace })
100
+ ),
101
+ autoSelect: true,
102
+ freeSolo: allowArbitraryValues,
103
+ renderInput: (params) => /* @__PURE__ */ React.createElement(
104
+ TextField,
105
+ {
106
+ ...params,
107
+ label: title,
108
+ margin: "dense",
109
+ helperText: description,
110
+ FormHelperTextProps: { margin: "dense", style: { marginLeft: 0 } },
111
+ variant: "outlined",
112
+ required,
113
+ InputProps: params.InputProps
114
+ }
115
+ )
116
+ }
117
+ )
118
+ );
119
+ };
120
+ function convertOpsValues(value) {
121
+ if (typeof value === "object" && value.exists) {
122
+ return CATALOG_FILTER_EXISTS;
123
+ }
124
+ return value == null ? void 0 : value.toString();
125
+ }
126
+ function convertSchemaFiltersToQuery(schemaFilters) {
127
+ const query = {};
128
+ for (const [key, value] of Object.entries(schemaFilters)) {
129
+ if (Array.isArray(value)) {
130
+ query[key] = value;
131
+ } else {
132
+ query[key] = convertOpsValues(value);
133
+ }
134
+ }
135
+ return query;
136
+ }
137
+ function buildCatalogFilter(uiSchema) {
138
+ var _a, _b;
139
+ const allowedKinds = (_a = uiSchema["ui:options"]) == null ? void 0 : _a.allowedKinds;
140
+ const catalogFilter = ((_b = uiSchema["ui:options"]) == null ? void 0 : _b.catalogFilter) || allowedKinds && { kind: allowedKinds };
141
+ if (!catalogFilter) {
142
+ return void 0;
143
+ }
144
+ if (Array.isArray(catalogFilter)) {
145
+ return catalogFilter.map(convertSchemaFiltersToQuery);
146
+ }
147
+ return convertSchemaFiltersToQuery(catalogFilter);
148
+ }
149
+
150
+ export { EntityPicker };
151
+ //# sourceMappingURL=EntityPicker.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityPicker.esm.js","sources":["../../../../src/components/fields/EntityPicker/EntityPicker.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 */\nimport {\n type EntityFilterQuery,\n CATALOG_FILTER_EXISTS,\n} from '@backstage/catalog-client';\nimport {\n Entity,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n catalogApiRef,\n humanizeEntityRef,\n} from '@backstage/plugin-catalog-react';\nimport TextField from '@material-ui/core/TextField';\nimport FormControl from '@material-ui/core/FormControl';\nimport Autocomplete, {\n AutocompleteChangeReason,\n} from '@material-ui/lab/Autocomplete';\nimport React, { useCallback, useEffect } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n EntityPickerFilterQueryValue,\n EntityPickerProps,\n EntityPickerUiOptions,\n EntityPickerFilterQuery,\n} from './schema';\n\nexport { EntityPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `EntityPicker`\n * field extension.\n *\n * @public\n */\nexport const EntityPicker = (props: EntityPickerProps) => {\n const {\n onChange,\n schema: { title = 'Entity', description = 'An entity from the catalog' },\n required,\n uiSchema,\n rawErrors,\n formData,\n idSchema,\n } = props;\n const catalogFilter = buildCatalogFilter(uiSchema);\n const defaultKind = uiSchema['ui:options']?.defaultKind;\n const defaultNamespace =\n uiSchema['ui:options']?.defaultNamespace || undefined;\n\n const catalogApi = useApi(catalogApiRef);\n\n const { value: entities, loading } = useAsync(async () => {\n const fields = ['metadata.name', 'metadata.namespace', 'kind'];\n const { items } = await catalogApi.getEntities(\n catalogFilter\n ? { filter: catalogFilter, fields }\n : { filter: undefined, fields },\n );\n return items;\n });\n const allowArbitraryValues =\n uiSchema['ui:options']?.allowArbitraryValues ?? true;\n\n const getLabel = useCallback(\n (ref: string) => {\n try {\n return humanizeEntityRef(\n parseEntityRef(ref, { defaultKind, defaultNamespace }),\n {\n defaultKind,\n defaultNamespace,\n },\n );\n } catch (err) {\n return ref;\n }\n },\n [defaultKind, defaultNamespace],\n );\n\n const onSelect = useCallback(\n (_: any, ref: string | Entity | null, reason: AutocompleteChangeReason) => {\n // ref can either be a string from free solo entry or\n if (typeof ref !== 'string') {\n // if ref does not exist: pass 'undefined' to trigger validation for required value\n onChange(ref ? stringifyEntityRef(ref as Entity) : undefined);\n } else {\n if (reason === 'blur' || reason === 'create-option') {\n // Add in default namespace, etc.\n let entityRef = ref;\n try {\n // Attempt to parse the entity ref into it's full form.\n entityRef = stringifyEntityRef(\n parseEntityRef(ref as string, {\n defaultKind,\n defaultNamespace,\n }),\n );\n } catch (err) {\n // If the passed in value isn't an entity ref, do nothing.\n }\n // We need to check against formData here as that's the previous value for this field.\n if (formData !== ref || allowArbitraryValues) {\n onChange(entityRef);\n }\n }\n }\n },\n [onChange, formData, defaultKind, defaultNamespace, allowArbitraryValues],\n );\n\n // Since free solo can be enabled, attempt to parse as a full entity ref first, then fall\n // back to the given value.\n const selectedEntity =\n entities?.find(e => stringifyEntityRef(e) === formData) ??\n (allowArbitraryValues && formData ? getLabel(formData) : '');\n\n useEffect(() => {\n if (entities?.length === 1 && selectedEntity === '') {\n onChange(stringifyEntityRef(entities[0]));\n }\n }, [entities, onChange, selectedEntity]);\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !formData}\n >\n <Autocomplete\n disabled={entities?.length === 1}\n id={idSchema?.$id}\n value={selectedEntity}\n loading={loading}\n onChange={onSelect}\n options={entities || []}\n getOptionLabel={option =>\n // option can be a string due to freeSolo.\n typeof option === 'string'\n ? option\n : humanizeEntityRef(option, { defaultKind, defaultNamespace })!\n }\n autoSelect\n freeSolo={allowArbitraryValues}\n renderInput={params => (\n <TextField\n {...params}\n label={title}\n margin=\"dense\"\n helperText={description}\n FormHelperTextProps={{ margin: 'dense', style: { marginLeft: 0 } }}\n variant=\"outlined\"\n required={required}\n InputProps={params.InputProps}\n />\n )}\n />\n </FormControl>\n );\n};\n\n/**\n * Converts a especial `{exists: true}` value to the `CATALOG_FILTER_EXISTS` symbol.\n *\n * @param value - The value to convert.\n * @returns The converted value.\n */\nfunction convertOpsValues(\n value: Exclude<EntityPickerFilterQueryValue, Array<any>>,\n): string | symbol {\n if (typeof value === 'object' && value.exists) {\n return CATALOG_FILTER_EXISTS;\n }\n return value?.toString();\n}\n\n/**\n * Converts schema filters to entity filter query, replacing `{exists:true}` values\n * with the constant `CATALOG_FILTER_EXISTS`.\n *\n * @param schemaFilters - An object containing schema filters with keys as filter names\n * and values as filter values.\n * @returns An object with the same keys as the input object, but with `{exists:true}` values\n * transformed to `CATALOG_FILTER_EXISTS` symbol.\n */\nfunction convertSchemaFiltersToQuery(\n schemaFilters: EntityPickerFilterQuery,\n): Exclude<EntityFilterQuery, Array<any>> {\n const query: EntityFilterQuery = {};\n\n for (const [key, value] of Object.entries(schemaFilters)) {\n if (Array.isArray(value)) {\n query[key] = value;\n } else {\n query[key] = convertOpsValues(value);\n }\n }\n\n return query;\n}\n\n/**\n * Builds an `EntityFilterQuery` based on the `uiSchema` passed in.\n * If `catalogFilter` is specified in the `uiSchema`, it is converted to a `EntityFilterQuery`.\n * If `allowedKinds` is specified in the `uiSchema` will support the legacy `allowedKinds` option.\n *\n * @param uiSchema The `uiSchema` of an `EntityPicker` component.\n * @returns An `EntityFilterQuery` based on the `uiSchema`, or `undefined` if `catalogFilter` is not specified in the `uiSchema`.\n */\nfunction buildCatalogFilter(\n uiSchema: EntityPickerProps['uiSchema'],\n): EntityFilterQuery | undefined {\n const allowedKinds = uiSchema['ui:options']?.allowedKinds;\n\n const catalogFilter: EntityPickerUiOptions['catalogFilter'] | undefined =\n uiSchema['ui:options']?.catalogFilter ||\n (allowedKinds && { kind: allowedKinds });\n\n if (!catalogFilter) {\n return undefined;\n }\n\n if (Array.isArray(catalogFilter)) {\n return catalogFilter.map(convertSchemaFiltersToQuery);\n }\n\n return convertSchemaFiltersToQuery(catalogFilter);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAmDa,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AAnD1D,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAoDE,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,MAAQ,EAAA,EAAE,KAAQ,GAAA,QAAA,EAAU,cAAc,4BAA6B,EAAA;AAAA,IACvE,QAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AACJ,EAAM,MAAA,aAAA,GAAgB,mBAAmB,QAAQ,CAAA,CAAA;AACjD,EAAA,MAAM,WAAc,GAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAY,CAAA,KAArB,IAAwB,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,WAAA,CAAA;AAC5C,EAAA,MAAM,gBACJ,GAAA,CAAA,CAAA,EAAA,GAAA,QAAA,CAAS,YAAY,CAAA,KAArB,mBAAwB,g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,CAAA,CAAA;AAClD;;;;"}
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import { makeFieldSchemaFromZod } from '../utils.esm.js';
3
+
4
+ const entityQueryFilterExpressionSchema = z.record(
5
+ z.string().or(z.object({ exists: z.boolean().optional() })).or(z.array(z.string()))
6
+ );
7
+ const EntityPickerFieldSchema = makeFieldSchemaFromZod(
8
+ z.string(),
9
+ z.object({
10
+ /**
11
+ * @deprecated Use `catalogFilter` instead.
12
+ */
13
+ allowedKinds: z.array(z.string()).optional().describe(
14
+ "DEPRECATED: Use `catalogFilter` instead. List of kinds of entities to derive options from"
15
+ ),
16
+ defaultKind: z.string().optional().describe(
17
+ "The default entity kind. Options of this kind will not be prefixed."
18
+ ),
19
+ allowArbitraryValues: z.boolean().optional().describe("Whether to allow arbitrary user input. Defaults to true"),
20
+ defaultNamespace: z.union([z.string(), z.literal(false)]).optional().describe(
21
+ "The default namespace. Options with this namespace will not be prefixed."
22
+ ),
23
+ catalogFilter: z.array(entityQueryFilterExpressionSchema).or(entityQueryFilterExpressionSchema).optional().describe("List of key-value filter expression for entities")
24
+ })
25
+ );
26
+ const EntityPickerSchema = EntityPickerFieldSchema.schema;
27
+
28
+ export { EntityPickerFieldSchema, EntityPickerSchema, entityQueryFilterExpressionSchema };
29
+ //# sourceMappingURL=schema.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.esm.js","sources":["../../../../src/components/fields/EntityPicker/schema.ts"],"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 { z } from 'zod';\nimport { makeFieldSchemaFromZod } from '../utils';\n\n/**\n * @public\n */\nexport const entityQueryFilterExpressionSchema = z.record(\n z\n .string()\n .or(z.object({ exists: z.boolean().optional() }))\n .or(z.array(z.string())),\n);\n\n/**\n * @public\n */\nexport const EntityPickerFieldSchema = makeFieldSchemaFromZod(\n z.string(),\n z.object({\n /**\n * @deprecated Use `catalogFilter` instead.\n */\n allowedKinds: z\n .array(z.string())\n .optional()\n .describe(\n 'DEPRECATED: Use `catalogFilter` instead. List of kinds of entities to derive options from',\n ),\n defaultKind: z\n .string()\n .optional()\n .describe(\n 'The default entity kind. Options of this kind will not be prefixed.',\n ),\n allowArbitraryValues: z\n .boolean()\n .optional()\n .describe('Whether to allow arbitrary user input. Defaults to true'),\n defaultNamespace: z\n .union([z.string(), z.literal(false)])\n .optional()\n .describe(\n 'The default namespace. Options with this namespace will not be prefixed.',\n ),\n catalogFilter: z\n .array(entityQueryFilterExpressionSchema)\n .or(entityQueryFilterExpressionSchema)\n .optional()\n .describe('List of key-value filter expression for entities'),\n }),\n);\n\n/**\n * The input props that can be specified under `ui:options` for the\n * `EntityPicker` field extension.\n *\n * @public\n */\nexport type EntityPickerUiOptions =\n typeof EntityPickerFieldSchema.uiOptionsType;\n\nexport type EntityPickerProps = typeof EntityPickerFieldSchema.type;\n\nexport const EntityPickerSchema = EntityPickerFieldSchema.schema;\n\nexport type EntityPickerFilterQuery = z.TypeOf<\n typeof entityQueryFilterExpressionSchema\n>;\n\nexport type EntityPickerFilterQueryValue =\n EntityPickerFilterQuery[keyof EntityPickerFilterQuery];\n"],"names":[],"mappings":";;;AAqBO,MAAM,oCAAoC,CAAE,CAAA,MAAA;AAAA,EACjD,CAAA,CACG,QACA,CAAA,EAAA,CAAG,EAAE,MAAO,CAAA,EAAE,MAAQ,EAAA,CAAA,CAAE,OAAQ,EAAA,CAAE,UAAW,EAAC,CAAC,CAC/C,CAAA,EAAA,CAAG,EAAE,KAAM,CAAA,CAAA,CAAE,MAAO,EAAC,CAAC,CAAA;AAC3B,EAAA;AAKO,MAAM,uBAA0B,GAAA,sBAAA;AAAA,EACrC,EAAE,MAAO,EAAA;AAAA,EACT,EAAE,MAAO,CAAA;AAAA;AAAA;AAAA;AAAA,IAIP,YAAA,EAAc,EACX,KAAM,CAAA,CAAA,CAAE,QAAQ,CAAA,CAChB,UACA,CAAA,QAAA;AAAA,MACC,2FAAA;AAAA,KACF;AAAA,IACF,WAAa,EAAA,CAAA,CACV,MAAO,EAAA,CACP,UACA,CAAA,QAAA;AAAA,MACC,qEAAA;AAAA,KACF;AAAA,IACF,sBAAsB,CACnB,CAAA,OAAA,GACA,QAAS,EAAA,CACT,SAAS,yDAAyD,CAAA;AAAA,IACrE,gBAAkB,EAAA,CAAA,CACf,KAAM,CAAA,CAAC,EAAE,MAAO,EAAA,EAAG,CAAE,CAAA,OAAA,CAAQ,KAAK,CAAC,CAAC,CAAA,CACpC,UACA,CAAA,QAAA;AAAA,MACC,0EAAA;AAAA,KACF;AAAA,IACF,aAAA,EAAe,CACZ,CAAA,KAAA,CAAM,iCAAiC,CAAA,CACvC,EAAG,CAAA,iCAAiC,CACpC,CAAA,QAAA,EACA,CAAA,QAAA,CAAS,kDAAkD,CAAA;AAAA,GAC/D,CAAA;AACH,EAAA;AAaO,MAAM,qBAAqB,uBAAwB,CAAA;;;;"}
@@ -0,0 +1,84 @@
1
+ import React, { useState } from 'react';
2
+ import useAsync from 'react-use/esm/useAsync';
3
+ import useEffectOnce from 'react-use/esm/useEffectOnce';
4
+ import { makeValidator } from '@backstage/catalog-model';
5
+ import { useApi } from '@backstage/core-plugin-api';
6
+ import { catalogApiRef } from '@backstage/plugin-catalog-react';
7
+ import FormControl from '@material-ui/core/FormControl';
8
+ import TextField from '@material-ui/core/TextField';
9
+ import Autocomplete from '@material-ui/lab/Autocomplete';
10
+ export { EntityTagsPickerSchema } from './schema.esm.js';
11
+
12
+ const EntityTagsPicker = (props) => {
13
+ var _a, _b, _c;
14
+ const { formData, onChange, uiSchema } = props;
15
+ const catalogApi = useApi(catalogApiRef);
16
+ const [tagOptions, setTagOptions] = useState([]);
17
+ const [inputValue, setInputValue] = useState("");
18
+ const [inputError, setInputError] = useState(false);
19
+ const tagValidator = makeValidator().isValidTag;
20
+ const kinds = (_a = uiSchema["ui:options"]) == null ? void 0 : _a.kinds;
21
+ const showCounts = (_b = uiSchema["ui:options"]) == null ? void 0 : _b.showCounts;
22
+ const helperText = (_c = uiSchema["ui:options"]) == null ? void 0 : _c.helperText;
23
+ const { loading, value: existingTags } = useAsync(async () => {
24
+ const facet = "metadata.tags";
25
+ const tagsRequest = { facets: [facet] };
26
+ if (kinds) {
27
+ tagsRequest.filter = { kind: kinds };
28
+ }
29
+ const { facets } = await catalogApi.getEntityFacets(tagsRequest);
30
+ const tagFacets = Object.fromEntries(
31
+ facets[facet].map(({ value, count }) => [value, count])
32
+ );
33
+ setTagOptions(
34
+ Object.keys(tagFacets).sort(
35
+ (a, b) => showCounts ? tagFacets[b] - tagFacets[a] : a.localeCompare(b)
36
+ )
37
+ );
38
+ return tagFacets;
39
+ });
40
+ const setTags = (_, values) => {
41
+ let hasError = false;
42
+ let addDuplicate = false;
43
+ const currentTags = formData || [];
44
+ if ((values == null ? void 0 : values.length) && currentTags.length < values.length) {
45
+ const newTag = values[values.length - 1] = values[values.length - 1].toLocaleLowerCase("en-US").trim();
46
+ hasError = !tagValidator(newTag);
47
+ addDuplicate = currentTags.indexOf(newTag) !== -1;
48
+ }
49
+ setInputError(hasError);
50
+ setInputValue(!hasError ? "" : inputValue);
51
+ if (!hasError && !addDuplicate) {
52
+ onChange(values || []);
53
+ }
54
+ };
55
+ useEffectOnce(() => onChange(formData || []));
56
+ return /* @__PURE__ */ React.createElement(FormControl, { margin: "normal" }, /* @__PURE__ */ React.createElement(
57
+ Autocomplete,
58
+ {
59
+ multiple: true,
60
+ freeSolo: true,
61
+ filterSelectedOptions: true,
62
+ onChange: setTags,
63
+ value: formData || [],
64
+ inputValue,
65
+ loading,
66
+ options: tagOptions,
67
+ ChipProps: { size: "small" },
68
+ renderOption: (option) => showCounts ? `${option} (${existingTags == null ? void 0 : existingTags[option]})` : option,
69
+ renderInput: (params) => /* @__PURE__ */ React.createElement(
70
+ TextField,
71
+ {
72
+ ...params,
73
+ label: "Tags",
74
+ onChange: (e) => setInputValue(e.target.value),
75
+ error: inputError,
76
+ helperText: helperText != null ? helperText : "Add any relevant tags, hit 'Enter' to add new tags. Valid format: [a-z0-9+#] separated by [-], at most 63 characters"
77
+ }
78
+ )
79
+ }
80
+ ));
81
+ };
82
+
83
+ export { EntityTagsPicker };
84
+ //# sourceMappingURL=EntityTagsPicker.esm.js.map