@backstage/plugin-scaffolder 1.30.0-next.1 → 1.30.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.
Files changed (139) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/alpha/components/TemplateEditorPage/CustomFieldExplorer.esm.js +98 -84
  3. package/dist/alpha/components/TemplateEditorPage/CustomFieldExplorer.esm.js.map +1 -1
  4. package/dist/alpha/components/TemplateEditorPage/CustomFieldPlaygroud.esm.js +119 -102
  5. package/dist/alpha/components/TemplateEditorPage/CustomFieldPlaygroud.esm.js.map +1 -1
  6. package/dist/alpha/components/TemplateEditorPage/CustomFieldsPage.esm.js +13 -10
  7. package/dist/alpha/components/TemplateEditorPage/CustomFieldsPage.esm.js.map +1 -1
  8. package/dist/alpha/components/TemplateEditorPage/DirectoryEditorContext.esm.js +4 -3
  9. package/dist/alpha/components/TemplateEditorPage/DirectoryEditorContext.esm.js.map +1 -1
  10. package/dist/alpha/components/TemplateEditorPage/DryRunContext.esm.js +3 -2
  11. package/dist/alpha/components/TemplateEditorPage/DryRunContext.esm.js.map +1 -1
  12. package/dist/alpha/components/TemplateEditorPage/DryRunResults/DryRunResults.esm.js +22 -15
  13. package/dist/alpha/components/TemplateEditorPage/DryRunResults/DryRunResults.esm.js.map +1 -1
  14. package/dist/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js +49 -44
  15. package/dist/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsList.esm.js.map +1 -1
  16. package/dist/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsSplitView.esm.js +7 -2
  17. package/dist/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsSplitView.esm.js.map +1 -1
  18. package/dist/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js +79 -57
  19. package/dist/alpha/components/TemplateEditorPage/DryRunResults/DryRunResultsView.esm.js.map +1 -1
  20. package/dist/alpha/components/TemplateEditorPage/DryRunResults/IconLink.esm.js +5 -2
  21. package/dist/alpha/components/TemplateEditorPage/DryRunResults/IconLink.esm.js.map +1 -1
  22. package/dist/alpha/components/TemplateEditorPage/DryRunResults/TaskPageLinks.esm.js +6 -6
  23. package/dist/alpha/components/TemplateEditorPage/DryRunResults/TaskPageLinks.esm.js.map +1 -1
  24. package/dist/alpha/components/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js +40 -36
  25. package/dist/alpha/components/TemplateEditorPage/DryRunResults/TaskStatusStepper.esm.js.map +1 -1
  26. package/dist/alpha/components/TemplateEditorPage/TemplateEditor.esm.js +24 -17
  27. package/dist/alpha/components/TemplateEditorPage/TemplateEditor.esm.js.map +1 -1
  28. package/dist/alpha/components/TemplateEditorPage/TemplateEditorBrowser.esm.js +50 -42
  29. package/dist/alpha/components/TemplateEditorPage/TemplateEditorBrowser.esm.js.map +1 -1
  30. package/dist/alpha/components/TemplateEditorPage/TemplateEditorForm.esm.js +5 -4
  31. package/dist/alpha/components/TemplateEditorPage/TemplateEditorForm.esm.js.map +1 -1
  32. package/dist/alpha/components/TemplateEditorPage/TemplateEditorIntro.esm.js +87 -70
  33. package/dist/alpha/components/TemplateEditorPage/TemplateEditorIntro.esm.js.map +1 -1
  34. package/dist/alpha/components/TemplateEditorPage/TemplateEditorLayout.esm.js +7 -7
  35. package/dist/alpha/components/TemplateEditorPage/TemplateEditorLayout.esm.js.map +1 -1
  36. package/dist/alpha/components/TemplateEditorPage/TemplateEditorPage.esm.js +20 -17
  37. package/dist/alpha/components/TemplateEditorPage/TemplateEditorPage.esm.js.map +1 -1
  38. package/dist/alpha/components/TemplateEditorPage/TemplateEditorTextArea.esm.js +52 -45
  39. package/dist/alpha/components/TemplateEditorPage/TemplateEditorTextArea.esm.js.map +1 -1
  40. package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbar.esm.js +76 -60
  41. package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbar.esm.js.map +1 -1
  42. package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarFileMenu.esm.js +42 -36
  43. package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarFileMenu.esm.js.map +1 -1
  44. package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarTemplatesMenu.esm.js +42 -38
  45. package/dist/alpha/components/TemplateEditorPage/TemplateEditorToolbarTemplatesMenu.esm.js.map +1 -1
  46. package/dist/alpha/components/TemplateEditorPage/TemplateFormPage.esm.js +23 -19
  47. package/dist/alpha/components/TemplateEditorPage/TemplateFormPage.esm.js.map +1 -1
  48. package/dist/alpha/components/TemplateEditorPage/TemplateFormPreviewer.esm.js +39 -31
  49. package/dist/alpha/components/TemplateEditorPage/TemplateFormPreviewer.esm.js.map +1 -1
  50. package/dist/alpha/components/TemplateEditorPage/TemplateIntroPage.esm.js +14 -10
  51. package/dist/alpha/components/TemplateEditorPage/TemplateIntroPage.esm.js.map +1 -1
  52. package/dist/alpha/components/TemplateListPage/RegisterExistingButton.esm.js +6 -6
  53. package/dist/alpha/components/TemplateListPage/RegisterExistingButton.esm.js.map +1 -1
  54. package/dist/alpha/components/TemplateListPage/TemplateListPage.esm.js +54 -34
  55. package/dist/alpha/components/TemplateListPage/TemplateListPage.esm.js.map +1 -1
  56. package/dist/alpha/components/TemplateWizardPage/TemplateWizardPage.esm.js +29 -24
  57. package/dist/alpha/components/TemplateWizardPage/TemplateWizardPage.esm.js.map +1 -1
  58. package/dist/alpha/components/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js +40 -33
  59. package/dist/alpha/components/TemplateWizardPage/TemplateWizardPageContextMenu.esm.js.map +1 -1
  60. package/dist/alpha/extensions.esm.js +2 -2
  61. package/dist/alpha/extensions.esm.js.map +1 -1
  62. package/dist/alpha/fields/RepoUrlPicker.esm.js +1 -1
  63. package/dist/alpha.d.ts +12 -12
  64. package/dist/components/ActionsPage/ActionsPage.esm.js +120 -167
  65. package/dist/components/ActionsPage/ActionsPage.esm.js.map +1 -1
  66. package/dist/components/FileBrowser/FileBrowser.esm.js +10 -9
  67. package/dist/components/FileBrowser/FileBrowser.esm.js.map +1 -1
  68. package/dist/components/ListTasksPage/ListTasksPage.esm.js +80 -70
  69. package/dist/components/ListTasksPage/ListTasksPage.esm.js.map +1 -1
  70. package/dist/components/ListTasksPage/OwnerListPicker.esm.js +29 -23
  71. package/dist/components/ListTasksPage/OwnerListPicker.esm.js.map +1 -1
  72. package/dist/components/ListTasksPage/columns/CreatedAtColumn.esm.js +2 -2
  73. package/dist/components/ListTasksPage/columns/CreatedAtColumn.esm.js.map +1 -1
  74. package/dist/components/ListTasksPage/columns/OwnerEntityColumn.esm.js +3 -3
  75. package/dist/components/ListTasksPage/columns/OwnerEntityColumn.esm.js.map +1 -1
  76. package/dist/components/ListTasksPage/columns/TaskStatusColumn.esm.js +4 -4
  77. package/dist/components/ListTasksPage/columns/TaskStatusColumn.esm.js.map +1 -1
  78. package/dist/components/ListTasksPage/columns/TemplateTitleColumn.esm.js +2 -2
  79. package/dist/components/ListTasksPage/columns/TemplateTitleColumn.esm.js.map +1 -1
  80. package/dist/components/OngoingTask/ContextMenu.esm.js +80 -58
  81. package/dist/components/OngoingTask/ContextMenu.esm.js.map +1 -1
  82. package/dist/components/OngoingTask/OngoingTask.esm.js +95 -76
  83. package/dist/components/OngoingTask/OngoingTask.esm.js.map +1 -1
  84. package/dist/components/RenderSchema/RenderSchema.esm.js +379 -0
  85. package/dist/components/RenderSchema/RenderSchema.esm.js.map +1 -0
  86. package/dist/components/Router/Router.esm.js +105 -94
  87. package/dist/components/Router/Router.esm.js.map +1 -1
  88. package/dist/components/ScaffolderUsageExamplesTable/ScaffolderUsageExamplesTable.esm.js +28 -0
  89. package/dist/components/ScaffolderUsageExamplesTable/ScaffolderUsageExamplesTable.esm.js.map +1 -0
  90. package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js +42 -39
  91. package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js.map +1 -1
  92. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js +2 -2
  93. package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js.map +1 -1
  94. package/dist/components/fields/EntityPicker/EntityPicker.esm.js +41 -40
  95. package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -1
  96. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js +5 -4
  97. package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js.map +1 -1
  98. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js +45 -44
  99. package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js.map +1 -1
  100. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js +36 -35
  101. package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js.map +1 -1
  102. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js +4 -4
  103. package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js.map +1 -1
  104. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js +2 -2
  105. package/dist/components/fields/OwnerPicker/OwnerPicker.esm.js.map +1 -1
  106. package/dist/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.esm.js +26 -23
  107. package/dist/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.esm.js.map +1 -1
  108. package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js +17 -15
  109. package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js.map +1 -1
  110. package/dist/components/fields/RepoBranchPicker/GitHubRepoBranchPicker.esm.js +26 -23
  111. package/dist/components/fields/RepoBranchPicker/GitHubRepoBranchPicker.esm.js.map +1 -1
  112. package/dist/components/fields/RepoBranchPicker/RepoBranchPicker.esm.js +13 -5
  113. package/dist/components/fields/RepoBranchPicker/RepoBranchPicker.esm.js.map +1 -1
  114. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js +62 -53
  115. package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js.map +1 -1
  116. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +85 -77
  117. package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -1
  118. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js +28 -25
  119. package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js.map +1 -1
  120. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js +33 -30
  121. package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js.map +1 -1
  122. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js +37 -34
  123. package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js.map +1 -1
  124. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +41 -37
  125. package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -1
  126. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js +98 -83
  127. package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js.map +1 -1
  128. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js +22 -19
  129. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js.map +1 -1
  130. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +42 -39
  131. package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -1
  132. package/dist/components/fields/SecretInput/SecretInput.esm.js +5 -5
  133. package/dist/components/fields/SecretInput/SecretInput.esm.js.map +1 -1
  134. package/dist/components/fields/VirtualizedListbox.esm.js +29 -26
  135. package/dist/components/fields/VirtualizedListbox.esm.js.map +1 -1
  136. package/dist/index.d.ts +17 -16
  137. package/dist/translation.esm.js +12 -10
  138. package/dist/translation.esm.js.map +1 -1
  139. package/package.json +17 -17
