@backstage/plugin-scaffolder 0.12.1-next.0 → 0.12.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 CHANGED
@@ -1,5 +1,53 @@
1
1
  # @backstage/plugin-scaffolder
2
2
 
3
+ ## 0.12.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 33e139e652: Adds a loading bar to the scaffolder task page if the task is still loading. This can happen if it takes a while for a task worker to pick up a task.
8
+ - 6458be3307: Encode the `formData` in the `queryString` using `JSON.stringify` to keep the types in the decoded value
9
+ - 319f4b79a2: The ScaffolderPage can be passed an optional `TaskPageComponent` with a `loadingText` string. It will replace the Loading text in the scaffolder task page.
10
+ - Updated dependencies
11
+ - @backstage/catalog-client@0.6.0
12
+ - @backstage/core-components@0.8.8
13
+ - @backstage/plugin-catalog-react@0.6.14
14
+ - @backstage/integration-react@0.1.21
15
+
16
+ ## 0.12.2-next.0
17
+
18
+ ### Patch Changes
19
+
20
+ - 33e139e652: Adds a loading bar to the scaffolder task page if the task is still loading. This can happen if it takes a while for a task worker to pick up a task.
21
+ - 6458be3307: Encode the `formData` in the `queryString` using `JSON.stringify` to keep the types in the decoded value
22
+ - 319f4b79a2: The ScaffolderPage can be passed an optional `TaskPageComponent` with a `loadingText` string. It will replace the Loading text in the scaffolder task page.
23
+ - Updated dependencies
24
+ - @backstage/core-components@0.8.8-next.0
25
+ - @backstage/plugin-catalog-react@0.6.14-next.0
26
+ - @backstage/integration-react@0.1.21-next.0
27
+
28
+ ## 0.12.1
29
+
30
+ ### Patch Changes
31
+
32
+ - ba59832aed: Permission the Register Existing Component button
33
+ - cee44ad289: Added the ability to collect users `oauth` token from the `RepoUrlPicker` for use in the template manifest
34
+ - a681cb9c2f: Make linkTarget configurable for MarkdownContent component
35
+ - Updated dependencies
36
+ - @backstage/core-components@0.8.7
37
+ - @backstage/plugin-catalog-react@0.6.13
38
+ - @backstage/plugin-catalog-common@0.1.2
39
+ - @backstage/integration-react@0.1.20
40
+
41
+ ## 0.12.1-next.1
42
+
43
+ ### Patch Changes
44
+
45
+ - ba59832aed: Permission the Register Existing Component button
46
+ - Updated dependencies
47
+ - @backstage/core-components@0.8.7-next.1
48
+ - @backstage/plugin-catalog-react@0.6.13-next.1
49
+ - @backstage/plugin-catalog-common@0.1.2-next.0
50
+
3
51
  ## 0.12.1-next.0
4
52
 
5
53
  ### Patch Changes
