@backstage/plugin-scaffolder 0.11.18 → 0.11.19-next.0
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 +17 -0
- package/dist/esm/{Router-552fb2ce.esm.js → Router-263335a3.esm.js} +3 -3
- package/dist/esm/{Router-552fb2ce.esm.js.map → Router-263335a3.esm.js.map} +1 -1
- package/dist/esm/{index-768702c3.esm.js → index-adf0c216.esm.js} +248 -196
- package/dist/esm/index-adf0c216.esm.js.map +1 -0
- package/dist/index.d.ts +28 -2
- package/dist/index.esm.js +3 -3
- package/package.json +16 -16
- package/dist/esm/index-768702c3.esm.js.map +0 -1
|
@@ -6,16 +6,16 @@ import { catalogApiRef, formatEntityRefTitle, useOwnedEntities, useStarredEntity
|
|
|
6
6
|
import { TextField, FormControl as FormControl$1, withStyles, makeStyles, IconButton, Tooltip, useTheme, Card, CardMedia, CardContent, Box, Typography, Chip, CardActions, Link, FormControlLabel, Checkbox } from '@material-ui/core';
|
|
7
7
|
import FormControl from '@material-ui/core/FormControl';
|
|
8
8
|
import Autocomplete from '@material-ui/lab/Autocomplete';
|
|
9
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
9
|
+
import React, { useCallback, useEffect, useState, useMemo } from 'react';
|
|
10
10
|
import useAsync from 'react-use/lib/useAsync';
|
|
11
11
|
import { KubernetesValidatorFunctions, makeValidator, RELATION_OWNED_BY, stringifyEntityRef } from '@backstage/catalog-model';
|
|
12
|
-
import
|
|
12
|
+
import useEffectOnce from 'react-use/lib/useEffectOnce';
|
|
13
13
|
import { Autocomplete as Autocomplete$1 } from '@material-ui/lab';
|
|
14
|
-
import { Progress, Select, ItemCardHeader, Button, ContentHeader, WarningPanel, Link as Link$1, Content, ItemCardGrid } from '@backstage/core-components';
|
|
15
14
|
import { scmIntegrationsApiRef, ScmIntegrationIcon } from '@backstage/integration-react';
|
|
16
15
|
import FormHelperText from '@material-ui/core/FormHelperText';
|
|
17
16
|
import Input from '@material-ui/core/Input';
|
|
18
17
|
import InputLabel from '@material-ui/core/InputLabel';
|
|
18
|
+
import { Select, Progress, ItemCardHeader, Button, ContentHeader, WarningPanel, Link as Link$1, Content, ItemCardGrid } from '@backstage/core-components';
|
|
19
19
|
import Star from '@material-ui/icons/Star';
|
|
20
20
|
import StarBorder from '@material-ui/icons/StarBorder';
|
|
21
21
|
import WarningIcon from '@material-ui/icons/Warning';
|
|
@@ -46,7 +46,7 @@ class ScaffolderClient {
|
|
|
46
46
|
}
|
|
47
47
|
async getTemplateParameterSchema(templateName) {
|
|
48
48
|
const { namespace, kind, name } = templateName;
|
|
49
|
-
const token = await this.identityApi.
|
|
49
|
+
const { token } = await this.identityApi.getCredentials();
|
|
50
50
|
const baseUrl = await this.discoveryApi.getBaseUrl("scaffolder");
|
|
51
51
|
const templatePath = [namespace, kind, name].map((s) => encodeURIComponent(s)).join("/");
|
|
52
52
|
const url = `${baseUrl}/v2/templates/${templatePath}/parameter-schema`;
|
|
@@ -62,7 +62,7 @@ class ScaffolderClient {
|
|
|
62
62
|
return schema;
|
|
63
63
|
}
|
|
64
64
|
async scaffold(templateName, values) {
|
|
65
|
-
const token = await this.identityApi.
|
|
65
|
+
const { token } = await this.identityApi.getCredentials();
|
|
66
66
|
const url = `${await this.discoveryApi.getBaseUrl("scaffolder")}/v2/tasks`;
|
|
67
67
|
const response = await fetch(url, {
|
|
68
68
|
method: "POST",
|
|
@@ -81,7 +81,7 @@ class ScaffolderClient {
|
|
|
81
81
|
return id;
|
|
82
82
|
}
|
|
83
83
|
async getTask(taskId) {
|
|
84
|
-
const token = await this.identityApi.
|
|
84
|
+
const { token } = await this.identityApi.getCredentials();
|
|
85
85
|
const baseUrl = await this.discoveryApi.getBaseUrl("scaffolder");
|
|
86
86
|
const url = `${baseUrl}/v2/tasks/${encodeURIComponent(taskId)}`;
|
|
87
87
|
const response = await fetch(url, {
|
|
@@ -167,7 +167,7 @@ class ScaffolderClient {
|
|
|
167
167
|
}
|
|
168
168
|
async listActions() {
|
|
169
169
|
const baseUrl = await this.discoveryApi.getBaseUrl("scaffolder");
|
|
170
|
-
const token = await this.identityApi.
|
|
170
|
+
const { token } = await this.identityApi.getCredentials();
|
|
171
171
|
const response = await fetch(`${baseUrl}/v2/actions`, {
|
|
172
172
|
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
|
173
173
|
});
|
|
@@ -277,7 +277,7 @@ const EntityTagsPicker = ({
|
|
|
277
277
|
const [inputError, setInputError] = useState(false);
|
|
278
278
|
const tagValidator = makeValidator().isValidTag;
|
|
279
279
|
const kinds = (_a = uiSchema["ui:options"]) == null ? void 0 : _a.kinds;
|
|
280
|
-
const { loading, value: existingTags } = useAsync
|
|
280
|
+
const { loading, value: existingTags } = useAsync(async () => {
|
|
281
281
|
const tagsRequest = { fields: ["metadata.tags"] };
|
|
282
282
|
if (kinds) {
|
|
283
283
|
tagsRequest.filter = { kind: kinds };
|
|
@@ -351,221 +351,273 @@ const OwnerPicker = ({
|
|
|
351
351
|
});
|
|
352
352
|
};
|
|
353
353
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
let organization = void 0;
|
|
359
|
-
let workspace = void 0;
|
|
360
|
-
let project = void 0;
|
|
361
|
-
try {
|
|
362
|
-
if (url) {
|
|
363
|
-
const parsed = new URL(`https://${url}`);
|
|
364
|
-
host = parsed.host;
|
|
365
|
-
owner = parsed.searchParams.get("owner") || (allowedOwners == null ? void 0 : allowedOwners[0]);
|
|
366
|
-
repo = parsed.searchParams.get("repo") || void 0;
|
|
367
|
-
organization = parsed.searchParams.get("organization") || void 0;
|
|
368
|
-
workspace = parsed.searchParams.get("workspace") || void 0;
|
|
369
|
-
project = parsed.searchParams.get("project") || void 0;
|
|
370
|
-
}
|
|
371
|
-
} catch {
|
|
372
|
-
}
|
|
373
|
-
return { host, owner, repo, organization, workspace, project };
|
|
374
|
-
}
|
|
375
|
-
function serializeFormData(data) {
|
|
376
|
-
if (!data.host) {
|
|
377
|
-
return void 0;
|
|
378
|
-
}
|
|
379
|
-
const params = new URLSearchParams();
|
|
380
|
-
if (data.owner) {
|
|
381
|
-
params.set("owner", data.owner);
|
|
382
|
-
}
|
|
383
|
-
if (data.repo) {
|
|
384
|
-
params.set("repo", data.repo);
|
|
385
|
-
}
|
|
386
|
-
if (data.organization) {
|
|
387
|
-
params.set("organization", data.organization);
|
|
388
|
-
}
|
|
389
|
-
if (data.workspace) {
|
|
390
|
-
params.set("workspace", data.workspace);
|
|
391
|
-
}
|
|
392
|
-
if (data.project) {
|
|
393
|
-
params.set("project", data.project);
|
|
394
|
-
}
|
|
395
|
-
return `${data.host}?${params.toString()}`;
|
|
396
|
-
}
|
|
397
|
-
const RepoUrlPicker = ({
|
|
398
|
-
onChange,
|
|
399
|
-
uiSchema,
|
|
400
|
-
rawErrors,
|
|
401
|
-
formData
|
|
402
|
-
}) => {
|
|
403
|
-
var _a, _b, _c, _d, _e;
|
|
404
|
-
const scaffolderApi = useApi(scaffolderApiRef);
|
|
405
|
-
const integrationApi = useApi(scmIntegrationsApiRef);
|
|
406
|
-
const allowedHosts = (_a = uiSchema["ui:options"]) == null ? void 0 : _a.allowedHosts;
|
|
407
|
-
const allowedOwners = (_b = uiSchema["ui:options"]) == null ? void 0 : _b.allowedOwners;
|
|
408
|
-
const { value: integrations, loading } = useAsync(async () => {
|
|
409
|
-
return await scaffolderApi.getIntegrationsList({ allowedHosts });
|
|
410
|
-
});
|
|
411
|
-
const { host, owner, repo, organization, workspace, project } = splitFormData(formData, allowedOwners);
|
|
412
|
-
const updateHost = useCallback((value) => {
|
|
413
|
-
onChange(serializeFormData({
|
|
414
|
-
host: value,
|
|
415
|
-
owner,
|
|
416
|
-
repo,
|
|
417
|
-
organization,
|
|
418
|
-
workspace,
|
|
419
|
-
project
|
|
420
|
-
}));
|
|
421
|
-
}, [onChange, owner, repo, organization, workspace, project]);
|
|
422
|
-
const updateOwnerSelect = useCallback((value) => onChange(serializeFormData({
|
|
423
|
-
host,
|
|
424
|
-
owner: value,
|
|
425
|
-
repo,
|
|
426
|
-
organization,
|
|
427
|
-
workspace,
|
|
428
|
-
project
|
|
429
|
-
})), [onChange, host, repo, organization, workspace, project]);
|
|
430
|
-
const updateOwner = useCallback((evt) => onChange(serializeFormData({
|
|
431
|
-
host,
|
|
432
|
-
owner: evt.target.value,
|
|
433
|
-
repo,
|
|
434
|
-
organization,
|
|
435
|
-
workspace,
|
|
436
|
-
project
|
|
437
|
-
})), [onChange, host, repo, organization, workspace, project]);
|
|
438
|
-
const updateRepo = useCallback((evt) => onChange(serializeFormData({
|
|
439
|
-
host,
|
|
440
|
-
owner,
|
|
441
|
-
repo: evt.target.value,
|
|
442
|
-
organization,
|
|
443
|
-
workspace,
|
|
444
|
-
project
|
|
445
|
-
})), [onChange, host, owner, organization, workspace, project]);
|
|
446
|
-
const updateOrganization = useCallback((evt) => onChange(serializeFormData({
|
|
447
|
-
host,
|
|
448
|
-
owner,
|
|
449
|
-
repo,
|
|
450
|
-
organization: evt.target.value,
|
|
451
|
-
workspace,
|
|
452
|
-
project
|
|
453
|
-
})), [onChange, host, owner, repo, workspace, project]);
|
|
454
|
-
const updateWorkspace = useCallback((evt) => onChange(serializeFormData({
|
|
455
|
-
host,
|
|
456
|
-
owner,
|
|
457
|
-
repo,
|
|
458
|
-
organization,
|
|
459
|
-
workspace: evt.target.value,
|
|
460
|
-
project
|
|
461
|
-
})), [onChange, host, owner, repo, organization, project]);
|
|
462
|
-
const updateProject = useCallback((evt) => onChange(serializeFormData({
|
|
463
|
-
host,
|
|
464
|
-
owner,
|
|
465
|
-
repo,
|
|
466
|
-
organization,
|
|
467
|
-
workspace,
|
|
468
|
-
project: evt.target.value
|
|
469
|
-
})), [onChange, host, owner, repo, organization, workspace]);
|
|
470
|
-
useEffect(() => {
|
|
471
|
-
if (host === void 0 && (integrations == null ? void 0 : integrations.length)) {
|
|
472
|
-
onChange(serializeFormData({
|
|
473
|
-
host: integrations[0].host,
|
|
474
|
-
owner,
|
|
475
|
-
repo,
|
|
476
|
-
organization,
|
|
477
|
-
workspace,
|
|
478
|
-
project
|
|
479
|
-
}));
|
|
480
|
-
}
|
|
481
|
-
}, [
|
|
482
|
-
onChange,
|
|
483
|
-
integrations,
|
|
484
|
-
host,
|
|
485
|
-
owner,
|
|
486
|
-
repo,
|
|
487
|
-
organization,
|
|
488
|
-
workspace,
|
|
489
|
-
project
|
|
490
|
-
]);
|
|
491
|
-
if (loading) {
|
|
492
|
-
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
493
|
-
}
|
|
494
|
-
const hostsOptions = integrations ? integrations.filter((i) => allowedHosts == null ? void 0 : allowedHosts.includes(i.host)).map((i) => ({ label: i.title, value: i.host })) : [{ label: "Loading...", value: "loading" }];
|
|
495
|
-
const ownersOptions = allowedOwners ? allowedOwners.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
|
|
354
|
+
const GithubRepoPicker = (props) => {
|
|
355
|
+
const { allowedOwners = [], rawErrors, state, onChange } = props;
|
|
356
|
+
const ownerItems = allowedOwners ? allowedOwners.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
|
|
357
|
+
const { owner, repoName } = state;
|
|
496
358
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(FormControl, {
|
|
497
359
|
margin: "normal",
|
|
498
360
|
required: true,
|
|
499
|
-
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !
|
|
500
|
-
}, /* @__PURE__ */ React.createElement(Select, {
|
|
361
|
+
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !owner
|
|
362
|
+
}, (allowedOwners == null ? void 0 : allowedOwners.length) ? /* @__PURE__ */ React.createElement(Select, {
|
|
501
363
|
native: true,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
selected:
|
|
506
|
-
items:
|
|
507
|
-
})
|
|
364
|
+
label: "Owner Available",
|
|
365
|
+
onChange: (s) => onChange({ owner: String(Array.isArray(s) ? s[0] : s) }),
|
|
366
|
+
disabled: allowedOwners.length === 1,
|
|
367
|
+
selected: owner,
|
|
368
|
+
items: ownerItems
|
|
369
|
+
}) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
370
|
+
htmlFor: "ownerInput"
|
|
371
|
+
}, "Owner"), /* @__PURE__ */ React.createElement(Input, {
|
|
372
|
+
id: "ownerInput",
|
|
373
|
+
onChange: (e) => onChange({ owner: e.target.value }),
|
|
374
|
+
value: owner
|
|
375
|
+
})), /* @__PURE__ */ React.createElement(FormHelperText, null, "The organization, user or project that this repo will belong to")), /* @__PURE__ */ React.createElement(FormControl, {
|
|
376
|
+
margin: "normal",
|
|
377
|
+
required: true,
|
|
378
|
+
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !repoName
|
|
379
|
+
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
380
|
+
htmlFor: "repoNameInput"
|
|
381
|
+
}, "Repository"), /* @__PURE__ */ React.createElement(Input, {
|
|
382
|
+
id: "repoNameInput",
|
|
383
|
+
onChange: (e) => onChange({ repoName: e.target.value }),
|
|
384
|
+
value: repoName
|
|
385
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The name of the repository")));
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
const GitlabRepoPicker = (props) => {
|
|
389
|
+
const { allowedOwners = [], rawErrors, state, onChange } = props;
|
|
390
|
+
const ownerItems = allowedOwners ? allowedOwners.map((i) => ({ label: i, value: i })) : [{ label: "Loading...", value: "loading" }];
|
|
391
|
+
const { owner, repoName } = state;
|
|
392
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(FormControl, {
|
|
393
|
+
margin: "normal",
|
|
394
|
+
required: true,
|
|
395
|
+
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !owner
|
|
396
|
+
}, (allowedOwners == null ? void 0 : allowedOwners.length) ? /* @__PURE__ */ React.createElement(Select, {
|
|
397
|
+
native: true,
|
|
398
|
+
label: "Owner Available",
|
|
399
|
+
onChange: (selected) => onChange({
|
|
400
|
+
owner: String(Array.isArray(selected) ? selected[0] : selected)
|
|
401
|
+
}),
|
|
402
|
+
disabled: allowedOwners.length === 1,
|
|
403
|
+
selected: owner,
|
|
404
|
+
items: ownerItems
|
|
405
|
+
}) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
406
|
+
htmlFor: "ownerInput"
|
|
407
|
+
}, "Owner"), /* @__PURE__ */ React.createElement(Input, {
|
|
408
|
+
id: "ownerInput",
|
|
409
|
+
onChange: (e) => onChange({ owner: e.target.value }),
|
|
410
|
+
value: owner
|
|
411
|
+
})), /* @__PURE__ */ React.createElement(FormHelperText, null, "The organization, user or project that this repo will belong to")), /* @__PURE__ */ React.createElement(FormControl, {
|
|
412
|
+
margin: "normal",
|
|
413
|
+
required: true,
|
|
414
|
+
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !repoName
|
|
415
|
+
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
416
|
+
htmlFor: "repoNameInput"
|
|
417
|
+
}, "Repository"), /* @__PURE__ */ React.createElement(Input, {
|
|
418
|
+
id: "repoNameInput",
|
|
419
|
+
onChange: (e) => onChange({ repoName: e.target.value }),
|
|
420
|
+
value: repoName
|
|
421
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The name of the repository")));
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const AzureRepoPicker = (props) => {
|
|
425
|
+
const { rawErrors, state, onChange } = props;
|
|
426
|
+
const { organization, repoName, owner } = state;
|
|
427
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(FormControl, {
|
|
508
428
|
margin: "normal",
|
|
509
429
|
required: true,
|
|
510
430
|
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !organization
|
|
511
431
|
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
512
|
-
htmlFor: "
|
|
432
|
+
htmlFor: "orgInput"
|
|
513
433
|
}, "Organization"), /* @__PURE__ */ React.createElement(Input, {
|
|
514
|
-
id: "
|
|
515
|
-
onChange:
|
|
434
|
+
id: "orgInput",
|
|
435
|
+
onChange: (e) => onChange({ organization: e.target.value }),
|
|
516
436
|
value: organization
|
|
517
|
-
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The
|
|
437
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The organization that this repo will belong to")), /* @__PURE__ */ React.createElement(FormControl, {
|
|
438
|
+
margin: "normal",
|
|
439
|
+
required: true,
|
|
440
|
+
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !owner
|
|
441
|
+
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
442
|
+
htmlFor: "ownerInput"
|
|
443
|
+
}, "Owner"), /* @__PURE__ */ React.createElement(Input, {
|
|
444
|
+
id: "ownerInput",
|
|
445
|
+
onChange: (e) => onChange({ owner: e.target.value }),
|
|
446
|
+
value: owner
|
|
447
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The Owner that this repo will belong to")), /* @__PURE__ */ React.createElement(FormControl, {
|
|
448
|
+
margin: "normal",
|
|
449
|
+
required: true,
|
|
450
|
+
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !repoName
|
|
451
|
+
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
452
|
+
htmlFor: "repoNameInput"
|
|
453
|
+
}, "Repository"), /* @__PURE__ */ React.createElement(Input, {
|
|
454
|
+
id: "repoNameInput",
|
|
455
|
+
onChange: (e) => onChange({ repoName: e.target.value }),
|
|
456
|
+
value: repoName
|
|
457
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The name of the repository")));
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
const BitbucketRepoPicker = (props) => {
|
|
461
|
+
const { onChange, rawErrors, state } = props;
|
|
462
|
+
const { host, workspace, project, repoName } = state;
|
|
463
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, host === "bitbucket.org" && /* @__PURE__ */ React.createElement(FormControl, {
|
|
518
464
|
margin: "normal",
|
|
519
465
|
required: true,
|
|
520
466
|
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !workspace
|
|
521
467
|
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
522
|
-
htmlFor: "
|
|
468
|
+
htmlFor: "workspaceInput"
|
|
523
469
|
}, "Workspace"), /* @__PURE__ */ React.createElement(Input, {
|
|
524
|
-
id: "
|
|
525
|
-
onChange:
|
|
470
|
+
id: "workspaceInput",
|
|
471
|
+
onChange: (e) => onChange({ workspace: e.target.value }),
|
|
526
472
|
value: workspace
|
|
527
|
-
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The
|
|
473
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The Organization that this repo will belong to")), /* @__PURE__ */ React.createElement(FormControl, {
|
|
528
474
|
margin: "normal",
|
|
529
475
|
required: true,
|
|
530
476
|
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !project
|
|
531
477
|
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
532
|
-
htmlFor: "
|
|
478
|
+
htmlFor: "projectInput"
|
|
533
479
|
}, "Project"), /* @__PURE__ */ React.createElement(Input, {
|
|
534
|
-
id: "
|
|
535
|
-
onChange:
|
|
480
|
+
id: "projectInput",
|
|
481
|
+
onChange: (e) => onChange({ project: e.target.value }),
|
|
536
482
|
value: project
|
|
537
|
-
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The
|
|
483
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The Project that this repo will belong to")), /* @__PURE__ */ React.createElement(FormControl, {
|
|
538
484
|
margin: "normal",
|
|
539
485
|
required: true,
|
|
540
|
-
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !
|
|
486
|
+
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !repoName
|
|
541
487
|
}, /* @__PURE__ */ React.createElement(InputLabel, {
|
|
542
|
-
htmlFor: "
|
|
543
|
-
}, "
|
|
544
|
-
id: "
|
|
545
|
-
onChange:
|
|
546
|
-
value:
|
|
547
|
-
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The
|
|
488
|
+
htmlFor: "repoNameInput"
|
|
489
|
+
}, "Repository"), /* @__PURE__ */ React.createElement(Input, {
|
|
490
|
+
id: "repoNameInput",
|
|
491
|
+
onChange: (e) => onChange({ repoName: e.target.value }),
|
|
492
|
+
value: repoName
|
|
493
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The name of the repository")));
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
const RepoUrlPickerHost = (props) => {
|
|
497
|
+
const { host, hosts, onChange, rawErrors } = props;
|
|
498
|
+
const scaffolderApi = useApi(scaffolderApiRef);
|
|
499
|
+
const { value: integrations, loading } = useAsync(async () => {
|
|
500
|
+
return await scaffolderApi.getIntegrationsList({
|
|
501
|
+
allowedHosts: hosts != null ? hosts : []
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
useEffect(() => {
|
|
505
|
+
if (hosts && !host) {
|
|
506
|
+
onChange(hosts[0]);
|
|
507
|
+
}
|
|
508
|
+
}, [hosts, host, onChange]);
|
|
509
|
+
const hostsOptions = integrations ? integrations.filter((i) => hosts == null ? void 0 : hosts.includes(i.host)).map((i) => ({ label: i.title, value: i.host })) : [{ label: "Loading...", value: "loading" }];
|
|
510
|
+
if (loading) {
|
|
511
|
+
return /* @__PURE__ */ React.createElement(Progress, null);
|
|
512
|
+
}
|
|
513
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(FormControl, {
|
|
548
514
|
margin: "normal",
|
|
549
515
|
required: true,
|
|
550
|
-
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !
|
|
516
|
+
error: (rawErrors == null ? void 0 : rawErrors.length) > 0 && !host
|
|
551
517
|
}, /* @__PURE__ */ React.createElement(Select, {
|
|
552
518
|
native: true,
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
selected:
|
|
557
|
-
items:
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
519
|
+
disabled: (hosts == null ? void 0 : hosts.length) === 1,
|
|
520
|
+
label: "Host",
|
|
521
|
+
onChange: (s) => onChange(String(Array.isArray(s) ? s[0] : s)),
|
|
522
|
+
selected: host,
|
|
523
|
+
items: hostsOptions,
|
|
524
|
+
"data-testid": "host-select"
|
|
525
|
+
}), /* @__PURE__ */ React.createElement(FormHelperText, null, "The host where the repository will be created")));
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
function serializeRepoPickerUrl(data) {
|
|
529
|
+
if (!data.host) {
|
|
530
|
+
return void 0;
|
|
531
|
+
}
|
|
532
|
+
const params = new URLSearchParams();
|
|
533
|
+
if (data.owner) {
|
|
534
|
+
params.set("owner", data.owner);
|
|
535
|
+
}
|
|
536
|
+
if (data.repoName) {
|
|
537
|
+
params.set("repo", data.repoName);
|
|
538
|
+
}
|
|
539
|
+
if (data.organization) {
|
|
540
|
+
params.set("organization", data.organization);
|
|
541
|
+
}
|
|
542
|
+
if (data.workspace) {
|
|
543
|
+
params.set("workspace", data.workspace);
|
|
544
|
+
}
|
|
545
|
+
if (data.project) {
|
|
546
|
+
params.set("project", data.project);
|
|
547
|
+
}
|
|
548
|
+
return `${data.host}?${params.toString()}`;
|
|
549
|
+
}
|
|
550
|
+
function parseRepoPickerUrl(url) {
|
|
551
|
+
let host = void 0;
|
|
552
|
+
let owner = void 0;
|
|
553
|
+
let repoName = void 0;
|
|
554
|
+
let organization = void 0;
|
|
555
|
+
let workspace = void 0;
|
|
556
|
+
let project = void 0;
|
|
557
|
+
try {
|
|
558
|
+
if (url) {
|
|
559
|
+
const parsed = new URL(`https://${url}`);
|
|
560
|
+
host = parsed.host;
|
|
561
|
+
owner = parsed.searchParams.get("owner") || void 0;
|
|
562
|
+
repoName = parsed.searchParams.get("repo") || void 0;
|
|
563
|
+
organization = parsed.searchParams.get("organization") || void 0;
|
|
564
|
+
workspace = parsed.searchParams.get("workspace") || void 0;
|
|
565
|
+
project = parsed.searchParams.get("project") || void 0;
|
|
566
|
+
}
|
|
567
|
+
} catch {
|
|
568
|
+
}
|
|
569
|
+
return { host, owner, repoName, organization, workspace, project };
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const RepoUrlPicker = (props) => {
|
|
573
|
+
var _a, _b;
|
|
574
|
+
const { uiSchema, onChange, rawErrors, formData } = props;
|
|
575
|
+
const [state, setState] = useState(parseRepoPickerUrl(formData));
|
|
576
|
+
const integrationApi = useApi(scmIntegrationsApiRef);
|
|
577
|
+
const allowedHosts = useMemo(() => {
|
|
578
|
+
var _a2, _b2;
|
|
579
|
+
return (_b2 = (_a2 = uiSchema == null ? void 0 : uiSchema["ui:options"]) == null ? void 0 : _a2.allowedHosts) != null ? _b2 : [];
|
|
580
|
+
}, [uiSchema]);
|
|
581
|
+
const allowedOwners = useMemo(() => {
|
|
582
|
+
var _a2, _b2;
|
|
583
|
+
return (_b2 = (_a2 = uiSchema == null ? void 0 : uiSchema["ui:options"]) == null ? void 0 : _a2.allowedOwners) != null ? _b2 : [];
|
|
584
|
+
}, [uiSchema]);
|
|
585
|
+
useEffect(() => {
|
|
586
|
+
onChange(serializeRepoPickerUrl(state));
|
|
587
|
+
}, [state, onChange]);
|
|
588
|
+
useEffect(() => {
|
|
589
|
+
if (allowedOwners.length === 1) {
|
|
590
|
+
setState((prevState) => ({ ...prevState, owner: allowedOwners[0] }));
|
|
591
|
+
}
|
|
592
|
+
}, [setState, allowedOwners]);
|
|
593
|
+
const updateLocalState = useCallback((newState) => {
|
|
594
|
+
setState((prevState) => ({ ...prevState, ...newState }));
|
|
595
|
+
}, [setState]);
|
|
596
|
+
const hostType = (_b = state.host && ((_a = integrationApi.byHost(state.host)) == null ? void 0 : _a.type)) != null ? _b : null;
|
|
597
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(RepoUrlPickerHost, {
|
|
598
|
+
host: state.host,
|
|
599
|
+
hosts: allowedHosts,
|
|
600
|
+
onChange: (host) => setState((prevState) => ({ ...prevState, host })),
|
|
601
|
+
rawErrors
|
|
602
|
+
}), hostType === "github" && /* @__PURE__ */ React.createElement(GithubRepoPicker, {
|
|
603
|
+
allowedOwners,
|
|
604
|
+
rawErrors,
|
|
605
|
+
state,
|
|
606
|
+
onChange: updateLocalState
|
|
607
|
+
}), hostType === "gitlab" && /* @__PURE__ */ React.createElement(GitlabRepoPicker, {
|
|
608
|
+
allowedOwners,
|
|
609
|
+
rawErrors,
|
|
610
|
+
state,
|
|
611
|
+
onChange: updateLocalState
|
|
612
|
+
}), hostType === "bitbucket" && /* @__PURE__ */ React.createElement(BitbucketRepoPicker, {
|
|
613
|
+
rawErrors,
|
|
614
|
+
state,
|
|
615
|
+
onChange: updateLocalState
|
|
616
|
+
}), hostType === "azure" && /* @__PURE__ */ React.createElement(AzureRepoPicker, {
|
|
617
|
+
rawErrors,
|
|
618
|
+
state,
|
|
619
|
+
onChange: updateLocalState
|
|
620
|
+
}));
|
|
569
621
|
};
|
|
570
622
|
|
|
571
623
|
const repoPickerValidation = (value, validation, context) => {
|
|
@@ -700,7 +752,7 @@ const OwnerPickerFieldExtension = scaffolderPlugin.provide(createScaffolderField
|
|
|
700
752
|
}));
|
|
701
753
|
const ScaffolderPage = scaffolderPlugin.provide(createRoutableExtension({
|
|
702
754
|
name: "ScaffolderPage",
|
|
703
|
-
component: () => import('./Router-
|
|
755
|
+
component: () => import('./Router-263335a3.esm.js').then((m) => m.Router),
|
|
704
756
|
mountPoint: rootRouteRef
|
|
705
757
|
}));
|
|
706
758
|
const OwnedEntityPickerFieldExtension = scaffolderPlugin.provide(createScaffolderFieldExtension({
|
|
@@ -943,4 +995,4 @@ const TemplateTypePicker = () => {
|
|
|
943
995
|
};
|
|
944
996
|
|
|
945
997
|
export { EntityPicker as E, FIELD_EXTENSION_WRAPPER_KEY as F, OwnerPicker as O, RepoUrlPicker as R, ScaffolderClient as S, TemplateTypePicker as T, EntityNamePicker as a, EntityTagsPicker as b, OwnedEntityPicker as c, registerComponentRouteRef as d, entityNamePickerValidation as e, TemplateList as f, rootRouteRef as g, FIELD_EXTENSION_KEY as h, createScaffolderFieldExtension as i, ScaffolderFieldExtensions as j, EntityPickerFieldExtension as k, EntityNamePickerFieldExtension as l, EntityTagsPickerFieldExtension as m, OwnerPickerFieldExtension as n, OwnedEntityPickerFieldExtension as o, RepoUrlPickerFieldExtension as p, ScaffolderPage as q, repoPickerValidation as r, scaffolderApiRef as s, scaffolderPlugin as t, TextValuePicker as u, FavouriteTemplate as v };
|
|
946
|
-
//# sourceMappingURL=index-
|
|
998
|
+
//# sourceMappingURL=index-adf0c216.esm.js.map
|