@@ -1,10 +1,11 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
1
2
  import { useApi } from '@backstage/core-plugin-api';
2
3
  import { scmIntegrationsApiRef, scmAuthApiRef } from '@backstage/integration-react';
3
4
  import { useTemplateSecrets } from '@backstage/plugin-scaffolder-react';
4
5
  import Box from '@material-ui/core/Box';
5
6
  import Divider from '@material-ui/core/Divider';
6
7
  import Typography from '@material-ui/core/Typography';
7
- import React, { useState, useMemo, useEffect, useCallback } from 'react';
8
+ import { useState, useMemo, useEffect, useCallback } from 'react';
8
9
  import useDebounce from 'react-use/esm/useDebounce';
9
10
  import { AzureRepoPicker } from './AzureRepoPicker.esm.js';
10
11
  import { BitbucketRepoPicker } from './BitbucketRepoPicker.esm.js';
@@ -114,88 +115,102 @@ const RepoUrlPicker = (props) => {
114
115
  [state, uiSchema]
115
116
  );
116
117
  const hostType = (state.host && integrationApi.byHost(state.host)?.type) ?? null;
117
- return /* @__PURE__ */ React.createElement(React.Fragment, null, schema.title && /* @__PURE__ */ React.createElement(Box, { my: 1 }, /* @__PURE__ */ React.createElement(Typography, { variant: "h5" }, schema.title), /* @__PURE__ */ React.createElement(Divider, null)), schema.description && /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, schema.description), /* @__PURE__ */ React.createElement(
118
- RepoUrlPickerHost,
119
- {
120
- host: state.host,
121
- hosts: allowedHosts,
122
- onChange: (host) => setState((prevState) => ({ ...prevState, host })),
123
- rawErrors,
124
- isDisabled
125
- }
126
- ), hostType === "github" && /* @__PURE__ */ React.createElement(
127
- GithubRepoPicker,
128
- {
129
- allowedOwners,
130
- onChange: updateLocalState,
131
- rawErrors,
132
- state,
133
- isDisabled,
134
- accessToken: uiSchema?.["ui:options"]?.requestUserCredentials?.secretsKey && secrets[uiSchema["ui:options"].requestUserCredentials.secretsKey]
135
- }
136
- ), hostType === "gitea" && /* @__PURE__ */ React.createElement(
137
- GiteaRepoPicker,
138
- {
139
- allowedOwners,
140
- allowedRepos,
141
- rawErrors,
142
- state,
143
- isDisabled,
144
- onChange: updateLocalState
145
- }
146
- ), hostType === "gitlab" && /* @__PURE__ */ React.createElement(
147
- GitlabRepoPicker,
148
- {
149
- allowedOwners,
150
- rawErrors,
151
- state,
152
- onChange: updateLocalState,
153
- isDisabled,
154
- accessToken: uiSchema?.["ui:options"]?.requestUserCredentials?.secretsKey && secrets[uiSchema["ui:options"].requestUserCredentials.secretsKey]
155
- }
156
- ), hostType === "bitbucket" && /* @__PURE__ */ React.createElement(
157
- BitbucketRepoPicker,
158
- {
159
- allowedOwners,
160
- allowedProjects,
161
- rawErrors,
162
- state,
163
- onChange: updateLocalState,
164
- isDisabled,
165
- accessToken: uiSchema?.["ui:options"]?.requestUserCredentials?.secretsKey && secrets[uiSchema["ui:options"].requestUserCredentials.secretsKey]
166
- }
167
- ), hostType === "azure" && /* @__PURE__ */ React.createElement(
168
- AzureRepoPicker,
169
- {
170
- allowedOrganizations,
171
- allowedProject: allowedProjects,
172
- rawErrors,
173
- state,
174
- isDisabled,
175
- onChange: updateLocalState
176
- }
177
- ), hostType === "gerrit" && /* @__PURE__ */ React.createElement(
178
- GerritRepoPicker,
179
- {
180
- rawErrors,
181
- state,
182
- onChange: updateLocalState,
183
- isDisabled
184
- }
185
- ), /* @__PURE__ */ React.createElement(
186
- RepoUrlPickerRepoName,
187
- {
188
- repoName: state.repoName,
189
- allowedRepos,
190
- onChange: (repo) => setState((prevState) => ({
191
- ...prevState,
192
- repoName: repo.id || repo.name
193
- })),
194
- isDisabled,
195
- rawErrors,
196
- availableRepos: state.availableRepos
197
- }
198
- ));
118
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
119
+ schema.title && /* @__PURE__ */ jsxs(Box, { my: 1, children: [
120
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", children: schema.title }),
121
+ /* @__PURE__ */ jsx(Divider, {})
122
+ ] }),
123
+ schema.description && /* @__PURE__ */ jsx(Typography, { variant: "body1", children: schema.description }),
124
+ /* @__PURE__ */ jsx(
125
+ RepoUrlPickerHost,
126
+ {
127
+ host: state.host,
128
+ hosts: allowedHosts,
129
+ onChange: (host) => setState((prevState) => ({ ...prevState, host })),
130
+ rawErrors,
131
+ isDisabled
132
+ }
133
+ ),
134
+ hostType === "github" && /* @__PURE__ */ jsx(
135
+ GithubRepoPicker,
136
+ {
137
+ allowedOwners,
138
+ onChange: updateLocalState,
139
+ rawErrors,
140
+ state,
141
+ isDisabled,
142
+ accessToken: uiSchema?.["ui:options"]?.requestUserCredentials?.secretsKey && secrets[uiSchema["ui:options"].requestUserCredentials.secretsKey]
143
+ }
144
+ ),
145
+ hostType === "gitea" && /* @__PURE__ */ jsx(
146
+ GiteaRepoPicker,
147
+ {
148
+ allowedOwners,
149
+ allowedRepos,
150
+ rawErrors,
151
+ state,
152
+ isDisabled,
153
+ onChange: updateLocalState
154
+ }
155
+ ),
156
+ hostType === "gitlab" && /* @__PURE__ */ jsx(
157
+ GitlabRepoPicker,
158
+ {
159
+ allowedOwners,
160
+ rawErrors,
161
+ state,
162
+ onChange: updateLocalState,
163
+ isDisabled,
164
+ accessToken: uiSchema?.["ui:options"]?.requestUserCredentials?.secretsKey && secrets[uiSchema["ui:options"].requestUserCredentials.secretsKey]
165
+ }
166
+ ),
167
+ hostType === "bitbucket" && /* @__PURE__ */ jsx(
168
+ BitbucketRepoPicker,
169
+ {
170
+ allowedOwners,
171
+ allowedProjects,
172
+ rawErrors,
173
+ state,
174
+ onChange: updateLocalState,
175
+ isDisabled,
176
+ accessToken: uiSchema?.["ui:options"]?.requestUserCredentials?.secretsKey && secrets[uiSchema["ui:options"].requestUserCredentials.secretsKey]
177
+ }
178
+ ),
179
+ hostType === "azure" && /* @__PURE__ */ jsx(
180
+ AzureRepoPicker,
181
+ {
182
+ allowedOrganizations,
183
+ allowedProject: allowedProjects,
184
+ rawErrors,
185
+ state,
186
+ isDisabled,
187
+ onChange: updateLocalState
188
+ }
189
+ ),
190
+ hostType === "gerrit" && /* @__PURE__ */ jsx(
191
+ GerritRepoPicker,
192
+ {
193
+ rawErrors,
194
+ state,
195
+ onChange: updateLocalState,
196
+ isDisabled
197
+ }
198
+ ),
199
+ /* @__PURE__ */ jsx(
200
+ RepoUrlPickerRepoName,
201
+ {
202
+ repoName: state.repoName,
203
+ allowedRepos,
204
+ onChange: (repo) => setState((prevState) => ({
205
+ ...prevState,
206
+ repoName: repo.id || repo.name
207
+ })),
208
+ isDisabled,
209
+ rawErrors,
210
+ availableRepos: state.availableRepos
211
+ }
212
+ )
213
+ ] });
199
214
  };