@@ -1,40 +1,30 @@
1
- import React, { useState, useCallback, useEffect, memo, useMemo } from 'react';
2
- import { useNavigate, Navigate, generatePath, useParams as useParams$1, useOutlet, Routes, Route } from 'react-router';
3
- import { Page, Header, Lifecycle, Content, ContentHeader, CreateButton, SupportButton, MarkdownContent, StructuredMetadataTable, InfoCard, Link, ErrorPage, LogViewer, Progress } from '@backstage/core-components';
4
- import { useRouteRef, useApi, errorApiRef, useApiHolder, useApp, useElementFilter } from '@backstage/core-plugin-api';
5
- import { EntityListProvider, EntitySearchBar, EntityKindPicker, UserListPicker, EntityTagPicker, entityRouteRef } from '@backstage/plugin-catalog-react';
6
- import { makeStyles, Stepper, Step, StepLabel, Typography, StepContent, Button, Paper, Box, LinearProgress, Grid, StepButton, CircularProgress, TableContainer, Table, TableHead, TableRow, TableCell, TableBody } from '@material-ui/core';
7
- import { E as EntityPicker, a as EntityNamePicker, e as entityNamePickerValidation, b as EntityTagsPicker, R as RepoUrlPicker, r as repoPickerValidation, O as OwnerPicker, c as OwnedEntityPicker, d as registerComponentRouteRef, T as TemplateTypePicker, f as TemplateList, s as scaffolderApiRef, g as rootRouteRef, F as FIELD_EXTENSION_WRAPPER_KEY, h as FIELD_EXTENSION_KEY } from './index-837d4328.esm.js';
1
+ import React, { useState, useContext, useCallback } from 'react';
2
+ import { useNavigate, Navigate, generatePath, useOutlet, Routes, Route } from 'react-router';
3
+ import { Page, Header, Lifecycle, Content, ContentHeader, CreateButton, SupportButton, MarkdownContent, StructuredMetadataTable, InfoCard, Progress, ErrorPage } from '@backstage/core-components';
4
+ import { useRouteRef, useApi, errorApiRef, useApiHolder, useElementFilter } from '@backstage/core-plugin-api';
5
+ import { EntityListProvider, EntitySearchBar, EntityKindPicker, UserListPicker, EntityTagPicker } from '@backstage/plugin-catalog-react';
6
+ import { makeStyles, Stepper, Step, StepLabel, Typography, StepContent, Button, Paper, Box, LinearProgress, TableContainer, Table, TableHead, TableRow, TableCell, TableBody } from '@material-ui/core';
7
+ import { E as EntityPicker, a as EntityNamePicker, e as entityNamePickerValidation, b as EntityTagsPicker, R as RepoUrlPicker, r as repoPickerValidation, O as OwnerPicker, c as OwnedEntityPicker, d as registerComponentRouteRef, T as TemplateTypePicker, f as TemplateList, S as SecretsContext, s as scaffolderApiRef, g as rootRouteRef, F as FIELD_EXTENSION_WRAPPER_KEY, h as FIELD_EXTENSION_KEY, i as SecretsContextProvider, j as TaskPage } from './index-71578268.esm.js';
8
+ import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common';
9
+ import { usePermission } from '@backstage/plugin-permission-react';
8
10
  import qs from 'qs';
9
11
  import { useParams } from 'react-router-dom';
10
12
  import useAsync from 'react-use/lib/useAsync';
11
13
  import { withTheme } from '@rjsf/core';
12
14
  import { Theme } from '@rjsf/material-ui';
13
- import Grid$1 from '@material-ui/core/Grid';
14
- import Step$1 from '@material-ui/core/Step';
15
- import StepLabel$1 from '@material-ui/core/StepLabel';
16
- import Stepper$1 from '@material-ui/core/Stepper';
17
- import { makeStyles as makeStyles$1, createStyles } from '@material-ui/core/styles';
18
- import Typography$1 from '@material-ui/core/Typography';
19
- import Cancel from '@material-ui/icons/Cancel';
20
- import Check from '@material-ui/icons/Check';
21
- import FiberManualRecordIcon from '@material-ui/icons/FiberManualRecord';
22
15
  import classNames from 'classnames';
23
- import { DateTime, Interval } from 'luxon';
24
- import useInterval from 'react-use/lib/useInterval';
25
- import { useImmerReducer } from 'use-immer';
26
- import { parseEntityName } from '@backstage/catalog-model';
27
- import LanguageIcon from '@material-ui/icons/Language';
28
16
  import '@backstage/errors';
29
17
  import 'zen-observable';
30
18
  import '@material-ui/core/FormControl';
31
19
  import '@material-ui/lab/Autocomplete';
20
+ import '@backstage/catalog-model';
32
21
  import 'react-use/lib/useEffectOnce';
33
22
  import '@material-ui/lab';
34
23
  import '@backstage/integration-react';
35
24
  import '@material-ui/core/FormHelperText';
36
25
  import '@material-ui/core/Input';
37
26
  import '@material-ui/core/InputLabel';
27
+ import 'react-use/lib/useDebounce';
38
28
  import '@material-ui/icons/Star';
39
29
  import '@material-ui/icons/StarBorder';
40
30
  import '@material-ui/icons/Warning';
@@ -42,6 +32,19 @@ import 'lodash/capitalize';
42
32
  import '@material-ui/icons/CheckBox';
43
33
  import '@material-ui/icons/CheckBoxOutlineBlank';
44
34
  import '@material-ui/icons/ExpandMore';
35
+ import '@material-ui/core/Grid';
36
+ import '@material-ui/core/Step';
37
+ import '@material-ui/core/StepLabel';
38
+ import '@material-ui/core/Stepper';
39
+ import '@material-ui/core/styles';
40
+ import '@material-ui/core/Typography';
41
+ import '@material-ui/icons/Cancel';
42
+ import '@material-ui/icons/Check';
43
+ import '@material-ui/icons/FiberManualRecord';
44
+ import 'luxon';
45
+ import 'react-use/lib/useInterval';
46
+ import 'use-immer';
47
+ import '@material-ui/icons/Language';
45
48
 
