@backstage/plugin-scaffolder 1.36.3-next.0 → 1.37.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/dist/alpha/api/FormDecoratorsApi.esm.js.map +1 -1
- package/dist/alpha/api/ref.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/CustomFieldExplorer.esm.js +4 -4
- package/dist/alpha/components/TemplateEditorPage/CustomFieldExplorer.esm.js.map +1 -1
- package/dist/alpha/components/TemplateEditorPage/CustomFieldPlayground.esm.js +5 -5
- package/dist/alpha/components/TemplateEditorPage/CustomFieldPlayground.esm.js.map +1 -1
- package/dist/alpha/components/TemplateListPage/TemplateListPage.esm.js +14 -14
- package/dist/alpha/components/TemplateListPage/TemplateListPage.esm.js.map +1 -1
- package/dist/alpha/components/TemplatesSubPage.esm.js +20 -10
- package/dist/alpha/components/TemplatesSubPage.esm.js.map +1 -1
- package/dist/alpha/extensions.esm.js +28 -2
- package/dist/alpha/extensions.esm.js.map +1 -1
- package/dist/alpha/hooks/useFormDecorators.esm.js +34 -3
- package/dist/alpha/hooks/useFormDecorators.esm.js.map +1 -1
- package/dist/alpha/lib/createGroupsWithOther.esm.js +13 -0
- package/dist/alpha/lib/createGroupsWithOther.esm.js.map +1 -0
- package/dist/alpha.d.ts +14 -4
- package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js +4 -4
- package/dist/components/TemplateTypePicker/TemplateTypePicker.esm.js.map +1 -1
- package/dist/components/TemplatingExtensionsPage/TemplatingExtensionsPage.esm.js +4 -4
- package/dist/components/TemplatingExtensionsPage/TemplatingExtensionsPage.esm.js.map +1 -1
- package/dist/components/fields/Autocomplete/Autocomplete.esm.js +23 -0
- package/dist/components/fields/Autocomplete/Autocomplete.esm.js.map +1 -0
- package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js +23 -2
- package/dist/components/fields/EntityNamePicker/EntityNamePicker.esm.js.map +1 -1
- package/dist/components/fields/EntityPicker/EntityPicker.esm.js +125 -9
- package/dist/components/fields/EntityPicker/EntityPicker.esm.js.map +1 -1
- package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js +106 -7
- package/dist/components/fields/EntityTagsPicker/EntityTagsPicker.esm.js.map +1 -1
- package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js +128 -10
- package/dist/components/fields/MultiEntityPicker/MultiEntityPicker.esm.js.map +1 -1
- package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js +66 -6
- package/dist/components/fields/MyGroupsPicker/MyGroupsPicker.esm.js.map +1 -1
- package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js +29 -6
- package/dist/components/fields/OwnedEntityPicker/OwnedEntityPicker.esm.js.map +1 -1
- package/dist/components/fields/OwnedEntityPicker/schema.esm.js +1 -0
- package/dist/components/fields/OwnedEntityPicker/schema.esm.js.map +1 -1
- package/dist/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.esm.js +29 -5
- package/dist/components/fields/RepoBranchPicker/BitbucketRepoBranchPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js +20 -3
- package/dist/components/fields/RepoBranchPicker/DefaultRepoBranchPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoBranchPicker/GitHubRepoBranchPicker.esm.js +29 -5
- package/dist/components/fields/RepoBranchPicker/GitHubRepoBranchPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoBranchPicker/RepoBranchPicker.esm.js +18 -6
- package/dist/components/fields/RepoBranchPicker/RepoBranchPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoOwnerPicker/DefaultRepoOwnerPicker.esm.js +20 -3
- package/dist/components/fields/RepoOwnerPicker/DefaultRepoOwnerPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoOwnerPicker/GitHubRepoOwnerPicker.esm.js +29 -5
- package/dist/components/fields/RepoOwnerPicker/GitHubRepoOwnerPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoOwnerPicker/RepoOwnerPicker.esm.js +28 -31
- package/dist/components/fields/RepoOwnerPicker/RepoOwnerPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js +86 -4
- package/dist/components/fields/RepoUrlPicker/AzureRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js +107 -11
- package/dist/components/fields/RepoUrlPicker/BitbucketRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js +33 -3
- package/dist/components/fields/RepoUrlPicker/GerritRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js +42 -5
- package/dist/components/fields/RepoUrlPicker/GiteaRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js +52 -7
- package/dist/components/fields/RepoUrlPicker/GithubRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js +60 -16
- package/dist/components/fields/RepoUrlPicker/GitlabRepoPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js +23 -9
- package/dist/components/fields/RepoUrlPicker/RepoUrlPicker.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js +27 -3
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerHost.esm.js.map +1 -1
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js +60 -6
- package/dist/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.esm.js.map +1 -1
- package/dist/components/fields/SecretInput/SecretInput.esm.js +57 -2
- package/dist/components/fields/SecretInput/SecretInput.esm.js.map +1 -1
- package/dist/components/fields/buiChipStyles.esm.js +25 -0
- package/dist/components/fields/buiChipStyles.esm.js.map +1 -0
- package/dist/components/fields/scaffolderFieldOverrides.module.css.esm.js +8 -0
- package/dist/components/fields/scaffolderFieldOverrides.module.css.esm.js.map +1 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js +29 -0
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js.map +1 -0
- package/dist/plugins/scaffolder/package.json.esm.js +4 -2
- package/dist/plugins/scaffolder/package.json.esm.js.map +1 -1
- package/package.json +18 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubRepoBranchPicker.esm.js","sources":["../../../../src/components/fields/RepoBranchPicker/GitHubRepoBranchPicker.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 { useApi } from '@backstage/core-plugin-api';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport
|
|
1
|
+
{"version":3,"file":"GitHubRepoBranchPicker.esm.js","sources":["../../../../src/components/fields/RepoBranchPicker/GitHubRepoBranchPicker.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 { useApi } from '@backstage/core-plugin-api';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport MuiTextField from '@material-ui/core/TextField';\nimport MuiAutocomplete from '@material-ui/lab/Autocomplete';\nimport { useCallback, useState } from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\nimport { BaseRepoBranchPickerProps } from './types';\nimport { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';\nimport { Autocomplete as BuiAutocomplete } from '../Autocomplete';\nimport type { Key } from 'react-aria-components';\n\n/**\n * The underlying component that is rendered in the form for the `GitHubRepoBranchPicker`\n * field extension.\n *\n * @public\n *\n */\nexport const GitHubRepoBranchPicker = ({\n onChange,\n state,\n rawErrors,\n accessToken,\n isDisabled,\n required,\n}: BaseRepoBranchPickerProps<{\n accessToken?: string;\n}>) => {\n const theme = useScaffolderTheme();\n const { host, owner, repository, branch } = state;\n\n const [availableBranches, setAvailableBranches] = useState<string[]>([]);\n\n const scaffolderApi = useApi(scaffolderApiRef);\n\n const updateAvailableBranches = useCallback(() => {\n if (\n !scaffolderApi.autocomplete ||\n !owner ||\n !repository ||\n !accessToken ||\n !host\n ) {\n setAvailableBranches([]);\n return;\n }\n\n scaffolderApi\n .autocomplete({\n token: accessToken,\n resource: 'branches',\n context: { host, owner, repository },\n provider: 'github',\n })\n .then(({ results }) => {\n setAvailableBranches(results.map(r => r.id));\n })\n .catch(() => {\n setAvailableBranches([]);\n });\n }, [host, owner, repository, accessToken, scaffolderApi]);\n\n useDebounce(updateAvailableBranches, 500, [updateAvailableBranches]);\n\n if (theme === 'bui') {\n const options = availableBranches.map(b => ({ label: b, value: b }));\n\n return (\n <BuiAutocomplete\n label=\"Branch\"\n description=\"The branch of the repository\"\n inputValue={branch ?? ''}\n onInputChange={value => onChange({ branch: value })}\n onSelectionChange={(key: Key | null) => {\n if (key !== null) {\n onChange({ branch: String(key) });\n }\n }}\n options={options}\n isDisabled={isDisabled}\n isRequired={required}\n isInvalid={rawErrors?.length > 0 && !branch}\n />\n );\n }\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !branch}\n >\n <MuiAutocomplete\n value={branch}\n onChange={(_, newValue) => {\n onChange({ branch: newValue || '' });\n }}\n disabled={isDisabled}\n options={availableBranches}\n renderInput={params => (\n <MuiTextField\n {...params}\n label=\"Branch\"\n disabled={isDisabled}\n required={required}\n />\n )}\n freeSolo\n autoSelect\n />\n <FormHelperText>The branch of the repository</FormHelperText>\n </FormControl>\n );\n};\n"],"names":["BuiAutocomplete"],"mappings":";;;;;;;;;;;;AAoCO,MAAM,yBAAyB,CAAC;AAAA,EACrC,QAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,KAEO;AACL,EAAA,MAAM,QAAQ,kBAAA,EAAmB;AACjC,EAAA,MAAM,EAAE,IAAA,EAAM,KAAA,EAAO,UAAA,EAAY,QAAO,GAAI,KAAA;AAE5C,EAAA,MAAM,CAAC,iBAAA,EAAmB,oBAAoB,CAAA,GAAI,QAAA,CAAmB,EAAE,CAAA;AAEvE,EAAA,MAAM,aAAA,GAAgB,OAAO,gBAAgB,CAAA;AAE7C,EAAA,MAAM,uBAAA,GAA0B,YAAY,MAAM;AAChD,IAAA,IACE,CAAC,aAAA,CAAc,YAAA,IACf,CAAC,KAAA,IACD,CAAC,UAAA,IACD,CAAC,WAAA,IACD,CAAC,IAAA,EACD;AACA,MAAA,oBAAA,CAAqB,EAAE,CAAA;AACvB,MAAA;AAAA,IACF;AAEA,IAAA,aAAA,CACG,YAAA,CAAa;AAAA,MACZ,KAAA,EAAO,WAAA;AAAA,MACP,QAAA,EAAU,UAAA;AAAA,MACV,OAAA,EAAS,EAAE,IAAA,EAAM,KAAA,EAAO,UAAA,EAAW;AAAA,MACnC,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AA,IAAA;AAAA,MACC,MAAA,EAAO,QAAA;AAAA,MACP,QAAA;AAAA,MACA,KAAA,EAAO,SAAA,EAAW,MAAA,GAAS,CAAA,IAAK,CAAC,MAAA;AAAA,MAEjC,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,eAAA;AAAA,UAAA;AAAA,YACC,KAAA,EAAO,MAAA;AAAA,YACP,QAAA,EAAU,CAAC,CAAA,EAAG,QAAA,KAAa;AACzB,cAAA,QAAA,CAAS,EAAE,MAAA,EAAQ,QAAA,IAAY,EAAA,EAAI,CAAA;AAAA,YACrC,CAAA;AAAA,YACA,QAAA,EAAU,UAAA;AAAA,YACV,OAAA,EAAS,iBAAA;AAAA,YACT,aAAa,CAAA,MAAA,qBACX,GAAA;AAAA,cAAC,YAAA;AAAA,cAAA;AAAA,gBACE,GAAG,MAAA;AAAA,gBACJ,KAAA,EAAM,QAAA;AAAA,gBACN,QAAA,EAAU,UAAA;AAAA,gBACV;AAAA;AAAA,aACF;AAAA,YAEF,QAAA,EAAQ,IAAA;AAAA,YACR,UAAA,EAAU;AAAA;AAAA,SACZ;AAAA,wBACA,GAAA,CAAC,kBAAe,QAAA,EAAA,8BAAA,EAA4B;AAAA;AAAA;AAAA,GAC9C;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs,
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useApi } from '@backstage/core-plugin-api';
|
|
3
3
|
import { scmIntegrationsApiRef, scmAuthApiRef } from '@backstage/integration-react';
|
|
4
4
|
import { useState, useEffect, useCallback } from 'react';
|
|
@@ -11,8 +11,11 @@ import { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker.esm.js';
|
|
|
11
11
|
import { DefaultRepoBranchPicker } from './DefaultRepoBranchPicker.esm.js';
|
|
12
12
|
import { GitHubRepoBranchPicker } from './GitHubRepoBranchPicker.esm.js';
|
|
13
13
|
import { MarkdownContent } from '@backstage/core-components';
|
|
14
|
+
import { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';
|
|
15
|
+
import { Flex, Text } from '@backstage/ui';
|
|
14
16
|
|
|
15
17
|
const RepoBranchPicker = (props) => {
|
|
18
|
+
const scaffolderTheme = useScaffolderTheme();
|
|
16
19
|
const {
|
|
17
20
|
uiSchema,
|
|
18
21
|
onChange,
|
|
@@ -75,6 +78,8 @@ const RepoBranchPicker = (props) => {
|
|
|
75
78
|
[setState]
|
|
76
79
|
);
|
|
77
80
|
const hostType = (host && integrationApi.byHost(host)?.type) ?? null;
|
|
81
|
+
const accessToken = uiSchema?.["ui:options"]?.requestUserCredentials?.secretsKey && secrets[uiSchema["ui:options"].requestUserCredentials.secretsKey];
|
|
82
|
+
const isDisabled = uiSchema?.["ui:disabled"] ?? false;
|
|
78
83
|
const renderRepoBranchPicker = () => {
|
|
79
84
|
switch (hostType) {
|
|
80
85
|
case "bitbucket":
|
|
@@ -84,8 +89,8 @@ const RepoBranchPicker = (props) => {
|
|
|
84
89
|
onChange: updateLocalState,
|
|
85
90
|
state,
|
|
86
91
|
rawErrors,
|
|
87
|
-
accessToken
|
|
88
|
-
isDisabled
|
|
92
|
+
accessToken,
|
|
93
|
+
isDisabled,
|
|
89
94
|
required
|
|
90
95
|
}
|
|
91
96
|
);
|
|
@@ -96,8 +101,8 @@ const RepoBranchPicker = (props) => {
|
|
|
96
101
|
onChange: updateLocalState,
|
|
97
102
|
state,
|
|
98
103
|
rawErrors,
|
|
99
|
-
accessToken
|
|
100
|
-
isDisabled
|
|
104
|
+
accessToken,
|
|
105
|
+
isDisabled,
|
|
101
106
|
required
|
|
102
107
|
}
|
|
103
108
|
);
|
|
@@ -108,13 +113,20 @@ const RepoBranchPicker = (props) => {
|
|
|
108
113
|
onChange: updateLocalState,
|
|
109
114
|
state,
|
|
110
115
|
rawErrors,
|
|
111
|
-
isDisabled
|
|
116
|
+
isDisabled,
|
|
112
117
|
required
|
|
113
118
|
}
|
|
114
119
|
);
|
|
115
120
|
}
|
|
116
121
|
};
|
|
117
122
|
const description = uiSchema["ui:description"] ?? schema.description;
|
|
123
|
+
if (scaffolderTheme === "bui") {
|
|
124
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", children: [
|
|
125
|
+
schema.title && /* @__PURE__ */ jsx(Text, { as: "h5", variant: "title-small", weight: "bold", children: schema.title }),
|
|
126
|
+
description && /* @__PURE__ */ jsx(MarkdownContent, { content: description }),
|
|
127
|
+
renderRepoBranchPicker()
|
|
128
|
+
] });
|
|
129
|
+
}
|
|
118
130
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
119
131
|
schema.title && /* @__PURE__ */ jsxs(Box, { my: 1, children: [
|
|
120
132
|
/* @__PURE__ */ jsx(Typography, { variant: "h5", children: schema.title }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepoBranchPicker.esm.js","sources":["../../../../src/components/fields/RepoBranchPicker/RepoBranchPicker.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 { useApi } from '@backstage/core-plugin-api';\nimport {\n scmIntegrationsApiRef,\n scmAuthApiRef,\n} from '@backstage/integration-react';\nimport { useEffect, useState, useCallback } from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\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';\n\nimport { RepoBranchPickerProps } from './schema';\nimport { RepoBranchPickerState } from './types';\nimport { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker';\nimport { DefaultRepoBranchPicker } from './DefaultRepoBranchPicker';\nimport { GitHubRepoBranchPicker } from './GitHubRepoBranchPicker';\nimport { MarkdownContent } from '@backstage/core-components';\n\n/**\n * The underlying component that is rendered in the form for the `RepoBranchPicker`\n * field extension.\n *\n * @public\n */\nexport const RepoBranchPicker = (props: RepoBranchPickerProps) => {\n const {\n uiSchema,\n onChange,\n rawErrors,\n formData,\n schema,\n formContext,\n required,\n } = props;\n const {\n formData: { repoUrl },\n } = formContext;\n\n const [state, setState] = useState<RepoBranchPickerState>({\n branch: formData || '',\n });\n const { host, branch } = state;\n\n const integrationApi = useApi(scmIntegrationsApiRef);\n const scmAuthApi = useApi(scmAuthApiRef);\n\n const { secrets, setSecrets } = useTemplateSecrets();\n\n useDebounce(\n async () => {\n const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {};\n\n if (!requestUserCredentials || !host) {\n return;\n }\n\n // don't show login prompt if secret value is already in state\n if (secrets[requestUserCredentials.secretsKey]) {\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://${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 },\n 500,\n [host, uiSchema],\n );\n\n useEffect(() => {\n if (repoUrl) {\n const url = new URL(`https://${repoUrl}`);\n\n setState(prevState => ({\n ...prevState,\n host: url.host,\n workspace: url.searchParams.get('workspace') || '',\n repository: url.searchParams.get('repo') || '',\n owner: url.searchParams.get('owner') || '',\n }));\n }\n }, [repoUrl]);\n\n useEffect(() => {\n onChange(branch);\n }, [branch, onChange]);\n\n const updateLocalState = useCallback(\n (newState: RepoBranchPickerState) => {\n setState(prevState => ({ ...prevState, ...newState }));\n },\n [setState],\n );\n\n const hostType = (host && integrationApi.byHost(host)?.type) ?? null;\n\n const renderRepoBranchPicker = () => {\n switch (hostType) {\n case 'bitbucket':\n return (\n <BitbucketRepoBranchPicker\n onChange={updateLocalState}\n state={state}\n rawErrors={rawErrors}\n accessToken={
|
|
1
|
+
{"version":3,"file":"RepoBranchPicker.esm.js","sources":["../../../../src/components/fields/RepoBranchPicker/RepoBranchPicker.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 { useApi } from '@backstage/core-plugin-api';\nimport {\n scmIntegrationsApiRef,\n scmAuthApiRef,\n} from '@backstage/integration-react';\nimport { useEffect, useState, useCallback } from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\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';\n\nimport { RepoBranchPickerProps } from './schema';\nimport { RepoBranchPickerState } from './types';\nimport { BitbucketRepoBranchPicker } from './BitbucketRepoBranchPicker';\nimport { DefaultRepoBranchPicker } from './DefaultRepoBranchPicker';\nimport { GitHubRepoBranchPicker } from './GitHubRepoBranchPicker';\nimport { MarkdownContent } from '@backstage/core-components';\nimport { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';\nimport { Flex, Text } from '@backstage/ui';\n\n/**\n * The underlying component that is rendered in the form for the `RepoBranchPicker`\n * field extension.\n *\n * @public\n */\nexport const RepoBranchPicker = (props: RepoBranchPickerProps) => {\n const scaffolderTheme = useScaffolderTheme();\n const {\n uiSchema,\n onChange,\n rawErrors,\n formData,\n schema,\n formContext,\n required,\n } = props;\n const {\n formData: { repoUrl },\n } = formContext;\n\n const [state, setState] = useState<RepoBranchPickerState>({\n branch: formData || '',\n });\n const { host, branch } = state;\n\n const integrationApi = useApi(scmIntegrationsApiRef);\n const scmAuthApi = useApi(scmAuthApiRef);\n\n const { secrets, setSecrets } = useTemplateSecrets();\n\n useDebounce(\n async () => {\n const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {};\n\n if (!requestUserCredentials || !host) {\n return;\n }\n\n // don't show login prompt if secret value is already in state\n if (secrets[requestUserCredentials.secretsKey]) {\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://${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 },\n 500,\n [host, uiSchema],\n );\n\n useEffect(() => {\n if (repoUrl) {\n const url = new URL(`https://${repoUrl}`);\n\n setState(prevState => ({\n ...prevState,\n host: url.host,\n workspace: url.searchParams.get('workspace') || '',\n repository: url.searchParams.get('repo') || '',\n owner: url.searchParams.get('owner') || '',\n }));\n }\n }, [repoUrl]);\n\n useEffect(() => {\n onChange(branch);\n }, [branch, onChange]);\n\n const updateLocalState = useCallback(\n (newState: RepoBranchPickerState) => {\n setState(prevState => ({ ...prevState, ...newState }));\n },\n [setState],\n );\n\n const hostType = (host && integrationApi.byHost(host)?.type) ?? null;\n\n const accessToken =\n uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&\n secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey];\n const isDisabled = uiSchema?.['ui:disabled'] ?? false;\n\n const renderRepoBranchPicker = () => {\n switch (hostType) {\n case 'bitbucket':\n return (\n <BitbucketRepoBranchPicker\n onChange={updateLocalState}\n state={state}\n rawErrors={rawErrors}\n accessToken={accessToken}\n isDisabled={isDisabled}\n required={required}\n />\n );\n case 'github':\n return (\n <GitHubRepoBranchPicker\n onChange={updateLocalState}\n state={state}\n rawErrors={rawErrors}\n accessToken={accessToken}\n isDisabled={isDisabled}\n required={required}\n />\n );\n default:\n return (\n <DefaultRepoBranchPicker\n onChange={updateLocalState}\n state={state}\n rawErrors={rawErrors}\n isDisabled={isDisabled}\n required={required}\n />\n );\n }\n };\n\n const description = uiSchema['ui:description'] ?? schema.description;\n\n if (scaffolderTheme === 'bui') {\n return (\n <Flex direction=\"column\" gap=\"4\">\n {schema.title && (\n <Text as=\"h5\" variant=\"title-small\" weight=\"bold\">\n {schema.title}\n </Text>\n )}\n {description && <MarkdownContent content={description} />}\n {renderRepoBranchPicker()}\n </Flex>\n );\n }\n\n return (\n <>\n {schema.title && (\n <Box my={1}>\n <Typography variant=\"h5\">{schema.title}</Typography>\n <Divider />\n </Box>\n )}\n {description && (\n <Typography variant=\"body1\">\n <MarkdownContent content={description} />\n </Typography>\n )}\n {renderRepoBranchPicker()}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA2CO,MAAM,gBAAA,GAAmB,CAAC,KAAA,KAAiC;AAChE,EAAA,MAAM,kBAAkB,kBAAA,EAAmB;AAC3C,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AACJ,EAAA,MAAM;AAAA,IACJ,QAAA,EAAU,EAAE,OAAA;AAAQ,GACtB,GAAI,WAAA;AAEJ,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAA,CAAgC;AAAA,IACxD,QAAQ,QAAA,IAAY;AAAA,GACrB,CAAA;AACD,EAAA,MAAM,EAAE,IAA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CAAC,eAAA,EAAA,EAAgB,OAAA,EAAS,WAAA,EAAa,CAAA,EACzC,CAAA;AAAA,IAED,sBAAA;AAAuB,GAAA,EAC1B,CAAA;AAEJ;;;;"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import FormControl from '@material-ui/core/FormControl';
|
|
3
3
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
|
4
|
-
import
|
|
4
|
+
import MuiTextField from '@material-ui/core/TextField';
|
|
5
5
|
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
6
6
|
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
7
|
+
import { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';
|
|
8
|
+
import { TextField } from '@backstage/ui';
|
|
7
9
|
|
|
8
10
|
const DefaultRepoOwnerPicker = ({
|
|
9
11
|
onChange,
|
|
@@ -13,8 +15,23 @@ const DefaultRepoOwnerPicker = ({
|
|
|
13
15
|
required,
|
|
14
16
|
schema
|
|
15
17
|
}) => {
|
|
18
|
+
const theme = useScaffolderTheme();
|
|
16
19
|
const { owner } = state;
|
|
17
20
|
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
21
|
+
if (theme === "bui") {
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
TextField,
|
|
24
|
+
{
|
|
25
|
+
label: schema?.title ?? t("fields.repoOwnerPicker.title"),
|
|
26
|
+
description: schema?.description ?? t("fields.repoOwnerPicker.description"),
|
|
27
|
+
isDisabled,
|
|
28
|
+
onChange: (value) => onChange({ owner: value }),
|
|
29
|
+
value: owner ?? "",
|
|
30
|
+
isInvalid: rawErrors?.length > 0 && !owner,
|
|
31
|
+
isRequired: required
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
18
35
|
return /* @__PURE__ */ jsxs(
|
|
19
36
|
FormControl,
|
|
20
37
|
{
|
|
@@ -23,7 +40,7 @@ const DefaultRepoOwnerPicker = ({
|
|
|
23
40
|
error: rawErrors?.length > 0 && !owner,
|
|
24
41
|
children: [
|
|
25
42
|
/* @__PURE__ */ jsx(
|
|
26
|
-
|
|
43
|
+
MuiTextField,
|
|
27
44
|
{
|
|
28
45
|
id: "ownerInput",
|
|
29
46
|
label: schema?.title ?? t("fields.repoOwnerPicker.title"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultRepoOwnerPicker.esm.js","sources":["../../../../src/components/fields/RepoOwnerPicker/DefaultRepoOwnerPicker.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport
|
|
1
|
+
{"version":3,"file":"DefaultRepoOwnerPicker.esm.js","sources":["../../../../src/components/fields/RepoOwnerPicker/DefaultRepoOwnerPicker.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport MuiTextField from '@material-ui/core/TextField';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\nimport { BaseRepoOwnerPickerProps } from './types';\nimport { scaffolderTranslationRef } from '../../../translation';\nimport { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';\nimport { TextField as BuiTextField } from '@backstage/ui';\n\n/**\n * The underlying component that is rendered in the form for the `DefaultRepoOwnerPicker`\n * field extension.\n *\n * @public\n *\n */\nexport const DefaultRepoOwnerPicker = ({\n onChange,\n state,\n rawErrors,\n isDisabled,\n required,\n schema,\n}: BaseRepoOwnerPickerProps) => {\n const theme = useScaffolderTheme();\n const { owner } = state;\n\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n if (theme === 'bui') {\n return (\n <BuiTextField\n label={schema?.title ?? t('fields.repoOwnerPicker.title')}\n description={\n schema?.description ?? t('fields.repoOwnerPicker.description')\n }\n isDisabled={isDisabled}\n onChange={value => onChange({ owner: value })}\n value={owner ?? ''}\n isInvalid={rawErrors?.length > 0 && !owner}\n isRequired={required}\n />\n );\n }\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !owner}\n >\n <MuiTextField\n id=\"ownerInput\"\n label={schema?.title ?? t('fields.repoOwnerPicker.title')}\n disabled={isDisabled}\n onChange={e => onChange({ owner: e.target.value })}\n value={owner}\n />\n <FormHelperText>\n {schema?.description ?? t('fields.repoOwnerPicker.description')}\n </FormHelperText>\n </FormControl>\n );\n};\n"],"names":["BuiTextField"],"mappings":";;;;;;;;;AAiCO,MAAM,yBAAyB,CAAC;AAAA,EACrC,QAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,KAAgC;AAC9B,EAAA,MAAM,QAAQ,kBAAA,EAAmB;AACjC,EAAA,MAAM,EAAE,OAAM,GAAI,KAAA;AAElB,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,IAAI,UAAU,K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-plugin-api';
|
|
3
3
|
import { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';
|
|
4
4
|
import FormControl from '@material-ui/core/FormControl';
|
|
5
5
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import MuiTextField from '@material-ui/core/TextField';
|
|
7
|
+
import MuiAutocomplete from '@material-ui/lab/Autocomplete';
|
|
8
8
|
import { useState, useCallback } from 'react';
|
|
9
9
|
import useDebounce from 'react-use/esm/useDebounce';
|
|
10
10
|
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
11
11
|
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
12
|
+
import { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';
|
|
13
|
+
import { Autocomplete } from '../Autocomplete/Autocomplete.esm.js';
|
|
12
14
|
|
|
13
15
|
const GitHubRepoOwnerPicker = ({
|
|
14
16
|
onChange,
|
|
@@ -20,6 +22,7 @@ const GitHubRepoOwnerPicker = ({
|
|
|
20
22
|
schema,
|
|
21
23
|
excludedOwners = []
|
|
22
24
|
}) => {
|
|
25
|
+
const theme = useScaffolderTheme();
|
|
23
26
|
const { host, owner } = state;
|
|
24
27
|
const [availableOwners, setAvailableOwners] = useState([]);
|
|
25
28
|
const scaffolderApi = useApi(scaffolderApiRef);
|
|
@@ -42,6 +45,27 @@ const GitHubRepoOwnerPicker = ({
|
|
|
42
45
|
});
|
|
43
46
|
}, [host, accessToken, scaffolderApi, excludedOwners]);
|
|
44
47
|
useDebounce(updateAvailableOwners, 500, [updateAvailableOwners]);
|
|
48
|
+
if (theme === "bui") {
|
|
49
|
+
const options = availableOwners.map((o) => ({ label: o, value: o }));
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
|
+
Autocomplete,
|
|
52
|
+
{
|
|
53
|
+
label: schema?.title ?? t("fields.repoOwnerPicker.title"),
|
|
54
|
+
description: schema?.description ?? t("fields.repoOwnerPicker.description"),
|
|
55
|
+
inputValue: owner ?? "",
|
|
56
|
+
onInputChange: (value) => onChange({ owner: value }),
|
|
57
|
+
onSelectionChange: (key) => {
|
|
58
|
+
if (key !== null) {
|
|
59
|
+
onChange({ owner: String(key) });
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
options,
|
|
63
|
+
isDisabled,
|
|
64
|
+
isRequired: required,
|
|
65
|
+
isInvalid: rawErrors?.length > 0 && !owner
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
45
69
|
return /* @__PURE__ */ jsxs(
|
|
46
70
|
FormControl,
|
|
47
71
|
{
|
|
@@ -50,7 +74,7 @@ const GitHubRepoOwnerPicker = ({
|
|
|
50
74
|
error: rawErrors?.length > 0 && !owner,
|
|
51
75
|
children: [
|
|
52
76
|
/* @__PURE__ */ jsx(
|
|
53
|
-
|
|
77
|
+
MuiAutocomplete,
|
|
54
78
|
{
|
|
55
79
|
value: owner,
|
|
56
80
|
onChange: (_, newValue) => {
|
|
@@ -59,7 +83,7 @@ const GitHubRepoOwnerPicker = ({
|
|
|
59
83
|
disabled: isDisabled,
|
|
60
84
|
options: availableOwners,
|
|
61
85
|
renderInput: (params) => /* @__PURE__ */ jsx(
|
|
62
|
-
|
|
86
|
+
MuiTextField,
|
|
63
87
|
{
|
|
64
88
|
...params,
|
|
65
89
|
label: schema?.title ?? t("fields.repoOwnerPicker.title"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitHubRepoOwnerPicker.esm.js","sources":["../../../../src/components/fields/RepoOwnerPicker/GitHubRepoOwnerPicker.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 { useApi } from '@backstage/core-plugin-api';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport
|
|
1
|
+
{"version":3,"file":"GitHubRepoOwnerPicker.esm.js","sources":["../../../../src/components/fields/RepoOwnerPicker/GitHubRepoOwnerPicker.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 { useApi } from '@backstage/core-plugin-api';\nimport { scaffolderApiRef } from '@backstage/plugin-scaffolder-react';\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport MuiTextField from '@material-ui/core/TextField';\nimport MuiAutocomplete from '@material-ui/lab/Autocomplete';\nimport { useCallback, useState } from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\n\nimport { BaseRepoOwnerPickerProps } from './types';\nimport { scaffolderTranslationRef } from '../../../translation';\nimport { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';\nimport { Autocomplete as BuiAutocomplete } from '../Autocomplete';\nimport type { Key } from 'react-aria-components';\n\n/**\n * The underlying component that is rendered in the form for the `GitHubRepoOwnerPicker`\n * field extension.\n *\n * @public\n *\n */\nexport const GitHubRepoOwnerPicker = ({\n onChange,\n state,\n rawErrors,\n accessToken,\n isDisabled,\n required,\n schema,\n excludedOwners = [],\n}: BaseRepoOwnerPickerProps<{\n accessToken?: string;\n excludedOwners?: string[];\n}>) => {\n const theme = useScaffolderTheme();\n const { host, owner } = state;\n\n const [availableOwners, setAvailableOwners] = useState<string[]>([]);\n\n const scaffolderApi = useApi(scaffolderApiRef);\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const updateAvailableOwners = useCallback(() => {\n if (!scaffolderApi.autocomplete || !accessToken || !host) {\n setAvailableOwners([]);\n return;\n }\n\n scaffolderApi\n .autocomplete({\n token: accessToken,\n resource: 'owners',\n context: { host },\n provider: 'github',\n })\n .then(({ results }) => {\n const owners = results\n .map(r => r.id)\n .filter(id => !excludedOwners.includes(id));\n\n setAvailableOwners(owners);\n })\n .catch(() => {\n setAvailableOwners([]);\n });\n }, [host, accessToken, scaffolderApi, excludedOwners]);\n\n useDebounce(updateAvailableOwners, 500, [updateAvailableOwners]);\n\n if (theme === 'bui') {\n const options = availableOwners.map(o => ({ label: o, value: o }));\n\n return (\n <BuiAutocomplete\n label={schema?.title ?? t('fields.repoOwnerPicker.title')}\n description={\n schema?.description ?? t('fields.repoOwnerPicker.description')\n }\n inputValue={owner ?? ''}\n onInputChange={value => onChange({ owner: value })}\n onSelectionChange={(key: Key | null) => {\n if (key !== null) {\n onChange({ owner: String(key) });\n }\n }}\n options={options}\n isDisabled={isDisabled}\n isRequired={required}\n isInvalid={rawErrors?.length > 0 && !owner}\n />\n );\n }\n\n return (\n <FormControl\n margin=\"normal\"\n required={required}\n error={rawErrors?.length > 0 && !owner}\n >\n <MuiAutocomplete\n value={owner}\n onChange={(_, newValue) => {\n onChange({ owner: newValue || '' });\n }}\n disabled={isDisabled}\n options={availableOwners}\n renderInput={params => (\n <MuiTextField\n {...params}\n label={schema?.title ?? t('fields.repoOwnerPicker.title')}\n disabled={isDisabled}\n required={required}\n />\n )}\n freeSolo\n autoSelect\n />\n <FormHelperText>\n {schema?.description ?? t('fields.repoOwnerPicker.description')}\n </FormHelperText>\n </FormControl>\n );\n};\n"],"names":["BuiAutocomplete"],"mappings":";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AAA;AAAA,UAAA;AAAA,YACC,KAAA,EAAO,KAAA;AAAA,YACP,QAAA,EAAU,CAAC,CAAA,EAAG,QAAA,KAAa;AACzB,cAAA,QAAA,CAAS,EAAE,KAAA,EAAO,QAAA,IAAY,EAAA,EAAI,CAAA;AAAA,YACpC,CAAA;AAAA,YACA,QAAA,EAAU,UAAA;AAAA,YACV,OAAA,EAAS,eAAA;AAAA,YACT,aAAa,CAAA,MAAA,qBACX,GAAA;AAAA,cAAC,YAAA;AAAA,cAAA;AAAA,gBACE,GAAG,MAAA;AAAA,gBACJ,KAAA,EAAO,MAAA,EAAQ,KAAA,IAAS,CAAA,CAAE,8BAA8B,CAAA;AAAA,gBACxD,QAAA,EAAU,UAAA;AAAA,gBACV;AAAA;AAAA,aACF;AAAA,YAEF,QAAA,EAAQ,IAAA;AAAA,YACR,UAAA,EAAU;AAAA;AAAA,SACZ;AAAA,4BACC,cAAA,EAAA,EACE,QAAA,EAAA,MAAA,EAAQ,WAAA,IAAe,CAAA,CAAE,oCAAoC,CAAA,EAChE;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -57,37 +57,34 @@ const RepoOwnerPicker = (props) => {
|
|
|
57
57
|
[setState]
|
|
58
58
|
);
|
|
59
59
|
const hostType = (host && integrationApi.byHost(host)?.type) ?? null;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
return renderRepoOwnerPicker();
|
|
60
|
+
switch (hostType) {
|
|
61
|
+
case "github":
|
|
62
|
+
return /* @__PURE__ */ jsx(
|
|
63
|
+
GitHubRepoOwnerPicker,
|
|
64
|
+
{
|
|
65
|
+
onChange: updateLocalState,
|
|
66
|
+
state,
|
|
67
|
+
rawErrors,
|
|
68
|
+
accessToken: uiSchema?.["ui:options"]?.requestUserCredentials?.secretsKey && secrets[uiSchema["ui:options"].requestUserCredentials.secretsKey],
|
|
69
|
+
isDisabled: uiSchema?.["ui:disabled"] ?? false,
|
|
70
|
+
required,
|
|
71
|
+
schema,
|
|
72
|
+
excludedOwners
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
default:
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
DefaultRepoOwnerPicker,
|
|
78
|
+
{
|
|
79
|
+
onChange: updateLocalState,
|
|
80
|
+
state,
|
|
81
|
+
rawErrors,
|
|
82
|
+
isDisabled: uiSchema?.["ui:disabled"] ?? false,
|
|
83
|
+
required,
|
|
84
|
+
schema
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
91
88
|
};
|
|
92
89
|
|
|
93
90
|
export { RepoOwnerPicker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepoOwnerPicker.esm.js","sources":["../../../../src/components/fields/RepoOwnerPicker/RepoOwnerPicker.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 { useApi } from '@backstage/core-plugin-api';\nimport {\n scmIntegrationsApiRef,\n scmAuthApiRef,\n} from '@backstage/integration-react';\nimport { useEffect, useState, useCallback, useMemo } from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\nimport { useTemplateSecrets } from '@backstage/plugin-scaffolder-react';\n\nimport { RepoOwnerPickerProps } from './schema';\nimport { RepoOwnerPickerState } from './types';\nimport { DefaultRepoOwnerPicker } from './DefaultRepoOwnerPicker';\nimport { GitHubRepoOwnerPicker } from './GitHubRepoOwnerPicker';\n
|
|
1
|
+
{"version":3,"file":"RepoOwnerPicker.esm.js","sources":["../../../../src/components/fields/RepoOwnerPicker/RepoOwnerPicker.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 { useApi } from '@backstage/core-plugin-api';\nimport {\n scmIntegrationsApiRef,\n scmAuthApiRef,\n} from '@backstage/integration-react';\nimport { useEffect, useState, useCallback, useMemo } from 'react';\nimport useDebounce from 'react-use/esm/useDebounce';\nimport { useTemplateSecrets } from '@backstage/plugin-scaffolder-react';\n\nimport { RepoOwnerPickerProps } from './schema';\nimport { RepoOwnerPickerState } from './types';\nimport { DefaultRepoOwnerPicker } from './DefaultRepoOwnerPicker';\nimport { GitHubRepoOwnerPicker } from './GitHubRepoOwnerPicker';\n/**\n * The underlying component that is rendered in the form for the `RepoOwnerPicker`\n * field extension.\n *\n * @public\n */\nexport const RepoOwnerPicker = (props: RepoOwnerPickerProps) => {\n const { uiSchema, onChange, rawErrors, formData, schema, required } = props;\n const [state, setState] = useState<RepoOwnerPickerState>({\n owner: formData || '',\n });\n const excludedOwners = useMemo(\n () => uiSchema?.['ui:options']?.excludedOwners ?? [],\n [uiSchema],\n );\n const { host, owner } = state;\n\n const integrationApi = useApi(scmIntegrationsApiRef);\n const scmAuthApi = useApi(scmAuthApiRef);\n\n const { secrets, setSecrets } = useTemplateSecrets();\n\n useDebounce(\n async () => {\n const { requestUserCredentials } = uiSchema?.['ui:options'] ?? {};\n\n if (!requestUserCredentials || !host) {\n return;\n }\n\n // don't show login prompt if secret value is already in state\n if (secrets[requestUserCredentials.secretsKey]) {\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://${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 },\n 500,\n [host, uiSchema],\n );\n\n useEffect(() => {\n if (uiSchema?.['ui:options']?.host) {\n const hostUiOption = uiSchema['ui:options'].host;\n setState(prevState => ({ ...prevState, host: hostUiOption }));\n }\n }, [uiSchema]);\n\n useEffect(() => {\n onChange(owner);\n }, [owner, onChange]);\n\n const updateLocalState = useCallback(\n (newState: RepoOwnerPickerState) => {\n setState(prevState => ({ ...prevState, ...newState }));\n },\n [setState],\n );\n\n const hostType = (host && integrationApi.byHost(host)?.type) ?? null;\n\n switch (hostType) {\n case 'github':\n return (\n <GitHubRepoOwnerPicker\n onChange={updateLocalState}\n state={state}\n rawErrors={rawErrors}\n accessToken={\n uiSchema?.['ui:options']?.requestUserCredentials?.secretsKey &&\n secrets[uiSchema['ui:options'].requestUserCredentials.secretsKey]\n }\n isDisabled={uiSchema?.['ui:disabled'] ?? false}\n required={required}\n schema={schema}\n excludedOwners={excludedOwners}\n />\n );\n default:\n return (\n <DefaultRepoOwnerPicker\n onChange={updateLocalState}\n state={state}\n rawErrors={rawErrors}\n isDisabled={uiSchema?.['ui:disabled'] ?? false}\n required={required}\n schema={schema}\n />\n );\n }\n};\n"],"names":[],"mapp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;AACE,MAAA,uBACE,GAAA;AAAA,QAAC,sBAAA;AAAA,QAAA;AAAA,UACC,QAAA,EAAU,gBAAA;AAAA,UACV,KAAA;AAAA,UACA,SAAA;AAAA,UACA,UAAA,EAAY,QAAA,GAAW,aAAa,CAAA,IAAK,KAAA;AAAA,UACzC,QAAA;AAAA,UACA;AAAA;AAAA,OACF;AAAA;AAGR;;;;"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import FormControl from '@material-ui/core/FormControl';
|
|
3
3
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
|
4
|
-
import
|
|
4
|
+
import MuiTextField from '@material-ui/core/TextField';
|
|
5
5
|
import { Select } from '@backstage/core-components';
|
|
6
6
|
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
7
7
|
import { scaffolderTranslationRef } from '../../../translation.esm.js';
|
|
8
|
+
import { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';
|
|
9
|
+
import { Select as Select$1, TextField } from '@backstage/ui';
|
|
10
|
+
import overrides from '../scaffolderFieldOverrides.module.css.esm.js';
|
|
8
11
|
|
|
9
12
|
const AzureRepoPicker = (props) => {
|
|
13
|
+
const theme = useScaffolderTheme();
|
|
10
14
|
const {
|
|
11
15
|
allowedOrganizations = [],
|
|
12
16
|
allowedProject = [],
|
|
@@ -16,9 +20,87 @@ const AzureRepoPicker = (props) => {
|
|
|
16
20
|
isDisabled
|
|
17
21
|
} = props;
|
|
18
22
|
const { t } = useTranslationRef(scaffolderTranslationRef);
|
|
23
|
+
const { organization, project } = state;
|
|
24
|
+
if (theme === "bui") {
|
|
25
|
+
const renderOrganizationPicker = () => {
|
|
26
|
+
if (allowedOrganizations?.length) {
|
|
27
|
+
const organizationItems2 = allowedOrganizations.map((i) => ({
|
|
28
|
+
label: i,
|
|
29
|
+
value: i
|
|
30
|
+
}));
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
Select$1,
|
|
33
|
+
{
|
|
34
|
+
className: overrides.select,
|
|
35
|
+
label: t("fields.azureRepoPicker.organization.title"),
|
|
36
|
+
description: t("fields.azureRepoPicker.organization.description"),
|
|
37
|
+
isDisabled: isDisabled || allowedOrganizations.length === 1,
|
|
38
|
+
isInvalid: rawErrors?.length > 0 && !organization,
|
|
39
|
+
selectedKey: organization ?? null,
|
|
40
|
+
onSelectionChange: (key) => {
|
|
41
|
+
if (key !== null) onChange({ organization: String(key) });
|
|
42
|
+
},
|
|
43
|
+
options: organizationItems2,
|
|
44
|
+
isRequired: true
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
TextField,
|
|
50
|
+
{
|
|
51
|
+
label: t("fields.azureRepoPicker.organization.title"),
|
|
52
|
+
description: t("fields.azureRepoPicker.organization.description"),
|
|
53
|
+
onChange: (value) => onChange({ organization: value }),
|
|
54
|
+
isDisabled,
|
|
55
|
+
value: organization ?? "",
|
|
56
|
+
isInvalid: rawErrors?.length > 0 && !organization,
|
|
57
|
+
isRequired: true
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
const renderProjectPicker = () => {
|
|
62
|
+
if (allowedProject?.length) {
|
|
63
|
+
const projectItems2 = allowedProject.map((i) => ({
|
|
64
|
+
label: i,
|
|
65
|
+
value: i
|
|
66
|
+
}));
|
|
67
|
+
return /* @__PURE__ */ jsx(
|
|
68
|
+
Select$1,
|
|
69
|
+
{
|
|
70
|
+
className: overrides.select,
|
|
71
|
+
label: t("fields.azureRepoPicker.project.title"),
|
|
72
|
+
description: t("fields.azureRepoPicker.project.description"),
|
|
73
|
+
isDisabled: isDisabled || allowedProject.length === 1,
|
|
74
|
+
isInvalid: rawErrors?.length > 0 && !project,
|
|
75
|
+
selectedKey: project ?? null,
|
|
76
|
+
onSelectionChange: (key) => {
|
|
77
|
+
if (key !== null) onChange({ project: String(key) });
|
|
78
|
+
},
|
|
79
|
+
options: projectItems2,
|
|
80
|
+
isRequired: true
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
85
|
+
TextField,
|
|
86
|
+
{
|
|
87
|
+
label: t("fields.azureRepoPicker.project.title"),
|
|
88
|
+
description: t("fields.azureRepoPicker.project.description"),
|
|
89
|
+
onChange: (value) => onChange({ project: value }),
|
|
90
|
+
value: project ?? "",
|
|
91
|
+
isDisabled,
|
|
92
|
+
isInvalid: rawErrors?.length > 0 && !project,
|
|
93
|
+
isRequired: true
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
98
|
+
renderOrganizationPicker(),
|
|
99
|
+
renderProjectPicker()
|
|
100
|
+
] });
|
|
101
|
+
}
|
|
19
102
|
const organizationItems = allowedOrganizations ? allowedOrganizations.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
|
|
20
103
|
const projectItems = allowedProject ? allowedProject.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
|
|
21
|
-
const { organization, project } = state;
|
|
22
104
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23
105
|
/* @__PURE__ */ jsx(
|
|
24
106
|
FormControl,
|
|
@@ -40,7 +122,7 @@ const AzureRepoPicker = (props) => {
|
|
|
40
122
|
),
|
|
41
123
|
/* @__PURE__ */ jsx(FormHelperText, { children: t("fields.azureRepoPicker.organization.description") })
|
|
42
124
|
] }) : /* @__PURE__ */ jsx(
|
|
43
|
-
|
|
125
|
+
MuiTextField,
|
|
44
126
|
{
|
|
45
127
|
id: "orgInput",
|
|
46
128
|
label: t("fields.azureRepoPicker.organization.title"),
|
|
@@ -72,7 +154,7 @@ const AzureRepoPicker = (props) => {
|
|
|
72
154
|
),
|
|
73
155
|
/* @__PURE__ */ jsx(FormHelperText, { children: t("fields.azureRepoPicker.project.description") })
|
|
74
156
|
] }) : /* @__PURE__ */ jsx(
|
|
75
|
-
|
|
157
|
+
MuiTextField,
|
|
76
158
|
{
|
|
77
159
|
id: "projectInput",
|
|
78
160
|
label: t("fields.azureRepoPicker.project.title"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/AzureRepoPicker.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport TextField from '@material-ui/core/TextField';\nimport { BaseRepoUrlPickerProps } from './types';\nimport { Select, SelectItem } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\n\nexport const AzureRepoPicker = (\n props: BaseRepoUrlPickerProps<{\n allowedOrganizations?: string[];\n allowedProject?: string[];\n }>,\n) => {\n const {\n allowedOrganizations = [],\n allowedProject = [],\n rawErrors,\n state,\n onChange,\n isDisabled,\n } = props;\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const organizationItems: SelectItem[] = allowedOrganizations\n ? allowedOrganizations.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const projectItems: SelectItem[] = allowedProject\n ? allowedProject.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const { organization, project } = state;\n\n return (\n <>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !organization}\n >\n {allowedOrganizations?.length ? (\n <>\n <Select\n native\n label={t('fields.azureRepoPicker.organization.title')}\n onChange={s =>\n onChange({ organization: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={isDisabled || allowedOrganizations.length === 1}\n selected={organization}\n items={organizationItems}\n />\n <FormHelperText>\n {t('fields.azureRepoPicker.organization.description')}\n </FormHelperText>\n </>\n ) : (\n <TextField\n id=\"orgInput\"\n label={t('fields.azureRepoPicker.organization.title')}\n onChange={e => onChange({ organization: e.target.value })}\n helperText={t('fields.azureRepoPicker.organization.description')}\n disabled={isDisabled}\n value={organization}\n />\n )}\n </FormControl>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !project}\n >\n {allowedProject?.length ? (\n <>\n <Select\n native\n label={t('fields.azureRepoPicker.project.title')}\n onChange={s =>\n onChange({ project: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={isDisabled || allowedProject.length === 1}\n selected={project}\n items={projectItems}\n />\n <FormHelperText>\n {t('fields.azureRepoPicker.project.description')}\n </FormHelperText>\n </>\n ) : (\n <TextField\n id=\"projectInput\"\n label={t('fields.azureRepoPicker.project.title')}\n onChange={e => onChange({ project: e.target.value })}\n value={project}\n disabled={isDisabled}\n helperText={t('fields.azureRepoPicker.project.description')}\n />\n )}\n </FormControl>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAwBO,MAAM,eAAA,GAAkB,CAC7B,KAAA,KAIG;AACH,EAAA,MAAM;AAAA,IACJ,uBAAuB,EAAC;AAAA,IACxB,iBAAiB,EAAC;AAAA,IAClB,SAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,MAAM,oBAAkC,oBAAA,GACpC,oBAAA,CAAqB,IAAI,CAAA,CAAA,MAAM,EAAE,OAAO,CAAA,EAAG,KAAA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,OAAK,QAAA,CAAS,EAAE,SAAS,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA;AAAA,YACnD,KAAA,EAAO,OAAA;AAAA,YACP,QAAA,EAAU,UAAA;AAAA,YACV,UAAA,EAAY,EAAE,4CAA4C;AAAA;AAAA;AAC5D;AAAA;AAEJ,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"AzureRepoPicker.esm.js","sources":["../../../../src/components/fields/RepoUrlPicker/AzureRepoPicker.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport FormControl from '@material-ui/core/FormControl';\nimport FormHelperText from '@material-ui/core/FormHelperText';\nimport MuiTextField from '@material-ui/core/TextField';\nimport { BaseRepoUrlPickerProps } from './types';\nimport { Select as MuiSelect, SelectItem } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { scaffolderTranslationRef } from '../../../translation';\nimport { useScaffolderTheme } from '@backstage/plugin-scaffolder-react/alpha';\nimport { TextField as BuiTextField, Select as BuiSelect } from '@backstage/ui';\nimport overrides from '../scaffolderFieldOverrides.module.css';\nimport type { Key } from 'react-aria-components';\n\nexport const AzureRepoPicker = (\n props: BaseRepoUrlPickerProps<{\n allowedOrganizations?: string[];\n allowedProject?: string[];\n }>,\n) => {\n const theme = useScaffolderTheme();\n const {\n allowedOrganizations = [],\n allowedProject = [],\n rawErrors,\n state,\n onChange,\n isDisabled,\n } = props;\n const { t } = useTranslationRef(scaffolderTranslationRef);\n\n const { organization, project } = state;\n\n if (theme === 'bui') {\n const renderOrganizationPicker = () => {\n if (allowedOrganizations?.length) {\n const organizationItems = allowedOrganizations.map(i => ({\n label: i,\n value: i,\n }));\n\n return (\n <BuiSelect\n className={overrides.select}\n label={t('fields.azureRepoPicker.organization.title')}\n description={t('fields.azureRepoPicker.organization.description')}\n isDisabled={isDisabled || allowedOrganizations.length === 1}\n isInvalid={rawErrors?.length > 0 && !organization}\n selectedKey={organization ?? null}\n onSelectionChange={(key: Key | null) => {\n if (key !== null) onChange({ organization: String(key) });\n }}\n options={organizationItems}\n isRequired\n />\n );\n }\n\n return (\n <BuiTextField\n label={t('fields.azureRepoPicker.organization.title')}\n description={t('fields.azureRepoPicker.organization.description')}\n onChange={value => onChange({ organization: value })}\n isDisabled={isDisabled}\n value={organization ?? ''}\n isInvalid={rawErrors?.length > 0 && !organization}\n isRequired\n />\n );\n };\n\n const renderProjectPicker = () => {\n if (allowedProject?.length) {\n const projectItems = allowedProject.map(i => ({\n label: i,\n value: i,\n }));\n\n return (\n <BuiSelect\n className={overrides.select}\n label={t('fields.azureRepoPicker.project.title')}\n description={t('fields.azureRepoPicker.project.description')}\n isDisabled={isDisabled || allowedProject.length === 1}\n isInvalid={rawErrors?.length > 0 && !project}\n selectedKey={project ?? null}\n onSelectionChange={(key: Key | null) => {\n if (key !== null) onChange({ project: String(key) });\n }}\n options={projectItems}\n isRequired\n />\n );\n }\n\n return (\n <BuiTextField\n label={t('fields.azureRepoPicker.project.title')}\n description={t('fields.azureRepoPicker.project.description')}\n onChange={value => onChange({ project: value })}\n value={project ?? ''}\n isDisabled={isDisabled}\n isInvalid={rawErrors?.length > 0 && !project}\n isRequired\n />\n );\n };\n\n return (\n <>\n {renderOrganizationPicker()}\n {renderProjectPicker()}\n </>\n );\n }\n\n const organizationItems: SelectItem[] = allowedOrganizations\n ? allowedOrganizations.map(i => ({ label: i, value: i }))\n : [{ label: 'Loading...', value: 'loading' }];\n\n const projectItems: SelectItem[] = allowedProject\n ? allowedProject.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 && !organization}\n >\n {allowedOrganizations?.length ? (\n <>\n <MuiSelect\n native\n label={t('fields.azureRepoPicker.organization.title')}\n onChange={s =>\n onChange({ organization: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={isDisabled || allowedOrganizations.length === 1}\n selected={organization}\n items={organizationItems}\n />\n <FormHelperText>\n {t('fields.azureRepoPicker.organization.description')}\n </FormHelperText>\n </>\n ) : (\n <MuiTextField\n id=\"orgInput\"\n label={t('fields.azureRepoPicker.organization.title')}\n onChange={e => onChange({ organization: e.target.value })}\n helperText={t('fields.azureRepoPicker.organization.description')}\n disabled={isDisabled}\n value={organization}\n />\n )}\n </FormControl>\n <FormControl\n margin=\"normal\"\n required\n error={rawErrors?.length > 0 && !project}\n >\n {allowedProject?.length ? (\n <>\n <MuiSelect\n native\n label={t('fields.azureRepoPicker.project.title')}\n onChange={s =>\n onChange({ project: String(Array.isArray(s) ? s[0] : s) })\n }\n disabled={isDisabled || allowedProject.length === 1}\n selected={project}\n items={projectItems}\n />\n <FormHelperText>\n {t('fields.azureRepoPicker.project.description')}\n </FormHelperText>\n </>\n ) : (\n <MuiTextField\n id=\"projectInput\"\n label={t('fields.azureRepoPicker.project.title')}\n onChange={e => onChange({ project: e.target.value })}\n value={project}\n disabled={isDisabled}\n helperText={t('fields.azureRepoPicker.project.description')}\n />\n )}\n </FormControl>\n </>\n );\n};\n"],"names":["organizationItems","BuiSelect","BuiTextField","projectItems","MuiSelect"],"mappings":";;;;;;;;;;;AA4BO,MAAM,eAAA,GAAkB,CAC7B,KAAA,KAIG;AACH,EAAA,MAAM,QAAQ,kBAAA,EAAmB;AACjC,EAAA,MAAM;AAAA,IACJ,uBAAuB,EAAC;AAAA,IACxB,iBAAiB,EAAC;AAAA,IAClB,SAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACF,GAA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