200
215
 
201
216
  export { RepoUrlPicker };
@@ -1 +1 @@
1
- {"version":3,"file":"RepoUrlPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/RepoUrlPicker.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 { useApi } from '@backstage/core-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport { useTemplateSecrets } from '@backstage/plugin-scaffolder-react';\nimport Box from '@material-ui/core/Box';\nimport Divider from '@material-ui/core/Divider';\nimport Typography from '@material-ui/core/Typography';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\nimport { AzureRepoPicker } from './AzureRepoPicker';\nimport { BitbucketRepoPicker } from './BitbucketRepoPicker';\nimport { GerritRepoPicker } from './GerritRepoPicker';\nimport { GiteaRepoPicker } from './GiteaRepoPicker';\nimport { GithubRepoPicker } from './GithubRepoPicker';\nimport { GitlabRepoPicker } from './GitlabRepoPicker';\nimport { RepoUrlPickerHost } from './RepoUrlPickerHost';\nimport { RepoUrlPickerRepoName } from './RepoUrlPickerRepoName';\nimport { RepoUrlPickerFieldSchema } from './schema';\nimport { RepoUrlPickerState } from './types';\nimport { parseRepoPickerUrl, serializeRepoPickerUrl } from './utils';\n\nexport { RepoUrlPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `RepoUrlPicker`\n * field extension.\n *\n * @public\n */\nexport const RepoUrlPicker = (\n props: typeof RepoUrlPickerFieldSchema.TProps,\n) => {\n const { uiSchema, onChange, rawErrors, formData, schema } = props;\n const [state, setState] = useState<RepoUrlPickerState>(\n parseRepoPickerUrl(formData),\n );\n const [credentialsHost, setCredentialsHost] = useState<string | undefined>(\n undefined,\n );\n const integrationApi = useApi(scmIntegrationsApiRef);\n const scmAuthApi = useApi(scmAuthApiRef);\n const { secrets, setSecrets } = useTemplateSecrets();\n const allowedHosts = useMemo(\n () => uiSchema?.['ui:options']?.allowedHosts ?? [],\n [uiSchema],\n );\n const allowedOrganizations = useMemo(\n () => uiSchema?.['ui:options']?.allowedOrganizations ?? [],\n [uiSchema],\n );\n const allowedOwners = useMemo(\n () => uiSchema?.['ui:options']?.allowedOwners ?? [],\n [uiSchema],\n );\n const allowedProjects = useMemo(\n () => uiSchema?.['ui:options']?.allowedProjects ?? [],\n [uiSchema],\n );\n const allowedRepos = useMemo(\n () => uiSchema?.['ui:options']?.allowedRepos ?? [],\n [uiSchema],\n );\n const isDisabled = useMemo(\n () => uiSchema?.['ui:disabled'] ?? false,\n [uiSchema],\n );\n const { owner, organization, project, repoName } = state;\n\n useEffect(() => {\n onChange(serializeRepoPickerUrl(state));\n }, [state, onChange]);\n\n /* we deal with calling the repo setting here instead of in each components for ease */\n useEffect(() => {\n if (allowedOrganizations.length > 0 && !organization) {\n setState(prevState => ({\n ...prevState,\n organization: allowedOrganizations[0],\n }));\n }\n }, [setState, allowedOrganizations, organization]);\n\n useEffect(() => {\n if (allowedOwners.length > 0 && !owner) {\n setState(prevState => ({\n ...prevState,\n owner: allowedOwners[0],\n }));\n }\n }, [setState, allowedOwners, owner]);\n\n useEffect(() => {\n if (allowedProjects.length > 0 && !project) {\n setState(prevState => ({\n ...prevState,\n project: allowedProjects[0],\n }));\n }\n }, [setState, allowedProjects, project]);\n\n useEffect(() => {\n if (allowedRepos.length > 0 && !repoName) {\n setState(prevState => ({ ...prevState, repoName: allowedRepos[0] }));\n }\n }, [setState, allowedRepos, repoName]);\n\n const updateLocalState = useCallback(\n (newState: RepoUrlPickerState) => {\n setState(prevState => ({ ...prevState, ...newState }));\n },\n [setState],\n );\n\n useDebounce(\n async () => {\n const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {};\n\n if (!requestUserCredentials || !state.host) {\n return;\n }\n\n // don't show login prompt if secret value is already in state for selected host\n if (\n secrets[requestUserCredentials.secretsKey] &&\n credentialsHost === state.host\n ) {\n return;\n }\n\n // user has requested that we use the users credentials\n // so lets grab them using the scmAuthApi and pass through\n // any additional scopes from the ui:options\n const { token } = await scmAuthApi.getCredentials({\n url: `https://${state.host}`,\n additionalScope: {\n repoWrite: true,\n customScopes: requestUserCredentials.additionalScopes,\n },\n });\n\n // set the secret using the key provided in the ui:options for use\n // in the templating the manifest with ${{ secrets[secretsKey] }}\n setSecrets({ [requestUserCredentials.secretsKey]: token });\n setCredentialsHost(state.host);\n },\n 500,\n [state, uiSchema],\n );\n\n const hostType =\n (state.host && integrationApi.byHost(state.host)?.type) ?? null;\n return (\n <>\n {schema.title && (\n <Box my={1}>\n <Typography variant=\"h5\">{schema.title}</Typography>\n <Divider />\n </Box>\n )}\n {schema.description && (\n <Typography variant=\"body1\">{schema.description}</Typography>\n )}\n <RepoUrlPickerHost\n host={state.host}\n hosts={allowedHosts}\n onChange={host => setState(prevState => ({ ...prevState, host }))}\n rawErrors={rawErrors}\n isDisabled={isDisabled}\n />\n {hostType === 'github' && (\n <GithubRepoPicker\n allowedOwners={allowedOwners}\n onChange={updateLocalState}\n rawErrors={rawErrors}\n state={state}\n isDisabled={isDisabled}\n accessToken={\n uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&\n secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]\n }\n />\n )}\n {hostType === 'gitea' && (\n <GiteaRepoPicker\n allowedOwners={allowedOwners}\n allowedRepos={allowedRepos}\n rawErrors={rawErrors}\n state={state}\n isDisabled={isDisabled}\n onChange={updateLocalState}\n />\n )}\n {hostType === 'gitlab' && (\n <GitlabRepoPicker\n allowedOwners={allowedOwners}\n rawErrors={rawErrors}\n state={state}\n onChange={updateLocalState}\n isDisabled={isDisabled}\n accessToken={\n uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&\n secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]\n }\n />\n )}\n {hostType === 'bitbucket' && (\n <BitbucketRepoPicker\n allowedOwners={allowedOwners}\n allowedProjects={allowedProjects}\n rawErrors={rawErrors}\n state={state}\n onChange={updateLocalState}\n isDisabled={isDisabled}\n accessToken={\n uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&\n secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]\n }\n />\n )}\n {hostType === 'azure' && (\n <AzureRepoPicker\n allowedOrganizations={allowedOrganizations}\n allowedProject={allowedProjects}\n rawErrors={rawErrors}\n state={state}\n isDisabled={isDisabled}\n onChange={updateLocalState}\n />\n )}\n {hostType === 'gerrit' && (\n <GerritRepoPicker\n rawErrors={rawErrors}\n state={state}\n onChange={updateLocalState}\n isDisabled={isDisabled}\n />\n )}\n <RepoUrlPickerRepoName\n repoName={state.repoName}\n allowedRepos={allowedRepos}\n onChange={repo =>\n setState(prevState => ({\n ...prevState,\n repoName: repo.id || repo.name,\n }))\n }\n isDisabled={isDisabled}\n rawErrors={rawErrors}\n availableRepos={state.availableRepos}\n />\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA8Ca,MAAA,aAAA,GAAgB,CAC3B,KACG,KAAA;AACH,EAAA,MAAM,EAAE,QAAU,EAAA,QAAA,EAAU,SAAW,EAAA,QAAA,EAAU,QAAW,GAAA,KAAA;AAC5D,EAAM,M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AA,EAAA,IAAM,IAAK,CAAA;AAAA,OAC1B,CAAA,CAAA;AAAA,MAEJ,UAAA;AAAA,MACA,SAAA;AAAA,MACA,gBAAgB,KAAM,CAAA;AAAA;AAAA,GAE1B,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"RepoUrlPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/RepoUrlPicker.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 { useApi } from '@backstage/core-plugin-api';\nimport {\n scmAuthApiRef,\n scmIntegrationsApiRef,\n} from '@backstage/integration-react';\nimport { useTemplateSecrets } from '@backstage/plugin-scaffolder-react';\nimport Box from '@material-ui/core/Box';\nimport Divider from '@material-ui/core/Divider';\nimport Typography from '@material-ui/core/Typography';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\nimport { AzureRepoPicker } from './AzureRepoPicker';\nimport { BitbucketRepoPicker } from './BitbucketRepoPicker';\nimport { GerritRepoPicker } from './GerritRepoPicker';\nimport { GiteaRepoPicker } from './GiteaRepoPicker';\nimport { GithubRepoPicker } from './GithubRepoPicker';\nimport { GitlabRepoPicker } from './GitlabRepoPicker';\nimport { RepoUrlPickerHost } from './RepoUrlPickerHost';\nimport { RepoUrlPickerRepoName } from './RepoUrlPickerRepoName';\nimport { RepoUrlPickerFieldSchema } from './schema';\nimport { RepoUrlPickerState } from './types';\nimport { parseRepoPickerUrl, serializeRepoPickerUrl } from './utils';\n\nexport { RepoUrlPickerSchema } from './schema';\n\n/**\n * The underlying component that is rendered in the form for the `RepoUrlPicker`\n * field extension.\n *\n * @public\n */\nexport const RepoUrlPicker = (\n props: typeof RepoUrlPickerFieldSchema.TProps,\n) => {\n const { uiSchema, onChange, rawErrors, formData, schema } = props;\n const [state, setState] = useState<RepoUrlPickerState>(\n parseRepoPickerUrl(formData),\n );\n const [credentialsHost, setCredentialsHost] = useState<string | undefined>(\n undefined,\n );\n const integrationApi = useApi(scmIntegrationsApiRef);\n const scmAuthApi = useApi(scmAuthApiRef);\n const { secrets, setSecrets } = useTemplateSecrets();\n const allowedHosts = useMemo(\n () => uiSchema?.['ui:options']?.allowedHosts ?? [],\n [uiSchema],\n );\n const allowedOrganizations = useMemo(\n () => uiSchema?.['ui:options']?.allowedOrganizations ?? [],\n [uiSchema],\n );\n const allowedOwners = useMemo(\n () => uiSchema?.['ui:options']?.allowedOwners ?? [],\n [uiSchema],\n );\n const allowedProjects = useMemo(\n () => uiSchema?.['ui:options']?.allowedProjects ?? [],\n [uiSchema],\n );\n const allowedRepos = useMemo(\n () => uiSchema?.['ui:options']?.allowedRepos ?? [],\n [uiSchema],\n );\n const isDisabled = useMemo(\n () => uiSchema?.['ui:disabled'] ?? false,\n [uiSchema],\n );\n const { owner, organization, project, repoName } = state;\n\n useEffect(() => {\n onChange(serializeRepoPickerUrl(state));\n }, [state, onChange]);\n\n /* we deal with calling the repo setting here instead of in each components for ease */\n useEffect(() => {\n if (allowedOrganizations.length > 0 && !organization) {\n setState(prevState => ({\n ...prevState,\n organization: allowedOrganizations[0],\n }));\n }\n }, [setState, allowedOrganizations, organization]);\n\n useEffect(() => {\n if (allowedOwners.length > 0 && !owner) {\n setState(prevState => ({\n ...prevState,\n owner: allowedOwners[0],\n }));\n }\n }, [setState, allowedOwners, owner]);\n\n useEffect(() => {\n if (allowedProjects.length > 0 && !project) {\n setState(prevState => ({\n ...prevState,\n project: allowedProjects[0],\n }));\n }\n }, [setState, allowedProjects, project]);\n\n useEffect(() => {\n if (allowedRepos.length > 0 && !repoName) {\n setState(prevState => ({ ...prevState, repoName: allowedRepos[0] }));\n }\n }, [setState, allowedRepos, repoName]);\n\n const updateLocalState = useCallback(\n (newState: RepoUrlPickerState) => {\n setState(prevState => ({ ...prevState, ...newState }));\n },\n [setState],\n );\n\n useDebounce(\n async () => {\n const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {};\n\n if (!requestUserCredentials || !state.host) {\n return;\n }\n\n // don't show login prompt if secret value is already in state for selected host\n if (\n secrets[requestUserCredentials.secretsKey] &&\n credentialsHost === state.host\n ) {\n return;\n }\n\n // user has requested that we use the users credentials\n // so lets grab them using the scmAuthApi and pass through\n // any additional scopes from the ui:options\n const { token } = await scmAuthApi.getCredentials({\n url: `https://${state.host}`,\n additionalScope: {\n repoWrite: true,\n customScopes: requestUserCredentials.additionalScopes,\n },\n });\n\n // set the secret using the key provided in the ui:options for use\n // in the templating the manifest with ${{ secrets[secretsKey] }}\n setSecrets({ [requestUserCredentials.secretsKey]: token });\n setCredentialsHost(state.host);\n },\n 500,\n [state, uiSchema],\n );\n\n const hostType =\n (state.host && integrationApi.byHost(state.host)?.type) ?? null;\n return (\n <>\n {schema.title && (\n <Box my={1}>\n <Typography variant=\"h5\">{schema.title}</Typography>\n <Divider />\n </Box>\n )}\n {schema.description && (\n <Typography variant=\"body1\">{schema.description}</Typography>\n )}\n <RepoUrlPickerHost\n host={state.host}\n hosts={allowedHosts}\n onChange={host => setState(prevState => ({ ...prevState, host }))}\n rawErrors={rawErrors}\n isDisabled={isDisabled}\n />\n {hostType === 'github' && (\n <GithubRepoPicker\n allowedOwners={allowedOwners}\n onChange={updateLocalState}\n rawErrors={rawErrors}\n state={state}\n isDisabled={isDisabled}\n accessToken={\n uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&\n secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]\n }\n />\n )}\n {hostType === 'gitea' && (\n <GiteaRepoPicker\n allowedOwners={allowedOwners}\n allowedRepos={allowedRepos}\n rawErrors={rawErrors}\n state={state}\n isDisabled={isDisabled}\n onChange={updateLocalState}\n />\n )}\n {hostType === 'gitlab' && (\n <GitlabRepoPicker\n allowedOwners={allowedOwners}\n rawErrors={rawErrors}\n state={state}\n onChange={updateLocalState}\n isDisabled={isDisabled}\n accessToken={\n uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&\n secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]\n }\n />\n )}\n {hostType === 'bitbucket' && (\n <BitbucketRepoPicker\n allowedOwners={allowedOwners}\n allowedProjects={allowedProjects}\n rawErrors={rawErrors}\n state={state}\n onChange={updateLocalState}\n isDisabled={isDisabled}\n accessToken={\n uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&\n secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]\n }\n />\n )}\n {hostType === 'azure' && (\n <AzureRepoPicker\n allowedOrganizations={allowedOrganizations}\n allowedProject={allowedProjects}\n rawErrors={rawErrors}\n state={state}\n isDisabled={isDisabled}\n onChange={updateLocalState}\n />\n )}\n {hostType === 'gerrit' && (\n <GerritRepoPicker\n rawErrors={rawErrors}\n state={state}\n onChange={updateLocalState}\n isDisabled={isDisabled}\n />\n )}\n <RepoUrlPickerRepoName\n repoName={state.repoName}\n allowedRepos={allowedRepos}\n onChange={repo =>\n setState(prevState => ({\n ...prevState,\n repoName: repo.id || repo.name,\n }))\n }\n isDisabled={isDisabled}\n rawErrors={rawErrors}\n availableRepos={state.availableRepos}\n />\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AA8Ca,MAAA,aAAA,GAAgB,CAC3B,KACG,KAAA;AACH,EAAA,MAAM,EAAE,QAAU,EAAA,QAAA,EAAU,SAAW,EAAA,QAAA,EAAU,QAAW,GAAA,KAAA;AAC5D,EAAM,MAAA,CAAC,KAAO,EAAA,QAAQ,CAAI,GAAA,QAAA;AAAA,IACxB,mBAAmB,QAAQ;AAAA,GAC7B;AACA,EAAM,MAAA,CAAC,eAAiB,EAAA,kBAAkB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
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { useEffect } from 'react';
2
3
  import { Progress, Select } from '@backstage/core-components';
3
4
  import FormControl from '@material-ui/core/FormControl';
4
5
  import FormHelperText from '@material-ui/core/FormHelperText';
@@ -30,29 +31,31 @@ const RepoUrlPickerHost = (props) => {
30
31
  }, [hosts, host, onChange, integrations]);
31
32
  const hostsOptions = integrations ? integrations.filter((i) => hosts?.length ? hosts?.includes(i.host) : true).map((i) => ({ label: i.title, value: i.host })) : [{ label: "Loading...", value: "loading" }];
32
33
  if (loading) {
33
- return /* @__PURE__ */ React.createElement(Progress, null);
34
+ return /* @__PURE__ */ jsx(Progress, {});
34
35
  }
35
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
36
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
36
37
  FormControl,
37
38
  {
38
39
  margin: "normal",
39
40
  required: true,
40
- error: rawErrors?.length > 0 && !host
41
- },
42
- /* @__PURE__ */ React.createElement(
43
- Select,
44
- {
45
- native: true,
46
- disabled: isDisabled || hosts?.length === 1,
47
- label: t("fields.repoUrlPicker.host.title"),
48
- onChange: (s) => onChange(String(Array.isArray(s) ? s[0] : s)),
49
- selected: host,
50
- items: hostsOptions,
51
- "data-testid": "host-select"
52
- }
53
- ),
54
- /* @__PURE__ */ React.createElement(FormHelperText, null, t("fields.repoUrlPicker.host.description"))
55
- ));
41
+ error: rawErrors?.length > 0 && !host,
42
+ children: [
43
+ /* @__PURE__ */ jsx(
44
+ Select,
45
+ {
46
+ native: true,
47
+ disabled: isDisabled || hosts?.length === 1,
48
+ label: t("fields.repoUrlPicker.host.title"),
49
+ onChange: (s) => onChange(String(Array.isArray(s) ? s[0] : s)),
50
+ selected: host,
51
+ items: hostsOptions,
52
+ "data-testid": "host-select"
53
+ }
54
+ ),
55
+ /* @__PURE__ */ jsx(FormHelperText, { children: t("fields.repoUrlPicker.host.description") })
56
+ ]
57
+ }
58
+ ) });
56
59
  };
