@backstage/plugin-scaffolder-react 1.15.0-next.1 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/dist/alpha.d.ts +22 -21
- package/dist/hooks/useCustomFieldExtensions.esm.js +2 -1
- package/dist/hooks/useCustomFieldExtensions.esm.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/layouts/createScaffolderLayout.esm.js.map +1 -1
- package/dist/next/components/Form/DescriptionFieldTemplate.esm.js +3 -3
- package/dist/next/components/Form/DescriptionFieldTemplate.esm.js.map +1 -1
- package/dist/next/components/Form/FieldTemplate.esm.js +18 -18
- package/dist/next/components/Form/FieldTemplate.esm.js.map +1 -1
- package/dist/next/components/Form/Form.esm.js +6 -5
- package/dist/next/components/Form/Form.esm.js.map +1 -1
- package/dist/next/components/PasswordWidget/PasswordWidget.esm.js +17 -14
- package/dist/next/components/PasswordWidget/PasswordWidget.esm.js.map +1 -1
- package/dist/next/components/ReviewState/ReviewState.esm.js +2 -2
- package/dist/next/components/ReviewState/ReviewState.esm.js.map +1 -1
- package/dist/next/components/ScaffolderField/ScaffolderField.esm.js +17 -15
- package/dist/next/components/ScaffolderField/ScaffolderField.esm.js.map +1 -1
- package/dist/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.esm.js +65 -44
- package/dist/next/components/ScaffolderPageContextMenu/ScaffolderPageContextMenu.esm.js.map +1 -1
- package/dist/next/components/SecretWidget/SecretWidget.esm.js +3 -2
- package/dist/next/components/SecretWidget/SecretWidget.esm.js.map +1 -1
- package/dist/next/components/Stepper/ErrorListTemplate/errorListTemplate.esm.js +11 -8
- package/dist/next/components/Stepper/ErrorListTemplate/errorListTemplate.esm.js.map +1 -1
- package/dist/next/components/Stepper/FieldOverrides/DescriptionField.esm.js +2 -2
- package/dist/next/components/Stepper/FieldOverrides/DescriptionField.esm.js.map +1 -1
- package/dist/next/components/Stepper/Stepper.esm.js +106 -90
- package/dist/next/components/Stepper/Stepper.esm.js.map +1 -1
- package/dist/next/components/TaskLogStream/TaskLogStream.esm.js +3 -3
- package/dist/next/components/TaskLogStream/TaskLogStream.esm.js.map +1 -1
- package/dist/next/components/TaskSteps/StepIcon.esm.js +10 -10
- package/dist/next/components/TaskSteps/StepIcon.esm.js.map +1 -1
- package/dist/next/components/TaskSteps/StepTime.esm.js +3 -2
- package/dist/next/components/TaskSteps/StepTime.esm.js.map +1 -1
- package/dist/next/components/TaskSteps/TaskBorder.esm.js +3 -3
- package/dist/next/components/TaskSteps/TaskBorder.esm.js.map +1 -1
- package/dist/next/components/TaskSteps/TaskSteps.esm.js +43 -38
- package/dist/next/components/TaskSteps/TaskSteps.esm.js.map +1 -1
- package/dist/next/components/TemplateCard/CardHeader.esm.js +24 -9
- package/dist/next/components/TemplateCard/CardHeader.esm.js.map +1 -1
- package/dist/next/components/TemplateCard/CardLink.esm.js +5 -2
- package/dist/next/components/TemplateCard/CardLink.esm.js.map +1 -1
- package/dist/next/components/TemplateCard/TemplateCard.esm.js +29 -19
- package/dist/next/components/TemplateCard/TemplateCard.esm.js.map +1 -1
- package/dist/next/components/TemplateCard/TemplateCardActions.esm.js +31 -25
- package/dist/next/components/TemplateCard/TemplateCardActions.esm.js.map +1 -1
- package/dist/next/components/TemplateCard/TemplateCardContent.esm.js +3 -3
- package/dist/next/components/TemplateCard/TemplateCardContent.esm.js.map +1 -1
- package/dist/next/components/TemplateCard/TemplateCardLinks.esm.js +35 -29
- package/dist/next/components/TemplateCard/TemplateCardLinks.esm.js.map +1 -1
- package/dist/next/components/TemplateCard/TemplateCardTags.esm.js +21 -18
- package/dist/next/components/TemplateCard/TemplateCardTags.esm.js.map +1 -1
- package/dist/next/components/TemplateCard/TemplateDetailButton.esm.js +14 -14
- package/dist/next/components/TemplateCard/TemplateDetailButton.esm.js.map +1 -1
- package/dist/next/components/TemplateCategoryPicker/TemplateCategoryPicker.esm.js +44 -41
- package/dist/next/components/TemplateCategoryPicker/TemplateCategoryPicker.esm.js.map +1 -1
- package/dist/next/components/TemplateGroup/TemplateGroup.esm.js +14 -11
- package/dist/next/components/TemplateGroup/TemplateGroup.esm.js.map +1 -1
- package/dist/next/components/TemplateGroups/TemplateGroups.esm.js +14 -8
- package/dist/next/components/TemplateGroups/TemplateGroups.esm.js.map +1 -1
- package/dist/next/components/TemplateOutputs/DefaultTemplateOutputs.esm.js +33 -27
- package/dist/next/components/TemplateOutputs/DefaultTemplateOutputs.esm.js.map +1 -1
- package/dist/next/components/TemplateOutputs/LinkOutputs.esm.js +4 -4
- package/dist/next/components/TemplateOutputs/LinkOutputs.esm.js.map +1 -1
- package/dist/next/components/TemplateOutputs/TextOutputs.esm.js +8 -8
- package/dist/next/components/TemplateOutputs/TextOutputs.esm.js.map +1 -1
- package/dist/next/components/Workflow/Workflow.esm.js +27 -23
- package/dist/next/components/Workflow/Workflow.esm.js.map +1 -1
- package/dist/secrets/SecretsContext.esm.js +6 -5
- package/dist/secrets/SecretsContext.esm.js.map +1 -1
- package/package.json +21 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.esm.js","sources":["../../../../src/next/components/Stepper/Stepper.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 { useAnalytics, useApiHolder } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport {\n FieldExtensionOptions,\n FormProps,\n LayoutOptions,\n ReviewStepProps,\n TemplateParameterSchema,\n} from '@backstage/plugin-scaffolder-react';\nimport { JsonValue } from '@backstage/types';\nimport Button from '@material-ui/core/Button';\nimport LinearProgress from '@material-ui/core/LinearProgress';\nimport MuiStep from '@material-ui/core/Step';\nimport MuiStepLabel from '@material-ui/core/StepLabel';\nimport MuiStepper from '@material-ui/core/Stepper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { type IChangeEvent } from '@rjsf/core';\nimport { ErrorSchema } from '@rjsf/utils';\nimport { customizeValidator } from '@rjsf/validator-ajv8';\nimport ajvErrors from 'ajv-errors';\nimport { merge } from 'lodash';\nimport React, {\n ComponentType,\n useCallback,\n useMemo,\n useState,\n type ReactNode,\n} from 'react';\n\nimport { scaffolderReactTranslationRef } from '../../../translation';\nimport { useFormDataFromQuery, useTemplateSchema } from '../../hooks';\nimport { useTransformSchemaToProps } from '../../hooks/useTransformSchemaToProps';\nimport { Form } from '../Form';\nimport { PasswordWidget } from '../PasswordWidget/PasswordWidget';\nimport { ReviewState, type ReviewStateProps } from '../ReviewState';\nimport {\n createAsyncValidators,\n type FormValidation,\n} from './createAsyncValidators';\nimport { ErrorListTemplate } from './ErrorListTemplate';\nimport * as FieldOverrides from './FieldOverrides';\nimport { hasErrors } from './utils';\n\nconst validator = customizeValidator();\najvErrors(validator.ajv);\n\n/** @alpha */\nexport type BackstageTemplateStepperClassKey =\n | 'backButton'\n | 'footer'\n | 'formWrapper';\n\nconst useStyles = makeStyles(\n theme => ({\n backButton: {\n marginRight: theme.spacing(1),\n },\n footer: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'right',\n marginTop: theme.spacing(2),\n },\n formWrapper: {\n padding: theme.spacing(2),\n },\n }),\n { name: 'BackstageTemplateStepper' },\n);\n\n/**\n * The Props for {@link Stepper} component\n * @alpha\n */\nexport type StepperProps = {\n manifest: TemplateParameterSchema;\n extensions: FieldExtensionOptions<any, any>[];\n /**\n * @deprecated This was only ever used for analytics tracking purposes, which\n * is now handled in the `<Workflow />` component. Passing it in will have no\n * effect.\n */\n templateName?: string;\n formProps?: FormProps;\n initialState?: Record<string, JsonValue>;\n onCreate: (values: Record<string, JsonValue>) => Promise<void>;\n components?: {\n ReviewStepComponent?: ComponentType<ReviewStepProps>;\n ReviewStateComponent?: (props: ReviewStateProps) => JSX.Element;\n backButtonText?: ReactNode;\n createButtonText?: ReactNode;\n reviewButtonText?: ReactNode;\n };\n layouts?: LayoutOptions[];\n};\n\n/**\n * The `Stepper` component is the Wizard that is rendered when a user selects a template\n * @alpha\n */\nexport const Stepper = (stepperProps: StepperProps) => {\n const { t } = useTranslationRef(scaffolderReactTranslationRef);\n const { layouts = [], components = {}, onCreate, ...props } = stepperProps;\n const {\n ReviewStateComponent = ReviewState,\n ReviewStepComponent,\n backButtonText = t('stepper.backButtonText'),\n createButtonText = t('stepper.createButtonText'),\n reviewButtonText = t('stepper.reviewButtonText'),\n } = components;\n const analytics = useAnalytics();\n const { presentation, steps } = useTemplateSchema(props.manifest);\n const apiHolder = useApiHolder();\n const [activeStep, setActiveStep] = useState(0);\n const [isValidating, setIsValidating] = useState(false);\n const [initialState] = useFormDataFromQuery(props.initialState);\n const [stepsState, setStepsState] =\n useState<Record<string, JsonValue>>(initialState);\n\n const [errors, setErrors] = useState<undefined | FormValidation>();\n const styles = useStyles();\n\n const backLabel =\n presentation?.buttonLabels?.backButtonText ?? backButtonText;\n const createLabel =\n presentation?.buttonLabels?.createButtonText ?? createButtonText;\n const reviewLabel =\n presentation?.buttonLabels?.reviewButtonText ?? reviewButtonText;\n\n const extensions = useMemo(() => {\n return Object.fromEntries(\n props.extensions.map(({ name, component }) => [name, component]),\n );\n }, [props.extensions]);\n\n const fields = useMemo(\n () => ({ ...FieldOverrides, ...extensions }),\n [extensions],\n );\n\n const validators = useMemo(() => {\n return Object.fromEntries(\n props.extensions.map(({ name, validation }) => [name, validation]),\n );\n }, [props.extensions]);\n\n const validation = useMemo(() => {\n return createAsyncValidators(steps[activeStep]?.mergedSchema, validators, {\n apiHolder,\n });\n }, [steps, activeStep, validators, apiHolder]);\n\n const handleBack = useCallback(() => {\n setActiveStep(prevActiveStep => prevActiveStep - 1);\n }, [setActiveStep]);\n\n const currentStep = useTransformSchemaToProps(steps[activeStep], { layouts });\n\n const {\n formContext: propFormContext,\n uiSchema: propUiSchema,\n liveOmit: _shouldLiveOmit,\n omitExtraData: _shouldOmitExtraData,\n ...restFormProps\n } = props.formProps ?? {};\n\n const handleChange = useCallback(\n (e: IChangeEvent) => {\n setStepsState(current => {\n return { ...current, ...e.formData };\n });\n },\n [setStepsState],\n );\n\n const handleNext = useCallback(\n async ({ formData = {} }: { formData?: Record<string, JsonValue> }) => {\n // The validation should never throw, as the validators are wrapped in a try/catch.\n // This makes it fine to set and unset state without try/catch.\n setErrors(undefined);\n setIsValidating(true);\n\n const returnedValidation = await validation(formData);\n\n setStepsState(current => ({\n ...current,\n ...formData,\n }));\n\n setIsValidating(false);\n\n if (hasErrors(returnedValidation)) {\n setErrors(returnedValidation);\n } else {\n setErrors(undefined);\n setActiveStep(prevActiveStep => {\n const stepNum = prevActiveStep + 1;\n analytics.captureEvent('click', `Next Step (${stepNum})`);\n return stepNum;\n });\n }\n },\n [validation, analytics],\n );\n\n const mergedUiSchema = merge({}, propUiSchema, currentStep?.uiSchema);\n\n const [isCreating, setIsCreating] = useState(false);\n\n const handleCreate = useCallback(async () => {\n setIsCreating(true);\n analytics.captureEvent('click', `${createLabel}`);\n try {\n await onCreate(stepsState);\n } finally {\n setIsCreating(false);\n }\n }, [analytics, createLabel, onCreate, stepsState]);\n\n return (\n <>\n {isValidating && <LinearProgress variant=\"indeterminate\" />}\n <MuiStepper\n activeStep={activeStep}\n alternativeLabel\n variant=\"elevation\"\n style={{ overflowX: 'auto' }}\n >\n {steps.map((step, index) => {\n const isAllowedLabelClick = activeStep > index;\n return (\n <MuiStep key={index}>\n <MuiStepLabel\n aria-label={t('stepper.stepIndexLabel', { index: index + 1 })}\n style={{ cursor: isAllowedLabelClick ? 'pointer' : 'default' }}\n onClick={() => {\n if (isAllowedLabelClick) setActiveStep(index);\n }}\n >\n {step.title}\n </MuiStepLabel>\n </MuiStep>\n );\n })}\n <MuiStep>\n <MuiStepLabel>{reviewLabel}</MuiStepLabel>\n </MuiStep>\n </MuiStepper>\n <div className={styles.formWrapper}>\n {/* eslint-disable-next-line no-nested-ternary */}\n {activeStep < steps.length ? (\n <Form\n key={activeStep}\n validator={validator}\n extraErrors={errors as unknown as ErrorSchema}\n formData={stepsState}\n formContext={{ ...propFormContext, formData: stepsState }}\n schema={currentStep.schema}\n uiSchema={mergedUiSchema}\n onSubmit={handleNext}\n fields={fields}\n showErrorList=\"top\"\n templates={{ ErrorListTemplate }}\n onChange={handleChange}\n widgets={{ password: PasswordWidget }}\n experimental_defaultFormStateBehavior={{\n allOf: 'populateDefaults',\n }}\n {...restFormProps}\n >\n <div className={styles.footer}>\n <Button\n onClick={handleBack}\n className={styles.backButton}\n disabled={activeStep < 1 || isValidating}\n >\n {backLabel}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n type=\"submit\"\n disabled={isValidating}\n >\n {activeStep === steps.length - 1\n ? reviewLabel\n : t('stepper.nextButtonText')}\n </Button>\n </div>\n </Form>\n ) : // TODO: potentially move away from this pattern, deprecate?\n ReviewStepComponent ? (\n <ReviewStepComponent\n disableButtons={isValidating}\n formData={stepsState}\n handleBack={handleBack}\n handleReset={() => {}}\n steps={steps}\n handleCreate={handleCreate}\n />\n ) : (\n <>\n <ReviewStateComponent formState={stepsState} schemas={steps} />\n <div className={styles.footer}>\n <Button\n onClick={handleBack}\n className={styles.backButton}\n disabled={activeStep < 1}\n >\n {backLabel}\n </Button>\n <Button\n disabled={isCreating}\n variant=\"contained\"\n color=\"primary\"\n onClick={handleCreate}\n >\n {createLabel}\n </Button>\n </div>\n </>\n )}\n </div>\n </>\n );\n};\n"],"names":["FieldOverrides","validation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,YAAY,kBAAmB,EAAA;AACrC,SAAA,CAAU,UAAU,GAAG,CAAA;AAQvB,MAAM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A;AAAA,QACC,OAAS,EAAA,UAAA;AAAA,QACT,WAAW,MAAO,CAAA,UAAA;AAAA,QAClB,UAAU,UAAa,GAAA;AAAA,OAAA;AAAA,MAEtB;AAAA,KAEH,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,QAAU,EAAA,UAAA;AAAA,QACV,OAAQ,EAAA,WAAA;AAAA,QACR,KAAM,EAAA,SAAA;AAAA,QACN,OAAS,EAAA;AAAA,OAAA;AAAA,MAER;AAAA,KAEL,CACF;AAAA,GAEJ,CACF,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"Stepper.esm.js","sources":["../../../../src/next/components/Stepper/Stepper.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 { useAnalytics, useApiHolder } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport {\n FieldExtensionOptions,\n FormProps,\n LayoutOptions,\n ReviewStepProps,\n TemplateParameterSchema,\n} from '@backstage/plugin-scaffolder-react';\nimport { JsonValue } from '@backstage/types';\nimport Button from '@material-ui/core/Button';\nimport LinearProgress from '@material-ui/core/LinearProgress';\nimport MuiStep from '@material-ui/core/Step';\nimport MuiStepLabel from '@material-ui/core/StepLabel';\nimport MuiStepper from '@material-ui/core/Stepper';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { type IChangeEvent } from '@rjsf/core';\nimport { ErrorSchema } from '@rjsf/utils';\nimport { customizeValidator } from '@rjsf/validator-ajv8';\nimport ajvErrors from 'ajv-errors';\nimport { merge } from 'lodash';\nimport {\n ComponentType,\n useCallback,\n useMemo,\n useState,\n type ReactNode,\n} from 'react';\n\nimport { scaffolderReactTranslationRef } from '../../../translation';\nimport { useFormDataFromQuery, useTemplateSchema } from '../../hooks';\nimport { useTransformSchemaToProps } from '../../hooks/useTransformSchemaToProps';\nimport { Form } from '../Form';\nimport { PasswordWidget } from '../PasswordWidget/PasswordWidget';\nimport { ReviewState, type ReviewStateProps } from '../ReviewState';\nimport {\n createAsyncValidators,\n type FormValidation,\n} from './createAsyncValidators';\nimport { ErrorListTemplate } from './ErrorListTemplate';\nimport * as FieldOverrides from './FieldOverrides';\nimport { hasErrors } from './utils';\n\nconst validator = customizeValidator();\najvErrors(validator.ajv);\n\n/** @alpha */\nexport type BackstageTemplateStepperClassKey =\n | 'backButton'\n | 'footer'\n | 'formWrapper';\n\nconst useStyles = makeStyles(\n theme => ({\n backButton: {\n marginRight: theme.spacing(1),\n },\n footer: {\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'right',\n marginTop: theme.spacing(2),\n },\n formWrapper: {\n padding: theme.spacing(2),\n },\n }),\n { name: 'BackstageTemplateStepper' },\n);\n\n/**\n * The Props for {@link Stepper} component\n * @alpha\n */\nexport type StepperProps = {\n manifest: TemplateParameterSchema;\n extensions: FieldExtensionOptions<any, any>[];\n /**\n * @deprecated This was only ever used for analytics tracking purposes, which\n * is now handled in the `<Workflow />` component. Passing it in will have no\n * effect.\n */\n templateName?: string;\n formProps?: FormProps;\n initialState?: Record<string, JsonValue>;\n onCreate: (values: Record<string, JsonValue>) => Promise<void>;\n components?: {\n ReviewStepComponent?: ComponentType<ReviewStepProps>;\n ReviewStateComponent?: (props: ReviewStateProps) => JSX.Element;\n backButtonText?: ReactNode;\n createButtonText?: ReactNode;\n reviewButtonText?: ReactNode;\n };\n layouts?: LayoutOptions[];\n};\n\n/**\n * The `Stepper` component is the Wizard that is rendered when a user selects a template\n * @alpha\n */\nexport const Stepper = (stepperProps: StepperProps) => {\n const { t } = useTranslationRef(scaffolderReactTranslationRef);\n const { layouts = [], components = {}, onCreate, ...props } = stepperProps;\n const {\n ReviewStateComponent = ReviewState,\n ReviewStepComponent,\n backButtonText = t('stepper.backButtonText'),\n createButtonText = t('stepper.createButtonText'),\n reviewButtonText = t('stepper.reviewButtonText'),\n } = components;\n const analytics = useAnalytics();\n const { presentation, steps } = useTemplateSchema(props.manifest);\n const apiHolder = useApiHolder();\n const [activeStep, setActiveStep] = useState(0);\n const [isValidating, setIsValidating] = useState(false);\n const [initialState] = useFormDataFromQuery(props.initialState);\n const [stepsState, setStepsState] =\n useState<Record<string, JsonValue>>(initialState);\n\n const [errors, setErrors] = useState<undefined | FormValidation>();\n const styles = useStyles();\n\n const backLabel =\n presentation?.buttonLabels?.backButtonText ?? backButtonText;\n const createLabel =\n presentation?.buttonLabels?.createButtonText ?? createButtonText;\n const reviewLabel =\n presentation?.buttonLabels?.reviewButtonText ?? reviewButtonText;\n\n const extensions = useMemo(() => {\n return Object.fromEntries(\n props.extensions.map(({ name, component }) => [name, component]),\n );\n }, [props.extensions]);\n\n const fields = useMemo(\n () => ({ ...FieldOverrides, ...extensions }),\n [extensions],\n );\n\n const validators = useMemo(() => {\n return Object.fromEntries(\n props.extensions.map(({ name, validation }) => [name, validation]),\n );\n }, [props.extensions]);\n\n const validation = useMemo(() => {\n return createAsyncValidators(steps[activeStep]?.mergedSchema, validators, {\n apiHolder,\n });\n }, [steps, activeStep, validators, apiHolder]);\n\n const handleBack = useCallback(() => {\n setActiveStep(prevActiveStep => prevActiveStep - 1);\n }, [setActiveStep]);\n\n const currentStep = useTransformSchemaToProps(steps[activeStep], { layouts });\n\n const {\n formContext: propFormContext,\n uiSchema: propUiSchema,\n liveOmit: _shouldLiveOmit,\n omitExtraData: _shouldOmitExtraData,\n ...restFormProps\n } = props.formProps ?? {};\n\n const handleChange = useCallback(\n (e: IChangeEvent) => {\n setStepsState(current => {\n return { ...current, ...e.formData };\n });\n },\n [setStepsState],\n );\n\n const handleNext = useCallback(\n async ({ formData = {} }: { formData?: Record<string, JsonValue> }) => {\n // The validation should never throw, as the validators are wrapped in a try/catch.\n // This makes it fine to set and unset state without try/catch.\n setErrors(undefined);\n setIsValidating(true);\n\n const returnedValidation = await validation(formData);\n\n setStepsState(current => ({\n ...current,\n ...formData,\n }));\n\n setIsValidating(false);\n\n if (hasErrors(returnedValidation)) {\n setErrors(returnedValidation);\n } else {\n setErrors(undefined);\n setActiveStep(prevActiveStep => {\n const stepNum = prevActiveStep + 1;\n analytics.captureEvent('click', `Next Step (${stepNum})`);\n return stepNum;\n });\n }\n },\n [validation, analytics],\n );\n\n const mergedUiSchema = merge({}, propUiSchema, currentStep?.uiSchema);\n\n const [isCreating, setIsCreating] = useState(false);\n\n const handleCreate = useCallback(async () => {\n setIsCreating(true);\n analytics.captureEvent('click', `${createLabel}`);\n try {\n await onCreate(stepsState);\n } finally {\n setIsCreating(false);\n }\n }, [analytics, createLabel, onCreate, stepsState]);\n\n return (\n <>\n {isValidating && <LinearProgress variant=\"indeterminate\" />}\n <MuiStepper\n activeStep={activeStep}\n alternativeLabel\n variant=\"elevation\"\n style={{ overflowX: 'auto' }}\n >\n {steps.map((step, index) => {\n const isAllowedLabelClick = activeStep > index;\n return (\n <MuiStep key={index}>\n <MuiStepLabel\n aria-label={t('stepper.stepIndexLabel', { index: index + 1 })}\n style={{ cursor: isAllowedLabelClick ? 'pointer' : 'default' }}\n onClick={() => {\n if (isAllowedLabelClick) setActiveStep(index);\n }}\n >\n {step.title}\n </MuiStepLabel>\n </MuiStep>\n );\n })}\n <MuiStep>\n <MuiStepLabel>{reviewLabel}</MuiStepLabel>\n </MuiStep>\n </MuiStepper>\n <div className={styles.formWrapper}>\n {/* eslint-disable-next-line no-nested-ternary */}\n {activeStep < steps.length ? (\n <Form\n key={activeStep}\n validator={validator}\n extraErrors={errors as unknown as ErrorSchema}\n formData={stepsState}\n formContext={{ ...propFormContext, formData: stepsState }}\n schema={currentStep.schema}\n uiSchema={mergedUiSchema}\n onSubmit={handleNext}\n fields={fields}\n showErrorList=\"top\"\n templates={{ ErrorListTemplate }}\n onChange={handleChange}\n widgets={{ password: PasswordWidget }}\n experimental_defaultFormStateBehavior={{\n allOf: 'populateDefaults',\n }}\n {...restFormProps}\n >\n <div className={styles.footer}>\n <Button\n onClick={handleBack}\n className={styles.backButton}\n disabled={activeStep < 1 || isValidating}\n >\n {backLabel}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n type=\"submit\"\n disabled={isValidating}\n >\n {activeStep === steps.length - 1\n ? reviewLabel\n : t('stepper.nextButtonText')}\n </Button>\n </div>\n </Form>\n ) : // TODO: potentially move away from this pattern, deprecate?\n ReviewStepComponent ? (\n <ReviewStepComponent\n disableButtons={isValidating}\n formData={stepsState}\n handleBack={handleBack}\n handleReset={() => {}}\n steps={steps}\n handleCreate={handleCreate}\n />\n ) : (\n <>\n <ReviewStateComponent formState={stepsState} schemas={steps} />\n <div className={styles.footer}>\n <Button\n onClick={handleBack}\n className={styles.backButton}\n disabled={activeStep < 1}\n >\n {backLabel}\n </Button>\n <Button\n disabled={isCreating}\n variant=\"contained\"\n color=\"primary\"\n onClick={handleCreate}\n >\n {createLabel}\n </Button>\n </div>\n </>\n )}\n </div>\n </>\n );\n};\n"],"names":["FieldOverrides","validation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,YAAY,kBAAmB,EAAA;AACrC,SAAA,CAAU,UAAU,GAAG,CAAA;AAQvB,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAU,KAAA,MAAA;AAAA,IACR,UAAY,EAAA;AAAA,MACV,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA,KAC9B;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,OAAS,EAAA,MAAA;AAAA,MACT,aAAe,EAAA,KAAA;AAAA,MACf,cAAgB,EAAA,OAAA;AAAA,MAChB,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ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,OAAS,EAAA,YAAA;AAAA,cAER,QAAA,EAAA;AAAA;AAAA;AACH,SACF,EAAA;AAAA,OACF,EAAA;AAAA,KAEJ,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { LogViewer } from '@backstage/core-components';
|
|
3
3
|
import { makeStyles } from '@material-ui/core/styles';
|
|
4
4
|
|
|
@@ -11,12 +11,12 @@ const useStyles = makeStyles({
|
|
|
11
11
|
});
|
|
12
12
|
const TaskLogStream = (props) => {
|
|
13
13
|
const styles = useStyles();
|
|
14
|
-
return /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ jsx("div", { className: styles.root, children: /* @__PURE__ */ jsx(
|
|
15
15
|
LogViewer,
|
|
16
16
|
{
|
|
17
17
|
text: Object.values(props.logs).map((l) => l.join("\n")).filter(Boolean).join("\n")
|
|
18
18
|
}
|
|
19
|
-
));
|
|
19
|
+
) });
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export { TaskLogStream };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskLogStream.esm.js","sources":["../../../../src/next/components/TaskLogStream/TaskLogStream.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
|
|
1
|
+
{"version":3,"file":"TaskLogStream.esm.js","sources":["../../../../src/next/components/TaskLogStream/TaskLogStream.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 { LogViewer } from '@backstage/core-components';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n height: '100%',\n position: 'relative',\n },\n});\n\n/**\n * The text of the event stream\n *\n * @alpha\n */\nexport const TaskLogStream = (props: { logs: { [k: string]: string[] } }) => {\n const styles = useStyles();\n return (\n <div className={styles.root}>\n <LogViewer\n text={Object.values(props.logs)\n .map(l => l.join('\\n'))\n .filter(Boolean)\n .join('\\n')}\n />\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AAkBA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,IAAM,EAAA;AAAA,IACJ,KAAO,EAAA,MAAA;AAAA,IACP,MAAQ,EAAA,MAAA;AAAA,IACR,QAAU,EAAA;AAAA;AAEd,CAAC,CAAA;AAOY,MAAA,aAAA,GAAgB,CAAC,KAA+C,KAAA;AAC3E,EAAA,MAAM,SAAS,SAAU,EAAA;AACzB,EAAA,uBACG,GAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,MAAA,CAAO,IACrB,EAAA,QAAA,kBAAA,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,MAAM,MAAO,CAAA,MAAA,CAAO,KAAM,CAAA,IAAI,EAC3B,GAAI,CAAA,CAAA,CAAA,KAAK,CAAE,CAAA,IAAA,CAAK,IAAI,CAAC,CAAA,CACrB,OAAO,OAAO,CAAA,CACd,KAAK,IAAI;AAAA;AAAA,GAEhB,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
3
3
|
import { makeStyles } from '@material-ui/core/styles';
|
|
4
4
|
import RemoveCircleOutline from '@material-ui/icons/RemoveCircleOutline';
|
|
@@ -23,28 +23,28 @@ const StepIcon = (props) => {
|
|
|
23
23
|
const { active, completed, error, skipped } = props;
|
|
24
24
|
const getMiddle = () => {
|
|
25
25
|
if (active) {
|
|
26
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ jsx(CircularProgress, { size: "20px" });
|
|
27
27
|
}
|
|
28
28
|
if (completed) {
|
|
29
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ jsx(CheckCircleOutline, {});
|
|
30
30
|
}
|
|
31
31
|
if (error) {
|
|
32
|
-
return /* @__PURE__ */
|
|
32
|
+
return /* @__PURE__ */ jsx(ErrorOutline, {});
|
|
33
33
|
}
|
|
34
34
|
if (skipped) {
|
|
35
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ jsx(RemoveCircleOutline, {});
|
|
36
36
|
}
|
|
37
|
-
return /* @__PURE__ */
|
|
37
|
+
return /* @__PURE__ */ jsx(PanoramaFishEyeIcon, {});
|
|
38
38
|
};
|
|
39
|
-
return /* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
40
|
"div",
|
|
41
41
|
{
|
|
42
42
|
className: classNames(classes.root, {
|
|
43
43
|
[classes.completed]: completed,
|
|
44
44
|
[classes.error]: error
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
}),
|
|
46
|
+
children: getMiddle()
|
|
47
|
+
}
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepIcon.esm.js","sources":["../../../../src/next/components/TaskSteps/StepIcon.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 */\n\nimport
|
|
1
|
+
{"version":3,"file":"StepIcon.esm.js","sources":["../../../../src/next/components/TaskSteps/StepIcon.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 */\n\nimport CircularProgress from '@material-ui/core/CircularProgress';\nimport { StepIconProps } from '@material-ui/core/StepIcon';\nimport { makeStyles } from '@material-ui/core/styles';\nimport RemoveCircleOutline from '@material-ui/icons/RemoveCircleOutline';\nimport PanoramaFishEyeIcon from '@material-ui/icons/PanoramaFishEye';\nimport classNames from 'classnames';\nimport CheckCircleOutline from '@material-ui/icons/CheckCircleOutline';\nimport ErrorOutline from '@material-ui/icons/ErrorOutline';\n\nconst useStepIconStyles = makeStyles(theme => ({\n root: {\n color: theme.palette.text.disabled,\n },\n completed: {\n color: theme.palette.status.ok,\n },\n error: {\n color: theme.palette.status.error,\n },\n}));\n\nexport const StepIcon = (props: StepIconProps & { skipped: boolean }) => {\n const classes = useStepIconStyles();\n const { active, completed, error, skipped } = props;\n\n const getMiddle = () => {\n if (active) {\n return <CircularProgress size=\"20px\" />;\n }\n if (completed) {\n return <CheckCircleOutline />;\n }\n\n if (error) {\n return <ErrorOutline />;\n }\n\n if (skipped) {\n return <RemoveCircleOutline />;\n }\n\n return <PanoramaFishEyeIcon />;\n };\n\n return (\n <div\n className={classNames(classes.root, {\n [classes.completed]: completed,\n [classes.error]: error,\n })}\n >\n {getMiddle()}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAyBA,MAAM,iBAAA,GAAoB,WAAW,CAAU,KAAA,MAAA;AAAA,EAC7C,IAAM,EAAA;AAAA,IACJ,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,GAC5B;AAAA,EACA,SAAW,EAAA;AAAA,IACT,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA;AAAA,GAC9B;AAAA,EACA,KAAO,EAAA;AAAA,IACL,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA;AAAA;AAEhC,CAAE,CAAA,CAAA;AAEW,MAAA,QAAA,GAAW,CAAC,KAAgD,KAAA;AACvE,EAAA,MAAM,UAAU,iBAAkB,EAAA;AAClC,EAAA,MAAM,EAAE,MAAA,EAAQ,SAAW,EAAA,KAAA,EAAO,SAAY,GAAA,KAAA;AAE9C,EAAA,MAAM,YAAY,MAAM;AACtB,IAAA,IAAI,MAAQ,EAAA;AACV,MAAO,uBAAA,GAAA,CAAC,gBAAiB,EAAA,EAAA,IAAA,EAAK,MAAO,EAAA,CAAA;AAAA;AAEvC,IAAA,IAAI,SAAW,EAAA;AACb,MAAA,2BAAQ,kBAAmB,EAAA,EAAA,CAAA;AAAA;AAG7B,IAAA,IAAI,KAAO,EAAA;AACT,MAAA,2BAAQ,YAAa,EAAA,EAAA,CAAA;AAAA;AAGvB,IAAA,IAAI,OAAS,EAAA;AACX,MAAA,2BAAQ,mBAAoB,EAAA,EAAA,CAAA;AAAA;AAG9B,IAAA,2BAAQ,mBAAoB,EAAA,EAAA,CAAA;AAAA,GAC9B;AAEA,EACE,uBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,UAAW,CAAA,OAAA,CAAQ,IAAM,EAAA;AAAA,QAClC,CAAC,OAAQ,CAAA,SAAS,GAAG,SAAA;AAAA,QACrB,CAAC,OAAQ,CAAA,KAAK,GAAG;AAAA,OAClB,CAAA;AAAA,MAEA,QAAU,EAAA,SAAA;AAAA;AAAA,GACb;AAEJ;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useCallback } from 'react';
|
|
2
3
|
import useInterval from 'react-use/esm/useInterval';
|
|
3
4
|
import { DateTime, Interval } from 'luxon';
|
|
4
5
|
import humanizeDuration from 'humanize-duration';
|
|
@@ -29,7 +30,7 @@ const StepTime = (props) => {
|
|
|
29
30
|
}, [step.endedAt, step.startedAt]);
|
|
30
31
|
useMountEffect(calculate);
|
|
31
32
|
useInterval(calculate, getDelay());
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "caption", children: time });
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export { StepTime };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepTime.esm.js","sources":["../../../../src/next/components/TaskSteps/StepTime.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
|
|
1
|
+
{"version":3,"file":"StepTime.esm.js","sources":["../../../../src/next/components/TaskSteps/StepTime.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 { useCallback, useState } from 'react';\nimport useInterval from 'react-use/esm/useInterval';\nimport { DateTime, Interval } from 'luxon';\nimport humanizeDuration from 'humanize-duration';\nimport Typography from '@material-ui/core/Typography';\nimport { useMountEffect } from '@react-hookz/web';\n\nexport const StepTime = (props: {\n step: {\n id: string;\n name: string;\n startedAt?: string;\n endedAt?: string;\n };\n}) => {\n const [time, setTime] = useState('');\n const { step } = props;\n\n const getDelay = () => {\n if (step.startedAt && step.endedAt && time) {\n return null;\n }\n if (step.startedAt && step.endedAt) {\n return 1;\n }\n return 1000;\n };\n\n const calculate = useCallback(() => {\n if (!step.startedAt) {\n setTime('');\n return;\n }\n\n const end = step.endedAt\n ? DateTime.fromISO(step.endedAt)\n : DateTime.local();\n\n const startedAt = DateTime.fromISO(step.startedAt);\n const formatted = Interval.fromDateTimes(startedAt, end)\n .toDuration()\n .valueOf();\n\n setTime(humanizeDuration(formatted, { round: true }));\n }, [step.endedAt, step.startedAt]);\n\n useMountEffect(calculate);\n useInterval(calculate, getDelay());\n\n return <Typography variant=\"caption\">{time}</Typography>;\n};\n"],"names":[],"mappings":";;;;;;;;AAsBa,MAAA,QAAA,GAAW,CAAC,KAOnB,KAAA;AACJ,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,EAAE,CAAA;AACnC,EAAM,MAAA,EAAE,MAAS,GAAA,KAAA;AAEjB,EAAA,MAAM,WAAW,MAAM;AACrB,IAAA,IAAI,IAAK,CAAA,SAAA,IAAa,IAAK,CAAA,OAAA,IAAW,IAAM,EAAA;AAC1C,MAAO,OAAA,IAAA;AAAA;AAET,IAAI,IAAA,IAAA,CAAK,SAAa,IAAA,IAAA,CAAK,OAAS,EAAA;AAClC,MAAO,OAAA,CAAA;AAAA;AAET,IAAO,OAAA,GAAA;AAAA,GACT;AAEA,EAAM,MAAA,SAAA,GAAY,YAAY,MAAM;AAClC,IAAI,IAAA,CAAC,KAAK,SAAW,EAAA;AACnB,MAAA,OAAA,CAAQ,EAAE,CAAA;AACV,MAAA;AAAA;AAGF,IAAM,MAAA,GAAA,GAAM,KAAK,OACb,GAAA,QAAA,CAAS,QAAQ,IAAK,CAAA,OAAO,CAC7B,GAAA,QAAA,CAAS,KAAM,EAAA;AAEnB,IAAA,MAAM,SAAY,GAAA,QAAA,CAAS,OAAQ,CAAA,IAAA,CAAK,SAAS,CAAA;AACjD,IAAM,MAAA,SAAA,GAAY,SAAS,aAAc,CAAA,SAAA,EAAW,GAAG,CACpD,CAAA,UAAA,GACA,OAAQ,EAAA;AAEX,IAAA,OAAA,CAAQ,iBAAiB,SAAW,EAAA,EAAE,KAAO,EAAA,IAAA,EAAM,CAAC,CAAA;AAAA,KACnD,CAAC,IAAA,CAAK,OAAS,EAAA,IAAA,CAAK,SAAS,CAAC,CAAA;AAEjC,EAAA,cAAA,CAAe,SAAS,CAAA;AACxB,EAAY,WAAA,CAAA,SAAA,EAAW,UAAU,CAAA;AAEjC,EAAA,uBAAQ,GAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,SAAA,EAAW,QAAK,EAAA,IAAA,EAAA,CAAA;AAC7C;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import LinearProgress from '@material-ui/core/LinearProgress';
|
|
3
3
|
import { makeStyles } from '@material-ui/core/styles';
|
|
4
4
|
|
|
@@ -13,9 +13,9 @@ const useStyles = makeStyles((theme) => ({
|
|
|
13
13
|
const TaskBorder = (props) => {
|
|
14
14
|
const styles = useStyles();
|
|
15
15
|
if (!props.isComplete) {
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsx(LinearProgress, { variant: "indeterminate" });
|
|
17
17
|
}
|
|
18
|
-
return /* @__PURE__ */
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
19
|
LinearProgress,
|
|
20
20
|
{
|
|
21
21
|
variant: "determinate",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskBorder.esm.js","sources":["../../../../src/next/components/TaskSteps/TaskBorder.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 */\n\nimport
|
|
1
|
+
{"version":3,"file":"TaskBorder.esm.js","sources":["../../../../src/next/components/TaskSteps/TaskBorder.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 */\n\nimport LinearProgress from '@material-ui/core/LinearProgress';\nimport { makeStyles } from '@material-ui/core/styles';\n\nconst useStyles = makeStyles(theme => ({\n failed: {\n backgroundColor: theme.palette.error.main,\n },\n success: {\n backgroundColor: theme.palette.success.main,\n },\n}));\n\n/**\n * The visual progress of the task event stream\n */\nexport const TaskBorder = (props: {\n isComplete: boolean;\n isError: boolean;\n}) => {\n const styles = useStyles();\n\n if (!props.isComplete) {\n return <LinearProgress variant=\"indeterminate\" />;\n }\n\n return (\n <LinearProgress\n variant=\"determinate\"\n classes={{ bar: props.isError ? styles.failed : styles.success }}\n value={100}\n />\n );\n};\n"],"names":[],"mappings":";;;;AAmBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,MAAQ,EAAA;AAAA,IACN,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,KAAM,CAAA;AAAA,GACvC;AAAA,EACA,OAAS,EAAA;AAAA,IACP,eAAA,EAAiB,KAAM,CAAA,OAAA,CAAQ,OAAQ,CAAA;AAAA;AAE3C,CAAE,CAAA,CAAA;AAKW,MAAA,UAAA,GAAa,CAAC,KAGrB,KAAA;AACJ,EAAA,MAAM,SAAS,SAAU,EAAA;AAEzB,EAAI,IAAA,CAAC,MAAM,UAAY,EAAA;AACrB,IAAO,uBAAA,GAAA,CAAC,cAAe,EAAA,EAAA,OAAA,EAAQ,eAAgB,EAAA,CAAA;AAAA;AAGjD,EACE,uBAAA,GAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,OAAQ,EAAA,aAAA;AAAA,MACR,OAAA,EAAS,EAAE,GAAK,EAAA,KAAA,CAAM,UAAU,MAAO,CAAA,MAAA,GAAS,OAAO,OAAQ,EAAA;AAAA,MAC/D,KAAO,EAAA;AAAA;AAAA,GACT;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import MuiStepper from '@material-ui/core/Stepper';
|
|
3
3
|
import MuiStep from '@material-ui/core/Step';
|
|
4
4
|
import MuiStepButton from '@material-ui/core/StepButton';
|
|
@@ -10,43 +10,48 @@ import { StepTime } from './StepTime.esm.js';
|
|
|
10
10
|
import { TaskBorder } from './TaskBorder.esm.js';
|
|
11
11
|
|
|
12
12
|
const TaskSteps = (props) => {
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
13
|
+
return /* @__PURE__ */ jsxs(Paper, { style: { position: "relative", overflow: "hidden" }, children: [
|
|
14
|
+
/* @__PURE__ */ jsx(
|
|
15
|
+
TaskBorder,
|
|
16
|
+
{
|
|
17
|
+
isComplete: props.isComplete ?? false,
|
|
18
|
+
isError: props.isError ?? false
|
|
19
|
+
}
|
|
20
|
+
),
|
|
21
|
+
/* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(
|
|
22
|
+
MuiStepper,
|
|
23
|
+
{
|
|
24
|
+
activeStep: props.activeStep,
|
|
25
|
+
alternativeLabel: true,
|
|
26
|
+
variant: "elevation",
|
|
27
|
+
style: { overflowX: "auto" },
|
|
28
|
+
children: props.steps.map((step) => {
|
|
29
|
+
const isCompleted = step.status === "completed";
|
|
30
|
+
const isFailed = step.status === "failed";
|
|
31
|
+
const isActive = step.status === "processing";
|
|
32
|
+
const isSkipped = step.status === "skipped";
|
|
33
|
+
const stepIconProps = {
|
|
34
|
+
completed: isCompleted,
|
|
35
|
+
error: isFailed,
|
|
36
|
+
active: isActive,
|
|
37
|
+
skipped: isSkipped
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ jsx(MuiStep, { children: /* @__PURE__ */ jsx(MuiStepButton, { children: /* @__PURE__ */ jsxs(
|
|
40
|
+
MuiStepLabel,
|
|
41
|
+
{
|
|
42
|
+
StepIconProps: stepIconProps,
|
|
43
|
+
StepIconComponent: StepIcon,
|
|
44
|
+
"data-testid": "step-label",
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsx(Box, { children: step.name }),
|
|
47
|
+
!isSkipped && /* @__PURE__ */ jsx(StepTime, { step })
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
) }) }, step.id);
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
) })
|
|
54
|
+
] });
|
|
50
55
|
};
|
|
51
56
|
|
|
52
57
|
export { TaskSteps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TaskSteps.esm.js","sources":["../../../../src/next/components/TaskSteps/TaskSteps.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
|
|
1
|
+
{"version":3,"file":"TaskSteps.esm.js","sources":["../../../../src/next/components/TaskSteps/TaskSteps.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 MuiStepper from '@material-ui/core/Stepper';\nimport MuiStep from '@material-ui/core/Step';\nimport MuiStepButton from '@material-ui/core/StepButton';\nimport MuiStepLabel from '@material-ui/core/StepLabel';\nimport { StepIconProps } from '@material-ui/core/StepIcon';\nimport Box from '@material-ui/core/Box';\nimport Paper from '@material-ui/core/Paper';\nimport { TaskStep } from '@backstage/plugin-scaffolder-common';\nimport { StepIcon } from './StepIcon';\nimport { StepTime } from './StepTime';\nimport { TaskBorder } from './TaskBorder';\nimport { ScaffolderStep } from '@backstage/plugin-scaffolder-react';\n\n/**\n * Props for the TaskSteps component\n *\n * @alpha\n */\nexport interface TaskStepsProps {\n steps: (TaskStep & ScaffolderStep)[];\n activeStep?: number;\n isComplete?: boolean;\n isError?: boolean;\n}\n\n/**\n * The visual stepper of the task event stream\n *\n * @alpha\n */\nexport const TaskSteps = (props: TaskStepsProps) => {\n return (\n <Paper style={{ position: 'relative', overflow: 'hidden' }}>\n <TaskBorder\n isComplete={props.isComplete ?? false}\n isError={props.isError ?? false}\n />\n <Box padding={2}>\n <MuiStepper\n activeStep={props.activeStep}\n alternativeLabel\n variant=\"elevation\"\n style={{ overflowX: 'auto' }}\n >\n {props.steps.map(step => {\n const isCompleted = step.status === 'completed';\n const isFailed = step.status === 'failed';\n const isActive = step.status === 'processing';\n const isSkipped = step.status === 'skipped';\n const stepIconProps: Partial<StepIconProps & { skipped: boolean }> =\n {\n completed: isCompleted,\n error: isFailed,\n active: isActive,\n skipped: isSkipped,\n };\n\n return (\n <MuiStep key={step.id}>\n <MuiStepButton>\n <MuiStepLabel\n StepIconProps={stepIconProps}\n StepIconComponent={StepIcon}\n data-testid=\"step-label\"\n >\n <Box>{step.name}</Box>\n {!isSkipped && <StepTime step={step} />}\n </MuiStepLabel>\n </MuiStepButton>\n </MuiStep>\n );\n })}\n </MuiStepper>\n </Box>\n </Paper>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA6Ca,MAAA,SAAA,GAAY,CAAC,KAA0B,KAAA;AAClD,EACE,uBAAA,IAAA,CAAC,SAAM,KAAO,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EAAK,eAAK,IAAK,EAAA,CAAA;AAAA,gBACf,CAAC,SAAA,oBAAc,GAAA,CAAA,QAAA,EAAA,EAAS,IAAY,EAAA;AAAA;AAAA;AAAA,WACvC,EACF,CAVY,EAAA,EAAA,IAAA,CAAK,EAWnB,CAAA;AAAA,SAEH;AAAA;AAAA,KAEL,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { makeStyles, useTheme } from '@material-ui/core/styles';
|
|
3
3
|
import { ItemCardHeader } from '@backstage/core-components';
|
|
4
4
|
import { FavoriteEntity } from '@backstage/plugin-catalog-react';
|
|
@@ -12,6 +12,9 @@ const useStyles = makeStyles(() => ({
|
|
|
12
12
|
subtitleWrapper: {
|
|
13
13
|
display: "flex",
|
|
14
14
|
justifyContent: "space-between"
|
|
15
|
+
},
|
|
16
|
+
detailIcon: {
|
|
17
|
+
color: ({ cardFontColor }) => cardFontColor
|
|
15
18
|
}
|
|
16
19
|
}));
|
|
17
20
|
const CardHeader = (props) => {
|
|
@@ -27,14 +30,26 @@ const CardHeader = (props) => {
|
|
|
27
30
|
cardFontColor: themeForType.fontColor,
|
|
28
31
|
cardBackgroundImage: themeForType.backgroundImage
|
|
29
32
|
});
|
|
30
|
-
const SubtitleComponent = /* @__PURE__ */
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const SubtitleComponent = /* @__PURE__ */ jsxs("div", { className: styles.subtitleWrapper, children: [
|
|
34
|
+
/* @__PURE__ */ jsx("div", { children: type }),
|
|
35
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
TemplateDetailButton,
|
|
38
|
+
{
|
|
39
|
+
className: styles.detailIcon,
|
|
40
|
+
template: props.template
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
FavoriteEntity,
|
|
45
|
+
{
|
|
46
|
+
entity: props.template,
|
|
47
|
+
style: { padding: 0, marginLeft: 6 }
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
] })
|
|
51
|
+
] });
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
38
53
|
ItemCardHeader,
|
|
39
54
|
{
|
|
40
55
|
title: title ?? name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardHeader.esm.js","sources":["../../../../src/next/components/TemplateCard/CardHeader.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
|
|
1
|
+
{"version":3,"file":"CardHeader.esm.js","sources":["../../../../src/next/components/TemplateCard/CardHeader.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 { makeStyles, Theme, useTheme } from '@material-ui/core/styles';\nimport { ItemCardHeader } from '@backstage/core-components';\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport { FavoriteEntity } from '@backstage/plugin-catalog-react';\nimport { TemplateDetailButton } from './TemplateDetailButton.tsx';\n\nconst useStyles = makeStyles<\n Theme,\n {\n cardFontColor: string;\n cardBackgroundImage: string;\n }\n>(() => ({\n header: {\n backgroundImage: ({ cardBackgroundImage }) => cardBackgroundImage,\n color: ({ cardFontColor }) => cardFontColor,\n },\n subtitleWrapper: {\n display: 'flex',\n justifyContent: 'space-between',\n },\n detailIcon: {\n color: ({ cardFontColor }) => cardFontColor,\n },\n}));\n\n/**\n * Props for the CardHeader component\n */\nexport interface CardHeaderProps {\n template: TemplateEntityV1beta3;\n}\n\n/**\n * The Card Header with the background for the TemplateCard.\n */\nexport const CardHeader = (props: CardHeaderProps) => {\n const {\n template: {\n metadata: { title, name },\n spec: { type },\n },\n } = props;\n const { getPageTheme } = useTheme();\n const themeForType = getPageTheme({ themeId: type });\n\n const styles = useStyles({\n cardFontColor: themeForType.fontColor,\n cardBackgroundImage: themeForType.backgroundImage,\n });\n\n const SubtitleComponent = (\n <div className={styles.subtitleWrapper}>\n <div>{type}</div>\n <div>\n <TemplateDetailButton\n className={styles.detailIcon}\n template={props.template}\n />\n <FavoriteEntity\n entity={props.template}\n style={{ padding: 0, marginLeft: 6 }}\n />\n </div>\n </div>\n );\n\n return (\n <ItemCardHeader\n title={title ?? name}\n subtitle={SubtitleComponent}\n classes={{ root: styles.header }}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;AAsBA,MAAM,SAAA,GAAY,WAMhB,OAAO;AAAA,EACP,MAAQ,EAAA;AAAA,IACN,eAAiB,EAAA,CAAC,EAAE,mBAAA,EAA0B,KAAA,mBAAA;AAAA,IAC9C,KAAO,EAAA,CAAC,EAAE,aAAA,EAAoB,KAAA;AAAA,GAChC;AAAA,EACA,eAAiB,EAAA;AAAA,IACf,OAAS,EAAA,MAAA;AAAA,IACT,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,CAAC,EAAE,aAAA,EAAoB,KAAA;AAAA;AA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@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
1
2
|
import { Link } from '@backstage/core-components';
|
|
2
3
|
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
-
import React from 'react';
|
|
4
4
|
|
|
5
5
|
const useStyles = makeStyles(() => ({
|
|
6
6
|
linkText: {
|
|
@@ -10,7 +10,10 @@ const useStyles = makeStyles(() => ({
|
|
|
10
10
|
}));
|
|
11
11
|
const CardLink = ({ icon: Icon, text, url }) => {
|
|
12
12
|
const styles = useStyles();
|
|
13
|
-
return /* @__PURE__ */
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.linkText, children: [
|
|
14
|
+
/* @__PURE__ */ jsx(Icon, { fontSize: "small" }),
|
|
15
|
+
/* @__PURE__ */ jsx(Link, { style: { marginLeft: "8px" }, to: url, children: text || url })
|
|
16
|
+
] });
|
|
14
17
|
};
|
|
15
18
|
|
|
16
19
|
export { CardLink };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardLink.esm.js","sources":["../../../../src/next/components/TemplateCard/CardLink.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 { IconComponent } from '@backstage/core-plugin-api';\nimport { Link } from '@backstage/core-components';\nimport { makeStyles } from '@material-ui/core/styles';\
|
|
1
|
+
{"version":3,"file":"CardLink.esm.js","sources":["../../../../src/next/components/TemplateCard/CardLink.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 { IconComponent } from '@backstage/core-plugin-api';\nimport { Link } from '@backstage/core-components';\nimport { makeStyles } from '@material-ui/core/styles';\n\nexport interface CardLinkProps {\n icon: IconComponent;\n text: string;\n url: string;\n}\n\nconst useStyles = makeStyles(() => ({\n linkText: {\n display: 'inline-flex',\n alignItems: 'center',\n },\n}));\n\nexport const CardLink = ({ icon: Icon, text, url }: CardLinkProps) => {\n const styles = useStyles();\n\n return (\n <div className={styles.linkText}>\n <Icon fontSize=\"small\" />\n <Link style={{ marginLeft: '8px' }} to={url}>\n {text || url}\n </Link>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AA0BA,MAAM,SAAA,GAAY,WAAW,OAAO;AAAA,EAClC,QAAU,EAAA;AAAA,IACR,OAAS,EAAA,aAAA;AAAA,IACT,UAAY,EAAA;AAAA;AAEhB,CAAE,CAAA,CAAA;AAEK,MAAM,WAAW,CAAC,EAAE,MAAM,IAAM,EAAA,IAAA,EAAM,KAAyB,KAAA;AACpE,EAAA,MAAM,SAAS,SAAU,EAAA;AAEzB,EAAA,uBACG,IAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,MAAA,CAAO,QACrB,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,IAAA,EAAA,EAAK,UAAS,OAAQ,EAAA,CAAA;AAAA,oBACvB,GAAA,CAAC,IAAK,EAAA,EAAA,KAAA,EAAO,EAAE,UAAA,EAAY,OAAS,EAAA,EAAA,EAAI,GACrC,EAAA,QAAA,EAAA,IAAA,IAAQ,GACX,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
1
2
|
import { RELATION_OWNED_BY } from '@backstage/catalog-model';
|
|
2
3
|
import { useAnalytics } from '@backstage/core-plugin-api';
|
|
3
4
|
import { getEntityRelations } from '@backstage/plugin-catalog-react';
|
|
@@ -7,7 +8,7 @@ import CardContent from '@material-ui/core/CardContent';
|
|
|
7
8
|
import Divider from '@material-ui/core/Divider';
|
|
8
9
|
import Grid from '@material-ui/core/Grid';
|
|
9
10
|
import { makeStyles } from '@material-ui/core/styles';
|
|
10
|
-
import
|
|
11
|
+
import { useCallback } from 'react';
|
|
11
12
|
import { CardHeader } from './CardHeader.esm.js';
|
|
12
13
|
import { usePermission } from '@backstage/plugin-permission-react';
|
|
13
14
|
import { taskCreatePermission } from '@backstage/plugin-scaffolder-common/alpha';
|
|
@@ -34,27 +35,36 @@ const TemplateCard = (props) => {
|
|
|
34
35
|
analytics.captureEvent("click", `Template has been opened`);
|
|
35
36
|
onSelected?.(template);
|
|
36
37
|
}, [analytics, onSelected, template]);
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
template,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
return /* @__PURE__ */ jsxs(Card, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(CardHeader, { template, "data-testid": "template-card-header" }),
|
|
40
|
+
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, "data-testid": "template-card-content", children: [
|
|
41
|
+
/* @__PURE__ */ jsx(TemplateCardContent, { template }),
|
|
42
|
+
displayDefaultDivider && /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(Divider, { "data-testid": "template-card-separator" }) }),
|
|
43
|
+
hasTags && /* @__PURE__ */ jsx(TemplateCardTags, { template }),
|
|
44
|
+
hasLinks && /* @__PURE__ */ jsx(
|
|
45
|
+
TemplateCardLinks,
|
|
46
|
+
{
|
|
47
|
+
template,
|
|
48
|
+
additionalLinks
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
] }) }),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
CardActions,
|
|
51
54
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
className: styles.actionContainer,
|
|
56
|
+
"data-testid": "template-card-actions",
|
|
57
|
+
children: /* @__PURE__ */ jsx(
|
|
58
|
+
TemplateCardActions,
|
|
59
|
+
{
|
|
60
|
+
canCreateTask,
|
|
61
|
+
handleChoose,
|
|
62
|
+
ownedByRelations
|
|
63
|
+
}
|
|
64
|
+
)
|
|
55
65
|
}
|
|
56
66
|
)
|
|
57
|
-
)
|
|
67
|
+
] });
|
|
58
68
|
};
|
|
59
69
|
|
|
60
70
|
export { TemplateCard };
|
|
@@ -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 { IconComponent, useAnalytics } from '@backstage/core-plugin-api';\nimport { getEntityRelations } from '@backstage/plugin-catalog-react';\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport CardContent from '@material-ui/core/CardContent';\nimport Divider from '@material-ui/core/Divider';\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles, Theme } from '@material-ui/core/styles';\nimport
|
|
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 { IconComponent, useAnalytics } from '@backstage/core-plugin-api';\nimport { getEntityRelations } from '@backstage/plugin-catalog-react';\nimport { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';\nimport Card from '@material-ui/core/Card';\nimport CardActions from '@material-ui/core/CardActions';\nimport CardContent from '@material-ui/core/CardContent';\nimport Divider from '@material-ui/core/Divider';\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles, Theme } from '@material-ui/core/styles';\nimport { useCallback } from 'react';\nimport { CardHeader } from './CardHeader';\nimport { usePermission } from '@backstage/plugin-permission-react';\nimport { taskCreatePermission } from '@backstage/plugin-scaffolder-common/alpha';\nimport { TemplateCardContent } from './TemplateCardContent';\nimport { TemplateCardTags } from './TemplateCardTags';\nimport { TemplateCardLinks } from './TemplateCardLinks';\nimport { TemplateCardActions } from './TemplateCardActions';\n\nconst useStyles = makeStyles<Theme>(() => ({\n actionContainer: { padding: '16px', flex: 1, alignItems: 'flex-end' },\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 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 { additionalLinks, onSelected, template } = props;\n const styles = useStyles();\n const analytics = useAnalytics();\n const ownedByRelations = getEntityRelations(template, RELATION_OWNED_BY);\n const hasTags = !!template.metadata.tags?.length;\n const hasLinks =\n !!additionalLinks?.length || !!template.metadata.links?.length;\n const displayDefaultDivider = !hasTags && !hasLinks;\n\n const { allowed: canCreateTask } = usePermission({\n permission: taskCreatePermission,\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} data-testid=\"template-card-header\" />\n <CardContent>\n <Grid container spacing={2} data-testid=\"template-card-content\">\n <TemplateCardContent template={template} />\n {displayDefaultDivider && (\n <Grid item xs={12}>\n <Divider data-testid=\"template-card-separator\" />\n </Grid>\n )}\n {hasTags && <TemplateCardTags template={template} />}\n {hasLinks && (\n <TemplateCardLinks\n template={template}\n additionalLinks={additionalLinks}\n />\n )}\n </Grid>\n </CardContent>\n <CardActions\n className={styles.actionContainer}\n data-testid=\"template-card-actions\"\n >\n <TemplateCardActions\n canCreateTask={canCreateTask}\n handleChoose={handleChoose}\n ownedByRelations={ownedByRelations}\n />\n </CardActions>\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,MAAM,SAAA,GAAY,WAAkB,OAAO;AAAA,EACzC,iBAAiB,EAAE,OAAA,EAAS,QAAQ,IAAM,EAAA,CAAA,EAAG,YAAY,UAAW;AACtE,CAAE,CAAA,CAAA;AAoBW,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AACxD,EAAA,MAAM,EAAE,eAAA,EAAiB,UAAY,EAAA,QAAA,EAAa,GAAA,KAAA;AAClD,EAAA,MAAM,SAAS,SAAU,EAA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