@backstage/plugin-scaffolder-react 1.8.6-next.0 → 1.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +1378 -7
  2. package/alpha/package.json +1 -1
  3. package/dist/hooks/useEventStream.esm.js +5 -4
  4. package/dist/hooks/useEventStream.esm.js.map +1 -1
  5. package/dist/next/components/Form/Form.esm.js +20 -16
  6. package/dist/next/components/Form/Form.esm.js.map +1 -1
  7. package/dist/next/components/ReviewState/ReviewState.esm.js +2 -1
  8. package/dist/next/components/ReviewState/ReviewState.esm.js.map +1 -1
  9. package/dist/next/components/ScaffolderField/ScaffolderField.esm.js +0 -1
  10. package/dist/next/components/ScaffolderField/ScaffolderField.esm.js.map +1 -1
  11. package/dist/next/components/Stepper/Stepper.esm.js +8 -6
  12. package/dist/next/components/Stepper/Stepper.esm.js.map +1 -1
  13. package/dist/next/components/Stepper/createAsyncValidators.esm.js +2 -1
  14. package/dist/next/components/Stepper/createAsyncValidators.esm.js.map +1 -1
  15. package/dist/next/components/Stepper/utils.esm.js +2 -1
  16. package/dist/next/components/Stepper/utils.esm.js.map +1 -1
  17. package/dist/next/components/TaskSteps/TaskSteps.esm.js +3 -2
  18. package/dist/next/components/TaskSteps/TaskSteps.esm.js.map +1 -1
  19. package/dist/next/components/TemplateCard/CardHeader.esm.js +1 -1
  20. package/dist/next/components/TemplateCard/CardHeader.esm.js.map +1 -1
  21. package/dist/next/components/TemplateCard/TemplateCard.esm.js +11 -7
  22. package/dist/next/components/TemplateCard/TemplateCard.esm.js.map +1 -1
  23. package/dist/next/components/TemplateGroups/TemplateGroups.esm.js +3 -2
  24. package/dist/next/components/TemplateGroups/TemplateGroups.esm.js.map +1 -1
  25. package/dist/next/components/TemplateOutputs/DefaultTemplateOutputs.esm.js +8 -4
  26. package/dist/next/components/TemplateOutputs/DefaultTemplateOutputs.esm.js.map +1 -1
  27. package/dist/next/components/TemplateOutputs/LinkOutputs.esm.js +4 -1
  28. package/dist/next/components/TemplateOutputs/LinkOutputs.esm.js.map +1 -1
  29. package/dist/next/components/TemplateOutputs/TextOutputs.esm.js +5 -2
  30. package/dist/next/components/TemplateOutputs/TextOutputs.esm.js.map +1 -1
  31. package/dist/next/components/Workflow/Workflow.esm.js +5 -3
  32. package/dist/next/components/Workflow/Workflow.esm.js.map +1 -1
  33. package/dist/next/hooks/useFilteredSchemaProperties.esm.js +3 -2
  34. package/dist/next/hooks/useFilteredSchemaProperties.esm.js.map +1 -1
  35. package/dist/next/hooks/useTemplateSchema.esm.js +7 -4
  36. package/dist/next/hooks/useTemplateSchema.esm.js.map +1 -1
  37. package/dist/next/hooks/useTemplateTimeSaved.esm.js +2 -1
  38. package/dist/next/hooks/useTemplateTimeSaved.esm.js.map +1 -1
  39. package/dist/next/hooks/useTransformSchemaToProps.esm.js +4 -3
  40. package/dist/next/hooks/useTransformSchemaToProps.esm.js.map +1 -1
  41. package/dist/next/lib/schema.esm.js +2 -1
  42. package/dist/next/lib/schema.esm.js.map +1 -1
  43. package/dist/secrets/SecretsContext.esm.js +2 -1
  44. package/dist/secrets/SecretsContext.esm.js.map +1 -1
  45. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateCard.esm.js","sources":["../../../../src/next/components/TemplateCard/TemplateCard.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 { RELATION_OWNED_BY } from '@backstage/catalog-model';\nimport { MarkdownContent, UserIcon } from '@backstage/core-components';\nimport {\n IconComponent,\n useAnalytics,\n useApp,\n} from '@backstage/core-plugin-api';\nimport {\n EntityRefLinks,\n getEntityRelations,\n} from '@backstage/plugin-catalog-react';\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport Box from '@material-ui/core/Box';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport CardContent from '@material-ui/core/CardContent';\nimport Chip from '@material-ui/core/Chip';\nimport Divider from '@material-ui/core/Divider';\nimport Button from '@material-ui/core/Button';\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles, Theme } from '@material-ui/core/styles';\nimport LanguageIcon from '@material-ui/icons/Language';\nimport React, { useCallback } from 'react';\nimport { CardHeader } from './CardHeader';\nimport { CardLink } from './CardLink';\n\nconst useStyles = makeStyles<Theme>(theme => ({\n box: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n display: '-webkit-box',\n '-webkit-line-clamp': 10,\n '-webkit-box-orient': 'vertical',\n },\n markdown: {\n /** to make the styles for React Markdown not leak into the description */\n '& :first-child': {\n margin: 0,\n },\n },\n label: {\n color: theme.palette.text.secondary,\n textTransform: 'uppercase',\n fontWeight: 'bold',\n letterSpacing: 0.5,\n lineHeight: 1,\n fontSize: '0.75rem',\n },\n footer: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: 1,\n alignItems: 'center',\n },\n ownedBy: {\n display: 'flex',\n alignItems: 'center',\n flex: 1,\n color: theme.palette.link,\n },\n}));\n\n/**\n * The Props for the {@link TemplateCard} component\n * @alpha\n */\nexport interface TemplateCardProps {\n template: TemplateEntityV1beta3;\n additionalLinks?: {\n icon: IconComponent;\n text: string;\n url: string;\n }[];\n\n onSelected?: (template: TemplateEntityV1beta3) => void;\n}\n\n/**\n * The `TemplateCard` component that is rendered in a list for each template\n * @alpha\n */\nexport const TemplateCard = (props: TemplateCardProps) => {\n const { onSelected, template } = props;\n const styles = useStyles();\n const analytics = useAnalytics();\n const ownedByRelations = getEntityRelations(template, RELATION_OWNED_BY);\n const app = useApp();\n const iconResolver = (key?: string): IconComponent =>\n key ? app.getSystemIcon(key) ?? LanguageIcon : LanguageIcon;\n const hasTags = !!template.metadata.tags?.length;\n const hasLinks =\n !!props.additionalLinks?.length || !!template.metadata.links?.length;\n const displayDefaultDivider = !hasTags && !hasLinks;\n\n const handleChoose = useCallback(() => {\n analytics.captureEvent('click', `Template has been opened`);\n onSelected?.(template);\n }, [analytics, onSelected, template]);\n\n return (\n <Card>\n <CardHeader template={template} />\n <CardContent>\n <Grid container spacing={2}>\n <Grid item xs={12}>\n <Box className={styles.box}>\n <MarkdownContent\n className={styles.markdown}\n content={template.metadata.description ?? 'No description'}\n />\n </Box>\n </Grid>\n {displayDefaultDivider && (\n <Grid item xs={12}>\n <Divider data-testid=\"template-card-separator\" />\n </Grid>\n )}\n {hasTags && (\n <>\n <Grid item xs={12}>\n <Divider data-testid=\"template-card-separator--tags\" />\n </Grid>\n <Grid item xs={12}>\n <Grid container spacing={2}>\n {template.metadata.tags?.map(tag => (\n <Grid key={`grid-${tag}`} item>\n <Chip\n style={{ margin: 0 }}\n size=\"small\"\n label={tag}\n key={tag}\n />\n </Grid>\n ))}\n </Grid>\n </Grid>\n </>\n )}\n {hasLinks && (\n <>\n <Grid item xs={12}>\n <Divider data-testid=\"template-card-separator--links\" />\n </Grid>\n <Grid item xs={12}>\n <Grid container spacing={2}>\n {props.additionalLinks?.map(({ icon, text, url }, index) => (\n <Grid className={styles.linkText} item xs={6} key={index}>\n <CardLink icon={icon} text={text} url={url} />\n </Grid>\n ))}\n {template.metadata.links?.map(\n ({ url, icon, title }, index) => (\n <Grid className={styles.linkText} item xs={6} key={index}>\n <CardLink\n icon={iconResolver(icon)}\n text={title || url}\n url={url}\n />\n </Grid>\n ),\n )}\n </Grid>\n </Grid>\n </>\n )}\n </Grid>\n </CardContent>\n <CardActions style={{ padding: '16px', flex: 1, alignItems: 'flex-end' }}>\n <div className={styles.footer}>\n <div className={styles.ownedBy}>\n {ownedByRelations.length > 0 && (\n <>\n <UserIcon fontSize=\"small\" />\n <EntityRefLinks\n style={{ marginLeft: '8px' }}\n entityRefs={ownedByRelations}\n defaultKind=\"Group\"\n hideIcons\n />\n </>\n )}\n </div>\n <Button\n size=\"small\"\n variant=\"outlined\"\n color=\"primary\"\n onClick={handleChoose}\n >\n Choose\n </Button>\n </div>\n </CardActions>\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA0CA,MAAM,SAAA,GAAY,WAAkB,CAAU,KAAA,MAAA;AAAA,EAC5C,GAAK,EAAA;AAAA,IACH,QAAU,EAAA,QAAA;AAAA,IACV,YAAc,EAAA,UAAA;AAAA,IACd,OAAS,EAAA,aAAA;AAAA,IACT,oBAAsB,EAAA,EAAA;AAAA,IACtB,oBAAsB,EAAA,UAAA;AAAA,GACxB;AAAA,EACA,QAAU,EAAA;AAAA;AAAA,IAER,gBAAkB,EAAA;AAAA,MAChB,MAAQ,EAAA,CAAA;AAAA,KACV;AAAA,GACF;AAAA,EACA,KAAO,EAAA;AAAA,IACL,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,SAAA;AAAA,IAC1B,aAAe,EAAA,WAAA;AAAA,IACf,UAAY,EAAA,MAAA;AAAA,IACZ,aAAe,EAAA,GAAA;AAAA,IACf,UAAY,EAAA,CAAA;AAAA,IACZ,QAAU,EAAA,SAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,OAAS,EAAA,MAAA;AAAA,IACT,cAAgB,EAAA,eAAA;AAAA,IAChB,IAAM,EAAA,CAAA;AAAA,IACN,UAAY,EAAA,QAAA;AAAA,GACd;AAAA,EACA,OAAS,EAAA;AAAA,IACP,OAAS,EAAA,MAAA;AAAA,IACT,UAAY,EAAA,QAAA;AAAA,IACZ,IAAM,EAAA,CAAA;AAAA,IACN,KAAA,EAAO,MAAM,OAAQ,CAAA,IAAA;AAAA,GACvB;AACF,CAAE,CAAA,CAAA,CAAA;AAqBW,MAAA,YA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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 { RELATION_OWNED_BY } from '@backstage/catalog-model';\nimport { MarkdownContent, UserIcon } from '@backstage/core-components';\nimport {\n IconComponent,\n useAnalytics,\n useApp,\n} from '@backstage/core-plugin-api';\nimport {\n EntityRefLinks,\n getEntityRelations,\n} from '@backstage/plugin-catalog-react';\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport Box from '@material-ui/core/Box';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport CardContent from '@material-ui/core/CardContent';\nimport Chip from '@material-ui/core/Chip';\nimport Divider from '@material-ui/core/Divider';\nimport Button from '@material-ui/core/Button';\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles, Theme } from '@material-ui/core/styles';\nimport LanguageIcon from '@material-ui/icons/Language';\nimport React, { useCallback } from 'react';\nimport { CardHeader } from './CardHeader';\nimport { CardLink } from './CardLink';\n\nconst useStyles = makeStyles<Theme>(theme => ({\n box: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n display: '-webkit-box',\n '-webkit-line-clamp': 10,\n '-webkit-box-orient': 'vertical',\n },\n markdown: {\n /** to make the styles for React Markdown not leak into the description */\n '& :first-child': {\n margin: 0,\n },\n },\n label: {\n color: theme.palette.text.secondary,\n textTransform: 'uppercase',\n fontWeight: 'bold',\n letterSpacing: 0.5,\n lineHeight: 1,\n fontSize: '0.75rem',\n },\n footer: {\n display: 'flex',\n justifyContent: 'space-between',\n flex: 1,\n alignItems: 'center',\n },\n ownedBy: {\n display: 'flex',\n alignItems: 'center',\n flex: 1,\n color: theme.palette.link,\n },\n}));\n\n/**\n * The Props for the {@link TemplateCard} component\n * @alpha\n */\nexport interface TemplateCardProps {\n template: TemplateEntityV1beta3;\n additionalLinks?: {\n icon: IconComponent;\n text: string;\n url: string;\n }[];\n\n onSelected?: (template: TemplateEntityV1beta3) => void;\n}\n\n/**\n * The `TemplateCard` component that is rendered in a list for each template\n * @alpha\n */\nexport const TemplateCard = (props: TemplateCardProps) => {\n const { onSelected, template } = props;\n const styles = useStyles();\n const analytics = useAnalytics();\n const ownedByRelations = getEntityRelations(template, RELATION_OWNED_BY);\n const app = useApp();\n const iconResolver = (key?: string): IconComponent =>\n key ? app.getSystemIcon(key) ?? LanguageIcon : LanguageIcon;\n const hasTags = !!template.metadata.tags?.length;\n const hasLinks =\n !!props.additionalLinks?.length || !!template.metadata.links?.length;\n const displayDefaultDivider = !hasTags && !hasLinks;\n\n const handleChoose = useCallback(() => {\n analytics.captureEvent('click', `Template has been opened`);\n onSelected?.(template);\n }, [analytics, onSelected, template]);\n\n return (\n <Card>\n <CardHeader template={template} />\n <CardContent>\n <Grid container spacing={2}>\n <Grid item xs={12}>\n <Box className={styles.box}>\n <MarkdownContent\n className={styles.markdown}\n content={template.metadata.description ?? 'No description'}\n />\n </Box>\n </Grid>\n {displayDefaultDivider && (\n <Grid item xs={12}>\n <Divider data-testid=\"template-card-separator\" />\n </Grid>\n )}\n {hasTags && (\n <>\n <Grid item xs={12}>\n <Divider data-testid=\"template-card-separator--tags\" />\n </Grid>\n <Grid item xs={12}>\n <Grid container spacing={2}>\n {template.metadata.tags?.map(tag => (\n <Grid key={`grid-${tag}`} item>\n <Chip\n style={{ margin: 0 }}\n size=\"small\"\n label={tag}\n key={tag}\n />\n </Grid>\n ))}\n </Grid>\n </Grid>\n </>\n )}\n {hasLinks && (\n <>\n <Grid item xs={12}>\n <Divider data-testid=\"template-card-separator--links\" />\n </Grid>\n <Grid item xs={12}>\n <Grid container spacing={2}>\n {props.additionalLinks?.map(({ icon, text, url }, index) => (\n <Grid className={styles.linkText} item xs={6} key={index}>\n <CardLink icon={icon} text={text} url={url} />\n </Grid>\n ))}\n {template.metadata.links?.map(\n ({ url, icon, title }, index) => (\n <Grid className={styles.linkText} item xs={6} key={index}>\n <CardLink\n icon={iconResolver(icon)}\n text={title || url}\n url={url}\n />\n </Grid>\n ),\n )}\n </Grid>\n </Grid>\n </>\n )}\n </Grid>\n </CardContent>\n <CardActions style={{ padding: '16px', flex: 1, alignItems: 'flex-end' }}>\n <div className={styles.footer}>\n <div className={styles.ownedBy}>\n {ownedByRelations.length > 0 && (\n <>\n <UserIcon fontSize=\"small\" />\n <EntityRefLinks\n style={{ marginLeft: '8px' }}\n entityRefs={ownedByRelations}\n defaultKind=\"Group\"\n hideIcons\n />\n </>\n )}\n </div>\n <Button\n size=\"small\"\n variant=\"outlined\"\n color=\"primary\"\n onClick={handleChoose}\n >\n Choose\n </Button>\n </div>\n </CardActions>\n </Card>\n );\n};\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;AA0CA,MAAM,SAAA,GAAY,WAAkB,CAAU,KAAA,MAAA;AAAA,EAC5C,GAAK,EAAA;AAAA,IACH,QAAU,EAAA,QAAA;AAAA,IACV,YAAc,EAAA,UAAA;AAAA,IACd,OAAS,EAAA,aAAA;AAAA,IACT,oBAAsB,EAAA,EAAA;AAAA,IACtB,oBAAsB,EAAA,UAAA;AAAA,GACxB;AAAA,EACA,QAAU,EAAA;AAAA;AAAA,IAER,gBAAkB,EAAA;AAAA,MAChB,MAAQ,EAAA,CAAA;AAAA,KACV;AAAA,GACF;AAAA,EACA,KAAO,EAAA;AAAA,IACL,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,SAAA;AAAA,IAC1B,aAAe,EAAA,WAAA;AAAA,IACf,UAAY,EAAA,MAAA;AAAA,IACZ,aAAe,EAAA,GAAA;AAAA,IACf,UAAY,EAAA,CAAA;AAAA,IACZ,QAAU,EAAA,SAAA;A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AA;AAAA,GAGN,CACF,CACF,CAEJ,CACF,mBACC,KAAA,CAAA,aAAA,CAAA,WAAA,EAAA,EAAY,KAAO,EAAA,EAAE,SAAS,MAAQ,EAAA,IAAA,EAAM,CAAG,EAAA,UAAA,EAAY,YAC1D,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAW,MAAO,CAAA,MAAA,EAAA,kBACpB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,WAAW,MAAO,CAAA,OAAA,EAAA,EACpB,gBAAiB,CAAA,MAAA,GAAS,qBAEvB,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,QAAA,EAAS,SAAQ,CAC3B,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,UAAA,EAAY,KAAM,EAAA;AAAA,MAC3B,UAAY,EAAA,gBAAA;AAAA,MACZ,WAAY,EAAA,OAAA;AAAA,MACZ,SAAS,EAAA,IAAA;AAAA,KAAA;AAAA,GAEb,CAEJ,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,IAAK,EAAA,OAAA;AAAA,MACL,OAAQ,EAAA,UAAA;AAAA,MACR,KAAM,EAAA,SAAA;AAAA,MACN,OAAS,EAAA,YAAA;AAAA,KAAA;AAAA,IACV,QAAA;AAAA,GAGH,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -12,7 +12,7 @@ const TemplateGroups = (props) => {
12
12
  const errorApi = useApi(errorApiRef);
13
13
  const onSelected = useCallback(
14
14
  (template) => {
15
- onTemplateSelected?.(template);
15
+ onTemplateSelected == null ? void 0 : onTemplateSelected(template);
16
16
  },
17
17
  [onTemplateSelected]
18
18
  );
@@ -28,7 +28,8 @@ const TemplateGroups = (props) => {
28
28
  }
29
29
  return /* @__PURE__ */ React.createElement(React.Fragment, null, groups.map(({ title, filter }, index) => {
30
30
  const templates = entities.filter(isTemplateEntityV1beta3).filter((e) => templateFilter ? templateFilter(e) : true).filter(filter).map((template) => {
31
- const additionalLinks = props.additionalLinksForEntity?.(template) ?? [];
31
+ var _a, _b;
32
+ const additionalLinks = (_b = (_a = props.additionalLinksForEntity) == null ? void 0 : _a.call(props, template)) != null ? _b : [];
32
33
  return {
33
34
  template,
34
35
  additionalLinks
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateGroups.esm.js","sources":["../../../../src/next/components/TemplateGroups/TemplateGroups.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useCallback } from 'react';\n\nimport { useEntityList } from '@backstage/plugin-catalog-react';\nimport {\n isTemplateEntityV1beta3,\n TemplateEntityV1beta3,\n} from '@backstage/plugin-scaffolder-common';\nimport { Progress, Link } from '@backstage/core-components';\nimport Typography from '@material-ui/core/Typography';\nimport { errorApiRef, IconComponent, useApi } from '@backstage/core-plugin-api';\nimport { TemplateGroupFilter } from '@backstage/plugin-scaffolder-react';\nimport { TemplateGroup } from '../TemplateGroup/TemplateGroup';\n\n/**\n * @alpha\n */\nexport interface TemplateGroupsProps {\n groups: TemplateGroupFilter[];\n templateFilter?: (entity: TemplateEntityV1beta3) => boolean;\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n onTemplateSelected?: (template: TemplateEntityV1beta3) => void;\n additionalLinksForEntity?: (template: TemplateEntityV1beta3) => {\n icon: IconComponent;\n text: string;\n url: string;\n }[];\n}\n\n/**\n * @alpha\n */\nexport const TemplateGroups = (props: TemplateGroupsProps) => {\n const { loading, error, entities } = useEntityList();\n const { groups, templateFilter, TemplateCardComponent, onTemplateSelected } =\n props;\n const errorApi = useApi(errorApiRef);\n const onSelected = useCallback(\n (template: TemplateEntityV1beta3) => {\n onTemplateSelected?.(template);\n },\n [onTemplateSelected],\n );\n\n if (loading) {\n return <Progress />;\n }\n\n if (error) {\n errorApi.post(error);\n return null;\n }\n\n if (!entities || !entities.length) {\n return (\n <Typography variant=\"body2\">\n No templates found that match your filter. Learn more about{' '}\n <Link to=\"https://backstage.io/docs/features/software-templates/adding-templates\">\n adding templates\n </Link>\n .\n </Typography>\n );\n }\n\n return (\n <>\n {groups.map(({ title, filter }, index) => {\n const templates = entities\n .filter(isTemplateEntityV1beta3)\n .filter(e => (templateFilter ? templateFilter(e) : true))\n .filter(filter)\n .map(template => {\n const additionalLinks =\n props.additionalLinksForEntity?.(template) ?? [];\n\n return {\n template,\n additionalLinks,\n };\n });\n\n return (\n <TemplateGroup\n key={index}\n templates={templates}\n title={title}\n components={{ CardComponent: TemplateCardComponent }}\n onSelected={onSelected}\n />\n );\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAgDa,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAA,MAAM,EAAE,OAAA,EAAS,KAAO,EAAA,QAAA,KAAa,aAAc,EAAA,CAAA;AACnD,EAAA,MAAM,EAAE,MAAA,EAAQ,cAAgB,EAAA,qBAAA,EAAuB,oBACrD,GAAA,KAAA,CAAA;AACF,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAA,MAAM,UAAa,GAAA,WAAA;AAAA,IACjB,CAAC,QAAoC,KAAA;AACnC,MAAA,kBAAA,GAAqB,QAAQ,CAAA,CAAA;AAAA,KAC/B;AAAA,IACA,CAAC,kBAAkB,CAAA;AAAA,GACrB,CAAA;AAEA,E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,OAAA;AAAA,KACF,CAAA;AAAA,GAEH,CACH,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TemplateGroups.esm.js","sources":["../../../../src/next/components/TemplateGroups/TemplateGroups.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, { useCallback } from 'react';\n\nimport { useEntityList } from '@backstage/plugin-catalog-react';\nimport {\n isTemplateEntityV1beta3,\n TemplateEntityV1beta3,\n} from '@backstage/plugin-scaffolder-common';\nimport { Progress, Link } from '@backstage/core-components';\nimport Typography from '@material-ui/core/Typography';\nimport { errorApiRef, IconComponent, useApi } from '@backstage/core-plugin-api';\nimport { TemplateGroupFilter } from '@backstage/plugin-scaffolder-react';\nimport { TemplateGroup } from '../TemplateGroup/TemplateGroup';\n\n/**\n * @alpha\n */\nexport interface TemplateGroupsProps {\n groups: TemplateGroupFilter[];\n templateFilter?: (entity: TemplateEntityV1beta3) => boolean;\n TemplateCardComponent?: React.ComponentType<{\n template: TemplateEntityV1beta3;\n }>;\n onTemplateSelected?: (template: TemplateEntityV1beta3) => void;\n additionalLinksForEntity?: (template: TemplateEntityV1beta3) => {\n icon: IconComponent;\n text: string;\n url: string;\n }[];\n}\n\n/**\n * @alpha\n */\nexport const TemplateGroups = (props: TemplateGroupsProps) => {\n const { loading, error, entities } = useEntityList();\n const { groups, templateFilter, TemplateCardComponent, onTemplateSelected } =\n props;\n const errorApi = useApi(errorApiRef);\n const onSelected = useCallback(\n (template: TemplateEntityV1beta3) => {\n onTemplateSelected?.(template);\n },\n [onTemplateSelected],\n );\n\n if (loading) {\n return <Progress />;\n }\n\n if (error) {\n errorApi.post(error);\n return null;\n }\n\n if (!entities || !entities.length) {\n return (\n <Typography variant=\"body2\">\n No templates found that match your filter. Learn more about{' '}\n <Link to=\"https://backstage.io/docs/features/software-templates/adding-templates\">\n adding templates\n </Link>\n .\n </Typography>\n );\n }\n\n return (\n <>\n {groups.map(({ title, filter }, index) => {\n const templates = entities\n .filter(isTemplateEntityV1beta3)\n .filter(e => (templateFilter ? templateFilter(e) : true))\n .filter(filter)\n .map(template => {\n const additionalLinks =\n props.additionalLinksForEntity?.(template) ?? [];\n\n return {\n template,\n additionalLinks,\n };\n });\n\n return (\n <TemplateGroup\n key={index}\n templates={templates}\n title={title}\n components={{ CardComponent: TemplateCardComponent }}\n onSelected={onSelected}\n />\n );\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAgDa,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAA,MAAM,EAAE,OAAA,EAAS,KAAO,EAAA,QAAA,KAAa,aAAc,EAAA,CAAA;AACnD,EAAA,MAAM,EAAE,MAAA,EAAQ,cAAgB,EAAA,qBAAA,EAAuB,oBACrD,GAAA,KAAA,CAAA;AACF,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA,CAAA;AACnC,EAAA,MAAM,UAAa,GAAA,WAAA;AAAA,IACjB,CAAC,QAAoC,KAAA;AACnC,MAAqB,kBAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,kBAAA,CAAA,QAAA,CAAA,CAAA;AAAA,KACvB;AAAA,IACA,CAAC,kBAAkB,CAAA;AAAA,GACrB,CAAA;AAEA,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,2CAAQ,QAAS,EAAA,IAAA,CAAA,CAAA;AAAA,GACnB;AAEA,EAAA,IAAI,KAAO,EAAA;AACT,IAAA,QAAA,CAAS,KAAK,KAAK,CAAA,CAAA;AACnB,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EA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;;;;"}
@@ -6,12 +6,13 @@ import { LinkOutputs } from './LinkOutputs.esm.js';
6
6
  import { TextOutputs } from './TextOutputs.esm.js';
7
7
 
8
8
  const DefaultTemplateOutputs = (props) => {
9
+ var _a, _b;
9
10
  const { output } = props;
10
11
  const [textOutputIndex, setTextOutputIndex] = useState(
11
12
  void 0
12
13
  );
13
14
  useEffect(() => {
14
- if (textOutputIndex === void 0 && output?.text) {
15
+ if (textOutputIndex === void 0 && (output == null ? void 0 : output.text)) {
15
16
  const defaultIndex = output.text.findIndex(
16
17
  (t) => t.default
17
18
  );
@@ -19,7 +20,10 @@ const DefaultTemplateOutputs = (props) => {
19
20
  }
20
21
  }, [textOutputIndex, output]);
21
22
  const textOutput = useMemo(
22
- () => textOutputIndex !== void 0 ? output?.text?.[textOutputIndex] : null,
23
+ () => {
24
+ var _a2;
25
+ return textOutputIndex !== void 0 ? (_a2 = output == null ? void 0 : output.text) == null ? void 0 : _a2[textOutputIndex] : null;
26
+ },
23
27
  [output, textOutputIndex]
24
28
  );
25
29
  if (!output) {
@@ -35,11 +39,11 @@ const DefaultTemplateOutputs = (props) => {
35
39
  ), /* @__PURE__ */ React.createElement(LinkOutputs, { output })))), textOutput ? /* @__PURE__ */ React.createElement(Box, { paddingBottom: 2 }, /* @__PURE__ */ React.createElement(
36
40
  InfoCard,
37
41
  {
38
- title: textOutput.title ?? "Text Output",
42
+ title: (_a = textOutput.title) != null ? _a : "Text Output",
39
43
  noPadding: true,
40
44
  titleTypographyProps: { component: "h2" }
41
45
  },
42
- /* @__PURE__ */ React.createElement(Box, { padding: 2, height: "100%" }, /* @__PURE__ */ React.createElement(MarkdownContent, { content: textOutput.content ?? "" }))
46
+ /* @__PURE__ */ React.createElement(Box, { padding: 2, height: "100%" }, /* @__PURE__ */ React.createElement(MarkdownContent, { content: (_b = textOutput.content) != null ? _b : "" }))
43
47
  )) : null);
44
48
  };
45
49
 
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultTemplateOutputs.esm.js","sources":["../../../../src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { InfoCard, MarkdownContent } from '@backstage/core-components';\nimport {\n ScaffolderOutputText,\n ScaffolderTaskOutput,\n} from '@backstage/plugin-scaffolder-react';\nimport Box from '@material-ui/core/Box';\nimport Paper from '@material-ui/core/Paper';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { LinkOutputs } from './LinkOutputs';\nimport { TextOutputs } from './TextOutputs';\n\n/**\n * The DefaultOutputs renderer for the scaffolder task output\n *\n * @alpha\n */\nexport const DefaultTemplateOutputs = (props: {\n output?: ScaffolderTaskOutput;\n}) => {\n const { output } = props;\n const [textOutputIndex, setTextOutputIndex] = useState<number | undefined>(\n undefined,\n );\n\n useEffect(() => {\n if (textOutputIndex === undefined && output?.text) {\n const defaultIndex = output.text.findIndex(\n (t: ScaffolderOutputText) => t.default,\n );\n setTextOutputIndex(defaultIndex >= 0 ? defaultIndex : 0);\n }\n }, [textOutputIndex, output]);\n\n const textOutput = useMemo(\n () =>\n textOutputIndex !== undefined ? output?.text?.[textOutputIndex] : null,\n [output, textOutputIndex],\n );\n\n if (!output) {\n return null;\n }\n\n return (\n <>\n <Box paddingBottom={2}>\n <Paper>\n <Box padding={2} justifyContent=\"center\" display=\"flex\" gridGap={16}>\n <TextOutputs\n output={output}\n index={textOutputIndex}\n setIndex={setTextOutputIndex}\n />\n <LinkOutputs output={output} />\n </Box>\n </Paper>\n </Box>\n {textOutput ? (\n <Box paddingBottom={2}>\n <InfoCard\n title={textOutput.title ?? 'Text Output'}\n noPadding\n titleTypographyProps={{ component: 'h2' }}\n >\n <Box padding={2} height=\"100%\">\n <MarkdownContent content={textOutput.content ?? ''} />\n </Box>\n </InfoCard>\n </Box>\n ) : null}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA+Ba,MAAA,sBAAA,GAAyB,CAAC,KAEjC,KAAA;AACJ,EAAM,MAAA,EAAE,QAAW,GAAA,KAAA,CAAA;AACnB,EAAM,MAAA,CAAC,eAAiB,EAAA,kBAAkB,CAAI,GAAA,QAAA;AAAA,IAC5C,KAAA,CAAA;AAAA,GACF,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,eAAA,KAAoB,KAAa,CAAA,IAAA,MAAA,EAAQ,IAAM,EAAA;AACjD,MAAM,MAAA,YAAA,GAAe,OAAO,IAAK,CAAA,SAAA;AAAA,QAC/B,CAAC,MAA4B,CAAE,CAAA,OAAA;AAAA,OACjC,CAAA;AACA,MAAmB,kBAAA,CAAA,YAAA,IAAgB,CAAI,GAAA,YAAA,GAAe,CAAC,CAAA,CAAA;AAAA,KACzD;AAAA,GACC,EAAA,CAAC,eAAiB,EAAA,MAAM,CAAC,CAAA,CAAA;AAE5B,EAAA,MAAM,UAAa,GAAA,OAAA;AAAA,IACjB,MACE,eAAoB,KAAA,KAAA,CAAA,GAAY,MAAQ,EAAA,IAAA,GAAO,eAAe,CAAI,GAAA,IAAA;AAAA,IACpE,CAAC,QAAQ,eAAe,CAAA;AAAA,GAC1B,CAAA;AAEA,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,iFAEK,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,aAAe,EAAA,CAAA,EAAA,sCACjB,KACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,GAAI,EAAA,EAAA,OAAA,EAAS,GAAG,cAAe,EAAA,QAAA,EAAS,OAAQ,EAAA,MAAA,EAAO,SAAS,EAC/D,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,KAAO,EAAA,eAAA;AAAA,MACP,QAAU,EAAA,kBAAA;AAAA,KAAA;AAAA,GAEZ,kBAAA,KAAA,CAAA,aAAA,CAAC,WAAY,EAAA,EAAA,MAAA,EAAgB,CAC/B,CACF,CACF,CAAA,EACC,UACC,mBAAA,KAAA,CAAA,aAAA,CAAC,GAAI,EAAA,EAAA,aAAA,EAAe,CAClB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,WAAW,KAAS,IAAA,aAAA;AAAA,MAC3B,SAAS,EAAA,IAAA;AAAA,MACT,oBAAA,EAAsB,EAAE,SAAA,EAAW,IAAK,EAAA;AAAA,KAAA;AAAA,oBAEvC,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,OAAS,EAAA,CAAA,EAAG,MAAO,EAAA,MAAA,EAAA,kBACrB,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,EAAgB,OAAS,EAAA,UAAA,CAAW,OAAW,IAAA,EAAA,EAAI,CACtD,CAAA;AAAA,GAEJ,IACE,IACN,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"DefaultTemplateOutputs.esm.js","sources":["../../../../src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { InfoCard, MarkdownContent } from '@backstage/core-components';\nimport {\n ScaffolderOutputText,\n ScaffolderTaskOutput,\n} from '@backstage/plugin-scaffolder-react';\nimport Box from '@material-ui/core/Box';\nimport Paper from '@material-ui/core/Paper';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { LinkOutputs } from './LinkOutputs';\nimport { TextOutputs } from './TextOutputs';\n\n/**\n * The DefaultOutputs renderer for the scaffolder task output\n *\n * @alpha\n */\nexport const DefaultTemplateOutputs = (props: {\n output?: ScaffolderTaskOutput;\n}) => {\n const { output } = props;\n const [textOutputIndex, setTextOutputIndex] = useState<number | undefined>(\n undefined,\n );\n\n useEffect(() => {\n if (textOutputIndex === undefined && output?.text) {\n const defaultIndex = output.text.findIndex(\n (t: ScaffolderOutputText) => t.default,\n );\n setTextOutputIndex(defaultIndex >= 0 ? defaultIndex : 0);\n }\n }, [textOutputIndex, output]);\n\n const textOutput = useMemo(\n () =>\n textOutputIndex !== undefined ? output?.text?.[textOutputIndex] : null,\n [output, textOutputIndex],\n );\n\n if (!output) {\n return null;\n }\n\n return (\n <>\n <Box paddingBottom={2}>\n <Paper>\n <Box padding={2} justifyContent=\"center\" display=\"flex\" gridGap={16}>\n <TextOutputs\n output={output}\n index={textOutputIndex}\n setIndex={setTextOutputIndex}\n />\n <LinkOutputs output={output} />\n </Box>\n </Paper>\n </Box>\n {textOutput ? (\n <Box paddingBottom={2}>\n <InfoCard\n title={textOutput.title ?? 'Text Output'}\n noPadding\n titleTypographyProps={{ component: 'h2' }}\n >\n <Box padding={2} height=\"100%\">\n <MarkdownContent content={textOutput.content ?? ''} />\n </Box>\n </InfoCard>\n </Box>\n ) : null}\n </>\n );\n};\n"],"names":["_a"],"mappings":";;;;;;;AA+Ba,MAAA,sBAAA,GAAyB,CAAC,KAEjC,KAAA;AAjCN,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAkCE,EAAM,MAAA,EAAE,QAAW,GAAA,KAAA,CAAA;AACnB,EAAM,MAAA,CAAC,eAAiB,EAAA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;AAAA,MACA,KAAO,EAAA,eAAA;AAAA,MACP,QAAU,EAAA,kBAAA;AAAA,KAAA;AAAA,GAEZ,kBAAA,KAAA,CAAA,aAAA,CAAC,WAAY,EAAA,EAAA,MAAA,EAAgB,CAC/B,CACF,CACF,CAAA,EACC,UACC,mBAAA,KAAA,CAAA,aAAA,CAAC,GAAI,EAAA,EAAA,aAAA,EAAe,CAClB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAA,CAAO,EAAW,GAAA,UAAA,CAAA,KAAA,KAAX,IAAoB,GAAA,EAAA,GAAA,aAAA;AAAA,MAC3B,SAAS,EAAA,IAAA;AAAA,MACT,oBAAA,EAAsB,EAAE,SAAA,EAAW,IAAK,EAAA;AAAA,KAAA;AAAA,oBAEvC,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,OAAS,EAAA,CAAA,EAAG,MAAO,EAAA,MAAA,EAAA,kBACrB,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,EAAgB,OAAS,EAAA,CAAA,EAAA,GAAA,UAAA,CAAW,OAAX,KAAA,IAAA,GAAA,EAAA,GAAsB,IAAI,CACtD,CAAA;AAAA,GAEJ,IACE,IACN,CAAA,CAAA;AAEJ;;;;"}
@@ -19,7 +19,10 @@ const LinkOutputs = (props) => {
19
19
  const classes = useStyles();
20
20
  const app = useApp();
21
21
  const entityRoute = useRouteRef(entityRouteRef);
22
- const iconResolver = (key) => app.getSystemIcon(key) ?? LinkIcon;
22
+ const iconResolver = (key) => {
23
+ var _a;
24
+ return (_a = app.getSystemIcon(key)) != null ? _a : LinkIcon;
25
+ };
23
26
  return /* @__PURE__ */ React.createElement(React.Fragment, null, links.filter(({ url, entityRef }) => url || entityRef).map(({ url, entityRef, title, icon }) => {
24
27
  if (entityRef) {
25
28
  const entityName = parseEntityRef(entityRef);
@@ -1 +1 @@
1
- {"version":3,"file":"LinkOutputs.esm.js","sources":["../../../../src/next/components/TemplateOutputs/LinkOutputs.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { IconComponent, useApp, useRouteRef } from '@backstage/core-plugin-api';\nimport { entityRouteRef } from '@backstage/plugin-catalog-react';\nimport Button from '@material-ui/core/Button';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React from 'react';\nimport LinkIcon from '@material-ui/icons/Link';\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Link } from '@backstage/core-components';\nimport { ScaffolderTaskOutput } from '../../../api';\n\nconst useStyles = makeStyles({\n root: {\n '&:hover': {\n textDecoration: 'none',\n },\n },\n});\n\nexport const LinkOutputs = (props: { output: ScaffolderTaskOutput }) => {\n const { links = [] } = props.output;\n const classes = useStyles();\n const app = useApp();\n const entityRoute = useRouteRef(entityRouteRef);\n\n const iconResolver = (key?: string): IconComponent =>\n app.getSystemIcon(key!) ?? LinkIcon;\n\n return (\n <>\n {links\n .filter(({ url, entityRef }) => url || entityRef)\n .map(({ url, entityRef, title, icon }) => {\n if (entityRef) {\n const entityName = parseEntityRef(entityRef);\n const target = entityRoute(entityName);\n return { title, icon, url: target };\n }\n return { title, icon, url: url! };\n })\n .map(({ url, title, icon }, i) => {\n const Icon = iconResolver(icon);\n return (\n <Link to={url} key={i} classes={{ root: classes.root }}>\n <Button startIcon={<Icon />} component=\"div\" color=\"primary\">\n {title}\n </Button>\n </Link>\n );\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAyBA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA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CAAA,MAAA,EAAA,EAAO,SAAW,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,IAAA,CAAA,EAAI,WAAU,KAAM,EAAA,KAAA,EAAM,SAChD,EAAA,EAAA,KACH,CACF,CAAA,CAAA;AAAA,GAEH,CACL,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"LinkOutputs.esm.js","sources":["../../../../src/next/components/TemplateOutputs/LinkOutputs.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { IconComponent, useApp, useRouteRef } from '@backstage/core-plugin-api';\nimport { entityRouteRef } from '@backstage/plugin-catalog-react';\nimport Button from '@material-ui/core/Button';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React from 'react';\nimport LinkIcon from '@material-ui/icons/Link';\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport { Link } from '@backstage/core-components';\nimport { ScaffolderTaskOutput } from '../../../api';\n\nconst useStyles = makeStyles({\n root: {\n '&:hover': {\n textDecoration: 'none',\n },\n },\n});\n\nexport const LinkOutputs = (props: { output: ScaffolderTaskOutput }) => {\n const { links = [] } = props.output;\n const classes = useStyles();\n const app = useApp();\n const entityRoute = useRouteRef(entityRouteRef);\n\n const iconResolver = (key?: string): IconComponent =>\n app.getSystemIcon(key!) ?? LinkIcon;\n\n return (\n <>\n {links\n .filter(({ url, entityRef }) => url || entityRef)\n .map(({ url, entityRef, title, icon }) => {\n if (entityRef) {\n const entityName = parseEntityRef(entityRef);\n const target = entityRoute(entityName);\n return { title, icon, url: target };\n }\n return { title, icon, url: url! };\n })\n .map(({ url, title, icon }, i) => {\n const Icon = iconResolver(icon);\n return (\n <Link to={url} key={i} classes={{ root: classes.root }}>\n <Button startIcon={<Icon />} component=\"div\" color=\"primary\">\n {title}\n </Button>\n </Link>\n );\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAyBA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA,IACJ,SAAW,EAAA;AAAA,MACT,cAAgB,EAAA,MAAA;AAAA,KAClB;AAAA,GACF;AACF,CAAC,CAAA,CAAA;AAEY,MAAA,WAAA,GAAc,CAAC,KAA4C,KAAA;AACtE,EAAA,MAAM,EAAE,KAAA,GAAQ,EAAC,KAAM,KAAM,CAAA,MAAA,CAAA;AAC7B,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AACnB,EAAM,MAAA,WAAA,GAAc,YAAY,cAAc,CAAA,CAAA;AAE9C,EAAM,MAAA,YAAA,GAAe,CAAC,GAA6B,KAAA;AAvCrD,IAAA,IAAA,EAAA,CAAA;AAwCI,IAAI,OAAA,CAAA,EAAA,GAAA,GAAA,CAAA,aAAA,CAAc,GAAI,CAAA,KAAtB,IAA2B,GAAA,EAAA,GAAA,QAAA,CAAA;AAAA,GAAA,CAAA;AAE7B,EAAA,iEAEK,KACE,CAAA,MAAA,CAAO,CAAC,EAAE,GAAA,EAAK,WAAgB,KAAA,GAAA,IAAO,SAAS,CAAA,CAC/C,IAAI,CAAC,EAAE,KAAK,SAAW,EAAA,KAAA,EAAO,MAAW,KAAA;AACxC,IAAA,IAAI,SAAW,EAAA;AACb,MAAM,MAAA,UAAA,GAAa,eAAe,SAAS,CAAA,CAAA;AAC3C,MAAM,MAAA,MAAA,GAAS,YAAY,UAAU,CAAA,CAAA;AACrC,MAAA,OAAO,EAAE,KAAA,EAAO,IAAM,EAAA,GAAA,EAAK,MAAO,EAAA,CAAA;AAAA,KACpC;AACA,IAAO,OAAA,EAAE,KAAO,EAAA,IAAA,EAAM,GAAU,EAAA,CAAA;AAAA,GACjC,EACA,GAAI,CAAA,CAAC,EAAE,GAAK,EAAA,KAAA,EAAO,IAAK,EAAA,EAAG,CAAM,KAAA;AAChC,IAAM,MAAA,IAAA,GAAO,aAAa,IAAI,CAAA,CAAA;AAC9B,IACE,uBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,EAAI,EAAA,GAAA,EAAK,KAAK,CAAG,EAAA,OAAA,EAAS,EAAE,IAAA,EAAM,OAAQ,CAAA,IAAA,sBAC7C,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAO,SAAW,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,IAAA,CAAA,EAAI,WAAU,KAAM,EAAA,KAAA,EAAM,SAChD,EAAA,EAAA,KACH,CACF,CAAA,CAAA;AAAA,GAEH,CACL,CAAA,CAAA;AAEJ;;;;"}
@@ -10,7 +10,10 @@ const TextOutputs = (props) => {
10
10
  setIndex
11
11
  } = props;
12
12
  const app = useApp();
13
- const iconResolver = (key) => app.getSystemIcon(key) ?? DescriptionIcon;
13
+ const iconResolver = (key) => {
14
+ var _a;
15
+ return (_a = app.getSystemIcon(key)) != null ? _a : DescriptionIcon;
16
+ };
14
17
  return /* @__PURE__ */ React.createElement(React.Fragment, null, text.filter(({ content }) => content !== void 0).map(({ title, icon }, i) => {
15
18
  const Icon = iconResolver(icon);
16
19
  return /* @__PURE__ */ React.createElement(
@@ -22,7 +25,7 @@ const TextOutputs = (props) => {
22
25
  color: "primary",
23
26
  onClick: () => {
24
27
  if (index !== i) {
25
- setIndex?.(i);
28
+ setIndex == null ? void 0 : setIndex(i);
26
29
  }
27
30
  },
28
31
  variant: index === i ? "outlined" : void 0
@@ -1 +1 @@
1
- {"version":3,"file":"TextOutputs.esm.js","sources":["../../../../src/next/components/TemplateOutputs/TextOutputs.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { IconComponent, useApp } from '@backstage/core-plugin-api';\nimport Button from '@material-ui/core/Button';\nimport DescriptionIcon from '@material-ui/icons/Description';\nimport React from 'react';\nimport { ScaffolderTaskOutput } from '../../../api';\n\nexport const TextOutputs = (props: {\n output: ScaffolderTaskOutput;\n index?: number;\n setIndex?: (index: number | undefined) => void;\n}) => {\n const {\n output: { text = [] },\n index,\n setIndex,\n } = props;\n\n const app = useApp();\n\n const iconResolver = (key?: string): IconComponent =>\n app.getSystemIcon(key!) ?? DescriptionIcon;\n\n return (\n <>\n {text\n .filter(({ content }) => content !== undefined)\n .map(({ title, icon }, i) => {\n const Icon = iconResolver(icon);\n return (\n <Button\n key={i}\n startIcon={<Icon />}\n component=\"div\"\n color=\"primary\"\n onClick={() => {\n if (index !== i) {\n setIndex?.(i);\n }\n }}\n variant={index === i ? 'outlined' : undefined}\n >\n {title}\n </Button>\n );\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;AAqBa,MAAA,WAAA,GAAc,CAAC,KAItB,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA,EAAE,IAAO,GAAA,EAAG,EAAA;AAAA,IACpB,KAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AAEnB,EAAA,MAAM,eAAe,CAAC,GAAA,KACpB,GAAI,CAAA,aAAA,CAAc,GAAI,CAAK,IAAA,eAAA,CAAA;AAE7B,EAAA,iEAEK,IACE,CAAA,MAAA,CAAO,CAAC,EAAE,SAAc,KAAA,OAAA,KAAY,KAAS,CAAA,CAAA,CAC7C,IAAI,CAAC,EAAE,KAAO,EAAA,IAAA,IAAQ,CAAM,KAAA;AAC3B,IAAM,MAAA,IAAA,GAAO,aAAa,IAAI,CAAA,CAAA;AAC9B,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,CAAA;AAAA,QACL,SAAA,sCAAY,IAAK,EAAA,IAAA,CAAA;AAAA,QACjB,SAAU,EAAA,KAAA;AAAA,QACV,KAAM,EAAA,SAAA;AAAA,QACN,SAAS,MAAM;AACb,UAAA,IAAI,UAAU,CAAG,EAAA;AACf,YAAA,QAAA,GAAW,CAAC,CAAA,CAAA;AAAA,WACd;AAAA,SACF;AAAA,QACA,OAAA,EAAS,KAAU,KAAA,CAAA,GAAI,UAAa,GAAA,KAAA,CAAA;AAAA,OAAA;AAAA,MAEnC,KAAA;AAAA,KACH,CAAA;AAAA,GAEH,CACL,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TextOutputs.esm.js","sources":["../../../../src/next/components/TemplateOutputs/TextOutputs.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { IconComponent, useApp } from '@backstage/core-plugin-api';\nimport Button from '@material-ui/core/Button';\nimport DescriptionIcon from '@material-ui/icons/Description';\nimport React from 'react';\nimport { ScaffolderTaskOutput } from '../../../api';\n\nexport const TextOutputs = (props: {\n output: ScaffolderTaskOutput;\n index?: number;\n setIndex?: (index: number | undefined) => void;\n}) => {\n const {\n output: { text = [] },\n index,\n setIndex,\n } = props;\n\n const app = useApp();\n\n const iconResolver = (key?: string): IconComponent =>\n app.getSystemIcon(key!) ?? DescriptionIcon;\n\n return (\n <>\n {text\n .filter(({ content }) => content !== undefined)\n .map(({ title, icon }, i) => {\n const Icon = iconResolver(icon);\n return (\n <Button\n key={i}\n startIcon={<Icon />}\n component=\"div\"\n color=\"primary\"\n onClick={() => {\n if (index !== i) {\n setIndex?.(i);\n }\n }}\n variant={index === i ? 'outlined' : undefined}\n >\n {title}\n </Button>\n );\n })}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;AAqBa,MAAA,WAAA,GAAc,CAAC,KAItB,KAAA;AACJ,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA,EAAE,IAAO,GAAA,EAAG,EAAA;AAAA,IACpB,KAAA;AAAA,IACA,QAAA;AAAA,GACE,GAAA,KAAA,CAAA;AAEJ,EAAA,MAAM,MAAM,MAAO,EAAA,CAAA;AAEnB,EAAM,MAAA,YAAA,GAAe,CAAC,GAA6B,KAAA;AAlCrD,IAAA,IAAA,EAAA,CAAA;AAmCI,IAAI,OAAA,CAAA,EAAA,GAAA,GAAA,CAAA,aAAA,CAAc,GAAI,CAAA,KAAtB,IAA2B,GAAA,EAAA,GAAA,eAAA,CAAA;AAAA,GAAA,CAAA;AAE7B,EAAA,iEAEK,IACE,CAAA,MAAA,CAAO,CAAC,EAAE,SAAc,KAAA,OAAA,KAAY,KAAS,CAAA,CAAA,CAC7C,IAAI,CAAC,EAAE,KAAO,EAAA,IAAA,IAAQ,CAAM,KAAA;AAC3B,IAAM,MAAA,IAAA,GAAO,aAAa,IAAI,CAAA,CAAA;AAC9B,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,CAAA;AAAA,QACL,SAAA,sCAAY,IAAK,EAAA,IAAA,CAAA;AAAA,QACjB,SAAU,EAAA,KAAA;AAAA,QACV,KAAM,EAAA,SAAA;AAAA,QACN,SAAS,MAAM;AACb,UAAA,IAAI,UAAU,CAAG,EAAA;AACf,YAAW,QAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAA,CAAA,CAAA,CAAA;AAAA,WACb;AAAA,SACF;AAAA,QACA,OAAA,EAAS,KAAU,KAAA,CAAA,GAAI,UAAa,GAAA,KAAA,CAAA;AAAA,OAAA;AAAA,MAEnC,KAAA;AAAA,KACH,CAAA;AAAA,GAEH,CACL,CAAA,CAAA;AAEJ;;;;"}
@@ -21,6 +21,7 @@ const useStyles = makeStyles({
21
21
  }
22
22
  });
23
23
  const Workflow = (workflowProps) => {
24
+ var _a;
24
25
  const { title, description, namespace, templateName, onCreate, ...props } = workflowProps;
25
26
  const analytics = useAnalytics();
26
27
  const styles = useStyles();
@@ -35,9 +36,10 @@ const Workflow = (workflowProps) => {
35
36
  const minutesSaved = useTemplateTimeSavedMinutes(templateRef);
36
37
  const workflowOnCreate = useCallback(
37
38
  async (formState) => {
39
+ var _a2;
38
40
  onCreate(formState);
39
41
  const name = typeof formState.name === "string" ? formState.name : void 0;
40
- analytics.captureEvent("create", name ?? templateName ?? "unknown", {
42
+ analytics.captureEvent("create", (_a2 = name != null ? name : templateName) != null ? _a2 : "unknown", {
41
43
  value: minutesSaved
42
44
  });
43
45
  },
@@ -54,12 +56,12 @@ const Workflow = (workflowProps) => {
54
56
  return /* @__PURE__ */ React.createElement(Content, null, loading && /* @__PURE__ */ React.createElement(Progress, null), sortedManifest && /* @__PURE__ */ React.createElement(
55
57
  InfoCard,
56
58
  {
57
- title: title ?? sortedManifest.title,
59
+ title: title != null ? title : sortedManifest.title,
58
60
  subheader: /* @__PURE__ */ React.createElement(
59
61
  MarkdownContent,
60
62
  {
61
63
  className: styles.markdown,
62
- content: description ?? sortedManifest.description ?? "No description"
64
+ content: (_a = description != null ? description : sortedManifest.description) != null ? _a : "No description"
63
65
  }
64
66
  ),
65
67
  noPadding: true,
@@ -1 +1 @@
1
- {"version":3,"file":"Workflow.esm.js","sources":["../../../../src/next/components/Workflow/Workflow.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 React, { useCallback, useEffect } from 'react';\nimport {\n Content,\n InfoCard,\n MarkdownContent,\n Progress,\n} from '@backstage/core-components';\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { errorApiRef, useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport { useTemplateParameterSchema } from '../../hooks/useTemplateParameterSchema';\nimport { Stepper, type StepperProps } from '../Stepper/Stepper';\nimport { SecretsContextProvider } from '../../../secrets/SecretsContext';\nimport { useFilteredSchemaProperties } from '../../hooks/useFilteredSchemaProperties';\nimport { ReviewStepProps } from '@backstage/plugin-scaffolder-react';\nimport { useTemplateTimeSavedMinutes } from '../../hooks/useTemplateTimeSaved';\nimport { JsonValue } from '@backstage/types';\n\nconst useStyles = makeStyles({\n markdown: {\n /** to make the styles for React Markdown not leak into the description */\n '& :first-child': {\n marginTop: 0,\n },\n '& :last-child': {\n marginBottom: 0,\n },\n },\n});\n\n/**\n * @alpha\n */\nexport type WorkflowProps = {\n title?: string;\n description?: string;\n namespace: string;\n templateName: string;\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n };\n onError(error: Error | undefined): JSX.Element | null;\n} & Pick<\n StepperProps,\n | 'extensions'\n | 'formProps'\n | 'components'\n | 'onCreate'\n | 'initialState'\n | 'layouts'\n>;\n\n/**\n * @alpha\n */\nexport const Workflow = (workflowProps: WorkflowProps): JSX.Element | null => {\n const { title, description, namespace, templateName, onCreate, ...props } =\n workflowProps;\n\n const analytics = useAnalytics();\n const styles = useStyles();\n const templateRef = stringifyEntityRef({\n kind: 'Template',\n namespace: namespace,\n name: templateName,\n });\n\n const errorApi = useApi(errorApiRef);\n\n const { loading, manifest, error } = useTemplateParameterSchema(templateRef);\n\n const sortedManifest = useFilteredSchemaProperties(manifest);\n\n const minutesSaved = useTemplateTimeSavedMinutes(templateRef);\n\n const workflowOnCreate = useCallback(\n async (formState: Record<string, JsonValue>) => {\n onCreate(formState);\n\n const name =\n typeof formState.name === 'string' ? formState.name : undefined;\n analytics.captureEvent('create', name ?? templateName ?? 'unknown', {\n value: minutesSaved,\n });\n },\n [onCreate, analytics, templateName, minutesSaved],\n );\n\n useEffect(() => {\n if (error) {\n errorApi.post(new Error(`Failed to load template, ${error}`));\n }\n }, [error, errorApi]);\n\n if (error) {\n return props.onError(error);\n }\n\n return (\n <Content>\n {loading && <Progress />}\n {sortedManifest && (\n <InfoCard\n title={title ?? sortedManifest.title}\n subheader={\n <MarkdownContent\n className={styles.markdown}\n content={\n description ?? sortedManifest.description ?? 'No description'\n }\n />\n }\n noPadding\n titleTypographyProps={{ component: 'h2' }}\n >\n <Stepper\n manifest={sortedManifest}\n onCreate={workflowOnCreate}\n {...props}\n />\n </InfoCard>\n )}\n </Content>\n );\n};\n\n/**\n * @alpha\n */\nexport const EmbeddableWorkflow = (props: WorkflowProps) => (\n <SecretsContextProvider>\n <Workflow {...props} />\n </SecretsContextProvider>\n);\n"],"names":[],"mappings":";;;;;;;;;;;AAkCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,QAAU,EAAA;AAAA;AAAA,IAER,gBAAkB,EAAA;AAAA,MAChB,SAAW,EAAA,CAAA;AAAA,KACb;AAAA,IACA,eAAiB,EAAA;AAAA,MACf,YAAc,EAAA,CAAA;AAAA,KAChB;AAAA,GACF;AACF,CAAC,CAAA,CAAA;AA2BY,MAAA,QAAA,GAAW,CAAC,aAAqD,KAAA;AAC5E,EAAM,MA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AQ,CAAC,CAAA,CAAA;AAEpB,EAAA,IAAI,KAAO,EAAA;AACT,IAAO,OAAA,KAAA,CAAM,QAAQ,KAAK,CAAA,CAAA;AAAA,GAC5B;AAEA,EAAA,2CACG,OACE,EAAA,IAAA,EAAA,OAAA,oBAAY,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAS,GACrB,cACC,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,SAAS,cAAe,CAAA,KAAA;AAAA,MAC/B,SACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,eAAA;AAAA,QAAA;AAAA,UACC,WAAW,MAAO,CAAA,QAAA;AAAA,UAClB,OAAA,EACE,WAAe,IAAA,cAAA,CAAe,WAAe,IAAA,gBAAA;AAAA,SAAA;AAAA,OAEjD;AAAA,MAEF,SAAS,EAAA,IAAA;AAAA,MACT,oBAAA,EAAsB,EAAE,SAAA,EAAW,IAAK,EAAA;AAAA,KAAA;AAAA,oBAExC,KAAA,CAAA,aAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,QAAU,EAAA,cAAA;AAAA,QACV,QAAU,EAAA,gBAAA;AAAA,QACT,GAAG,KAAA;AAAA,OAAA;AAAA,KACN;AAAA,GAGN,CAAA,CAAA;AAEJ,EAAA;AAKa,MAAA,kBAAA,GAAqB,CAAC,KACjC,qBAAA,KAAA,CAAA,aAAA,CAAC,8CACE,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAU,GAAG,KAAA,EAAO,CACvB;;;;"}
1
+ {"version":3,"file":"Workflow.esm.js","sources":["../../../../src/next/components/Workflow/Workflow.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 React, { useCallback, useEffect } from 'react';\nimport {\n Content,\n InfoCard,\n MarkdownContent,\n Progress,\n} from '@backstage/core-components';\nimport { stringifyEntityRef } from '@backstage/catalog-model';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { errorApiRef, useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport { useTemplateParameterSchema } from '../../hooks/useTemplateParameterSchema';\nimport { Stepper, type StepperProps } from '../Stepper/Stepper';\nimport { SecretsContextProvider } from '../../../secrets/SecretsContext';\nimport { useFilteredSchemaProperties } from '../../hooks/useFilteredSchemaProperties';\nimport { ReviewStepProps } from '@backstage/plugin-scaffolder-react';\nimport { useTemplateTimeSavedMinutes } from '../../hooks/useTemplateTimeSaved';\nimport { JsonValue } from '@backstage/types';\n\nconst useStyles = makeStyles({\n markdown: {\n /** to make the styles for React Markdown not leak into the description */\n '& :first-child': {\n marginTop: 0,\n },\n '& :last-child': {\n marginBottom: 0,\n },\n },\n});\n\n/**\n * @alpha\n */\nexport type WorkflowProps = {\n title?: string;\n description?: string;\n namespace: string;\n templateName: string;\n components?: {\n ReviewStepComponent?: React.ComponentType<ReviewStepProps>;\n };\n onError(error: Error | undefined): JSX.Element | null;\n} & Pick<\n StepperProps,\n | 'extensions'\n | 'formProps'\n | 'components'\n | 'onCreate'\n | 'initialState'\n | 'layouts'\n>;\n\n/**\n * @alpha\n */\nexport const Workflow = (workflowProps: WorkflowProps): JSX.Element | null => {\n const { title, description, namespace, templateName, onCreate, ...props } =\n workflowProps;\n\n const analytics = useAnalytics();\n const styles = useStyles();\n const templateRef = stringifyEntityRef({\n kind: 'Template',\n namespace: namespace,\n name: templateName,\n });\n\n const errorApi = useApi(errorApiRef);\n\n const { loading, manifest, error } = useTemplateParameterSchema(templateRef);\n\n const sortedManifest = useFilteredSchemaProperties(manifest);\n\n const minutesSaved = useTemplateTimeSavedMinutes(templateRef);\n\n const workflowOnCreate = useCallback(\n async (formState: Record<string, JsonValue>) => {\n onCreate(formState);\n\n const name =\n typeof formState.name === 'string' ? formState.name : undefined;\n analytics.captureEvent('create', name ?? templateName ?? 'unknown', {\n value: minutesSaved,\n });\n },\n [onCreate, analytics, templateName, minutesSaved],\n );\n\n useEffect(() => {\n if (error) {\n errorApi.post(new Error(`Failed to load template, ${error}`));\n }\n }, [error, errorApi]);\n\n if (error) {\n return props.onError(error);\n }\n\n return (\n <Content>\n {loading && <Progress />}\n {sortedManifest && (\n <InfoCard\n title={title ?? sortedManifest.title}\n subheader={\n <MarkdownContent\n className={styles.markdown}\n content={\n description ?? sortedManifest.description ?? 'No description'\n }\n />\n }\n noPadding\n titleTypographyProps={{ component: 'h2' }}\n >\n <Stepper\n manifest={sortedManifest}\n onCreate={workflowOnCreate}\n {...props}\n />\n </InfoCard>\n )}\n </Content>\n );\n};\n\n/**\n * @alpha\n */\nexport const EmbeddableWorkflow = (props: WorkflowProps) => (\n <SecretsContextProvider>\n <Workflow {...props} />\n </SecretsContextProvider>\n);\n"],"names":["_a"],"mappings":";;;;;;;;;;;AAkCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,QAAU,EAAA;AAAA;AAAA,IAER,gBAAkB,EAAA;AAAA,MAChB,SAAW,EAAA,CAAA;AAAA,KACb;AAAA,IACA,eAAiB,EAAA;AAAA,MACf,YAAc,EAAA,CAAA;AAAA,KAChB;AAAA,GACF;AACF,CAAC,CAAA,CAAA;AA2BY,MAAA,QAAA,GAAW,CAAC,aAAqD,KAAA;AAvE9E,EAAA,IAAA,EAAA,CAAA;AAwEE,EAAM,MAAA,EAAE,OAAO,WAAa,EAAA,SAAA,EAAW,cAAc,QAAU,EAAA,GAAG,OAChE,GAAA,aAAA,CAAA;AAEF,EAAA,MAAM,YAAY,YAAa,EAAA,CAAA;AAC/B,EAAA,MAAM,SAAS,SAAU,EAAA,CAAA;AACzB,E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A,GAC5B;AAEA,EAAA,2CACG,OACE,EAAA,IAAA,EAAA,OAAA,oBAAY,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,IAAS,GACrB,cACC,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,wBAAS,cAAe,CAAA,KAAA;AAAA,MAC/B,SACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,eAAA;AAAA,QAAA;AAAA,UACC,WAAW,MAAO,CAAA,QAAA;AAAA,UAClB,OACE,EAAA,CAAA,EAAA,GAAA,WAAA,IAAA,IAAA,GAAA,WAAA,GAAe,cAAe,CAAA,WAAA,KAA9B,IAA6C,GAAA,EAAA,GAAA,gBAAA;AAAA,SAAA;AAAA,OAEjD;AAAA,MAEF,SAAS,EAAA,IAAA;AAAA,MACT,oBAAA,EAAsB,EAAE,SAAA,EAAW,IAAK,EAAA;AAAA,KAAA;AAAA,oBAExC,KAAA,CAAA,aAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,QAAU,EAAA,cAAA;AAAA,QACV,QAAU,EAAA,gBAAA;AAAA,QACT,GAAG,KAAA;AAAA,OAAA;AAAA,KACN;AAAA,GAGN,CAAA,CAAA;AAEJ,EAAA;AAKa,MAAA,kBAAA,GAAqB,CAAC,KACjC,qBAAA,KAAA,CAAA,aAAA,CAAC,8CACE,KAAA,CAAA,aAAA,CAAA,QAAA,EAAA,EAAU,GAAG,KAAA,EAAO,CACvB;;;;"}
@@ -7,10 +7,11 @@ const useFilteredSchemaProperties = (manifest) => {
7
7
  if (!manifest) {
8
8
  return void 0;
9
9
  }
10
- const filteredSteps = manifest?.steps.filter((step) => {
10
+ const filteredSteps = manifest == null ? void 0 : manifest.steps.filter((step) => {
11
11
  const featureFlag = step.schema[featureFlagKey];
12
12
  return typeof featureFlag !== "string" || featureFlagApi.isActive(featureFlag);
13
13
  }).map((step) => {
14
+ var _a;
14
15
  const filteredStep = cloneDeep(step);
15
16
  const removedPropertyKeys = [];
16
17
  if (filteredStep.schema.properties) {
@@ -30,7 +31,7 @@ const useFilteredSchemaProperties = (manifest) => {
30
31
  );
31
32
  filteredStep.schema.required = Array.isArray(
32
33
  filteredStep.schema.required
33
- ) ? filteredStep.schema.required?.filter(
34
+ ) ? (_a = filteredStep.schema.required) == null ? void 0 : _a.filter(
34
35
  (r) => !removedPropertyKeys.includes(r)
35
36
  ) : filteredStep.schema.required;
36
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useFilteredSchemaProperties.esm.js","sources":["../../../src/next/hooks/useFilteredSchemaProperties.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport cloneDeep from 'lodash/cloneDeep';\nimport { useApi, featureFlagsApiRef } from '@backstage/core-plugin-api';\nimport { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';\n\n/**\n * Returns manifest of software templates with steps without a featureFlag tag.\n * @alpha\n */\n\nexport const useFilteredSchemaProperties = (\n manifest: TemplateParameterSchema | undefined,\n): TemplateParameterSchema | undefined => {\n const featureFlagKey = 'backstage:featureFlag';\n const featureFlagApi = useApi(featureFlagsApiRef);\n\n if (!manifest) {\n return undefined;\n }\n\n const filteredSteps = manifest?.steps\n .filter(step => {\n const featureFlag = step.schema[featureFlagKey];\n return (\n typeof featureFlag !== 'string' || featureFlagApi.isActive(featureFlag)\n );\n })\n .map(step => {\n const filteredStep = cloneDeep(step);\n const removedPropertyKeys: Array<string> = [];\n if (filteredStep.schema.properties) {\n filteredStep.schema.properties = Object.fromEntries(\n Object.entries(filteredStep.schema.properties).filter(\n ([key, value]) => {\n if (value[featureFlagKey]) {\n if (featureFlagApi.isActive(value[featureFlagKey])) {\n return true;\n }\n\n removedPropertyKeys.push(key);\n return false;\n }\n return true;\n },\n ),\n );\n\n // remove the feature flag property key from required if they are not active\n filteredStep.schema.required = Array.isArray(\n filteredStep.schema.required,\n )\n ? filteredStep.schema.required?.filter(\n r => !removedPropertyKeys.includes(r as string),\n )\n : filteredStep.schema.required;\n }\n\n return filteredStep;\n });\n\n return { ...manifest, steps: filteredSteps };\n};\n"],"names":[],"mappings":";;;AAwBa,MAAA,2BAAA,GAA8B,CACzC,QACwC,KAAA;AACxC,EAAA,MAAM,cAAiB,GAAA,uBAAA,CAAA;AACvB,EAAM,MAAA,cAAA,GAAiB,OAAO,kBAAkB,CAAA,CAAA;AAEhD,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,aAAgB,GAAA,QAAA,EAAU,KAC7B,CAAA,MAAA,CAAO,CAAQ,IAAA,KAAA;AACd,IAAM,MAAA,WAAA,GAAc,IAAK,CAAA,MAAA,CAAO,cAAc,CAAA,CAAA;AAC9C,IAAA,OACE,OAAO,WAAA,KAAgB,QAAY,IAAA,cAAA,CAAe,SAAS,WAAW,CAAA,CAAA;AAAA,GAEzE,CACA,CAAA,GAAA,CAAI,CAAQ,IAAA,KAAA;AACX,IAAM,MAAA,YAAA,GAAe,UAAU,IAAI,CAAA,CAAA;AACnC,IAAA,MAAM,sBAAqC,EAAC,CAAA;AAC5C,IAAI,IAAA,YAAA,CAAa,OAAO,UAAY,EAAA;AAClC,MAAa,YAAA,CAAA,MAAA,CAAO,aAAa,MAAO,CAAA,WAAA;AAAA,QACtC,MAAO,CAAA,OAAA,CAAQ,YAAa,CAAA,MAAA,CAAO,UAAU,CAAE,CAAA,MAAA;AAAA,UAC7C,CAAC,CAAC,GAAK,EAAA,KAAK,CAAM,KAAA;AAChB,YAAI,IAAA,KAAA,CAAM,cAAc,CAAG,EAAA;AACzB,cAAA,IAAI,cAAe,CAAA,QAAA,CAAS,KAAM,CAAA,cAAc,CAAC,CAAG,EAAA;AAClD,gBAAO,OAAA,IAAA,CAAA;AAAA,eACT;AAEA,cAAA,mBAAA,CAAoB,KAAK,GAAG,CAAA,CAAA;AAC5B,cAAO,OAAA,KAAA,CAAA;AAAA,aACT;AACA,YAAO,OAAA,IAAA,CAAA;AAAA,WACT;AAAA,SACF;AAAA,OACF,CAAA;AAGA,MAAa,YAAA,CAAA,MAAA,CAAO,WAAW,KAAM,CAAA,OAAA;AAAA,QACnC,aAAa,MAAO,CAAA,QAAA;AAAA,OACtB,GACI,YAAa,CAAA,MAAA,CAAO,QAAU,EAAA,MAAA;AAAA,QAC5B,CAAK,CAAA,KAAA,CAAC,mBAAoB,CAAA,QAAA,CAAS,CAAW,CAAA;AAAA,OAChD,GACA,aAAa,MAAO,CAAA,QAAA,CAAA;AAAA,KAC1B;AAEA,IAAO,OAAA,YAAA,CAAA;AAAA,GACR,CAAA,CAAA;AAEH,EAAA,OAAO,EAAE,GAAG,QAAU,EAAA,KAAA,EAAO,aAAc,EAAA,CAAA;AAC7C;;;;"}
1
+ {"version":3,"file":"useFilteredSchemaProperties.esm.js","sources":["../../../src/next/hooks/useFilteredSchemaProperties.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport cloneDeep from 'lodash/cloneDeep';\nimport { useApi, featureFlagsApiRef } from '@backstage/core-plugin-api';\nimport { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';\n\n/**\n * Returns manifest of software templates with steps without a featureFlag tag.\n * @alpha\n */\n\nexport const useFilteredSchemaProperties = (\n manifest: TemplateParameterSchema | undefined,\n): TemplateParameterSchema | undefined => {\n const featureFlagKey = 'backstage:featureFlag';\n const featureFlagApi = useApi(featureFlagsApiRef);\n\n if (!manifest) {\n return undefined;\n }\n\n const filteredSteps = manifest?.steps\n .filter(step => {\n const featureFlag = step.schema[featureFlagKey];\n return (\n typeof featureFlag !== 'string' || featureFlagApi.isActive(featureFlag)\n );\n })\n .map(step => {\n const filteredStep = cloneDeep(step);\n const removedPropertyKeys: Array<string> = [];\n if (filteredStep.schema.properties) {\n filteredStep.schema.properties = Object.fromEntries(\n Object.entries(filteredStep.schema.properties).filter(\n ([key, value]) => {\n if (value[featureFlagKey]) {\n if (featureFlagApi.isActive(value[featureFlagKey])) {\n return true;\n }\n\n removedPropertyKeys.push(key);\n return false;\n }\n return true;\n },\n ),\n );\n\n // remove the feature flag property key from required if they are not active\n filteredStep.schema.required = Array.isArray(\n filteredStep.schema.required,\n )\n ? filteredStep.schema.required?.filter(\n r => !removedPropertyKeys.includes(r as string),\n )\n : filteredStep.schema.required;\n }\n\n return filteredStep;\n });\n\n return { ...manifest, steps: filteredSteps };\n};\n"],"names":[],"mappings":";;;AAwBa,MAAA,2BAAA,GAA8B,CACzC,QACwC,KAAA;AACxC,EAAA,MAAM,cAAiB,GAAA,uBAAA,CAAA;AACvB,EAAM,MAAA,cAAA,GAAiB,OAAO,kBAAkB,CAAA,CAAA;AAEhD,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,aAAgB,GAAA,QAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,QAAA,CAAU,KAC7B,CAAA,MAAA,CAAO,CAAQ,IAAA,KAAA;AACd,IAAM,MAAA,WAAA,GAAc,IAAK,CAAA,MAAA,CAAO,cAAc,CAAA,CAAA;AAC9C,IA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,CAAA;AAEF,EAAA,OAAO,EAAE,GAAG,QAAU,EAAA,KAAA,EAAO,aAAc,EAAA,CAAA;AAC7C;;;;"}
@@ -10,9 +10,11 @@ const useTemplateSchema = (manifest) => {
10
10
  ...extractSchemaFromStep(schema)
11
11
  }));
12
12
  const returningSteps = steps.filter((step) => {
13
- const stepFeatureFlag = step.uiSchema["ui:backstage"]?.featureFlag;
13
+ var _a;
14
+ const stepFeatureFlag = (_a = step.uiSchema["ui:backstage"]) == null ? void 0 : _a.featureFlag;
14
15
  return stepFeatureFlag ? featureFlags.isActive(stepFeatureFlag) : true;
15
16
  }).map((step) => {
17
+ var _a, _b, _c, _d;
16
18
  const strippedSchema = {
17
19
  ...step,
18
20
  schema: {
@@ -21,11 +23,12 @@ const useTemplateSchema = (manifest) => {
21
23
  title: void 0
22
24
  }
23
25
  };
24
- if (step.schema?.properties || !step.schema?.dependencies) {
26
+ if (((_a = step.schema) == null ? void 0 : _a.properties) || !((_b = step.schema) == null ? void 0 : _b.dependencies)) {
25
27
  strippedSchema.schema.properties = Object.fromEntries(
26
- Object.entries(step.schema?.properties ?? {}).filter(
28
+ Object.entries((_d = (_c = step.schema) == null ? void 0 : _c.properties) != null ? _d : {}).filter(
27
29
  ([key]) => {
28
- const stepFeatureFlag = step.uiSchema[key]?.["ui:backstage"]?.featureFlag;
30
+ var _a2, _b2;
31
+ const stepFeatureFlag = (_b2 = (_a2 = step.uiSchema[key]) == null ? void 0 : _a2["ui:backstage"]) == null ? void 0 : _b2.featureFlag;
29
32
  return stepFeatureFlag ? featureFlags.isActive(stepFeatureFlag) : true;
30
33
  }
31
34
  )
@@ -1 +1 @@
1
- {"version":3,"file":"useTemplateSchema.esm.js","sources":["../../../src/next/hooks/useTemplateSchema.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { featureFlagsApiRef, useApi } from '@backstage/core-plugin-api';\nimport { TemplatePresentationV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { JsonObject } from '@backstage/types';\nimport { UiSchema } from '@rjsf/utils';\nimport { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';\nimport { extractSchemaFromStep } from '../lib';\n\n/**\n * This is the parsed template schema that is returned from the {@link useTemplateSchema} hook.\n * @alpha\n */\nexport interface ParsedTemplateSchema {\n uiSchema: UiSchema;\n mergedSchema: JsonObject;\n schema: JsonObject;\n title: string;\n description?: string;\n}\n\n/**\n * This hook will parse the template schema and return the steps with the\n * parsed schema and uiSchema. Filtering out any steps or properties that\n * are not enabled with feature flags.\n * @alpha\n */\nexport const useTemplateSchema = (\n manifest: TemplateParameterSchema,\n): {\n steps: ParsedTemplateSchema[];\n presentation?: TemplatePresentationV1beta3;\n} => {\n const featureFlags = useApi(featureFlagsApiRef);\n const steps = manifest.steps.map(({ title, description, schema }) => ({\n title,\n description,\n mergedSchema: schema,\n ...extractSchemaFromStep(schema),\n }));\n\n const returningSteps = steps\n // Filter out steps that are not enabled with the feature flags\n .filter(step => {\n const stepFeatureFlag = step.uiSchema['ui:backstage']?.featureFlag;\n return stepFeatureFlag ? featureFlags.isActive(stepFeatureFlag) : true;\n })\n // Then filter out the properties that are not enabled with feature flag\n .map(step => {\n const strippedSchema = {\n ...step,\n schema: {\n ...step.schema,\n // Title is rendered at the top of the page, so let's ignore this from jsonschemaform\n title: undefined,\n },\n } as ParsedTemplateSchema;\n\n if (step.schema?.properties || !step.schema?.dependencies) {\n strippedSchema.schema.properties = Object.fromEntries(\n Object.entries((step.schema?.properties ?? {}) as JsonObject).filter(\n ([key]) => {\n const stepFeatureFlag =\n step.uiSchema[key]?.['ui:backstage']?.featureFlag;\n return stepFeatureFlag\n ? featureFlags.isActive(stepFeatureFlag)\n : true;\n },\n ),\n );\n }\n\n return strippedSchema;\n });\n\n return {\n presentation: manifest.presentation,\n steps: returningSteps,\n };\n};\n"],"names":[],"mappings":";;;AAwCa,MAAA,iBAAA,GAAoB,CAC/B,QAIG,KAAA;AACH,EAAM,MAAA,YAAA,GAAe,OAAO,kBAAkB,CAAA,CAAA;AAC9C,EAAM,MAAA,KAAA,GAAQ,SAAS,KAAM,CAAA,GAAA,CAAI,CAAC,EAAE,KAAA,EAAO,WAAa,EAAA,MAAA,EAAc,MAAA;AAAA,IACpE,KAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAc,EAAA,MAAA;AAAA,IACd,GAAG,sBAAsB,MAAM,CAAA;AAAA,GAC/B,CAAA,CAAA,CAAA;AAEF,EAAM,MAAA,cAAA,GAAiB,KAEpB,CAAA,MAAA,CAAO,CAAQ,IAAA,KAAA;AACd,IAAA,MAAM,eAAkB,GAAA,IAAA,CAAK,QAAS,CAAA,cAAc,CAAG,EAAA,WAAA,CAAA;AACvD,IAAA,OAAO,eAAkB,GAAA,YAAA,CAAa,QAAS,CAAA,eAAe,CAAI,GAAA,IAAA,CAAA;AAAA,GACnE,CAEA,CAAA,GAAA,CAAI,CAAQ,IAAA,KAAA;AACX,IAAA,MAAM,cAAiB,GAAA;AAAA,MACrB,GAAG,IAAA;AAAA,MACH,MAAQ,EAAA;AAAA,QACN,GAAG,IAAK,CAAA,MAAA;AAAA;AAAA,QAER,KAAO,EAAA,KAAA,CAAA;AAAA,OACT;AAAA,KACF,CAAA;AAEA,IAAA,IAAI,KAAK,MAAQ,EAAA,UAAA,IAAc,CAAC,IAAA,CAAK,QAAQ,YAAc,EAAA;AACzD,MAAe,cAAA,CAAA,MAAA,CAAO,aAAa,MAAO,CAAA,WAAA;AAAA,QACxC,OAAO,OAAS,CAAA,IAAA,CAAK,QAAQ,UAAc,IAAA,EAAiB,CAAE,CAAA,MAAA;AAAA,UAC5D,CAAC,CAAC,GAAG,CAAM,KAAA;AACT,YAAA,MAAM,kBACJ,IAAK,CAAA,QAAA,CAAS,GAAG,CAAA,GAAI,cAAc,CAAG,EAAA,WAAA,CAAA;AACxC,YAAA,OAAO,eACH,GAAA,YAAA,CAAa,QAAS,CAAA,eAAe,CACrC,GAAA,IAAA,CAAA;AAAA,WACN;AAAA,SACF;AAAA,OACF,CAAA;AAAA,KACF;AAEA,IAAO,OAAA,cAAA,CAAA;AAAA,GACR,CAAA,CAAA;AAEH,EAAO,OAAA;AAAA,IACL,cAAc,QAAS,CAAA,YAAA;AAAA,IACvB,KAAO,EAAA,cAAA;AAAA,GACT,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"useTemplateSchema.esm.js","sources":["../../../src/next/hooks/useTemplateSchema.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { featureFlagsApiRef, useApi } from '@backstage/core-plugin-api';\nimport { TemplatePresentationV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { JsonObject } from '@backstage/types';\nimport { UiSchema } from '@rjsf/utils';\nimport { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react';\nimport { extractSchemaFromStep } from '../lib';\n\n/**\n * This is the parsed template schema that is returned from the {@link useTemplateSchema} hook.\n * @alpha\n */\nexport interface ParsedTemplateSchema {\n uiSchema: UiSchema;\n mergedSchema: JsonObject;\n schema: JsonObject;\n title: string;\n description?: string;\n}\n\n/**\n * This hook will parse the template schema and return the steps with the\n * parsed schema and uiSchema. Filtering out any steps or properties that\n * are not enabled with feature flags.\n * @alpha\n */\nexport const useTemplateSchema = (\n manifest: TemplateParameterSchema,\n): {\n steps: ParsedTemplateSchema[];\n presentation?: TemplatePresentationV1beta3;\n} => {\n const featureFlags = useApi(featureFlagsApiRef);\n const steps = manifest.steps.map(({ title, description, schema }) => ({\n title,\n description,\n mergedSchema: schema,\n ...extractSchemaFromStep(schema),\n }));\n\n const returningSteps = steps\n // Filter out steps that are not enabled with the feature flags\n .filter(step => {\n const stepFeatureFlag = step.uiSchema['ui:backstage']?.featureFlag;\n return stepFeatureFlag ? featureFlags.isActive(stepFeatureFlag) : true;\n })\n // Then filter out the properties that are not enabled with feature flag\n .map(step => {\n const strippedSchema = {\n ...step,\n schema: {\n ...step.schema,\n // Title is rendered at the top of the page, so let's ignore this from jsonschemaform\n title: undefined,\n },\n } as ParsedTemplateSchema;\n\n if (step.schema?.properties || !step.schema?.dependencies) {\n strippedSchema.schema.properties = Object.fromEntries(\n Object.entries((step.schema?.properties ?? {}) as JsonObject).filter(\n ([key]) => {\n const stepFeatureFlag =\n step.uiSchema[key]?.['ui:backstage']?.featureFlag;\n return stepFeatureFlag\n ? featureFlags.isActive(stepFeatureFlag)\n : true;\n },\n ),\n );\n }\n\n return strippedSchema;\n });\n\n return {\n presentation: manifest.presentation,\n steps: returningSteps,\n };\n};\n"],"names":["_a","_b"],"mappings":";;;AAwCa,MAAA,iBAAA,GAAoB,CAC/B,QAIG,KAAA;AACH,EAAM,MAAA,YAAA,GAAe,OAAO,kBAAkB,CAAA,CAAA;AAC9C,EAAM,MAAA,KAAA,GAAQ,SAAS,KAAM,CAAA,GAAA,CAAI,CAAC,EAAE,KAAA,EAAO,WAAa,EAAA,MAAA,EAAc,MAAA;AAAA,IACpE,KAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAc,EAAA,MAAA;AAAA,IACd,GAAG,sBAAsB,MAAM,CAAA;AAAA,GAC/B,CAAA,CAAA,CAAA;AAEF,EAAM,MAAA,cAAA,GAAiB,KAEpB,C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,CAAAA,GAAAA,GAAAA,CAAqB,cAArB,CAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAAC,GAAsC,CAAA,WAAA,CAAA;AACxC,YAAA,OAAO,eACH,GAAA,YAAA,CAAa,QAAS,CAAA,eAAe,CACrC,GAAA,IAAA,CAAA;AAAA,WACN;AAAA,SACF;AAAA,OACF,CAAA;AAAA,KACF;AAEA,IAAO,OAAA,cAAA,CAAA;AAAA,GACR,CAAA,CAAA;AAEH,EAAO,OAAA;AAAA,IACL,cAAc,QAAS,CAAA,YAAA;AAAA,IACvB,KAAO,EAAA,cAAA;AAAA,GACT,CAAA;AACF;;;;"}
@@ -6,8 +6,9 @@ import useAsync from 'react-use/lib/useAsync';
6
6
  const useTemplateTimeSavedMinutes = (templateRef) => {
7
7
  const catalogApi = useApi(catalogApiRef);
8
8
  const { value: timeSavedMinutes } = useAsync(async () => {
9
+ var _a;
9
10
  const entity = await catalogApi.getEntityByRef(templateRef);
10
- const timeSaved = entity?.metadata.annotations?.["backstage.io/time-saved"];
11
+ const timeSaved = (_a = entity == null ? void 0 : entity.metadata.annotations) == null ? void 0 : _a["backstage.io/time-saved"];
11
12
  if (!entity || !timeSaved) {
12
13
  return void 0;
13
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTemplateTimeSaved.esm.js","sources":["../../../src/next/hooks/useTemplateTimeSaved.ts"],"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 { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { Duration } from 'luxon';\nimport useAsync from 'react-use/lib/useAsync';\n\n/**\n * Returns the backstage.io/time-saved annotation (as a number of minutes) for\n * a given template entity ref.\n */\nexport const useTemplateTimeSavedMinutes = (templateRef: string) => {\n const catalogApi = useApi(catalogApiRef);\n\n const { value: timeSavedMinutes } = useAsync(async () => {\n const entity = await catalogApi.getEntityByRef(templateRef);\n const timeSaved = entity?.metadata.annotations?.['backstage.io/time-saved'];\n\n // This is not a valid template or the template has no time-saved value.\n if (!entity || !timeSaved) {\n return undefined;\n }\n\n const durationMs = Duration.fromISO(timeSaved).as('minutes');\n\n // The time-saved annotation has an invalid value. Ignore.\n if (Number.isNaN(durationMs)) {\n return undefined;\n }\n\n return durationMs;\n }, [catalogApi, templateRef]);\n\n return timeSavedMinutes;\n};\n"],"names":[],"mappings":";;;;;AAyBa,MAAA,2BAAA,GAA8B,CAAC,WAAwB,KAAA;AAClE,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AAEvC,EAAA,MAAM,EAAE,KAAA,EAAO,gBAAiB,EAAA,GAAI,SAAS,YAAY;AACvD,IAAA,MAAM,MAAS,GAAA,MAAM,UAAW,CAAA,cAAA,CAAe,WAAW,CAAA,CAAA;AAC1D,IAAA,MAAM,SAAY,GAAA,MAAA,EAAQ,QAAS,CAAA,WAAA,GAAc,yBAAyB,CAAA,CAAA;AAG1E,IAAI,IAAA,CAAC,MAAU,IAAA,CAAC,SAAW,EAAA;AACzB,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACT;AAEA,IAAA,MAAM,aAAa,QAAS,CAAA,OAAA,CAAQ,SAAS,CAAA,CAAE,GAAG,SAAS,CAAA,CAAA;AAG3D,IAAI,IAAA,MAAA,CAAO,KAAM,CAAA,UAAU,CAAG,EAAA;AAC5B,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACT;AAEA,IAAO,OAAA,UAAA,CAAA;AAAA,GACN,EAAA,CAAC,UAAY,EAAA,WAAW,CAAC,CAAA,CAAA;AAE5B,EAAO,OAAA,gBAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"useTemplateTimeSaved.esm.js","sources":["../../../src/next/hooks/useTemplateTimeSaved.ts"],"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 { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { Duration } from 'luxon';\nimport useAsync from 'react-use/lib/useAsync';\n\n/**\n * Returns the backstage.io/time-saved annotation (as a number of minutes) for\n * a given template entity ref.\n */\nexport const useTemplateTimeSavedMinutes = (templateRef: string) => {\n const catalogApi = useApi(catalogApiRef);\n\n const { value: timeSavedMinutes } = useAsync(async () => {\n const entity = await catalogApi.getEntityByRef(templateRef);\n const timeSaved = entity?.metadata.annotations?.['backstage.io/time-saved'];\n\n // This is not a valid template or the template has no time-saved value.\n if (!entity || !timeSaved) {\n return undefined;\n }\n\n const durationMs = Duration.fromISO(timeSaved).as('minutes');\n\n // The time-saved annotation has an invalid value. Ignore.\n if (Number.isNaN(durationMs)) {\n return undefined;\n }\n\n return durationMs;\n }, [catalogApi, templateRef]);\n\n return timeSavedMinutes;\n};\n"],"names":[],"mappings":";;;;;AAyBa,MAAA,2BAAA,GAA8B,CAAC,WAAwB,KAAA;AAClE,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA,CAAA;AAEvC,EAAA,MAAM,EAAE,KAAA,EAAO,gBAAiB,EAAA,GAAI,SAAS,YAAY;AA5B3D,IAAA,IAAA,EAAA,CAAA;AA6BI,IAAA,MAAM,MAAS,GAAA,MAAM,UAAW,CAAA,cAAA,CAAe,WAAW,CAAA,CAAA;AAC1D,IAAA,MAAM,SAAY,GAAA,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,MAAA,CAAQ,QAAS,CAAA,WAAA,KAAjB,IAA+B,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,yBAAA,CAAA,CAAA;AAGjD,IAAI,IAAA,CAAC,MAAU,IAAA,CAAC,SAAW,EAAA;AACzB,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACT;AAEA,IAAA,MAAM,aAAa,QAAS,CAAA,OAAA,CAAQ,SAAS,CAAA,CAAE,GAAG,SAAS,CAAA,CAAA;AAG3D,IAAI,IAAA,MAAA,CAAO,KAAM,CAAA,UAAU,CAAG,EAAA;AAC5B,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACT;AAEA,IAAO,OAAA,UAAA,CAAA;AAAA,GACN,EAAA,CAAC,UAAY,EAAA,WAAW,CAAC,CAAA,CAAA;AAE5B,EAAO,OAAA,gBAAA,CAAA;AACT;;;;"}
@@ -1,12 +1,13 @@
1
1
  const useTransformSchemaToProps = (step, options = {}) => {
2
+ var _a;
2
3
  const { layouts = [] } = options;
3
- const objectFieldTemplate = step?.uiSchema["ui:ObjectFieldTemplate"];
4
+ const objectFieldTemplate = step == null ? void 0 : step.uiSchema["ui:ObjectFieldTemplate"];
4
5
  if (typeof objectFieldTemplate !== "string") {
5
6
  return step;
6
7
  }
7
- const Layout = layouts.find(
8
+ const Layout = (_a = layouts.find(
8
9
  (layout) => layout.name === objectFieldTemplate
9
- )?.component;
10
+ )) == null ? void 0 : _a.component;
10
11
  if (!Layout) {
11
12
  return step;
12
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTransformSchemaToProps.esm.js","sources":["../../../src/next/hooks/useTransformSchemaToProps.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { LayoutOptions } from '../../layouts';\nimport { type ParsedTemplateSchema } from './useTemplateSchema';\n\ninterface Options {\n layouts?: LayoutOptions[];\n}\n\nexport const useTransformSchemaToProps = (\n step: ParsedTemplateSchema,\n options: Options = {},\n): ParsedTemplateSchema => {\n const { layouts = [] } = options;\n const objectFieldTemplate = step?.uiSchema['ui:ObjectFieldTemplate'] as\n | string\n | undefined;\n\n if (typeof objectFieldTemplate !== 'string') {\n return step;\n }\n\n const Layout = layouts.find(\n layout => layout.name === objectFieldTemplate,\n )?.component;\n\n if (!Layout) {\n return step;\n }\n\n return {\n ...step,\n uiSchema: {\n ...step.uiSchema,\n ['ui:ObjectFieldTemplate']: Layout,\n },\n };\n};\n"],"names":[],"mappings":"AAsBO,MAAM,yBAA4B,GAAA,CACvC,IACA,EAAA,OAAA,GAAmB,EACM,KAAA;AACzB,EAAA,MAAM,EAAE,OAAA,GAAU,EAAC,EAAM,GAAA,OAAA,CAAA;AACzB,EAAM,MAAA,mBAAA,GAAsB,IAAM,EAAA,QAAA,CAAS,wBAAwB,CAAA,CAAA;AAInE,EAAI,IAAA,OAAO,wBAAwB,QAAU,EAAA;AAC3C,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,SAAS,OAAQ,CAAA,IAAA;AAAA,IACrB,CAAA,MAAA,KAAU,OAAO,IAAS,KAAA,mBAAA;AAAA,GACzB,EAAA,SAAA,CAAA;AAEH,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA;AAAA,IACL,GAAG,IAAA;AAAA,IACH,QAAU,EAAA;AAAA,MACR,GAAG,IAAK,CAAA,QAAA;AAAA,MACR,CAAC,wBAAwB,GAAG,MAAA;AAAA,KAC9B;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"useTransformSchemaToProps.esm.js","sources":["../../../src/next/hooks/useTransformSchemaToProps.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { LayoutOptions } from '../../layouts';\nimport { type ParsedTemplateSchema } from './useTemplateSchema';\n\ninterface Options {\n layouts?: LayoutOptions[];\n}\n\nexport const useTransformSchemaToProps = (\n step: ParsedTemplateSchema,\n options: Options = {},\n): ParsedTemplateSchema => {\n const { layouts = [] } = options;\n const objectFieldTemplate = step?.uiSchema['ui:ObjectFieldTemplate'] as\n | string\n | undefined;\n\n if (typeof objectFieldTemplate !== 'string') {\n return step;\n }\n\n const Layout = layouts.find(\n layout => layout.name === objectFieldTemplate,\n )?.component;\n\n if (!Layout) {\n return step;\n }\n\n return {\n ...step,\n uiSchema: {\n ...step.uiSchema,\n ['ui:ObjectFieldTemplate']: Layout,\n },\n };\n};\n"],"names":[],"mappings":"AAsBO,MAAM,yBAA4B,GAAA,CACvC,IACA,EAAA,OAAA,GAAmB,EACM,KAAA;AAzB3B,EAAA,IAAA,EAAA,CAAA;AA0BE,EAAA,MAAM,EAAE,OAAA,GAAU,EAAC,EAAM,GAAA,OAAA,CAAA;AACzB,EAAM,MAAA,mBAAA,GAAsB,6BAAM,QAAS,CAAA,wBAAA,CAAA,CAAA;AAI3C,EAAI,IAAA,OAAO,wBAAwB,QAAU,EAAA;AAC3C,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAA,MAAM,UAAS,EAAQ,GAAA,OAAA,CAAA,IAAA;AAAA,IACrB,CAAA,MAAA,KAAU,OAAO,IAAS,KAAA,mBAAA;AAAA,QADb,IAEZ,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,SAAA,CAAA;AAEH,EAAA,IAAI,CAAC,MAAQ,EAAA;AACX,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA;AAAA,IACL,GAAG,IAAA;AAAA,IACH,QAAU,EAAA;AAAA,MACR,GAAG,IAAK,CAAA,QAAA;AAAA,MACR,CAAC,wBAAwB,GAAG,MAAA;AAAA,KAC9B;AAAA,GACF,CAAA;AACF;;;;"}
@@ -97,7 +97,8 @@ const createFieldValidation = () => {
97
97
  const fieldValidation = {
98
98
  __errors: [],
99
99
  addError: (message) => {
100
- fieldValidation.__errors?.push(message);
100
+ var _a;
101
+ (_a = fieldValidation.__errors) == null ? void 0 : _a.push(message);
101
102
  }
102
103
  };
103
104
  return fieldValidation;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.esm.js","sources":["../../../src/next/lib/schema.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { JsonObject } from '@backstage/types';\nimport { stringify, parse } from 'flatted';\nimport { FieldValidation, UiSchema } from '@rjsf/utils';\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction extractUiSchema(schema: JsonObject, uiSchema: JsonObject) {\n if (!isObject(schema)) {\n return;\n }\n\n const {\n properties,\n items,\n anyOf,\n oneOf,\n allOf,\n dependencies,\n then,\n else: _else,\n } = schema;\n\n for (const propName in schema) {\n if (!schema.hasOwnProperty(propName)) {\n continue;\n }\n\n if (propName.startsWith('ui:')) {\n uiSchema[propName] = schema[propName];\n delete schema[propName];\n }\n }\n\n if (isObject(properties)) {\n for (const propName in properties) {\n if (!properties.hasOwnProperty(propName)) {\n continue;\n }\n\n const schemaNode = properties[propName];\n if (!isObject(schemaNode)) {\n continue;\n }\n\n if (!isObject(uiSchema[propName])) {\n const innerUiSchema = {};\n uiSchema[propName] = innerUiSchema;\n }\n\n extractUiSchema(schemaNode, uiSchema[propName] as JsonObject);\n }\n }\n\n if (isObject(items)) {\n const innerUiSchema = {};\n uiSchema.items = innerUiSchema;\n extractUiSchema(items, innerUiSchema);\n }\n\n if (Array.isArray(anyOf)) {\n for (const schemaNode of anyOf) {\n if (!isObject(schemaNode)) {\n continue;\n }\n extractUiSchema(schemaNode, uiSchema);\n }\n }\n\n if (Array.isArray(oneOf)) {\n for (const schemaNode of oneOf) {\n if (!isObject(schemaNode)) {\n continue;\n }\n extractUiSchema(schemaNode, uiSchema);\n }\n }\n\n if (Array.isArray(allOf)) {\n for (const schemaNode of allOf) {\n if (!isObject(schemaNode)) {\n continue;\n }\n extractUiSchema(schemaNode, uiSchema);\n }\n }\n\n if (isObject(dependencies)) {\n for (const depName of Object.keys(dependencies)) {\n const schemaNode = dependencies[depName];\n if (!isObject(schemaNode)) {\n continue;\n }\n extractUiSchema(schemaNode, uiSchema);\n }\n }\n\n if (isObject(then)) {\n extractUiSchema(then, uiSchema);\n }\n\n if (isObject(_else)) {\n extractUiSchema(_else, uiSchema);\n }\n}\n\n/**\n * Takes a step from a Backstage Template Manifest and converts it to a JSON Schema and UI Schema for rjsf\n * @alpha\n */\nexport const extractSchemaFromStep = (\n inputStep: JsonObject,\n): { uiSchema: UiSchema; schema: JsonObject } => {\n const uiSchema: UiSchema = {};\n const returnSchema: JsonObject = parse(stringify(inputStep));\n extractUiSchema(returnSchema, uiSchema);\n return { uiSchema, schema: returnSchema };\n};\n\n/**\n * Creates a field validation object for use in react jsonschema form\n * @alpha\n */\nexport const createFieldValidation = (): FieldValidation => {\n const fieldValidation: FieldValidation = {\n __errors: [] as string[],\n addError: (message: string) => {\n fieldValidation.__errors?.push(message);\n },\n };\n\n return fieldValidation;\n};\n"],"names":[],"mappings":";;AAmBA,SAAS,SAAS,KAAqC,EAAA;AACrD,EAAO,OAAA,OAAO,UAAU,QAAY,IAAA,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA,CAAA;AAC5E,CAAA;AAEA,SAAS,eAAA,CAAgB,QAAoB,QAAsB,EAAA;AACjE,EAAI,IAAA,CAAC,QAAS,CAAA,MAAM,CAAG,EAAA;AACrB,IAAA,OAAA;AAAA,GACF;AAEA,EAAM,MAAA;AAAA,IACJ,UAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAM,EAAA,KAAA;AAAA,GACJ,GAAA,MAAA,CAAA;AAEJ,EAAA,KAAA,MAAW,YAAY,MAAQ,EAAA;AAC7B,IAAA,IAAI,CAAC,MAAA,CAAO,cAAe,CAAA,QAAQ,CAAG,EAAA;AACpC,MAAA,SAAA;AAAA,KACF;AAEA,IAAI,IAAA,QAAA,CAAS,UAAW,CAAA,KAAK,CAAG,EAAA;AAC9B,MAAS,QAAA,CAAA,QAAQ,CAAI,GAAA,MAAA,CAAO,QAAQ,CAAA,CAAA;AACpC,MAAA,OAAO,OAAO,QAAQ,CAAA,CAAA;AAAA,KACxB;AAAA,GACF;AAEA,EAAI,IAAA,QAAA,CAAS,UAAU,CAAG,EAAA;AACxB,IAAA,KAAA,MAAW,YAAY,UAAY,EAAA;AACjC,MAAA,IAAI,CAAC,UAAA,CAAW,cAAe,CAAA,QAAQ,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U,KAAK,OAAO,CAAA,CAAA;AAAA,KACxC;AAAA,GACF,CAAA;AAEA,EAAO,OAAA,eAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"schema.esm.js","sources":["../../../src/next/lib/schema.ts"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { JsonObject } from '@backstage/types';\nimport { stringify, parse } from 'flatted';\nimport { FieldValidation, UiSchema } from '@rjsf/utils';\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction extractUiSchema(schema: JsonObject, uiSchema: JsonObject) {\n if (!isObject(schema)) {\n return;\n }\n\n const {\n properties,\n items,\n anyOf,\n oneOf,\n allOf,\n dependencies,\n then,\n else: _else,\n } = schema;\n\n for (const propName in schema) {\n if (!schema.hasOwnProperty(propName)) {\n continue;\n }\n\n if (propName.startsWith('ui:')) {\n uiSchema[propName] = schema[propName];\n delete schema[propName];\n }\n }\n\n if (isObject(properties)) {\n for (const propName in properties) {\n if (!properties.hasOwnProperty(propName)) {\n continue;\n }\n\n const schemaNode = properties[propName];\n if (!isObject(schemaNode)) {\n continue;\n }\n\n if (!isObject(uiSchema[propName])) {\n const innerUiSchema = {};\n uiSchema[propName] = innerUiSchema;\n }\n\n extractUiSchema(schemaNode, uiSchema[propName] as JsonObject);\n }\n }\n\n if (isObject(items)) {\n const innerUiSchema = {};\n uiSchema.items = innerUiSchema;\n extractUiSchema(items, innerUiSchema);\n }\n\n if (Array.isArray(anyOf)) {\n for (const schemaNode of anyOf) {\n if (!isObject(schemaNode)) {\n continue;\n }\n extractUiSchema(schemaNode, uiSchema);\n }\n }\n\n if (Array.isArray(oneOf)) {\n for (const schemaNode of oneOf) {\n if (!isObject(schemaNode)) {\n continue;\n }\n extractUiSchema(schemaNode, uiSchema);\n }\n }\n\n if (Array.isArray(allOf)) {\n for (const schemaNode of allOf) {\n if (!isObject(schemaNode)) {\n continue;\n }\n extractUiSchema(schemaNode, uiSchema);\n }\n }\n\n if (isObject(dependencies)) {\n for (const depName of Object.keys(dependencies)) {\n const schemaNode = dependencies[depName];\n if (!isObject(schemaNode)) {\n continue;\n }\n extractUiSchema(schemaNode, uiSchema);\n }\n }\n\n if (isObject(then)) {\n extractUiSchema(then, uiSchema);\n }\n\n if (isObject(_else)) {\n extractUiSchema(_else, uiSchema);\n }\n}\n\n/**\n * Takes a step from a Backstage Template Manifest and converts it to a JSON Schema and UI Schema for rjsf\n * @alpha\n */\nexport const extractSchemaFromStep = (\n inputStep: JsonObject,\n): { uiSchema: UiSchema; schema: JsonObject } => {\n const uiSchema: UiSchema = {};\n const returnSchema: JsonObject = parse(stringify(inputStep));\n extractUiSchema(returnSchema, uiSchema);\n return { uiSchema, schema: returnSchema };\n};\n\n/**\n * Creates a field validation object for use in react jsonschema form\n * @alpha\n */\nexport const createFieldValidation = (): FieldValidation => {\n const fieldValidation: FieldValidation = {\n __errors: [] as string[],\n addError: (message: string) => {\n fieldValidation.__errors?.push(message);\n },\n };\n\n return fieldValidation;\n};\n"],"names":[],"mappings":";;AAmBA,SAAS,SAAS,KAAqC,EAAA;AACrD,EAAO,OAAA,OAAO,UAAU,QAAY,IAAA,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA,CAAA;AAC5E,CAAA;AAEA,SAAS,eAAA,CAAgB,QAAoB,QAAsB,EAAA;AACjE,EAAI,IAAA,CAAC,QAAS,CAAA,MAAM,CAAG,EAAA;AACrB,IAAA,OAAA;AAAA,GACF;AAEA,EAAM,MAAA;AAAA,IACJ,UAAA;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EAAA;AAClB,IAAA,eAAA,CAAgB,MAAM,QAAQ,CAAA,CAAA;AAAA,GAChC;AAEA,EAAI,IAAA,QAAA,CAAS,KAAK,CAAG,EAAA;AACnB,IAAA,eAAA,CAAgB,OAAO,QAAQ,CAAA,CAAA;AAAA,GACjC;AACF,CAAA;AAMa,MAAA,qBAAA,GAAwB,CACnC,SAC+C,KAAA;AAC/C,EAAA,MAAM,WAAqB,EAAC,CAAA;AAC5B,EAAA,MAAM,YAA2B,GAAA,KAAA,CAAM,SAAU,CAAA,SAAS,CAAC,CAAA,CAAA;AAC3D,EAAA,eAAA,CAAgB,cAAc,QAAQ,CAAA,CAAA;AACtC,EAAO,OAAA,EAAE,QAAU,EAAA,MAAA,EAAQ,YAAa,EAAA,CAAA;AAC1C,EAAA;AAMO,MAAM,wBAAwB,MAAuB;AAC1D,EAAA,MAAM,eAAmC,GAAA;AAAA,IACvC,UAAU,EAAC;AAAA,IACX,QAAA,EAAU,CAAC,OAAoB,KAAA;AA9InC,MAAA,IAAA,EAAA,CAAA;AA+IM,MAAgB,CAAA,EAAA,GAAA,eAAA,CAAA,QAAA,KAAhB,mBAA0B,IAAK,CAAA,OAAA,CAAA,CAAA;AAAA,KACjC;AAAA,GACF,CAAA;AAEA,EAAO,OAAA,eAAA,CAAA;AACT;;;;"}
@@ -16,7 +16,8 @@ const SecretsContextProvider = (props) => {
16
16
  );
17
17
  };
18
18
  const useTemplateSecrets = () => {
19
- const value = useContext(SecretsContext)?.atVersion(1);
19
+ var _a;
20
+ const value = (_a = useContext(SecretsContext)) == null ? void 0 : _a.atVersion(1);
20
21
  if (!value) {
21
22
  throw new Error(
22
23
  "useTemplateSecrets must be used within a SecretsContextProvider"
@@ -1 +1 @@
1
- {"version":3,"file":"SecretsContext.esm.js","sources":["../../src/secrets/SecretsContext.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\nimport React, {\n useState,\n useCallback,\n useContext,\n PropsWithChildren,\n} from 'react';\n\n/**\n * The contents of the `SecretsContext`\n */\ntype SecretsContextContents = {\n secrets: Record<string, string>;\n setSecrets: React.Dispatch<React.SetStateAction<Record<string, string>>>;\n};\n\n/**\n * The context to hold the Secrets.\n */\nconst SecretsContext = createVersionedContext<{\n 1: SecretsContextContents;\n}>('secrets-context');\n\n/**\n * The Context Provider that holds the state for the secrets.\n * @public\n */\nexport const SecretsContextProvider = (\n props: PropsWithChildren<{ initialSecrets?: Record<string, string> }>,\n) => {\n const { initialSecrets = {} } = props;\n const [secrets, setSecrets] = useState<Record<string, string>>({\n ...initialSecrets,\n });\n\n return (\n <SecretsContext.Provider\n value={createVersionedValueMap({ 1: { secrets, setSecrets } })}\n >\n {props.children}\n </SecretsContext.Provider>\n );\n};\n\n/**\n * The return type from the useTemplateSecrets hook.\n * @public\n */\nexport interface ScaffolderUseTemplateSecrets {\n setSecrets: (input: Record<string, string>) => void;\n secrets: Record<string, string>;\n}\n\n/**\n * Hook to access the secrets context to be able to set secrets that are\n * passed to the Scaffolder backend.\n * @public\n */\nexport const useTemplateSecrets = (): ScaffolderUseTemplateSecrets => {\n const value = useContext(SecretsContext)?.atVersion(1);\n\n if (!value) {\n throw new Error(\n 'useTemplateSecrets must be used within a SecretsContextProvider',\n );\n }\n\n const { setSecrets: updateSecrets, secrets = {} } = value;\n\n const setSecrets = useCallback(\n (input: Record<string, string>) => {\n updateSecrets(currentSecrets => ({ ...currentSecrets, ...input }));\n },\n [updateSecrets],\n );\n\n return { setSecrets, secrets };\n};\n"],"names":[],"mappings":";;;AAqCA,MAAM,cAAA,GAAiB,uBAEpB,iBAAiB,CAAA,CAAA;AAMP,MAAA,sBAAA,GAAyB,CACpC,KACG,KAAA;AACH,EAAA,MAAM,EAAE,cAAA,GAAiB,EAAC,EAAM,GAAA,KAAA,CAAA;AAChC,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,QAAiC,CAAA;AAAA,IAC7D,GAAG,cAAA;AAAA,GACJ,CAAA,CAAA;AAED,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAe,CAAA,QAAA;AAAA,IAAf;AAAA,MACC,KAAA,EAAO,wBAAwB,EAAE,CAAA,EAAG,EAAE,OAAS,EAAA,UAAA,IAAc,CAAA;AAAA,KAAA;AAAA,IAE5D,KAAM,CAAA,QAAA;AAAA,GACT,CAAA;AAEJ,EAAA;AAgBO,MAAM,qBAAqB,MAAoC;AACpE,EAAA,MAAM,KAAQ,GAAA,UAAA,CAAW,cAAc,CAAA,EAAG,UAAU,CAAC,CAAA,CAAA;AAErD,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,iEAAA;AAAA,KACF,CAAA;AAAA,GACF;AAEA,EAAA,MAAM,EAAE,UAAY,EAAA,aAAA,EAAe,OAAU,GAAA,IAAO,GAAA,KAAA,CAAA;AAEpD,EAAA,MAAM,UAAa,GAAA,WAAA;AAAA,IACjB,CAAC,KAAkC,KAAA;AACjC,MAAA,aAAA,CAAc,qBAAmB,EAAE,GAAG,cAAgB,EAAA,GAAG,OAAQ,CAAA,CAAA,CAAA;AAAA,KACnE;AAAA,IACA,CAAC,aAAa,CAAA;AAAA,GAChB,CAAA;AAEA,EAAO,OAAA,EAAE,YAAY,OAAQ,EAAA,CAAA;AAC/B;;;;"}
1
+ {"version":3,"file":"SecretsContext.esm.js","sources":["../../src/secrets/SecretsContext.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\nimport React, {\n useState,\n useCallback,\n useContext,\n PropsWithChildren,\n} from 'react';\n\n/**\n * The contents of the `SecretsContext`\n */\ntype SecretsContextContents = {\n secrets: Record<string, string>;\n setSecrets: React.Dispatch<React.SetStateAction<Record<string, string>>>;\n};\n\n/**\n * The context to hold the Secrets.\n */\nconst SecretsContext = createVersionedContext<{\n 1: SecretsContextContents;\n}>('secrets-context');\n\n/**\n * The Context Provider that holds the state for the secrets.\n * @public\n */\nexport const SecretsContextProvider = (\n props: PropsWithChildren<{ initialSecrets?: Record<string, string> }>,\n) => {\n const { initialSecrets = {} } = props;\n const [secrets, setSecrets] = useState<Record<string, string>>({\n ...initialSecrets,\n });\n\n return (\n <SecretsContext.Provider\n value={createVersionedValueMap({ 1: { secrets, setSecrets } })}\n >\n {props.children}\n </SecretsContext.Provider>\n );\n};\n\n/**\n * The return type from the useTemplateSecrets hook.\n * @public\n */\nexport interface ScaffolderUseTemplateSecrets {\n setSecrets: (input: Record<string, string>) => void;\n secrets: Record<string, string>;\n}\n\n/**\n * Hook to access the secrets context to be able to set secrets that are\n * passed to the Scaffolder backend.\n * @public\n */\nexport const useTemplateSecrets = (): ScaffolderUseTemplateSecrets => {\n const value = useContext(SecretsContext)?.atVersion(1);\n\n if (!value) {\n throw new Error(\n 'useTemplateSecrets must be used within a SecretsContextProvider',\n );\n }\n\n const { setSecrets: updateSecrets, secrets = {} } = value;\n\n const setSecrets = useCallback(\n (input: Record<string, string>) => {\n updateSecrets(currentSecrets => ({ ...currentSecrets,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