57
60
 
58
61
  export { RepoUrlPickerHost };
@@ -1 +1 @@
1
- {"version":3,"file":"RepoUrlPickerHost.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/RepoUrlPickerHost.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, { useEffect } from 'react';\nimport { Progress, Select, SelectItem } from '@backstage/core-components';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport const RepoUrlPickerHost = (props: {\n host?: string;\n hosts?: string[];\n onChange: (host: string) => void;\n rawErrors: string[];\n isDisabled?: boolean;\n}) => {\n const { host, hosts, onChange, rawErrors, isDisabled } = props;\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const scaffolderApi = useApi(scaffolderApiRef);\n\n const { value: { integrations } = { integrations: [] }, loading } = useAsync(\n async () => {\n return await scaffolderApi.getIntegrationsList({\n allowedHosts: hosts ?? [],\n });\n },\n );\n\n useEffect(() => {\n // If there is no host chosen currently\n if (!host) {\n // Set the first of the allowedHosts option if that available\n if (hosts?.length) {\n onChange(hosts[0]);\n // if there's no hosts provided, fallback to using the first integration\n } else if (integrations?.length) {\n onChange(integrations[0].host);\n }\n }\n }, [hosts, host, onChange, integrations]);\n\n // If there are no allowedHosts provided, then show all integrations. Otherwise, only show integrations\n // that are provided in the dropdown for the user to choose from.\n const hostsOptions: SelectItem[] = integrations\n ? integrations\n .filter(i => (hosts?.length ? hosts?.includes(i.host) : true))\n .map(i => ({ label: i.title, value: i.host }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n if (loading) {\n return <Progress />;\n }\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !host}\n >\n <Select\n native\n disabled={isDisabled || hosts?.length === 1}\n label={t('fields.repoUrlPicker.host.title')}\n onChange={s => onChange(String(Array.isArray(s) ? s[0] : s))}\n selected={host}\n items={hostsOptions}\n data-testid=\"host-select\"\n />\n\n <FormHelperText>\n {t('fields.repoUrlPicker.host.description')}\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAyBa,MAAA,iBAAA,GAAoB,CAAC,KAM5B,KAAA;AACJ,EAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,QAAU,EAAA,SAAA,EAAW,YAAe,GAAA,KAAA;AACzD,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA;AAE7C,EAAM,MAAA,EAAE,KAAO,EAAA,EAAE,YAAa,EAAA,GAAI,EAAE,YAAA,EAAc,EAAC,EAAK,EAAA,OAAA,EAAY,GAAA,QAAA;AAAA,IAClE,YAAY;AACV,MAAO,OAAA,MAAM,cAAc,mBAAoB,CAAA;AAAA,QAC7C,YAAA,EAAc,SAAS;AAAC,OACzB,CAAA;AAAA;AACH,GACF;AAEA,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,IAAI,CAAC,IAAM,EAAA;AAET,MAAA,IAAI,OAAO,MAAQ,EAAA;AACjB,QAAS,QAAA,CAAA,KAAA,CAAM,CAAC,CAAC,CAAA;AAAA,OAEnB,MAAA,IAAW,cAAc,MAAQ,EAAA;A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3D,QAAU,EAAA,IAAA;AAAA,QACV,KAAO,EAAA,YAAA;AAAA,QACP,aAAY,EAAA;AAAA;AAAA,KACd;AAAA,oBAEC,KAAA,CAAA,aAAA,CAAA,cAAA,EAAA,IAAA,EACE,CAAE,CAAA,uCAAuC,CAC5C;AAAA,GAEJ,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"RepoUrlPickerHost.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/RepoUrlPickerHost.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 { useEffect } from 'react';\nimport { Progress, Select, SelectItem } from '@backstage/core-components';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport const RepoUrlPickerHost = (props: {\n host?: string;\n hosts?: string[];\n onChange: (host: string) => void;\n rawErrors: string[];\n isDisabled?: boolean;\n}) => {\n const { host, hosts, onChange, rawErrors, isDisabled } = props;\n const { t } = useTranslationRef(scaffolderTranslationRef);\n const scaffolderApi = useApi(scaffolderApiRef);\n\n const { value: { integrations } = { integrations: [] }, loading } = useAsync(\n async () => {\n return await scaffolderApi.getIntegrationsList({\n allowedHosts: hosts ?? [],\n });\n },\n );\n\n useEffect(() => {\n // If there is no host chosen currently\n if (!host) {\n // Set the first of the allowedHosts option if that available\n if (hosts?.length) {\n onChange(hosts[0]);\n // if there's no hosts provided, fallback to using the first integration\n } else if (integrations?.length) {\n onChange(integrations[0].host);\n }\n }\n }, [hosts, host, onChange, integrations]);\n\n // If there are no allowedHosts provided, then show all integrations. Otherwise, only show integrations\n // that are provided in the dropdown for the user to choose from.\n const hostsOptions: SelectItem[] = integrations\n ? integrations\n .filter(i => (hosts?.length ? hosts?.includes(i.host) : true))\n .map(i => ({ label: i.title, value: i.host }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n if (loading) {\n return <Progress />;\n }\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !host}\n >\n <Select\n native\n disabled={isDisabled || hosts?.length === 1}\n label={t('fields.repoUrlPicker.host.title')}\n onChange={s => onChange(String(Array.isArray(s) ? s[0] : s))}\n selected={host}\n items={hostsOptions}\n data-testid=\"host-select\"\n />\n\n <FormHelperText>\n {t('fields.repoUrlPicker.host.description')}\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAyBa,MAAA,iBAAA,GAAoB,CAAC,KAM5B,KAAA;AACJ,EAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,QAAU,EAAA,SAAA,EAAW,YAAe,GAAA,KAAA;AACzD,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAM,MAAA,aAAA,GAAgB,OAAO,gBAAgB,CAAA;AAE7C,EAAM,MAAA,EAAE,KAAO,EAAA,EAAE,YAAa,EAAA,GAAI,EAAE,YAAA,EAAc,EAAC,EAAK,EAAA,OAAA,EAAY,GAAA,QAAA;AAAA,IAClE,YAAY;AACV,MAAO,OAAA,MAAM,cAAc,mBAAoB,CAAA;AAAA,QAC7C,YAAA,EAAc,SAAS;AAAC,OACzB,CAAA;AAAA;AACH,GACF;AAEA,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,IAAI,CAAC,IAAM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CAAA,MAAA,CAAO,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA,GAAI,CAAE,CAAA,CAAC,CAAI,GAAA,CAAC,CAAC,CAAA;AAAA,YAC3D,QAAU,EAAA,IAAA;AAAA,YACV,KAAO,EAAA,YAAA;AAAA,YACP,aAAY,EAAA;AAAA;AAAA,SACd;AAAA,wBAEC,GAAA,CAAA,cAAA,EAAA,EACE,QAAE,EAAA,CAAA,CAAA,uCAAuC,CAC5C,EAAA;AAAA;AAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ;;;;"}
@@ -1,10 +1,11 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
1
2
  import { Select } from '@backstage/core-components';
2
3
  import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
3
4
  import FormControl from '@material-ui/core/FormControl';
4
5
  import FormHelperText from '@material-ui/core/FormHelperText';
5
6
  import TextField from '@material-ui/core/TextField';
6
7
  import Autocomplete from '@material-ui/lab/Autocomplete';
7
- import React, { useEffect } from 'react';
8
+ import { useEffect } from 'react';
8
9
  import { scaffolderTranslationRef } from '../../../translation.esm.js';
9
10
 
10
11
  const RepoUrlPickerRepoName = (props) => {
@@ -25,51 +26,53 @@ const RepoUrlPickerRepoName = (props) => {
25
26
  }
26
27
  }, [allowedRepos, repoName, onChange]);
27
28
  const repoItems = allowedRepos ? allowedRepos.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
28
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
29
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
29
30
  FormControl,
30
31
  {
31
32
  margin: "normal",
32
33
  required: true,
33
- error: rawErrors?.length > 0 && !repoName
34
- },
35
- allowedRepos?.length ? /* @__PURE__ */ React.createElement(
36
- Select,
37
- {
38
- native: true,
39
- label: t("fields.repoUrlPicker.repository.title"),
40
- onChange: (selected) => onChange({
41
- name: String(Array.isArray(selected) ? selected[0] : selected)
42
- }),
43
- disabled: isDisabled || allowedRepos.length === 1,
44
- selected: repoName,
45
- items: repoItems
46
- }
47
- ) : /* @__PURE__ */ React.createElement(
48
- Autocomplete,
49
- {
50
- value: repoName,
51
- onInputChange: (_, newValue) => {
52
- const selectedRepo = availableRepos?.find(
53
- (r) => r.name === newValue
54
- );
55
- onChange(selectedRepo || { name: newValue || "" });
56
- },
57
- options: (availableRepos || []).map((r) => r.name),
58
- renderInput: (params) => /* @__PURE__ */ React.createElement(
59
- TextField,
34
+ error: rawErrors?.length > 0 && !repoName,
35
+ children: [
36
+ allowedRepos?.length ? /* @__PURE__ */ jsx(
37
+ Select,
38
+ {
39
+ native: true,
40
+ label: t("fields.repoUrlPicker.repository.title"),
41
+ onChange: (selected) => onChange({
42
+ name: String(Array.isArray(selected) ? selected[0] : selected)
43
+ }),
44
+ disabled: isDisabled || allowedRepos.length === 1,
45
+ selected: repoName,
46
+ items: repoItems
47
+ }
48
+ ) : /* @__PURE__ */ jsx(
49
+ Autocomplete,
60
50
  {
61
- ...params,
62
- label: t("fields.repoUrlPicker.repository.inputTitle"),
63
- required: true
51
+ value: repoName,
52
+ onInputChange: (_, newValue) => {
53
+ const selectedRepo = availableRepos?.find(
54
+ (r) => r.name === newValue
55
+ );
56
+ onChange(selectedRepo || { name: newValue || "" });
57
+ },
58
+ options: (availableRepos || []).map((r) => r.name),
59
+ renderInput: (params) => /* @__PURE__ */ jsx(
60
+ TextField,
61
+ {
62
+ ...params,
63
+ label: t("fields.repoUrlPicker.repository.inputTitle"),
64
+ required: true
65
+ }
66
+ ),
67
+ freeSolo: true,
68
+ autoSelect: true,
69
+ disabled: isDisabled
64
70
  }
65
71
  ),
66
- freeSolo: true,
67
- autoSelect: true,
68
- disabled: isDisabled
69
- }
70
- ),
71
- /* @__PURE__ */ React.createElement(FormHelperText, null, t("fields.repoUrlPicker.repository.description"))
72
- ));
72
+ /* @__PURE__ */ jsx(FormHelperText, { children: t("fields.repoUrlPicker.repository.description") })
73
+ ]
74
+ }
75
+ ) });
73
76
  };