46
49
  const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [
47
50
  {
@@ -72,7 +75,7 @@ const DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS = [
72
75
  }
73
76
  ];
74
77
 
75
- const useStyles$3 = makeStyles((theme) => ({
78
+ const useStyles$1 = makeStyles((theme) => ({
76
79
  contentWrapper: {
77
80
  display: "grid",
78
81
  gridTemplateAreas: "'filters' 'grid'",
@@ -84,7 +87,7 @@ const ScaffolderPageContents = ({
84
87
  TemplateCardComponent,
85
88
  groups
86
89
  }) => {
87
- const styles = useStyles$3();
90
+ const styles = useStyles$1();
88
91
  const registerComponentLink = useRouteRef(registerComponentRouteRef);
89
92
  const otherTemplatesGroup = {
90
93
  title: groups ? "Other Templates" : "Templates",
@@ -93,6 +96,7 @@ const ScaffolderPageContents = ({
93
96
  return !filtered.some((result) => result === true);
94
97
  }
95
98
  };
99
+ const { allowed } = usePermission(catalogEntityCreatePermission);
96
100
  return /* @__PURE__ */ React.createElement(Page, {
97
101
  themeId: "home"
98
102
  }, /* @__PURE__ */ React.createElement(Header, {
@@ -103,7 +107,7 @@ const ScaffolderPageContents = ({
103
107
  subtitle: "Create new software components using standard templates"
104
108
  }), /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(ContentHeader, {
105
109
  title: "Available Templates"
106
- }, /* @__PURE__ */ React.createElement(CreateButton, {
110
+ }, allowed && /* @__PURE__ */ React.createElement(CreateButton, {
107
111
  title: "Register Existing Component",
108
112
  to: registerComponentLink && registerComponentLink()
109
113
  }), /* @__PURE__ */ React.createElement(SupportButton, null, "Create new software components using standard templates. Different templates create different kinds of components (services, websites, documentation, ...).")), /* @__PURE__ */ React.createElement("div", {
@@ -399,6 +403,7 @@ const TemplatePage = ({
399
403
  customFieldExtensions = []
400
404
  }) => {
401
405
  const apiHolder = useApiHolder();
406
+ const secretsContext = useContext(SecretsContext);
402
407
  const errorApi = useApi(errorApiRef);
403
408
  const scaffolderApi = useApi(scaffolderApiRef);
404
409
  const { templateName } = useParams();
@@ -410,13 +415,17 @@ const TemplatePage = ({
410
415
  const query = qs.parse(window.location.search, {
411
416
  ignoreQueryPrefix: true
412
417
  });
413
- return (_a = query.formData) != null ? _a : {};
418
+ try {
419
+ return JSON.parse(query.formData);
420
+ } catch (e) {
421
+ return (_a = query.formData) != null ? _a : {};
422
+ }
414
423
  });
415
424
  const handleFormReset = () => setFormState({});
416
425
  const handleChange = useCallback((e) => setFormState(e.formData), [setFormState]);
417
426
  const handleCreate = async () => {
418
427
  var _a;
419
- const id = await scaffolderApi.scaffold(templateName, formState);
428
+ const id = await scaffolderApi.scaffold(templateName, formState, secretsContext == null ? void 0 : secretsContext.secrets);
420
429
  const formParams = qs.stringify({ formData: formState }, { addQueryPrefix: true });
421
430
  const newUrl = `${window.location.pathname}${formParams}`;
422
431
  (_a = window.history) == null ? void 0 : _a.replaceState(null, document.title, newUrl);
@@ -465,406 +474,6 @@ const TemplatePage = ({
465
474
  }))));
466
475
  };
467
476
 
468
- function reducer(draft, action) {
469
- var _a, _b, _c;
470
- switch (action.type) {
471
- case "INIT": {
472
- draft.steps = action.data.spec.steps.reduce((current, next) => {
473
- current[next.id] = { status: "open", id: next.id };
474
- return current;
475
- }, {});
476
- draft.stepLogs = action.data.spec.steps.reduce((current, next) => {
477
- current[next.id] = [];
478
- return current;
479
- }, {});
480
- draft.loading = false;
481
- draft.error = void 0;
482
- draft.completed = false;
483
- draft.task = action.data;
484
- return;
485
- }
486
- case "LOGS": {
487
- const entries = action.data;
488
- for (const entry of entries) {
489
- const logLine = `${entry.createdAt} ${entry.body.message}`;
490
- if (!entry.body.stepId || !((_a = draft.steps) == null ? void 0 : _a[entry.body.stepId])) {
491
- continue;
492
- }
493
- const currentStepLog = (_b = draft.stepLogs) == null ? void 0 : _b[entry.body.stepId];
494
- const currentStep = (_c = draft.steps) == null ? void 0 : _c[entry.body.stepId];
495
- if (entry.body.status && entry.body.status !== currentStep.status) {
496
- currentStep.status = entry.body.status;
497
- if (currentStep.status === "processing") {
498
- currentStep.startedAt = entry.createdAt;
499
- }
500
- if (["cancelled", "failed", "completed"].includes(currentStep.status)) {
501
- currentStep.endedAt = entry.createdAt;
502
- }
503
- }
504
- currentStepLog == null ? void 0 : currentStepLog.push(logLine);
505
- }
506
- return;
507
- }
508
- case "COMPLETED": {
509
- draft.completed = true;
510
- draft.output = action.data.body.output;
511
- return;
512
- }
513
- case "ERROR": {
514
- draft.error = action.data;
515
- draft.loading = false;
516
- draft.completed = true;
517
- return;
518
- }
519
- default:
520
- return;
521
- }
522
- }
523
- const useTaskEventStream = (taskId) => {
524
- const scaffolderApi = useApi(scaffolderApiRef);
525
- const [state, dispatch] = useImmerReducer(reducer, {
526
- loading: true,
527
- completed: false,
528
- stepLogs: {},
529
- steps: {}
530
- });
531
- useEffect(() => {
532
- let didCancel = false;
533
- let subscription;
534
- let logPusher;
535
- scaffolderApi.getTask(taskId).then((task) => {
536
- if (didCancel) {
537
- return;
538
- }
539
- dispatch({ type: "INIT", data: task });
540
- const observable = scaffolderApi.streamLogs({ taskId });
541
- const collectedLogEvents = new Array();
542
- function emitLogs() {
543
- if (collectedLogEvents.length) {
544
- const logs = collectedLogEvents.splice(0, collectedLogEvents.length);
545
- dispatch({ type: "LOGS", data: logs });
546
- }
547
- }
548
- logPusher = setInterval(emitLogs, 500);
549
- subscription = observable.subscribe({
550
- next: (event) => {
551
- switch (event.type) {
552
- case "log":
553
- return collectedLogEvents.push(event);
554
- case "completion":
555
- emitLogs();
556
- dispatch({ type: "COMPLETED", data: event });
557
- return void 0;
558
- default:
559
- throw new Error(`Unhandled event type ${event.type} in observer`);
560
- }
561
- },
562
- error: (error) => {
563
- emitLogs();
564
- dispatch({ type: "ERROR", data: error });
565
- }
566
- });
567
- }, (error) => {
568
- if (!didCancel) {
569
- dispatch({ type: "ERROR", data: error });
570
- }
571
- });
572
- return () => {
573
- didCancel = true;
574
- if (subscription) {
575
- subscription.unsubscribe();
576
- }
577
- if (logPusher) {
578
- clearInterval(logPusher);
579
- }
580
- };
581
- }, [scaffolderApi, dispatch, taskId]);
582
- return state;
583
- };
584
-
585
- const useStyles$2 = makeStyles({
586
- svgIcon: {
587
- display: "inline-block",
588
- "& svg": {
589
- display: "inline-block",
590
- fontSize: "inherit",
591
- verticalAlign: "baseline"
592
- }
593
- }
594
- });
595
- const IconLink = (props) => {
596
- const { href, text, Icon, ...linkProps } = props;
597
- const classes = useStyles$2();
598
- return /* @__PURE__ */ React.createElement(Grid, {
599
- container: true,
600
- direction: "row",
601
- spacing: 1
602
- }, /* @__PURE__ */ React.createElement(Grid, {
603
- item: true
604
- }, /* @__PURE__ */ React.createElement(Typography, {
605
- component: "div",
606
- className: classes.svgIcon
607
- }, Icon ? /* @__PURE__ */ React.createElement(Icon, null) : /* @__PURE__ */ React.createElement(LanguageIcon, null))), /* @__PURE__ */ React.createElement(Grid, {
608
- item: true
609
- }, /* @__PURE__ */ React.createElement(Link, {
610
- to: href,
611
- ...linkProps
612
- }, text || href)));
613
- };
614
-
615
- const TaskPageLinks = ({ output }) => {
616
- const { entityRef: entityRefOutput, remoteUrl } = output;
617
- let { links = [] } = output;
618
- const app = useApp();
619
- const entityRoute = useRouteRef(entityRouteRef);
620
- const iconResolver = (key) => {
621
- var _a;
622
- return key ? (_a = app.getSystemIcon(key)) != null ? _a : LanguageIcon : LanguageIcon;
623
- };
624
- if (remoteUrl) {
625
- links = [{ url: remoteUrl, title: "Repo" }, ...links];
626
- }
627
- if (entityRefOutput) {
628
- links = [
629
- {
630
- entityRef: entityRefOutput,
631
- title: "Open in catalog",
632
- icon: "catalog"
633
- },
634
- ...links
635
- ];
636
- }
637
- return /* @__PURE__ */ React.createElement(Box, {
638
- px: 3,
639
- pb: 3
640
- }, links.filter(({ url, entityRef }) => url || entityRef).map(({ url, entityRef, title, icon }) => {
641
- if (entityRef) {
642
- const entityName = parseEntityName(entityRef);
643
- const target = entityRoute(entityName);
644
- return { title, icon, url: target };
645
- }
646
- return { title, icon, url };
647
- }).map(({ url, title, icon }, i) => /* @__PURE__ */ React.createElement(IconLink, {
648
- key: `output-link-${i}`,
649
- href: url,
650
- text: title != null ? title : url,
651
- Icon: iconResolver(icon),
652
- target: "_blank"
653
- })));
654
- };
655
-
656
- const humanizeDuration = require("humanize-duration");
657
- const useStyles$1 = makeStyles$1((theme) => createStyles({
658
- root: {
659
- width: "100%"
660
- },
661
- button: {
662
- marginBottom: theme.spacing(2),
663
- marginLeft: theme.spacing(2)
664
- },
665
- actionsContainer: {
666
- marginBottom: theme.spacing(2)
667
- },
668
- resetContainer: {
669
- padding: theme.spacing(3)
670
- },
671
- labelWrapper: {
672
- display: "flex",
673
- flex: 1,
674
- flexDirection: "row",
675
- justifyContent: "space-between"
676
- },
677
- stepWrapper: {
678
- width: "100%"
679
- }
680
- }));
681
- const StepTimeTicker = ({ step }) => {
682
- const [time, setTime] = useState("");
683
- useInterval(() => {
684
- if (!step.startedAt) {
685
- setTime("");
686
- return;
687
- }
688
- const end = step.endedAt ? DateTime.fromISO(step.endedAt) : DateTime.local();
689
- const startedAt = DateTime.fromISO(step.startedAt);
690
- const formatted = Interval.fromDateTimes(startedAt, end).toDuration().valueOf();
691
- setTime(humanizeDuration(formatted, { round: true }));
692
- }, 1e3);
693
- return /* @__PURE__ */ React.createElement(Typography$1, {
694
- variant: "caption"
695
- }, time);
696
- };
697
- const useStepIconStyles = makeStyles$1((theme) => createStyles({
698
- root: {
699
- color: theme.palette.text.disabled,
700
- display: "flex",
701
- height: 22,
702
- alignItems: "center"
703
- },
704
- completed: {
705
- color: theme.palette.status.ok
706
- },
707
- error: {
708
- color: theme.palette.status.error
709
- }
710
- }));
711
- function TaskStepIconComponent(props) {
712
- const classes = useStepIconStyles();
713
- const { active, completed, error } = props;
714
- const getMiddle = () => {
715
- if (active) {
716
- return /* @__PURE__ */ React.createElement(CircularProgress, {
717
- size: "24px"
718
- });
719
- }
720
- if (completed) {
721
- return /* @__PURE__ */ React.createElement(Check, null);
722
- }
723
- if (error) {
724
- return /* @__PURE__ */ React.createElement(Cancel, null);
725
- }
726
- return /* @__PURE__ */ React.createElement(FiberManualRecordIcon, null);
727
- };
728
- return /* @__PURE__ */ React.createElement("div", {
729
- className: classNames(classes.root, {
730
- [classes.completed]: completed,
731
- [classes.error]: error
732
- })
733
- }, getMiddle());
734
- }
735
- const TaskStatusStepper = memo(({
736
- steps,
737
- currentStepId,
738
- onUserStepChange
739
- }) => {
740
- const classes = useStyles$1();
741
- return /* @__PURE__ */ React.createElement("div", {
742
- className: classes.root
743
- }, /* @__PURE__ */ React.createElement(Stepper$1, {
744
- activeStep: steps.findIndex((s) => s.id === currentStepId),
745
- orientation: "vertical",
746
- nonLinear: true
747
- }, steps.map((step, index) => {
748
- const isCompleted = step.status === "completed";
749
- const isFailed = step.status === "failed";
750
- const isActive = step.status === "processing";
751
- const isSkipped = step.status === "skipped";
752
- return /* @__PURE__ */ React.createElement(Step$1, {
753
- key: String(index),
754
- expanded: true
755
- }, /* @__PURE__ */ React.createElement(StepButton, {
756
- onClick: () => onUserStepChange(step.id)
757
- }, /* @__PURE__ */ React.createElement(StepLabel$1, {
758
- StepIconProps: {
759
- completed: isCompleted,
760
- error: isFailed,
761
- active: isActive
762
- },
763
- StepIconComponent: TaskStepIconComponent,
764
- className: classes.stepWrapper
765
- }, /* @__PURE__ */ React.createElement("div", {
766
- className: classes.labelWrapper
767
- }, /* @__PURE__ */ React.createElement(Typography$1, {
768
- variant: "subtitle2"
769
- }, step.name), isSkipped ? /* @__PURE__ */ React.createElement(Typography$1, {
770
- variant: "caption"
771
- }, "Skipped") : /* @__PURE__ */ React.createElement(StepTimeTicker, {
772
- step
773
- })))));
774
- })));
775
- });
776
- const hasLinks = ({ entityRef, remoteUrl, links = [] }) => !!(entityRef || remoteUrl || links.length > 0);
777
- const TaskPage = () => {
778
- const classes = useStyles$1();
779
- const navigate = useNavigate();
780
- const rootLink = useRouteRef(rootRouteRef);
781
- const [userSelectedStepId, setUserSelectedStepId] = useState(void 0);
782
- const [lastActiveStepId, setLastActiveStepId] = useState(void 0);
783
- const { taskId } = useParams$1();
784
- const taskStream = useTaskEventStream(taskId);
785
- const completed = taskStream.completed;
786
- const steps = useMemo(() => {
787
- var _a, _b;
788
- return (_b = (_a = taskStream.task) == null ? void 0 : _a.spec.steps.map((step) => {
789
- var _a2;
790
- return {
791
- ...step,
792
- ...(_a2 = taskStream == null ? void 0 : taskStream.steps) == null ? void 0 : _a2[step.id]
793
- };
794
- })) != null ? _b : [];
795
- }, [taskStream]);
796
- useEffect(() => {
797
- var _a;
798
- const mostRecentFailedOrActiveStep = steps.find((step) => ["failed", "processing"].includes(step.status));
799
- if (completed && !mostRecentFailedOrActiveStep) {
800
- setLastActiveStepId((_a = steps[steps.length - 1]) == null ? void 0 : _a.id);
801
- return;
802
- }
803
- setLastActiveStepId(mostRecentFailedOrActiveStep == null ? void 0 : mostRecentFailedOrActiveStep.id);
804
- }, [steps, completed]);
805
- const currentStepId = userSelectedStepId != null ? userSelectedStepId : lastActiveStepId;
806
- const logAsString = useMemo(() => {
807
- if (!currentStepId) {
808
- return "Loading...";
809
- }
810
- const log = taskStream.stepLogs[currentStepId];
811
- if (!(log == null ? void 0 : log.length)) {
812
- return "Waiting for logs...";
813
- }
814
- return log.join("\n");
815
- }, [taskStream.stepLogs, currentStepId]);
816
- const taskNotFound = taskStream.completed === true && taskStream.loading === false && !taskStream.task;
817
- const { output } = taskStream;
818
- const handleStartOver = () => {
819
- var _a, _b;
820
- if (!taskStream.task || !((_b = (_a = taskStream.task) == null ? void 0 : _a.spec.metadata) == null ? void 0 : _b.name)) {
821
- navigate(generatePath(rootLink()));
822
- }
823
- const formData = taskStream.task.spec.apiVersion === "backstage.io/v1beta2" ? taskStream.task.spec.values : taskStream.task.spec.parameters;
824
- navigate(generatePath(`${rootLink()}/templates/:templateName?${qs.stringify({ formData })}`, {
825
- templateName: taskStream.task.spec.metadata.name
826
- }));
827
- };
828
- return /* @__PURE__ */ React.createElement(Page, {
829
- themeId: "home"
830
- }, /* @__PURE__ */ React.createElement(Header, {
831
- pageTitleOverride: `Task ${taskId}`,
832
- title: /* @__PURE__ */ React.createElement(React.Fragment, null, "Task Activity ", /* @__PURE__ */ React.createElement(Lifecycle, {
833
- alpha: true,
834
- shorthand: true
835
- })),
836
- subtitle: `Activity for task: ${taskId}`
837
- }), /* @__PURE__ */ React.createElement(Content, null, taskNotFound ? /* @__PURE__ */ React.createElement(ErrorPage, {
838
- status: "404",
839
- statusMessage: "Task not found",
840
- additionalInfo: "No task found with this ID"
841
- }) : /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Grid$1, {
842
- container: true
843
- }, /* @__PURE__ */ React.createElement(Grid$1, {
844
- item: true,
845
- xs: 3
846
- }, /* @__PURE__ */ React.createElement(Paper, null, /* @__PURE__ */ React.createElement(TaskStatusStepper, {
847
- steps,
848
- currentStepId,
849
- onUserStepChange: setUserSelectedStepId
850
- }), output && hasLinks(output) && /* @__PURE__ */ React.createElement(TaskPageLinks, {
851
- output
852
- }), /* @__PURE__ */ React.createElement(Button, {
853
- className: classes.button,
854
- onClick: handleStartOver,
855
- disabled: !completed,
856
- variant: "contained",
857
- color: "primary"
858
- }, "Start Over"))), /* @__PURE__ */ React.createElement(Grid$1, {
859
- item: true,
860
- xs: 9
861
- }, /* @__PURE__ */ React.createElement("div", {
862
- style: { height: "80vh" }
863
- }, /* @__PURE__ */ React.createElement(LogViewer, {
864
- text: logAsString
865
- })))))));
866
- };
867
-
868
477
  const useStyles = makeStyles((theme) => ({
869
478
  code: {
870
479
  fontFamily: "Menlo, monospace",
@@ -973,8 +582,13 @@ const ActionsPage = () => {
973
582
  }), /* @__PURE__ */ React.createElement(Content, null, items));
974
583
  };
975
584
 
976
- const Router = ({ TemplateCardComponent, groups }) => {
585
+ const Router = ({
586
+ TemplateCardComponent,
587
+ TaskPageComponent,
588
+ groups
589
+ }) => {
977
590
  const outlet = useOutlet();
591
+ const TaskPageElement = TaskPageComponent || TaskPage;
978
592
  const customFieldExtensions = useElementFilter(outlet, (elements) => elements.selectByComponentData({
979
593
  key: FIELD_EXTENSION_WRAPPER_KEY
980
594
  }).findComponentData({
@@ -992,12 +606,12 @@ const Router = ({ TemplateCardComponent, groups }) => {
992
606
  })
993
607
  }), /* @__PURE__ */ React.createElement(Route, {
994
608
  path: "/templates/:templateName",
995
- element: /* @__PURE__ */ React.createElement(TemplatePage, {
609
+ element: /* @__PURE__ */ React.createElement(SecretsContextProvider, null, /* @__PURE__ */ React.createElement(TemplatePage, {
996
610
  customFieldExtensions: fieldExtensions
997
- })
611
+ }))
998
612
  }), /* @__PURE__ */ React.createElement(Route, {
999
613
  path: "/tasks/:taskId",
1000
- element: /* @__PURE__ */ React.createElement(TaskPage, null)
614
+ element: /* @__PURE__ */ React.createElement(TaskPageElement, null)
1001
615
  }), /* @__PURE__ */ React.createElement(Route, {
1002
616
  path: "/actions",
1003
617
  element: /* @__PURE__ */ React.createElement(ActionsPage, null)
@@ -1005,4 +619,4 @@ const Router = ({ TemplateCardComponent, groups }) => {
1005
619
  };
1006
620
 
1007
621
  export { Router };
1008
- //# sourceMappingURL=Router-9da81048.esm.js.map
622
+ //# sourceMappingURL=Router-5df57206.esm.js.map