74
77
 
75
78
  export { RepoUrlPickerRepoName };
@@ -1 +1 @@
1
- {"version":3,"file":"RepoUrlPickerRepoName.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.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 { Select, SelectItem } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport TextField from '@material-ui/core/TextField';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport React, { useEffect } from 'react';\nimport { scaffolderTranslationRef } from '../../../translation';\nimport { AvailableRepositories } from './types';\n\nexport const RepoUrlPickerRepoName = (props: {\n repoName?: string;\n allowedRepos?: string[];\n onChange: (chosenRepo: AvailableRepositories) => void;\n rawErrors: string[];\n availableRepos?: AvailableRepositories[];\n isDisabled?: boolean;\n}) => {\n const {\n repoName,\n allowedRepos,\n onChange,\n rawErrors,\n availableRepos,\n isDisabled,\n } = props;\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n useEffect(() => {\n // If there is no repoName chosen currently\n if (!repoName) {\n // Set the first of the allowedRepos option if that available\n if (allowedRepos?.length) {\n onChange({ name: allowedRepos[0] });\n }\n }\n }, [allowedRepos, repoName, onChange]);\n\n const repoItems: SelectItem[] = allowedRepos\n ? allowedRepos.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !repoName}\n >\n {allowedRepos?.length ? (\n <Select\n native\n label={t('fields.repoUrlPicker.repository.title')}\n onChange={selected =>\n onChange({\n name: String(Array.isArray(selected) ? selected[0] : selected),\n })\n }\n disabled={isDisabled || allowedRepos.length === 1}\n selected={repoName}\n items={repoItems}\n />\n ) : (\n <Autocomplete\n value={repoName}\n onInputChange={(_, newValue) => {\n const selectedRepo = availableRepos?.find(\n r => r.name === newValue,\n );\n onChange(selectedRepo || { name: newValue || '' });\n }}\n options={(availableRepos || []).map(r => r.name)}\n renderInput={params => (\n <TextField\n {...params}\n label={t('fields.repoUrlPicker.repository.inputTitle')}\n required\n />\n )}\n freeSolo\n autoSelect\n disabled={isDisabled}\n />\n )}\n <FormHelperText>\n {t('fields.repoUrlPicker.repository.description')}\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAyBa,MAAA,qBAAA,GAAwB,CAAC,KAOhC,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,YAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,IAAI,CAAC,QAAU,EAAA;AAEb,MAAA,IAAI,cAAc,MAAQ,EAAA;AACxB,QAAA,QAAA,CAAS,EAAE,IAAA,EAAM,YAAa,CAAA,CAAC,GAAG,CAAA;AAAA;AACpC;AACF,GACC,EAAA,CAAC,YAAc,EAAA,QAAA,EAAU,QAAQ,CAAC,CAAA;AAErC,EAAA,MAAM,YAA0B,YAC5B,GAAA,YAAA,CAAa,IAAI,CAAM,CAAA,MAAA,EAAE,OAAO,CAAG,EAAA,KAAA,EAAO,CAAE,EAAA,CAAE,IAC9C,CAAC,EAAE,OAAO,YAA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AA,UAAC,SAAA;AAAA,UAAA;AAAA,YACE,GAAG,MAAA;AAAA,YACJ,KAAA,EAAO,EAAE,4CAA4C,CAAA;AAAA,YACrD,QAAQ,EAAA;AAAA;AAAA,SACV;AAAA,QAEF,QAAQ,EAAA,IAAA;AAAA,QACR,UAAU,EAAA,IAAA;AAAA,QACV,QAAU,EAAA;AAAA;AAAA,KACZ;AAAA,oBAED,KAAA,CAAA,aAAA,CAAA,cAAA,EAAA,IAAA,EACE,CAAE,CAAA,6CAA6C,CAClD;AAAA,GAEJ,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"RepoUrlPickerRepoName.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.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 { Select, SelectItem } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport TextField from '@material-ui/core/TextField';\nimport Autocomplete from '@material-ui/lab/Autocomplete';\nimport { useEffect } from 'react';\nimport { scaffolderTranslationRef } from '../../../translation';\nimport { AvailableRepositories } from './types';\n\nexport const RepoUrlPickerRepoName = (props: {\n repoName?: string;\n allowedRepos?: string[];\n onChange: (chosenRepo: AvailableRepositories) => void;\n rawErrors: string[];\n availableRepos?: AvailableRepositories[];\n isDisabled?: boolean;\n}) => {\n const {\n repoName,\n allowedRepos,\n onChange,\n rawErrors,\n availableRepos,\n isDisabled,\n } = props;\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n useEffect(() => {\n // If there is no repoName chosen currently\n if (!repoName) {\n // Set the first of the allowedRepos option if that available\n if (allowedRepos?.length) {\n onChange({ name: allowedRepos[0] });\n }\n }\n }, [allowedRepos, repoName, onChange]);\n\n const repoItems: SelectItem[] = allowedRepos\n ? allowedRepos.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !repoName}\n >\n {allowedRepos?.length ? (\n <Select\n native\n label={t('fields.repoUrlPicker.repository.title')}\n onChange={selected =>\n onChange({\n name: String(Array.isArray(selected) ? selected[0] : selected),\n })\n }\n disabled={isDisabled || allowedRepos.length === 1}\n selected={repoName}\n items={repoItems}\n />\n ) : (\n <Autocomplete\n value={repoName}\n onInputChange={(_, newValue) => {\n const selectedRepo = availableRepos?.find(\n r => r.name === newValue,\n );\n onChange(selectedRepo || { name: newValue || '' });\n }}\n options={(availableRepos || []).map(r => r.name)}\n renderInput={params => (\n <TextField\n {...params}\n label={t('fields.repoUrlPicker.repository.inputTitle')}\n required\n />\n )}\n freeSolo\n autoSelect\n disabled={isDisabled}\n />\n )}\n <FormHelperText>\n {t('fields.repoUrlPicker.repository.description')}\n </FormHelperText>\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAyBa,MAAA,qBAAA,GAAwB,CAAC,KAOhC,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,YAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,IAAI,CAAC,QAAU,EAAA;AAEb,MAAA,IAAI,cAAc,MAAQ,EAAA;AACxB,QAAA,QAAA,CAAS,EAA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KAAA;AAAA,eAClB;AACA,cAAA,QAAA,CAAS,YAAgB,IAAA,EAAE,IAAM,EAAA,QAAA,IAAY,IAAI,CAAA;AAAA,aACnD;AAAA,YACA,UAAU,cAAkB,IAAA,IAAI,GAAI,CAAA,CAAA,CAAA,KAAK,EAAE,IAAI,CAAA;AAAA,YAC/C,aAAa,CACX,MAAA,qBAAA,GAAA;AAAA,cAAC,SAAA;AAAA,cAAA;AAAA,gBACE,GAAG,MAAA;AAAA,gBACJ,KAAA,EAAO,EAAE,4CAA4C,CAAA;AAAA,gBACrD,QAAQ,EAAA;AAAA;AAAA,aACV;AAAA,YAEF,QAAQ,EAAA,IAAA;AAAA,YACR,UAAU,EAAA,IAAA;AAAA,YACV,QAAU,EAAA;AAAA;AAAA,SACZ;AAAA,wBAED,GAAA,CAAA,cAAA,EAAA,EACE,QAAE,EAAA,CAAA,CAAA,6CAA6C,CAClD,EAAA;AAAA;AAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ;;;;"}
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { ScaffolderField, SecretWidget } from '@backstage/plugin-scaffolder-react/alpha';
3
3
 
4
4
  const SecretInput = (props) => {
@@ -9,16 +9,16 @@ const SecretInput = (props) => {
9
9
  errors,
10
10
  required
11
11
  } = props;
12
- return /* @__PURE__ */ React.createElement(
12
+ return /* @__PURE__ */ jsx(
13
13
  ScaffolderField,
14
14
  {
15
15
  rawErrors,
16
16
  rawDescription: description,
17
17
  disabled,
18
18
  errors,
19
- required
20
- },
21
- /* @__PURE__ */ React.createElement(SecretWidget, { ...props })
19
+ required,
20
+ children: /* @__PURE__ */ jsx(SecretWidget, { ...props })
21
+ }
22
22
  );
23
23
  };
24
24
 
@@ -1 +1 @@
1
- {"version":3,"file":"SecretInput.esm.js","sources":["../../../../src/components/fields/SecretInput/SecretInput.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 from 'react';\nimport { ScaffolderRJSFFieldProps } from '@backstage/plugin-scaffolder-react';\nimport {\n ScaffolderField,\n SecretWidget,\n} from '@backstage/plugin-scaffolder-react/alpha';\n\nexport const SecretInput = (props: ScaffolderRJSFFieldProps) => {\n const {\n schema: { description },\n rawErrors,\n disabled,\n errors,\n required,\n } = props;\n\n return (\n <ScaffolderField\n rawErrors={rawErrors}\n rawDescription={description}\n disabled={disabled}\n errors={errors}\n required={required}\n >\n <SecretWidget {...props} />\n </ScaffolderField>\n );\n};\n"],"names":[],"mappings":";;;AAsBa,MAAA,WAAA,GAAc,CAAC,KAAoC,KAAA;AAC9D,EAAM,MAAA;AAAA,IACJ,MAAA,EAAQ,EAAE,WAAY,EAAA;AAAA,IACtB,SAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AAEJ,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,cAAgB,EAAA,WAAA;AAAA,MAChB,QAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KAAA;AAAA,oBAEA,KAAA,CAAA,aAAA,CAAC,YAAc,EAAA,EAAA,GAAG,KAAO,EAAA;AAAA,GAC3B;AAEJ;;;;"}
1
+ {"version":3,"file":"SecretInput.esm.js","sources":["../../../../src/components/fields/SecretInput/SecretInput.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 { ScaffolderRJSFFieldProps } from '@backstage/plugin-scaffolder-react';\nimport {\n ScaffolderField,\n SecretWidget,\n} from '@backstage/plugin-scaffolder-react/alpha';\n\nexport const SecretInput = (props: ScaffolderRJSFFieldProps) => {\n const {\n schema: { description },\n rawErrors,\n disabled,\n errors,\n required,\n } = props;\n\n return (\n <ScaffolderField\n rawErrors={rawErrors}\n rawDescription={description}\n disabled={disabled}\n errors={errors}\n required={required}\n >\n <SecretWidget {...props} />\n </ScaffolderField>\n );\n};\n"],"names":[],"mappings":";;;AAqBa,MAAA,WAAA,GAAc,CAAC,KAAoC,KAAA;AAC9D,EAAM,MAAA;AAAA,IACJ,MAAA,EAAQ,EAAE,WAAY,EAAA;AAAA,IACtB,SAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AAEJ,EACE,uBAAA,GAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,cAAgB,EAAA,WAAA;AAAA,MAChB,QAAA;AAAA,MACA,MAAA;AAAA,MACA,QAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,YAAc,EAAA,EAAA,GAAG,KAAO,EAAA;AAAA;AAAA,GAC3B;AAEJ;;;;"}
@@ -1,37 +1,40 @@
1
- import React from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { createContext, forwardRef, useContext, Children, cloneElement } from 'react';
2
3
  import { FixedSizeList } from 'react-window';
3
4
 
4
5
  const renderRow = (props) => {
5
6
  const { data, index, style } = props;
6
- return React.cloneElement(data[index], { style });
7
+ return cloneElement(data[index], { style });
7
8
  };
8
- const OuterElementContext = React.createContext({});
9
- const OuterElementType = React.forwardRef(
9
+ const OuterElementContext = createContext({});
10
+ const OuterElementType = forwardRef(
10
11
  (props, ref) => {
11
- const outerProps = React.useContext(OuterElementContext);
12
- return /* @__PURE__ */ React.createElement("div", { ref, ...props, ...outerProps });
12
+ const outerProps = useContext(OuterElementContext);
13
+ return /* @__PURE__ */ jsx("div", { ref, ...props, ...outerProps });
14
+ }
15
+ );
16
+ const VirtualizedListbox = forwardRef(
17
+ (props, ref) => {
18
+ const { children, ...other } = props;
19
+ const itemData = Children.toArray(children);
20
+ const itemCount = itemData.length;
21
+ const itemSize = 36;
22
+ const itemsToShow = Math.min(10, itemCount) + 0.5;
23
+ const height = itemsToShow * itemSize;
24
+ return /* @__PURE__ */ jsx("div", { ref, children: /* @__PURE__ */ jsx(OuterElementContext.Provider, { value: other, children: /* @__PURE__ */ jsx(
25
+ FixedSizeList,
26
+ {
27
+ height,
28
+ itemData,
29
+ itemCount,
30
+ itemSize,
31
+ outerElementType: OuterElementType,
32
+ width: "100%",
33
+ children: renderRow
34
+ }
35
+ ) }) });
13
36
  }
14
37
  );
15
- const VirtualizedListbox = React.forwardRef((props, ref) => {
16
- const { children, ...other } = props;
17
- const itemData = React.Children.toArray(children);
18
- const itemCount = itemData.length;
19
- const itemSize = 36;
20
- const itemsToShow = Math.min(10, itemCount) + 0.5;
21
- const height = itemsToShow * itemSize;
22
- return /* @__PURE__ */ React.createElement("div", { ref }, /* @__PURE__ */ React.createElement(OuterElementContext.Provider, { value: other }, /* @__PURE__ */ React.createElement(
23
- FixedSizeList,
24
- {
25
- height,
26
- itemData,
27
- itemCount,
28
- itemSize,
29
- outerElementType: OuterElementType,
30
- width: "100%"
31
- },
32
- renderRow
33
- )));
34
- });
35
38
 
36
39
  export { VirtualizedListbox };
37
40
  //# sourceMappingURL=VirtualizedListbox.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualizedListbox.esm.js","sources":["../../../src/components/fields/VirtualizedListbox.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 from 'react';\nimport { FixedSizeList, ListChildComponentProps } from 'react-window';\n\ntype HTMLDivProps = React.HTMLAttributes<HTMLDivElement>;\n\nconst renderRow = (props: ListChildComponentProps) => {\n const { data, index, style } = props;\n return React.cloneElement(data[index], { style });\n};\n\n// Context needed to keep Autocomplete working correctly : https://v4.mui.com/components/autocomplete/#Virtualize.tsx\nconst OuterElementContext = React.createContext<HTMLDivProps>({});\n\nconst OuterElementType = React.forwardRef<HTMLDivElement, HTMLDivProps>(\n (props, ref) => {\n const outerProps = React.useContext(OuterElementContext);\n return <div ref={ref} {...props} {...outerProps} />;\n },\n);\n\nexport const VirtualizedListbox = React.forwardRef<\n HTMLDivElement,\n HTMLDivProps\n>((props, ref) => {\n const { children, ...other } = props;\n const itemData = React.Children.toArray(children);\n const itemCount = itemData.length;\n\n const itemSize = 36;\n\n const itemsToShow = Math.min(10, itemCount) + 0.5;\n const height = itemsToShow * itemSize;\n\n return (\n <div ref={ref}>\n <OuterElementContext.Provider value={other}>\n <FixedSizeList\n height={height}\n itemData={itemData}\n itemCount={itemCount}\n itemSize={itemSize}\n outerElementType={OuterElementType}\n width=\"100%\"\n >\n {renderRow}\n </FixedSizeList>\n </OuterElementContext.Provider>\n </div>\n );\n});\n"],"names":[],"mappings":";;;AAqBA,MAAM,SAAA,GAAY,CAAC,KAAmC,KAAA;AACpD,EAAA,MAAM,EAAE,IAAA,EAAM,KAAO,EAAA,KAAA,EAAU,GAAA,KAAA;AAC/B,EAAA,OAAO,MAAM,YAAa,CAAA,IAAA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js","sources":["../../../src/components/fields/VirtualizedListbox.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 {\n HTMLAttributes,\n cloneElement,\n createContext,\n forwardRef,\n useContext,\n Children,\n} from 'react';\nimport { FixedSizeList, ListChildComponentProps } from 'react-window';\n\ntype HTMLDivProps = HTMLAttributes<HTMLDivElement>;\n\nconst renderRow = (props: ListChildComponentProps) => {\n const { data, index, style } = props;\n return cloneElement(data[index], { style });\n};\n\n// Context needed to keep Autocomplete working correctly : https://v4.mui.com/components/autocomplete/#Virtualize.tsx\nconst OuterElementContext = createContext<HTMLDivProps>({});\n\nconst OuterElementType = forwardRef<HTMLDivElement, HTMLDivProps>(\n (props, ref) => {\n const outerProps = useContext(OuterElementContext);\n return <div ref={ref} {...props} {...outerProps} />;\n },\n);\n\nexport const VirtualizedListbox = forwardRef<HTMLDivElement, HTMLDivProps>(\n (props, ref) => {\n const { children, ...other } = props;\n const itemData = Children.toArray(children);\n const itemCount = itemData.length;\n\n const itemSize = 36;\n\n const itemsToShow = Math.min(10, itemCount) + 0.5;\n const height = itemsToShow * itemSize;\n\n return (\n <div ref={ref}>\n <OuterElementContext.Provider value={other}>\n <FixedSizeList\n height={height}\n itemData={itemData}\n itemCount={itemCount}\n itemSize={itemSize}\n outerElementType={OuterElementType}\n width=\"100%\"\n >\n {renderRow}\n </FixedSizeList>\n </OuterElementContext.Provider>\n </div>\n );\n },\n);\n"],"names":[],"mappings":";;;;AA4BA,MAAM,SAAA,GAAY,CAAC,KAAmC,KAAA;AACpD,EAAA,MAAM,EAAE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