@kartverket/backstage-plugin-risk-scorecard 3.1.2 → 3.1.3
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/dist/components/riScDialog/ConfigRiscInfo.esm.js +3 -3
- package/dist/components/riScDialog/ConfigRiscInfo.esm.js.map +1 -1
- package/dist/components/riScInfo/MigrationDialog.esm.js +2 -2
- package/dist/components/riScInfo/MigrationDialog.esm.js.map +1 -1
- package/dist/components/riScInfo/PublishDialog.esm.js +2 -2
- package/dist/components/riScInfo/PublishDialog.esm.js.map +1 -1
- package/dist/components/scenarioDrawer/ScenarioDrawer.esm.js +2 -2
- package/dist/components/scenarioDrawer/ScenarioDrawer.esm.js.map +1 -1
- package/dist/components/scenarioDrawer/components/ActionBox.esm.js +47 -41
- package/dist/components/scenarioDrawer/components/ActionBox.esm.js.map +1 -1
- package/dist/components/scenarioDrawer/components/ActionFormItem.esm.js +18 -14
- package/dist/components/scenarioDrawer/components/ActionFormItem.esm.js.map +1 -1
- package/dist/components/scenarioDrawer/components/ActionsSection.esm.js +14 -11
- package/dist/components/scenarioDrawer/components/ActionsSection.esm.js.map +1 -1
- package/dist/components/scenarioDrawer/components/DeleteConfirmation.esm.js +55 -22
- package/dist/components/scenarioDrawer/components/DeleteConfirmation.esm.js.map +1 -1
- package/dist/components/scenarioDrawer/components/ScopeFormSection.esm.js +20 -16
- package/dist/components/scenarioDrawer/components/ScopeFormSection.esm.js.map +1 -1
- package/dist/components/scenarioTable/ScenarioTable.esm.js +15 -15
- package/dist/components/scenarioTable/ScenarioTable.esm.js.map +1 -1
- package/dist/components/scenarioTable/ScenarioTableProgressBar.esm.js +46 -0
- package/dist/components/scenarioTable/ScenarioTableProgressBar.esm.js.map +1 -0
- package/dist/components/scenarioTable/ScenarioTableRow.esm.js +21 -21
- package/dist/components/scenarioTable/ScenarioTableRow.esm.js.map +1 -1
- package/dist/components/scenarioWizard/components/CloseConfirmation.esm.js +1 -1
- package/dist/components/scenarioWizard/components/CloseConfirmation.esm.js.map +1 -1
- package/dist/components/scenarioWizard/steps/ActionsStep.esm.js +56 -19
- package/dist/components/scenarioWizard/steps/ActionsStep.esm.js.map +1 -1
- package/dist/components/scenarioWizard/steps/ScenarioStep.esm.js +17 -14
- package/dist/components/scenarioWizard/steps/ScenarioStep.esm.js.map +1 -1
- package/dist/contexts/RiScContext.esm.js +0 -1
- package/dist/contexts/RiScContext.esm.js.map +1 -1
- package/dist/utils/constants.esm.js +33 -9
- package/dist/utils/constants.esm.js.map +1 -1
- package/dist/utils/translations.esm.js +422 -419
- package/dist/utils/translations.esm.js.map +1 -1
- package/dist/utils/types.esm.js.map +1 -1
- package/dist/utils/utilityfunctions.esm.js +35 -51
- package/dist/utils/utilityfunctions.esm.js.map +1 -1
- package/package.json +10 -1
- package/dist/risc_schema_en_v4_0.json.esm.js +0 -88
- package/dist/risc_schema_en_v4_0.json.esm.js.map +0 -1
|
@@ -29,14 +29,14 @@ function ConfigRiscInfo({
|
|
|
29
29
|
...register("content.title", { required: true }),
|
|
30
30
|
error: errors?.content?.title !== void 0,
|
|
31
31
|
label: t("dictionary.title"),
|
|
32
|
-
minRows: 4
|
|
32
|
+
minRows: 4,
|
|
33
|
+
helperText: errors?.content?.title && t("rosDialog.titleError")
|
|
33
34
|
}
|
|
34
35
|
),
|
|
35
36
|
/* @__PURE__ */ jsx(
|
|
36
37
|
MarkdownInput,
|
|
37
38
|
{
|
|
38
|
-
|
|
39
|
-
...register("content.scope", { required: true }),
|
|
39
|
+
...register("content.scope"),
|
|
40
40
|
value: currentScope,
|
|
41
41
|
label: t("dictionary.scope"),
|
|
42
42
|
sublabel: t("rosDialog.scopeDescription"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigRiscInfo.esm.js","sources":["../../../src/components/riScDialog/ConfigRiscInfo.tsx"],"sourcesContent":["import { MarkdownInput } from '../common/MarkdownInput';\nimport { Input } from '../common/Input';\nimport {\n UseFormRegister,\n UseFormSetValue,\n UseFormWatch,\n} from 'react-hook-form/dist/types/form';\nimport { RiScWithMetadata } from '../../utils/types';\nimport { CreateRiScFrom, RiScDialogStates } from './RiScDialog';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { pluginRiScTranslationRef } from '../../utils/translations';\nimport Box from '@mui/material/Box';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport Switch from '@mui/material/Switch';\nimport Typography from '@mui/material/Typography';\nimport { DialogContentText } from '@mui/material';\nimport { FieldErrors } from 'react-hook-form/dist/types/errors';\n\ninterface ConfigRiscInfoProps {\n dialogState: RiScDialogStates;\n createRiScFrom: CreateRiScFrom;\n handleChangeCreateRiScFrom: () => void;\n register: UseFormRegister<RiScWithMetadata>;\n errors: FieldErrors<RiScWithMetadata>;\n setValue: UseFormSetValue<RiScWithMetadata>;\n watch: UseFormWatch<RiScWithMetadata>;\n}\n\nfunction ConfigRiscInfo({\n dialogState,\n createRiScFrom,\n handleChangeCreateRiScFrom,\n register,\n errors,\n setValue,\n watch,\n}: ConfigRiscInfoProps) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const currentScope = watch('content.scope');\n\n return (\n <>\n <Input\n required\n {...register('content.title', { required: true })}\n error={errors?.content?.title !== undefined}\n label={t('dictionary.title')}\n minRows={4}\n />\n <MarkdownInput\n
|
|
1
|
+
{"version":3,"file":"ConfigRiscInfo.esm.js","sources":["../../../src/components/riScDialog/ConfigRiscInfo.tsx"],"sourcesContent":["import { MarkdownInput } from '../common/MarkdownInput';\nimport { Input } from '../common/Input';\nimport {\n UseFormRegister,\n UseFormSetValue,\n UseFormWatch,\n} from 'react-hook-form/dist/types/form';\nimport { RiScWithMetadata } from '../../utils/types';\nimport { CreateRiScFrom, RiScDialogStates } from './RiScDialog';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { pluginRiScTranslationRef } from '../../utils/translations';\nimport Box from '@mui/material/Box';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport Switch from '@mui/material/Switch';\nimport Typography from '@mui/material/Typography';\nimport { DialogContentText } from '@mui/material';\nimport { FieldErrors } from 'react-hook-form/dist/types/errors';\n\ninterface ConfigRiscInfoProps {\n dialogState: RiScDialogStates;\n createRiScFrom: CreateRiScFrom;\n handleChangeCreateRiScFrom: () => void;\n register: UseFormRegister<RiScWithMetadata>;\n errors: FieldErrors<RiScWithMetadata>;\n setValue: UseFormSetValue<RiScWithMetadata>;\n watch: UseFormWatch<RiScWithMetadata>;\n}\n\nfunction ConfigRiscInfo({\n dialogState,\n createRiScFrom,\n handleChangeCreateRiScFrom,\n register,\n errors,\n setValue,\n watch,\n}: ConfigRiscInfoProps) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const currentScope = watch('content.scope');\n\n return (\n <>\n <Input\n required\n {...register('content.title', { required: true })}\n error={errors?.content?.title !== undefined}\n label={t('dictionary.title')}\n minRows={4}\n helperText={errors?.content?.title && t('rosDialog.titleError')}\n />\n <MarkdownInput\n {...register('content.scope')}\n value={currentScope}\n label={t('dictionary.scope')}\n sublabel={t('rosDialog.scopeDescription')}\n error={errors?.content?.scope !== undefined}\n minRows={8}\n onMarkdownChange={value => setValue('content.scope', value)}\n />\n\n {dialogState === RiScDialogStates.Create && (\n <div>\n <DialogContentText>\n {t('rosDialog.generateInitialDescription')}\n </DialogContentText>\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n }}\n >\n <Typography\n sx={{\n fontWeight: 'bold',\n }}\n >\n {t('rosDialog.generateInitialToggleDescription')}\n </Typography>\n <FormControlLabel\n control={<Switch onChange={handleChangeCreateRiScFrom} />}\n label={\n createRiScFrom === CreateRiScFrom.Scratch\n ? t('dictionary.no')\n : t('dictionary.yes')\n }\n />\n </Box>\n </div>\n )}\n </>\n );\n}\n\nexport default ConfigRiscInfo;\n"],"names":[],"mappings":";;;;;;;;;;;;AA4BA,SAAS,cAAe,CAAA;AAAA,EACtB,WAAA;A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CAAA,sCAAsC,CAC3C,EAAA,CAAA;AAAA,sBACA,IAAA;AAAA,QAAC,GAAA;AAAA,QAAA;AAAA,UACC,EAAI,EAAA;AAAA,YACF,OAAS,EAAA,MAAA;AAAA,YACT,aAAe,EAAA,KAAA;AAAA,YACf,UAAY,EAAA,QAAA;AAAA,YACZ,GAAK,EAAA;AAAA,WACP;AAAA,UAEA,QAAA,EAAA;AAAA,4BAAA,GAAA;AAAA,cAAC,UAAA;AAAA,cAAA;AAAA,gBACC,EAAI,EAAA;AAAA,kBACF,UAAY,EAAA;AAAA,iBACd;AAAA,gBAEC,YAAE,4CAA4C;AAAA;AAAA,aACjD;AAAA,4BACA,GAAA;AAAA,cAAC,gBAAA;AAAA,cAAA;AAAA,gBACC,OAAS,kBAAA,GAAA,CAAC,MAAO,EAAA,EAAA,QAAA,EAAU,0BAA4B,EAAA,CAAA;AAAA,gBACvD,KAAA,EACE,mBAAmB,cAAe,CAAA,OAAA,GAC9B,EAAE,eAAe,CAAA,GACjB,EAAE,gBAAgB;AAAA;AAAA;AAE1B;AAAA;AAAA;AACF,KACF,EAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -65,6 +65,7 @@ const RiScMigrationDialog = ({
|
|
|
65
65
|
) })
|
|
66
66
|
] }),
|
|
67
67
|
/* @__PURE__ */ jsxs(DialogActions, { sx: dialogActions, children: [
|
|
68
|
+
/* @__PURE__ */ jsx(Button, { variant: "outlined", color: "primary", onClick: handleCancel, children: t("dictionary.cancel") }),
|
|
68
69
|
/* @__PURE__ */ jsx(
|
|
69
70
|
Button,
|
|
70
71
|
{
|
|
@@ -73,8 +74,7 @@ const RiScMigrationDialog = ({
|
|
|
73
74
|
disabled: !saveMigration,
|
|
74
75
|
children: t("dictionary.confirm")
|
|
75
76
|
}
|
|
76
|
-
)
|
|
77
|
-
/* @__PURE__ */ jsx(Button, { variant: "outlined", color: "primary", onClick: handleCancel, children: t("dictionary.cancel") })
|
|
77
|
+
)
|
|
78
78
|
] })
|
|
79
79
|
] });
|
|
80
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrationDialog.esm.js","sources":["../../../src/components/riScInfo/MigrationDialog.tsx"],"sourcesContent":["import { ReactComponentElement, useState } from 'react';\nimport Alert from '@mui/material/Alert';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport DialogActions from '@mui/material/DialogActions';\nimport Link from '@mui/material/Link';\nimport Typography from '@mui/material/Typography';\nimport Checkbox from '@mui/material/Checkbox';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport Box from '@mui/material/Box';\nimport { pluginRiScTranslationRef } from '../../utils/translations';\nimport { MigrationVersions } from '../../utils/types';\nimport { dialogActions } from '../common/mixins';\nimport { URLS } from '../../urls';\n\ninterface RiScMigrationDialogProps {\n openDialog: boolean;\n handleCancel: () => void;\n handleUpdate: () => void;\n migrationVersions?: MigrationVersions;\n}\n\nexport const RiScMigrationDialog = ({\n openDialog,\n handleCancel,\n handleUpdate,\n migrationVersions,\n}: RiScMigrationDialogProps): ReactComponentElement<any> => {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const [saveMigration, setSaveMigration] = useState<boolean>(false);\n\n function handleCheckboxInput(event: React.ChangeEvent<HTMLInputElement>) {\n setSaveMigration(event.target.checked);\n }\n\n return (\n <Dialog open={openDialog}>\n <DialogTitle>{t('migrationDialog.title')}</DialogTitle>\n <DialogContent>\n <Box sx={{ marginBottom: '16px' }}>\n <Typography>\n {t('migrationDialog.description')}\n {migrationVersions?.toVersion} {t('migrationDialog.description2')}{' '}\n {migrationVersions?.fromVersion}\n {t('migrationDialog.description3')}\n <Link\n underline=\"always\"\n target=\"_blank\"\n href={URLS.external.github_com__kartverket_changelog}\n >\n {t('migrationDialog.changelog')}\n </Link>{' '}\n {t('migrationDialog.description4')}\n </Typography>\n </Box>\n <Alert severity=\"info\" icon={false}>\n <FormControlLabel\n control={\n <Checkbox\n checked={saveMigration}\n onChange={handleCheckboxInput}\n />\n }\n label={t('migrationDialog.checkboxLabel')}\n />\n </Alert>\n </DialogContent>\n <DialogActions sx={dialogActions}>\n <Button
|
|
1
|
+
{"version":3,"file":"MigrationDialog.esm.js","sources":["../../../src/components/riScInfo/MigrationDialog.tsx"],"sourcesContent":["import { ReactComponentElement, useState } from 'react';\nimport Alert from '@mui/material/Alert';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport DialogActions from '@mui/material/DialogActions';\nimport Link from '@mui/material/Link';\nimport Typography from '@mui/material/Typography';\nimport Checkbox from '@mui/material/Checkbox';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport Box from '@mui/material/Box';\nimport { pluginRiScTranslationRef } from '../../utils/translations';\nimport { MigrationVersions } from '../../utils/types';\nimport { dialogActions } from '../common/mixins';\nimport { URLS } from '../../urls';\n\ninterface RiScMigrationDialogProps {\n openDialog: boolean;\n handleCancel: () => void;\n handleUpdate: () => void;\n migrationVersions?: MigrationVersions;\n}\n\nexport const RiScMigrationDialog = ({\n openDialog,\n handleCancel,\n handleUpdate,\n migrationVersions,\n}: RiScMigrationDialogProps): ReactComponentElement<any> => {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const [saveMigration, setSaveMigration] = useState<boolean>(false);\n\n function handleCheckboxInput(event: React.ChangeEvent<HTMLInputElement>) {\n setSaveMigration(event.target.checked);\n }\n\n return (\n <Dialog open={openDialog}>\n <DialogTitle>{t('migrationDialog.title')}</DialogTitle>\n <DialogContent>\n <Box sx={{ marginBottom: '16px' }}>\n <Typography>\n {t('migrationDialog.description')}\n {migrationVersions?.toVersion} {t('migrationDialog.description2')}{' '}\n {migrationVersions?.fromVersion}\n {t('migrationDialog.description3')}\n <Link\n underline=\"always\"\n target=\"_blank\"\n href={URLS.external.github_com__kartverket_changelog}\n >\n {t('migrationDialog.changelog')}\n </Link>{' '}\n {t('migrationDialog.description4')}\n </Typography>\n </Box>\n <Alert severity=\"info\" icon={false}>\n <FormControlLabel\n control={\n <Checkbox\n checked={saveMigration}\n onChange={handleCheckboxInput}\n />\n }\n label={t('migrationDialog.checkboxLabel')}\n />\n </Alert>\n </DialogContent>\n <DialogActions sx={dialogActions}>\n <Button variant=\"outlined\" color=\"primary\" onClick={handleCancel}>\n {t('dictionary.cancel')}\n </Button>\n <Button\n variant=\"contained\"\n onClick={handleUpdate}\n disabled={!saveMigration}\n >\n {t('dictionary.confirm')}\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAyBO,MAAM,sBAAsB,CAAC;AAAA,EAClC,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF,CAA4D,KAAA;AAC1D,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,MAAM,CAAC,aAAA,EAAe,gBAAgB,CAAA,GAAI,SAAkB,KAAK,CAAA;AAEjE,EAAA,SAAS,oBAAoB,KAA4C,EAAA;AACvE,IAAiB,gBAAA,CAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA;AAGvC,EACE,uBAAA,IAAA,CAAC,MAAO,EAAA,EAAA,IAAA,EAAM,UACZ,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,WAAA,EAAA,EAAa,QAAE,EAAA,CAAA,CAAA,uBAAuB,CAAE,EAAA,CAAA;AAAA,yBACxC,aACC,EAAA,EAAA,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,OAAI,EAAI,EAAA,EAAE,cAAc,MAAO,EAAA,EAC9B,+BAAC,UACE,EAAA,EAAA,QAAA,EAA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oB;AAAA;AAAA;AACzB,KACF,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -44,6 +44,7 @@ const RiScPublishDialog = ({
|
|
|
44
44
|
) })
|
|
45
45
|
] }) }),
|
|
46
46
|
/* @__PURE__ */ jsxs(DialogActions, { sx: dialogActions, children: [
|
|
47
|
+
/* @__PURE__ */ jsx(Button, { variant: "outlined", color: "primary", onClick: handleCancel, children: t("dictionary.cancel") }),
|
|
47
48
|
/* @__PURE__ */ jsx(
|
|
48
49
|
Button,
|
|
49
50
|
{
|
|
@@ -53,8 +54,7 @@ const RiScPublishDialog = ({
|
|
|
53
54
|
disabled: !riskOwnerApproves,
|
|
54
55
|
children: t("dictionary.confirm")
|
|
55
56
|
}
|
|
56
|
-
)
|
|
57
|
-
/* @__PURE__ */ jsx(Button, { variant: "outlined", color: "primary", onClick: handleCancel, children: t("dictionary.cancel") })
|
|
57
|
+
)
|
|
58
58
|
] })
|
|
59
59
|
] });
|
|
60
60
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublishDialog.esm.js","sources":["../../../src/components/riScInfo/PublishDialog.tsx"],"sourcesContent":["import { ReactComponentElement, useState } from 'react';\nimport Alert from '@mui/material/Alert';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport DialogActions from '@mui/material/DialogActions';\nimport Checkbox from '@mui/material/Checkbox';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport { DifferenceFetchState } from '../../utils/types';\nimport { pluginRiScTranslationRef } from '../../utils/translations';\nimport { RiScDifferenceDialog } from './riScStatus/RiScDifferenceDialog';\nimport { dialogActions } from '../common/mixins';\n\ninterface RiScPublishDialogProps {\n openDialog: boolean;\n handleCancel: () => void;\n handlePublish: () => void;\n differenceFetchState: DifferenceFetchState;\n}\n\nexport const RiScPublishDialog = ({\n openDialog,\n handleCancel,\n handlePublish,\n differenceFetchState,\n}: RiScPublishDialogProps): ReactComponentElement<any> => {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const [riskOwnerApproves, setRiskOwnerApproves] = useState<boolean>(false);\n\n function handleCheckboxInput(event: React.ChangeEvent<HTMLInputElement>) {\n setRiskOwnerApproves(event.target.checked);\n }\n\n return (\n <Dialog open={openDialog}>\n <DialogTitle>{t('publishDialog.title')}</DialogTitle>\n <DialogContent>\n <>\n <RiScDifferenceDialog differenceFetchState={differenceFetchState} />\n <Alert severity=\"info\" icon={false}>\n <FormControlLabel\n control={\n <Checkbox\n color=\"primary\"\n checked={riskOwnerApproves}\n onChange={handleCheckboxInput}\n />\n }\n label={t('publishDialog.checkboxLabel')}\n />\n </Alert>\n </>\n </DialogContent>\n <DialogActions sx={dialogActions}>\n <Button
|
|
1
|
+
{"version":3,"file":"PublishDialog.esm.js","sources":["../../../src/components/riScInfo/PublishDialog.tsx"],"sourcesContent":["import { ReactComponentElement, useState } from 'react';\nimport Alert from '@mui/material/Alert';\nimport Button from '@mui/material/Button';\nimport Dialog from '@mui/material/Dialog';\nimport DialogContent from '@mui/material/DialogContent';\nimport DialogTitle from '@mui/material/DialogTitle';\nimport DialogActions from '@mui/material/DialogActions';\nimport Checkbox from '@mui/material/Checkbox';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport { DifferenceFetchState } from '../../utils/types';\nimport { pluginRiScTranslationRef } from '../../utils/translations';\nimport { RiScDifferenceDialog } from './riScStatus/RiScDifferenceDialog';\nimport { dialogActions } from '../common/mixins';\n\ninterface RiScPublishDialogProps {\n openDialog: boolean;\n handleCancel: () => void;\n handlePublish: () => void;\n differenceFetchState: DifferenceFetchState;\n}\n\nexport const RiScPublishDialog = ({\n openDialog,\n handleCancel,\n handlePublish,\n differenceFetchState,\n}: RiScPublishDialogProps): ReactComponentElement<any> => {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const [riskOwnerApproves, setRiskOwnerApproves] = useState<boolean>(false);\n\n function handleCheckboxInput(event: React.ChangeEvent<HTMLInputElement>) {\n setRiskOwnerApproves(event.target.checked);\n }\n\n return (\n <Dialog open={openDialog}>\n <DialogTitle>{t('publishDialog.title')}</DialogTitle>\n <DialogContent>\n <>\n <RiScDifferenceDialog differenceFetchState={differenceFetchState} />\n <Alert severity=\"info\" icon={false}>\n <FormControlLabel\n control={\n <Checkbox\n color=\"primary\"\n checked={riskOwnerApproves}\n onChange={handleCheckboxInput}\n />\n }\n label={t('publishDialog.checkboxLabel')}\n />\n </Alert>\n </>\n </DialogContent>\n <DialogActions sx={dialogActions}>\n <Button variant=\"outlined\" color=\"primary\" onClick={handleCancel}>\n {t('dictionary.cancel')}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n onClick={handlePublish}\n disabled={!riskOwnerApproves}\n >\n {t('dictionary.confirm')}\n </Button>\n </DialogActions>\n </Dialog>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsBO,MAAM,oBAAoB,CAAC;AAAA,EAChC,UAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAA0D,KAAA;AACxD,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,MAAM,CAAC,iBAAA,EAAmB,oBAAoB,CAAA,GAAI,SAAkB,KAAK,CAAA;AAEzE,EAAA,SAAS,oBAAoB,KAA4C,EAAA;AACvE,IAAqB,oBAAA,CAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AAAA;AAG3C,EACE,uBAAA,IAAA,CAAC,MAAO,EAAA,EAAA,IAAA,EAAM,UACZ,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,WAAA,EAAA,EAAa,QAAE,EAAA,CAAA,CAAA,qBAAqB,CAAE,EAAA,CAAA;AAAA,oBACvC,GAAA,CAAC,iBACC,QACE,kBAAA,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,wBAAqB,oBAA4C,EAAA,CAAA;AAAA,sBACjE,GAAA,CAAA,KAAA,EAAA,EAAM,QAAS,EAAA,MAAA,EAAO,MAAM,KAC3B,EAAA,QAAA,kBAAA,GAAA;AAAA,QAAC,gBAAA;AAAA,QAAA;AAAA,UACC,OACE,kBAAA,GAAA;AAAA,YAAC,QAAA;AAAA,YAAA;AAAA,cACC,KAAM,EAAA,SAAA;AAAA,cACN,OAAS,EAAA,iBAAA;AAAA,cACT,QAAU,EAAA;AAAA;AAAA,WACZ;AAAA,UAEF,KAAA,EAAO,EAAE,6BAA6B;AAAA;AAAA,OAE1C,EAAA;AAAA,KAAA,EACF,CACF,EAAA,CAAA;AAAA,oBACA,IAAA,CAAC,aAAc,EAAA,EAAA,EAAA,EAAI,aACjB,EAAA,QAAA,EAAA;AAAA,sBAAC,GAAA,CAAA,MAAA,EAAA,EAAO,SAAQ,UAAW,EAAA,KAAA,EAAM,WAAU,OAAS,EAAA,YAAA,EACjD,QAAE,EAAA,CAAA,CAAA,mBAAmB,CACxB,EAAA,CAAA;AAAA,sBACA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,OAAQ,EAAA,WAAA;AAAA,UACR,KAAM,EAAA,SAAA;AAAA,UACN,OAAS,EAAA,aAAA;AAAA,UACT,UAAU,CAAC,iBAAA;AAAA,UAEV,YAAE,oBAAoB;AAAA;AAAA;AACzB,KACF,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -195,8 +195,8 @@ function ScenarioDrawer() {
|
|
|
195
195
|
/* @__PURE__ */ jsx(
|
|
196
196
|
DeleteConfirmation,
|
|
197
197
|
{
|
|
198
|
-
deleteConfirmationIsOpen,
|
|
199
|
-
setDeleteConfirmationIsOpen
|
|
198
|
+
isOpen: deleteConfirmationIsOpen,
|
|
199
|
+
setIsOpen: setDeleteConfirmationIsOpen
|
|
200
200
|
}
|
|
201
201
|
),
|
|
202
202
|
/* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScenarioDrawer.esm.js","sources":["../../../src/components/scenarioDrawer/ScenarioDrawer.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport Box from '@mui/material/Box';\nimport { useScenario } from '../../contexts/ScenarioContext';\nimport { RiskSection } from './components/RiskSection';\nimport { ActionsSection } from './components/ActionsSection';\nimport DeleteIcon from '@mui/icons-material/Delete';\nimport { DeleteConfirmation } from './components/DeleteConfirmation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { pluginRiScTranslationRef } from '../../utils/translations';\nimport { ScopeSection } from './components/ScopeSection';\nimport { useForm } from 'react-hook-form';\nimport { FormScenario, ProcessingStatus } from '../../utils/types';\nimport RiskFormSection from './components/RiskFormSection';\nimport ScopeFormSection from './components/ScopeFormSection';\nimport Drawer from '@mui/material/Drawer';\nimport Button from '@mui/material/Button';\nimport { useRiScs } from '../../contexts/RiScContext';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Alert from '@mui/material/Alert';\nimport { getAlertSeverity } from '../../utils/utilityfunctions';\nimport Typography from '@mui/material/Typography';\nimport { MatrixDialog } from '../riScDialog/MatrixDialog';\nimport { CloseConfirmation } from '../scenarioWizard/components/CloseConfirmation';\n\nexport function ScenarioDrawer() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n const [isEditing, setIsEditing] = useState(false);\n const {\n scenario,\n isDrawerOpen,\n closeScenarioForm,\n submitEditedScenarioToRiSc,\n mapScenarioToFormScenario,\n mapFormScenarioToScenario,\n collapseAllActions,\n } = useScenario();\n\n const [deleteConfirmationIsOpen, setDeleteConfirmationIsOpen] =\n useState(false);\n\n const [showCloseConfirmation, setShowCloseConfirmation] = useState(false);\n\n const [isMatrixDialogOpen, setIsMatrixDialogOpen] = useState<boolean>(false);\n\n const { updateStatus, response } = useRiScs();\n\n // Used to scroll to the bottom of the drawer when the user deletes a scenario\n // via the quick edit and DeleteConfirmation\n const deleteScenarioRef = useRef<HTMLDivElement>(null);\n\n const formMethods = useForm<FormScenario>({\n defaultValues: mapScenarioToFormScenario(scenario),\n mode: 'onBlur',\n });\n\n function onCancel() {\n formMethods.reset(mapScenarioToFormScenario(scenario));\n setIsEditing(false);\n }\n\n function handleClose() {\n closeScenarioForm();\n setIsEditing(false);\n setShowCloseConfirmation(false);\n collapseAllActions();\n }\n\n function onClose() {\n if (formMethods.formState.isDirty) {\n setShowCloseConfirmation(true);\n } else {\n closeScenarioForm();\n setIsEditing(false);\n collapseAllActions();\n }\n }\n\n const onSubmit = formMethods.handleSubmit((data: FormScenario) => {\n submitEditedScenarioToRiSc(mapFormScenarioToScenario(data), () =>\n setIsEditing(false),\n );\n });\n\n function onSubmitAndCloseDialog() {\n onSubmit();\n setShowCloseConfirmation(false);\n\n if (deleteScenarioRef.current) {\n deleteScenarioRef.current.scrollIntoView({ behavior: 'smooth' });\n }\n }\n\n useEffect(() => {\n formMethods.reset(mapScenarioToFormScenario(scenario));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [scenario]);\n\n return (\n <Drawer\n PaperProps={{\n sx: theme => ({\n padding: theme.spacing(4),\n width: '50%',\n gap: theme.spacing(3),\n [theme.breakpoints.down('sm')]: {\n width: '90%',\n padding: theme.spacing(2),\n },\n backgroundColor:\n theme.palette.mode === 'dark' ? '#333333' : '#f8f8f8',\n }),\n }}\n variant=\"temporary\"\n anchor=\"right\"\n open={isDrawerOpen}\n onClose={onClose}\n >\n <Box\n sx={{\n display: 'flex',\n gap: '16px',\n marginLeft: 'auto',\n }}\n >\n {!isEditing && (\n <Button\n color=\"primary\"\n variant=\"contained\"\n onClick={() => setIsEditing(true)}\n >\n {t('dictionary.edit')}\n </Button>\n )}\n <Button\n variant=\"outlined\"\n color=\"primary\"\n onClick={isEditing ? onCancel : onClose}\n >\n {t(isEditing ? 'dictionary.cancel' : 'dictionary.close')}\n </Button>\n </Box>\n\n {isEditing ? (\n <>\n <ScopeFormSection formMethods={formMethods} />\n <RiskFormSection\n formMethods={formMethods}\n setIsMatrixDialogOpen={setIsMatrixDialogOpen}\n />\n </>\n ) : (\n <>\n <ScopeSection />\n <RiskSection />\n </>\n )}\n <ActionsSection\n formMethods={formMethods}\n isEditing={isEditing}\n onSubmit={onSubmit}\n />\n <Box\n sx={{\n display: 'flex',\n gap: '16px',\n }}\n >\n {isEditing && (\n <Button\n color=\"primary\"\n variant=\"contained\"\n onClick={onSubmit}\n disabled={!formMethods.formState.isDirty || updateStatus.isLoading}\n >\n {t('dictionary.save')}\n {updateStatus.isLoading && (\n <CircularProgress\n size={16}\n sx={{ marginLeft: 1, color: 'inherit' }}\n />\n )}\n </Button>\n )}\n <div ref={deleteScenarioRef}>\n <Button\n startIcon={<DeleteIcon />}\n variant=\"text\"\n color=\"primary\"\n onClick={() => setDeleteConfirmationIsOpen(true)}\n sx={{ marginLeft: 'auto' }}\n >\n {t('scenarioDrawer.deleteScenarioButton')}\n </Button>\n </div>\n </Box>\n\n {response &&\n response.status !== ProcessingStatus.ErrorWhenFetchingRiScs && (\n <Alert severity={getAlertSeverity(updateStatus)}>\n <Typography>{response.statusMessage}</Typography>\n </Alert>\n )}\n\n <DeleteConfirmation\n deleteConfirmationIsOpen={deleteConfirmationIsOpen}\n setDeleteConfirmationIsOpen={setDeleteConfirmationIsOpen}\n />\n <MatrixDialog\n open={isMatrixDialogOpen}\n close={() => setIsMatrixDialogOpen(false)}\n />\n <CloseConfirmation\n isOpen={showCloseConfirmation}\n close={handleClose}\n save={onSubmitAndCloseDialog}\n />\n </Drawer>\n );\n}\n"],"names":["RiskFormSection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,SAAS,cAAiB,GAAA;AAC/B,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAA,MAAM,CAA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AAA,CAAA;AAAA,wBAGJ,GAAA;AAAA,UAAC,kBAAA;AAAA,UAAA;AAAA,YACC,wBAAA;AAAA,YACA;AAAA;AAAA,SACF;AAAA,wBACA,GAAA;AAAA,UAAC,YAAA;AAAA,UAAA;AAAA,YACC,IAAM,EAAA,kBAAA;AAAA,YACN,KAAA,EAAO,MAAM,qBAAA,CAAsB,KAAK;AAAA;AAAA,SAC1C;AAAA,wBACA,GAAA;AAAA,UAAC,iBAAA;AAAA,UAAA;AAAA,YACC,MAAQ,EAAA,qBAAA;AAAA,YACR,KAAO,EAAA,WAAA;AAAA,YACP,IAAM,EAAA;AAAA;AAAA;AACR;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"ScenarioDrawer.esm.js","sources":["../../../src/components/scenarioDrawer/ScenarioDrawer.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport Box from '@mui/material/Box';\nimport { useScenario } from '../../contexts/ScenarioContext';\nimport { RiskSection } from './components/RiskSection';\nimport { ActionsSection } from './components/ActionsSection';\nimport DeleteIcon from '@mui/icons-material/Delete';\nimport { DeleteConfirmation } from './components/DeleteConfirmation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { pluginRiScTranslationRef } from '../../utils/translations';\nimport { ScopeSection } from './components/ScopeSection';\nimport { useForm } from 'react-hook-form';\nimport { FormScenario, ProcessingStatus } from '../../utils/types';\nimport RiskFormSection from './components/RiskFormSection';\nimport ScopeFormSection from './components/ScopeFormSection';\nimport Drawer from '@mui/material/Drawer';\nimport Button from '@mui/material/Button';\nimport { useRiScs } from '../../contexts/RiScContext';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Alert from '@mui/material/Alert';\nimport { getAlertSeverity } from '../../utils/utilityfunctions';\nimport Typography from '@mui/material/Typography';\nimport { MatrixDialog } from '../riScDialog/MatrixDialog';\nimport { CloseConfirmation } from '../scenarioWizard/components/CloseConfirmation';\n\nexport function ScenarioDrawer() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n const [isEditing, setIsEditing] = useState(false);\n const {\n scenario,\n isDrawerOpen,\n closeScenarioForm,\n submitEditedScenarioToRiSc,\n mapScenarioToFormScenario,\n mapFormScenarioToScenario,\n collapseAllActions,\n } = useScenario();\n\n const [deleteConfirmationIsOpen, setDeleteConfirmationIsOpen] =\n useState(false);\n\n const [showCloseConfirmation, setShowCloseConfirmation] = useState(false);\n\n const [isMatrixDialogOpen, setIsMatrixDialogOpen] = useState<boolean>(false);\n\n const { updateStatus, response } = useRiScs();\n\n // Used to scroll to the bottom of the drawer when the user deletes a scenario\n // via the quick edit and DeleteConfirmation\n const deleteScenarioRef = useRef<HTMLDivElement>(null);\n\n const formMethods = useForm<FormScenario>({\n defaultValues: mapScenarioToFormScenario(scenario),\n mode: 'onBlur',\n });\n\n function onCancel() {\n formMethods.reset(mapScenarioToFormScenario(scenario));\n setIsEditing(false);\n }\n\n function handleClose() {\n closeScenarioForm();\n setIsEditing(false);\n setShowCloseConfirmation(false);\n collapseAllActions();\n }\n\n function onClose() {\n if (formMethods.formState.isDirty) {\n setShowCloseConfirmation(true);\n } else {\n closeScenarioForm();\n setIsEditing(false);\n collapseAllActions();\n }\n }\n\n const onSubmit = formMethods.handleSubmit((data: FormScenario) => {\n submitEditedScenarioToRiSc(mapFormScenarioToScenario(data), () =>\n setIsEditing(false),\n );\n });\n\n function onSubmitAndCloseDialog() {\n onSubmit();\n setShowCloseConfirmation(false);\n\n if (deleteScenarioRef.current) {\n deleteScenarioRef.current.scrollIntoView({ behavior: 'smooth' });\n }\n }\n\n useEffect(() => {\n formMethods.reset(mapScenarioToFormScenario(scenario));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [scenario]);\n\n return (\n <Drawer\n PaperProps={{\n sx: theme => ({\n padding: theme.spacing(4),\n width: '50%',\n gap: theme.spacing(3),\n [theme.breakpoints.down('sm')]: {\n width: '90%',\n padding: theme.spacing(2),\n },\n backgroundColor:\n theme.palette.mode === 'dark' ? '#333333' : '#f8f8f8',\n }),\n }}\n variant=\"temporary\"\n anchor=\"right\"\n open={isDrawerOpen}\n onClose={onClose}\n >\n <Box\n sx={{\n display: 'flex',\n gap: '16px',\n marginLeft: 'auto',\n }}\n >\n {!isEditing && (\n <Button\n color=\"primary\"\n variant=\"contained\"\n onClick={() => setIsEditing(true)}\n >\n {t('dictionary.edit')}\n </Button>\n )}\n <Button\n variant=\"outlined\"\n color=\"primary\"\n onClick={isEditing ? onCancel : onClose}\n >\n {t(isEditing ? 'dictionary.cancel' : 'dictionary.close')}\n </Button>\n </Box>\n\n {isEditing ? (\n <>\n <ScopeFormSection formMethods={formMethods} />\n <RiskFormSection\n formMethods={formMethods}\n setIsMatrixDialogOpen={setIsMatrixDialogOpen}\n />\n </>\n ) : (\n <>\n <ScopeSection />\n <RiskSection />\n </>\n )}\n <ActionsSection\n formMethods={formMethods}\n isEditing={isEditing}\n onSubmit={onSubmit}\n />\n <Box\n sx={{\n display: 'flex',\n gap: '16px',\n }}\n >\n {isEditing && (\n <Button\n color=\"primary\"\n variant=\"contained\"\n onClick={onSubmit}\n disabled={!formMethods.formState.isDirty || updateStatus.isLoading}\n >\n {t('dictionary.save')}\n {updateStatus.isLoading && (\n <CircularProgress\n size={16}\n sx={{ marginLeft: 1, color: 'inherit' }}\n />\n )}\n </Button>\n )}\n <div ref={deleteScenarioRef}>\n <Button\n startIcon={<DeleteIcon />}\n variant=\"text\"\n color=\"primary\"\n onClick={() => setDeleteConfirmationIsOpen(true)}\n sx={{ marginLeft: 'auto' }}\n >\n {t('scenarioDrawer.deleteScenarioButton')}\n </Button>\n </div>\n </Box>\n\n {response &&\n response.status !== ProcessingStatus.ErrorWhenFetchingRiScs && (\n <Alert severity={getAlertSeverity(updateStatus)}>\n <Typography>{response.statusMessage}</Typography>\n </Alert>\n )}\n\n <DeleteConfirmation\n isOpen={deleteConfirmationIsOpen}\n setIsOpen={setDeleteConfirmationIsOpen}\n />\n <MatrixDialog\n open={isMatrixDialogOpen}\n close={() => setIsMatrixDialogOpen(false)}\n />\n <CloseConfirmation\n isOpen={showCloseConfirmation}\n close={handleClose}\n save={onSubmitAndCloseDialog}\n />\n </Drawer>\n );\n}\n"],"names":["RiskFormSection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBO,SAAS,cAAiB,GAAA;AAC/B,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAChD,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,YAAA;AAAA,IACA,iBAAA;AAAA,IACA,0BAAA;AAAA,IACA,yBAAA;AAAA,IACA,yBAAA;AAAA,IACA;AAAA,MACE,WAAY,EAAA;AAEhB,EAAA,MAAM,CAAC,wBAAA,EAA0B,2BAA2B,CAAA,GAC1D,SAAS,KAAK,CAAA;AAEhB,EAAA,MAAM,CAAC,qBAAA,EAAuB,wBAAwB,CAAA,GAAI,SAAS,KAAK,CAAA;AAExE,EAAA,MAAM,CAAC,kBAAA,EAAoB,qBAAqB,CAAA,GAAI,SAAkB,KAAK,CAAA;AAE3E,EAAA,MAAM,EAAE,YAAA,EAAc,QAAS,EAAA,GAAI,QAAS,EAAA;AAI5C,EAAM,MAAA,iBAAA,GAAoB,OAAuB,IAAI,CAAA;AAErD,EAAA,MAAM,cAAc,OAAsB,CAAA;AAAA,IACxC,aAAA,EAAe,0BAA0B,QAAQ,CAAA;AAAA,IACjD,IAAM,EAAA;AAAA,GACP,CAAA;AAED,EAAA,SAAS,QAAW,GAAA;AAClB,IAAY,WAAA,CAAA,KAAA,CAAM,yBAA0B,CAAA,QAAQ,CAAC,CAAA;AACrD,IAAA,YAAA,CAAa,KAAK,CAAA;AAAA;AAGpB,EAAA,SAAS,WAAc,GAAA;AACrB,IAAkB,iBAAA,EAAA;AAClB,IAAA,YAAA,CAAa,KAAK,CAAA;AACl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AA;AAAA,kBAExB,YAAE,qCAAqC;AAAA;AAAA,eAE5C,EAAA;AAAA;AAAA;AAAA,SACF;AAAA,QAEC,QACC,IAAA,QAAA,CAAS,MAAW,KAAA,gBAAA,CAAiB,0CAClC,GAAA,CAAA,KAAA,EAAA,EAAM,QAAU,EAAA,gBAAA,CAAiB,YAAY,CAC5C,EAAA,QAAA,kBAAA,GAAA,CAAC,UAAY,EAAA,EAAA,QAAA,EAAA,QAAA,CAAS,eAAc,CACtC,EAAA,CAAA;AAAA,wBAGJ,GAAA;AAAA,UAAC,kBAAA;AAAA,UAAA;AAAA,YACC,MAAQ,EAAA,wBAAA;AAAA,YACR,SAAW,EAAA;AAAA;AAAA,SACb;AAAA,wBACA,GAAA;AAAA,UAAC,YAAA;AAAA,UAAA;AAAA,YACC,IAAM,EAAA,kBAAA;AAAA,YACN,KAAA,EAAO,MAAM,qBAAA,CAAsB,KAAK;AAAA;AAAA,SAC1C;AAAA,wBACA,GAAA;AAAA,UAAC,iBAAA;AAAA,UAAA;AAAA,YACC,MAAQ,EAAA,qBAAA;AAAA,YACR,KAAO,EAAA,WAAA;AAAA,YACP,IAAM,EAAA;AAAA;AAAA;AACR;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
import { pluginRiScTranslationRef } from '../../../utils/translations.esm.js';
|
|
4
2
|
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
|
-
import
|
|
3
|
+
import { ExpandLess, ExpandMore, Edit } from '@mui/icons-material';
|
|
4
|
+
import DeleteIcon from '@mui/icons-material/Delete';
|
|
6
5
|
import Box from '@mui/material/Box';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import Button from '@mui/material/Button';
|
|
7
|
+
import Chip from '@mui/material/Chip';
|
|
8
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
9
9
|
import Collapse from '@mui/material/Collapse';
|
|
10
|
-
import { ExpandLess, ExpandMore, Edit } from '@mui/icons-material';
|
|
11
|
-
import Link from '@mui/material/Link';
|
|
12
10
|
import IconButton from '@mui/material/IconButton';
|
|
13
|
-
import
|
|
14
|
-
import Button from '@mui/material/Button';
|
|
15
|
-
import { useScenario } from '../../../contexts/ScenarioContext.esm.js';
|
|
16
|
-
import { useRiScs } from '../../../contexts/RiScContext.esm.js';
|
|
11
|
+
import Link from '@mui/material/Link';
|
|
17
12
|
import Menu from '@mui/material/Menu';
|
|
18
13
|
import MenuItem from '@mui/material/MenuItem';
|
|
19
|
-
import
|
|
14
|
+
import Typography from '@mui/material/Typography';
|
|
15
|
+
import { useState, useEffect } from 'react';
|
|
16
|
+
import { useRiScs } from '../../../contexts/RiScContext.esm.js';
|
|
17
|
+
import { useScenario } from '../../../contexts/ScenarioContext.esm.js';
|
|
18
|
+
import { ActionStatusOptions } from '../../../utils/constants.esm.js';
|
|
20
19
|
import { useIsMounted } from '../../../utils/hooks.esm.js';
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import { deleteAction } from '../../../utils/utilityfunctions.esm.js';
|
|
20
|
+
import { pluginRiScTranslationRef } from '../../../utils/translations.esm.js';
|
|
21
|
+
import { actionStatusOptionsToTranslationKeys, deleteAction } from '../../../utils/utilityfunctions.esm.js';
|
|
24
22
|
import { Markdown } from '../../common/Markdown.esm.js';
|
|
23
|
+
import { label, body2, emptyState } from '../../common/typography.esm.js';
|
|
24
|
+
import { ActionFormItem } from './ActionFormItem.esm.js';
|
|
25
|
+
import { DeleteActionConfirmation } from './DeleteConfirmation.esm.js';
|
|
25
26
|
|
|
26
27
|
function ActionBox({
|
|
27
28
|
action,
|
|
@@ -34,18 +35,24 @@ function ActionBox({
|
|
|
34
35
|
const { isActionExpanded, toggleActionExpanded } = useScenario();
|
|
35
36
|
const isExpanded = isActionExpanded(action.ID);
|
|
36
37
|
const [isEditing, setIsEditing] = useState(false);
|
|
38
|
+
const [deleteActionConfirmationIsOpen, setDeleteActionConfirmationIsOpen] = useState(false);
|
|
37
39
|
const { updateStatus } = useRiScs();
|
|
38
40
|
const { submitEditedScenarioToRiSc, mapFormScenarioToScenario, scenario } = useScenario();
|
|
39
41
|
const isActionTitlePresent = action.title !== null && action.title !== "";
|
|
40
|
-
const translatedActionStatus = t(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/* @ts-ignore Because ts can't typecheck strings against our keys */
|
|
44
|
-
renderedValue: t(`actionStatus.${actionStatus}`)
|
|
45
|
-
}));
|
|
42
|
+
const translatedActionStatus = t(
|
|
43
|
+
actionStatusOptionsToTranslationKeys[action.status]
|
|
44
|
+
);
|
|
46
45
|
const isMounted = useIsMounted();
|
|
47
46
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
48
47
|
const open = Boolean(anchorEl);
|
|
48
|
+
function handleDeleteAction() {
|
|
49
|
+
setDeleteActionConfirmationIsOpen(true);
|
|
50
|
+
}
|
|
51
|
+
function confirmDeleteAction() {
|
|
52
|
+
remove(index);
|
|
53
|
+
deleteAction(remove, index, onSubmit);
|
|
54
|
+
setDeleteActionConfirmationIsOpen(false);
|
|
55
|
+
}
|
|
49
56
|
function handleChipClick(event) {
|
|
50
57
|
setAnchorEl(event.currentTarget);
|
|
51
58
|
}
|
|
@@ -72,7 +79,7 @@ function ActionBox({
|
|
|
72
79
|
{
|
|
73
80
|
formMethods,
|
|
74
81
|
index,
|
|
75
|
-
handleDelete:
|
|
82
|
+
handleDelete: handleDeleteAction,
|
|
76
83
|
showTitleNumber: false,
|
|
77
84
|
remove
|
|
78
85
|
}
|
|
@@ -150,7 +157,7 @@ function ActionBox({
|
|
|
150
157
|
label: translatedActionStatus,
|
|
151
158
|
sx: {
|
|
152
159
|
margin: 0,
|
|
153
|
-
backgroundColor: action.status ===
|
|
160
|
+
backgroundColor: action.status === ActionStatusOptions.Completed ? { backgroundColor: "#6BC6A4" } : void 0
|
|
154
161
|
},
|
|
155
162
|
onClick: handleChipClick
|
|
156
163
|
}
|
|
@@ -162,25 +169,16 @@ function ActionBox({
|
|
|
162
169
|
open,
|
|
163
170
|
onClose: handleMenuClose,
|
|
164
171
|
onClick: handleMenuClose,
|
|
165
|
-
children:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
))
|
|
172
|
+
children: Object.values(ActionStatusOptions).map((value) => /* @__PURE__ */ jsx(MenuItem, {
|
|
173
|
+
onClick: () => handleStatusChange(value),
|
|
174
|
+
/* @ts-ignore Because ts can't typecheck strings against our keys */
|
|
175
|
+
children: t(
|
|
176
|
+
actionStatusOptionsToTranslationKeys[value]
|
|
177
|
+
)
|
|
178
|
+
}, value))
|
|
173
179
|
}
|
|
174
180
|
),
|
|
175
|
-
/* @__PURE__ */ jsx(
|
|
176
|
-
IconButton,
|
|
177
|
-
{
|
|
178
|
-
onClick: () => {
|
|
179
|
-
deleteAction(remove, index, onSubmit);
|
|
180
|
-
},
|
|
181
|
-
children: /* @__PURE__ */ jsx(DeleteIcon, {})
|
|
182
|
-
}
|
|
183
|
-
)
|
|
181
|
+
/* @__PURE__ */ jsx(IconButton, { onClick: handleDeleteAction, children: /* @__PURE__ */ jsx(DeleteIcon, {}) })
|
|
184
182
|
] }),
|
|
185
183
|
/* @__PURE__ */ jsxs(Collapse, { in: isExpanded, children: [
|
|
186
184
|
/* @__PURE__ */ jsx(Typography, { sx: { ...label, marginTop: 1 }, children: t("dictionary.description") }),
|
|
@@ -214,7 +212,15 @@ function ActionBox({
|
|
|
214
212
|
] })
|
|
215
213
|
}
|
|
216
214
|
)
|
|
217
|
-
] })
|
|
215
|
+
] }),
|
|
216
|
+
/* @__PURE__ */ jsx(
|
|
217
|
+
DeleteActionConfirmation,
|
|
218
|
+
{
|
|
219
|
+
isOpen: deleteActionConfirmationIsOpen,
|
|
220
|
+
setIsOpen: setDeleteActionConfirmationIsOpen,
|
|
221
|
+
onConfirm: confirmDeleteAction
|
|
222
|
+
}
|
|
223
|
+
)
|
|
218
224
|
] });
|
|
219
225
|
}
|
|
220
226
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionBox.esm.js","sources":["../../../../src/components/scenarioDrawer/components/ActionBox.tsx"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { Action, FormScenario } from '../../../utils/types';\nimport { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport Chip from '@mui/material/Chip';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport { body2, emptyState, label } from '../../common/typography';\nimport Collapse from '@mui/material/Collapse';\nimport { ExpandLess, ExpandMore, Edit } from '@mui/icons-material';\nimport Link from '@mui/material/Link';\nimport IconButton from '@mui/material/IconButton';\nimport { UseFieldArrayRemove, UseFormReturn } from 'react-hook-form';\nimport { ActionFormItem } from './ActionFormItem';\nimport Button from '@mui/material/Button';\nimport { useScenario } from '../../../contexts/ScenarioContext';\nimport { useRiScs } from '../../../contexts/RiScContext';\nimport Menu from '@mui/material/Menu';\nimport MenuItem from '@mui/material/MenuItem';\nimport { actionStatusOptions } from '../../../utils/constants';\nimport { useIsMounted } from '../../../utils/hooks';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport DeleteIcon from '@mui/icons-material/Delete';\nimport { deleteAction } from '../../../utils/utilityfunctions';\nimport { Markdown } from '../../common/Markdown';\n\ninterface ActionBoxProps {\n action: Action;\n index: number;\n formMethods: UseFormReturn<FormScenario>;\n remove: UseFieldArrayRemove;\n onSubmit: () => void;\n}\n\nexport function ActionBox({\n action,\n index,\n formMethods,\n remove,\n onSubmit,\n}: ActionBoxProps) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const { isActionExpanded, toggleActionExpanded } = useScenario();\n\n const isExpanded = isActionExpanded(action.ID);\n\n const [isEditing, setIsEditing] = useState<boolean>(false);\n\n const { updateStatus } = useRiScs();\n\n const { submitEditedScenarioToRiSc, mapFormScenarioToScenario, scenario } =\n useScenario();\n\n const isActionTitlePresent = action.title !== null && action.title !== '';\n\n /* @ts-ignore Because ts can't typecheck strings against our keys */\n const translatedActionStatus = t(`actionStatus.${action.status}`);\n\n const translatedActionStatuses = actionStatusOptions.map(actionStatus => ({\n value: actionStatus,\n /* @ts-ignore Because ts can't typecheck strings against our keys */\n renderedValue: t(`actionStatus.${actionStatus}`),\n }));\n\n const isMounted = useIsMounted();\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n const open = Boolean(anchorEl);\n\n function handleChipClick(event: React.MouseEvent<HTMLElement>) {\n setAnchorEl(event.currentTarget);\n }\n\n function handleMenuClose() {\n setAnchorEl(null);\n }\n\n async function handleStatusChange(newStatus: string) {\n const updatedScenario = {\n ...scenario,\n actions: scenario.actions.map(a =>\n a.ID === action.ID ? { ...a, status: newStatus } : a,\n ),\n };\n\n await submitEditedScenarioToRiSc(updatedScenario);\n\n if (isMounted()) {\n handleMenuClose();\n }\n }\n\n useEffect(() => () => setAnchorEl(null), []);\n\n if (isEditing) {\n return (\n <>\n <ActionFormItem\n formMethods={formMethods}\n index={index}\n handleDelete={() => deleteAction(remove, index, onSubmit)}\n showTitleNumber={false}\n remove={remove}\n />\n <Box display=\"flex\" gap={1}>\n <Button\n color=\"primary\"\n variant=\"contained\"\n onClick={formMethods.handleSubmit((data: FormScenario) => {\n submitEditedScenarioToRiSc(mapFormScenarioToScenario(data));\n })}\n disabled={!formMethods.formState.isDirty || updateStatus.isLoading}\n >\n {t('dictionary.save')}\n {updateStatus.isLoading && (\n <CircularProgress\n size={16}\n sx={{ marginLeft: 8, color: 'inherit' }}\n />\n )}\n </Button>\n\n <Button onClick={() => setIsEditing(false)}>\n {t('dictionary.cancel')}\n </Button>\n </Box>\n </>\n );\n }\n\n return (\n <Box>\n <Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n cursor: 'pointer',\n width: '100%',\n }}\n onClick={() => toggleActionExpanded(action.ID)}\n >\n <IconButton>\n {isExpanded ? <ExpandLess /> : <ExpandMore />}\n </IconButton>\n <Typography\n sx={{\n fontSize: '16px',\n fontWeight: 500,\n }}\n >\n {isActionTitlePresent\n ? action.title\n : `${t('dictionary.measure')} ${index + 1}`}\n </Typography>\n </Box>\n <IconButton\n disabled={isExpanded ? false : true}\n sx={{\n marginLeft: 'auto',\n opacity: isExpanded ? 1 : 0,\n transition: 'opacity 300ms ease-in',\n }}\n onClick={() => setIsEditing(!isEditing)}\n >\n <Edit />\n </IconButton>\n <Chip\n label={translatedActionStatus}\n sx={{\n margin: 0,\n backgroundColor:\n action.status === 'Completed'\n ? { backgroundColor: '#6BC6A4' }\n : undefined,\n }}\n onClick={handleChipClick}\n />\n <Menu\n anchorEl={anchorEl}\n open={open}\n onClose={handleMenuClose}\n onClick={handleMenuClose}\n >\n {translatedActionStatuses.map(option => (\n <MenuItem\n key={option.value}\n onClick={() => handleStatusChange(option.value)}\n >\n {option.renderedValue}\n </MenuItem>\n ))}\n </Menu>\n <IconButton\n onClick={() => {\n deleteAction(remove, index, onSubmit);\n }}\n >\n <DeleteIcon />\n </IconButton>\n </Box>\n <Collapse in={isExpanded}>\n <Typography sx={{ ...label, marginTop: 1 }}>\n {t('dictionary.description')}\n </Typography>\n <Markdown description={action.description} />\n\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'end',\n marginTop: '16px',\n }}\n >\n <Box>\n <Typography sx={label}>{t('dictionary.url')}</Typography>\n {action.url ? (\n <Link\n sx={{\n ...body2,\n wordBreak: 'break-all',\n }}\n target=\"_blank\"\n rel=\"noreferrer\"\n href={\n action.url.startsWith('http') ? action.url : `//${action.url}`\n }\n >\n {action.url}\n </Link>\n ) : (\n <Typography sx={emptyState}>\n {t('dictionary.emptyField', {\n field: t('dictionary.url').toLowerCase(),\n })}\n </Typography>\n )}\n </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K,EAAA,EAAA,MAAA,CAAO,GAAG,CAAA,CAAA;AAAA,gBAG7D,QAAO,EAAA,MAAA,CAAA;AAAA;AAAA,gCAGT,GAAA,CAAA,UAAA,EAAA,EAAW,EAAI,EAAA,UAAA,EACb,YAAE,uBAAyB,EAAA;AAAA,cAC1B,KAAO,EAAA,CAAA,CAAE,gBAAgB,CAAA,CAAE,WAAY;AAAA,aACxC,CACH,EAAA;AAAA,WAEJ,EAAA;AAAA;AAAA;AACF,KACF,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"ActionBox.esm.js","sources":["../../../../src/components/scenarioDrawer/components/ActionBox.tsx"],"sourcesContent":["import { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { Edit, ExpandLess, ExpandMore } from '@mui/icons-material';\nimport DeleteIcon from '@mui/icons-material/Delete';\nimport Box from '@mui/material/Box';\nimport Button from '@mui/material/Button';\nimport Chip from '@mui/material/Chip';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Collapse from '@mui/material/Collapse';\nimport IconButton from '@mui/material/IconButton';\nimport Link from '@mui/material/Link';\nimport Menu from '@mui/material/Menu';\nimport MenuItem from '@mui/material/MenuItem';\nimport Typography from '@mui/material/Typography';\nimport { useEffect, useState } from 'react';\nimport { UseFieldArrayRemove, UseFormReturn } from 'react-hook-form';\nimport { useRiScs } from '../../../contexts/RiScContext';\nimport { useScenario } from '../../../contexts/ScenarioContext';\nimport { ActionStatusOptions } from '../../../utils/constants';\nimport { useIsMounted } from '../../../utils/hooks';\nimport { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { Action, FormScenario } from '../../../utils/types';\nimport {\n actionStatusOptionsToTranslationKeys,\n deleteAction,\n} from '../../../utils/utilityfunctions';\nimport { Markdown } from '../../common/Markdown';\nimport { body2, emptyState, label } from '../../common/typography';\nimport { ActionFormItem } from './ActionFormItem';\nimport { DeleteActionConfirmation } from './DeleteConfirmation';\n\ninterface ActionBoxProps {\n action: Action;\n index: number;\n formMethods: UseFormReturn<FormScenario>;\n remove: UseFieldArrayRemove;\n onSubmit: () => void;\n}\n\nexport function ActionBox({\n action,\n index,\n formMethods,\n remove,\n onSubmit,\n}: ActionBoxProps) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const { isActionExpanded, toggleActionExpanded } = useScenario();\n const isExpanded = isActionExpanded(action.ID);\n\n const [isEditing, setIsEditing] = useState<boolean>(false);\n const [deleteActionConfirmationIsOpen, setDeleteActionConfirmationIsOpen] =\n useState(false);\n\n const { updateStatus } = useRiScs();\n const { submitEditedScenarioToRiSc, mapFormScenarioToScenario, scenario } =\n useScenario();\n\n const isActionTitlePresent = action.title !== null && action.title !== '';\n\n /* @ts-ignore Because ts can't typecheck strings against our keys */\n const translatedActionStatus = t(\n actionStatusOptionsToTranslationKeys[action.status as ActionStatusOptions],\n );\n\n const isMounted = useIsMounted();\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n const open = Boolean(anchorEl);\n\n function handleDeleteAction(): void {\n setDeleteActionConfirmationIsOpen(true);\n }\n\n function confirmDeleteAction(): void {\n remove(index);\n deleteAction(remove, index, onSubmit);\n setDeleteActionConfirmationIsOpen(false);\n }\n\n function handleChipClick(event: React.MouseEvent<HTMLElement>) {\n setAnchorEl(event.currentTarget);\n }\n\n function handleMenuClose() {\n setAnchorEl(null);\n }\n\n async function handleStatusChange(newStatus: string) {\n const updatedScenario = {\n ...scenario,\n actions: scenario.actions.map(a =>\n a.ID === action.ID ? { ...a, status: newStatus } : a,\n ),\n };\n\n await submitEditedScenarioToRiSc(updatedScenario);\n\n if (isMounted()) {\n handleMenuClose();\n }\n }\n\n useEffect(() => () => setAnchorEl(null), []);\n\n if (isEditing) {\n return (\n <>\n <ActionFormItem\n formMethods={formMethods}\n index={index}\n handleDelete={handleDeleteAction}\n showTitleNumber={false}\n remove={remove}\n />\n <Box display=\"flex\" gap={1}>\n <Button\n color=\"primary\"\n variant=\"contained\"\n onClick={formMethods.handleSubmit((data: FormScenario) => {\n submitEditedScenarioToRiSc(mapFormScenarioToScenario(data));\n })}\n disabled={!formMethods.formState.isDirty || updateStatus.isLoading}\n >\n {t('dictionary.save')}\n {updateStatus.isLoading && (\n <CircularProgress\n size={16}\n sx={{ marginLeft: 8, color: 'inherit' }}\n />\n )}\n </Button>\n\n <Button onClick={() => setIsEditing(false)}>\n {t('dictionary.cancel')}\n </Button>\n </Box>\n </>\n );\n }\n\n return (\n <Box>\n <Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n cursor: 'pointer',\n width: '100%',\n }}\n onClick={() => toggleActionExpanded(action.ID)}\n >\n <IconButton>\n {isExpanded ? <ExpandLess /> : <ExpandMore />}\n </IconButton>\n <Typography\n sx={{\n fontSize: '16px',\n fontWeight: 500,\n }}\n >\n {isActionTitlePresent\n ? action.title\n : `${t('dictionary.measure')} ${index + 1}`}\n </Typography>\n </Box>\n <IconButton\n disabled={isExpanded ? false : true}\n sx={{\n marginLeft: 'auto',\n opacity: isExpanded ? 1 : 0,\n transition: 'opacity 300ms ease-in',\n }}\n onClick={() => setIsEditing(!isEditing)}\n >\n <Edit />\n </IconButton>\n <Chip\n label={translatedActionStatus}\n sx={{\n margin: 0,\n backgroundColor:\n action.status === ActionStatusOptions.Completed\n ? { backgroundColor: '#6BC6A4' }\n : undefined,\n }}\n onClick={handleChipClick}\n />\n <Menu\n anchorEl={anchorEl}\n open={open}\n onClose={handleMenuClose}\n onClick={handleMenuClose}\n >\n {Object.values(ActionStatusOptions).map(value => (\n <MenuItem key={value} onClick={() => handleStatusChange(value)}>\n {\n /* @ts-ignore Because ts can't typecheck strings against our keys */\n t(\n actionStatusOptionsToTranslationKeys[\n value as ActionStatusOptions\n ],\n )\n }\n </MenuItem>\n ))}\n </Menu>\n <IconButton onClick={handleDeleteAction}>\n <DeleteIcon />\n </IconButton>\n </Box>\n <Collapse in={isExpanded}>\n <Typography sx={{ ...label, marginTop: 1 }}>\n {t('dictionary.description')}\n </Typography>\n <Markdown description={action.description} />\n\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'end',\n marginTop: '16px',\n }}\n >\n <Box>\n <Typography sx={label}>{t('dictionary.url')}</Typography>\n {action.url ? (\n <Link\n sx={{\n ...body2,\n wordBreak: 'break-all',\n }}\n target=\"_blank\"\n rel=\"noreferrer\"\n href={\n action.url.startsWith('http') ? action.url : `//${action.url}`\n }\n >\n {action.url}\n </Link>\n ) : (\n <Typography sx={emptyState}>\n {t('dictionary.emptyField', {\n field: t('dictionary.url').toLowerCase(),\n })}\n </Typography>\n )}\n </Box>\n </Box>\n </Collapse>\n\n <DeleteActionConfirmation\n isOpen={deleteActionConfirmationIsOpen}\n setIsOpen={setDeleteActionConfirmationIsOpen}\n onConfirm={confirmDeleteAction}\n />\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,SAAS,SAAU,CAAA;AAAA,EACxB,MAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAmB,EAAA;AACjB,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,MAAM,EAAE,gBAAA,EAAkB,oBAAqB,EAAA,GAAI,WAAY,EAAA;AAC/D,EAAM,MAAA,UAAA,GAAa,gBAAiB,CAAA,MAAA,CAAO,EAAE,CAAA;AAE7C,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAkB,KAAK,CAAA;AACzD,EAAA,MAAM,CAAC,8BAAA,EAAgC,iCAAiC,CAAA,GACtE,SAAS,KAAK,CAAA;AAEhB,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,QAAS,EAAA;AAClC,EAAA,MAAM,EAAE,0BAAA,EAA4B,yBAA2B,EAAA,QAAA,KAC7D,WAAY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AAAA,YACZ,SAAW,EAAA;AAAA,WACb;AAAA,UAEA,+BAAC,GACC,EAAA,EAAA,QAAA,EAAA;AAAA,4BAAA,GAAA,CAAC,UAAW,EAAA,EAAA,EAAA,EAAI,KAAQ,EAAA,QAAA,EAAA,CAAA,CAAE,gBAAgB,CAAE,EAAA,CAAA;AAAA,YAC3C,OAAO,GACN,mBAAA,GAAA;AAAA,cAAC,IAAA;AAAA,cAAA;AAAA,gBACC,EAAI,EAAA;AAAA,kBACF,GAAG,KAAA;AAAA,kBACH,SAAW,EAAA;AAAA,iBACb;AAAA,gBACA,MAAO,EAAA,QAAA;AAAA,gBACP,GAAI,EAAA,YAAA;AAAA,gBACJ,IAAA,EACE,MAAO,CAAA,GAAA,CAAI,UAAW,CAAA,MAAM,IAAI,MAAO,CAAA,GAAA,GAAM,CAAK,EAAA,EAAA,MAAA,CAAO,GAAG,CAAA,CAAA;AAAA,gBAG7D,QAAO,EAAA,MAAA,CAAA;AAAA;AAAA,gCAGT,GAAA,CAAA,UAAA,EAAA,EAAW,EAAI,EAAA,UAAA,EACb,YAAE,uBAAyB,EAAA;AAAA,cAC1B,KAAO,EAAA,CAAA,CAAE,gBAAgB,CAAA,CAAE,WAAY;AAAA,aACxC,CACH,EAAA;AAAA,WAEJ,EAAA;AAAA;AAAA;AACF,KACF,EAAA,CAAA;AAAA,oBAEA,GAAA;AAAA,MAAC,wBAAA;AAAA,MAAA;AAAA,QACC,MAAQ,EAAA,8BAAA;AAAA,QACR,SAAW,EAAA,iCAAA;AAAA,QACX,SAAW,EAAA;AAAA;AAAA;AACb,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
3
|
+
import DeleteIcon from '@mui/icons-material/Delete';
|
|
2
4
|
import Box from '@mui/material/Box';
|
|
3
|
-
import Typography from '@mui/material/Typography';
|
|
4
5
|
import IconButton from '@mui/material/IconButton';
|
|
5
|
-
import
|
|
6
|
-
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
7
|
-
import { pluginRiScTranslationRef } from '../../../utils/translations.esm.js';
|
|
8
|
-
import { heading3 } from '../../common/typography.esm.js';
|
|
6
|
+
import Typography from '@mui/material/Typography';
|
|
9
7
|
import { Controller } from 'react-hook-form';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { ActionStatusOptions, urlRegExpPattern } from '../../../utils/constants.esm.js';
|
|
9
|
+
import { pluginRiScTranslationRef } from '../../../utils/translations.esm.js';
|
|
10
|
+
import { actionStatusOptionsToTranslationKeys } from '../../../utils/utilityfunctions.esm.js';
|
|
12
11
|
import { Input } from '../../common/Input.esm.js';
|
|
13
12
|
import { MarkdownInput } from '../../common/MarkdownInput.esm.js';
|
|
13
|
+
import { Select } from '../../common/Select.esm.js';
|
|
14
|
+
import { heading3 } from '../../common/typography.esm.js';
|
|
14
15
|
|
|
15
16
|
function ActionFormItem({
|
|
16
17
|
formMethods,
|
|
@@ -21,11 +22,13 @@ function ActionFormItem({
|
|
|
21
22
|
}) {
|
|
22
23
|
const { t } = useTranslationRef(pluginRiScTranslationRef);
|
|
23
24
|
const { control, register, formState } = formMethods;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const actionStatusOptions = Object.values(ActionStatusOptions).map(
|
|
26
|
+
(actionStatus) => ({
|
|
27
|
+
value: actionStatus,
|
|
28
|
+
/* @ts-ignore Because ts can't typecheck strings against our keys */
|
|
29
|
+
renderedValue: t(actionStatusOptionsToTranslationKeys[actionStatus])
|
|
30
|
+
})
|
|
31
|
+
);
|
|
29
32
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
30
33
|
Box,
|
|
31
34
|
{
|
|
@@ -66,7 +69,8 @@ function ActionFormItem({
|
|
|
66
69
|
required: true,
|
|
67
70
|
...register(`actions.${index}.title`, { required: true }),
|
|
68
71
|
error: formState.errors?.actions?.[index]?.title !== void 0,
|
|
69
|
-
label: t("dictionary.title")
|
|
72
|
+
label: t("dictionary.title"),
|
|
73
|
+
helperText: formState.errors?.actions?.[index]?.title && t("scenarioDrawer.measureTab.addMeasureTitleError")
|
|
70
74
|
}
|
|
71
75
|
),
|
|
72
76
|
/* @__PURE__ */ jsx(
|
|
@@ -116,7 +120,7 @@ function ActionFormItem({
|
|
|
116
120
|
control,
|
|
117
121
|
name: `actions.${index}.status`,
|
|
118
122
|
label: t("dictionary.status"),
|
|
119
|
-
options:
|
|
123
|
+
options: actionStatusOptions
|
|
120
124
|
}
|
|
121
125
|
)
|
|
122
126
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionFormItem.esm.js","sources":["../../../../src/components/scenarioDrawer/components/ActionFormItem.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"ActionFormItem.esm.js","sources":["../../../../src/components/scenarioDrawer/components/ActionFormItem.tsx"],"sourcesContent":["import { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport DeleteIcon from '@mui/icons-material/Delete';\nimport Box from '@mui/material/Box';\nimport IconButton from '@mui/material/IconButton';\nimport Typography from '@mui/material/Typography';\nimport {\n Controller,\n UseFieldArrayRemove,\n UseFormReturn,\n} from 'react-hook-form';\nimport {\n ActionStatusOptions,\n urlRegExpPattern,\n} from '../../../utils/constants';\nimport { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { FormScenario } from '../../../utils/types';\nimport { actionStatusOptionsToTranslationKeys } from '../../../utils/utilityfunctions';\nimport { Input } from '../../common/Input';\nimport { MarkdownInput } from '../../common/MarkdownInput';\nimport { Select } from '../../common/Select';\nimport { heading3 } from '../../common/typography';\n\ntype ActionFormItemProps = {\n formMethods: UseFormReturn<FormScenario>;\n index: number;\n remove: UseFieldArrayRemove;\n showTitleNumber?: boolean;\n handleDelete?: () => void;\n};\n\nexport function ActionFormItem({\n formMethods,\n index,\n remove,\n showTitleNumber = true,\n handleDelete,\n}: ActionFormItemProps) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const { control, register, formState } = formMethods;\n\n const actionStatusOptions = Object.values(ActionStatusOptions).map(\n actionStatus => ({\n value: actionStatus,\n /* @ts-ignore Because ts can't typecheck strings against our keys */\n renderedValue: t(actionStatusOptionsToTranslationKeys[actionStatus]),\n }),\n );\n\n return (\n <>\n <Box\n sx={{\n display: 'grid',\n gap: '24px',\n padding: 0,\n }}\n >\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n }}\n >\n {showTitleNumber ? (\n <Typography sx={heading3}>\n {t('dictionary.measure')} {index + 1}\n </Typography>\n ) : (\n <Typography sx={heading3}>{t('dictionary.edit')}</Typography>\n )}\n <IconButton\n onClick={() => (handleDelete ? handleDelete() : remove(index))}\n color=\"primary\"\n >\n <DeleteIcon aria-label=\"Delete\" />\n </IconButton>\n </Box>\n <Input\n required\n {...register(`actions.${index}.title`, { required: true })}\n error={formState.errors?.actions?.[index]?.title !== undefined}\n label={t('dictionary.title')}\n helperText={\n formState.errors?.actions?.[index]?.title &&\n t('scenarioDrawer.measureTab.addMeasureTitleError')\n }\n />\n <Controller\n control={control}\n name={`actions.${index}.description`}\n render={({ field: { onChange, value }, fieldState: { error } }) => (\n <MarkdownInput\n label={t('dictionary.description')}\n value={value}\n onMarkdownChange={onChange}\n error={!!error}\n minRows={4}\n />\n )}\n />\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: '2fr 1fr',\n gap: '24px',\n }}\n >\n <Input\n {...register(`actions.${index}.url`, {\n pattern: {\n value: urlRegExpPattern,\n message: t('scenarioDrawer.action.urlError'),\n },\n })}\n label={t('dictionary.url')}\n helperText={formState.errors.actions?.[index]?.url?.message}\n error={!!formState.errors.actions?.[index]?.url?.message}\n />\n <Select<FormScenario>\n required\n control={control}\n name={`actions.${index}.status`}\n label={t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AAAA;AAAA;AACX;AAAA,SAEJ;AAAA,wBACA,IAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,EAAI,EAAA;AAAA,cACF,OAAS,EAAA,MAAA;AAAA,cACT,mBAAqB,EAAA,SAAA;AAAA,cACrB,GAAK,EAAA;AAAA,aACP;AAAA,YAEA,QAAA,EAAA;AAAA,8BAAA,GAAA;AAAA,gBAAC,KAAA;AAAA,gBAAA;AAAA,kBACE,GAAG,QAAA,CAAS,CAAW,QAAA,EAAA,KAAK,CAAQ,IAAA,CAAA,EAAA;AAAA,oBACnC,OAAS,EAAA;AAAA,sBACP,KAAO,EAAA,gBAAA;AAAA,sBACP,OAAA,EAAS,EAAE,gCAAgC;AAAA;AAC7C,mBACD,CAAA;AAAA,kBACD,KAAA,EAAO,EAAE,gBAAgB,CAAA;AAAA,kBACzB,YAAY,SAAU,CAAA,MAAA,CAAO,OAAU,GAAA,KAAK,GAAG,GAAK,EAAA,OAAA;AAAA,kBACpD,KAAA,EAAO,CAAC,CAAC,SAAA,CAAU,OAAO,OAAU,GAAA,KAAK,GAAG,GAAK,EAAA;AAAA;AAAA,eACnD;AAAA,8BACA,GAAA;AAAA,gBAAC,MAAA;AAAA,gBAAA;AAAA,kBACC,QAAQ,EAAA,IAAA;AAAA,kBACR,OAAA;AAAA,kBACA,IAAA,EAAM,WAAW,KAAK,CAAA,OAAA,CAAA;AAAA,kBACtB,KAAA,EAAO,EAAE,mBAAmB,CAAA;AAAA,kBAC5B,OAAS,EAAA;AAAA;AAAA;AACX;AAAA;AAAA;AACF;AAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -13,6 +13,7 @@ import { useFieldArray } from 'react-hook-form';
|
|
|
13
13
|
import { ActionFormItem } from './ActionFormItem.esm.js';
|
|
14
14
|
import Button from '@mui/material/Button';
|
|
15
15
|
import { AddCircle } from '@mui/icons-material';
|
|
16
|
+
import Box from '@mui/material/Box';
|
|
16
17
|
|
|
17
18
|
function ActionsSection({
|
|
18
19
|
formMethods,
|
|
@@ -28,7 +29,18 @@ function ActionsSection({
|
|
|
28
29
|
const currentActions = watch("actions");
|
|
29
30
|
if (isEditing) {
|
|
30
31
|
return /* @__PURE__ */ jsxs(Paper, { sx: section, children: [
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 2 }, children: [
|
|
33
|
+
/* @__PURE__ */ jsx(Typography, { sx: heading3, children: t("dictionary.measure") }),
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
Button,
|
|
36
|
+
{
|
|
37
|
+
startIcon: /* @__PURE__ */ jsx(AddCircle, {}),
|
|
38
|
+
color: "primary",
|
|
39
|
+
onClick: () => append(emptyAction()),
|
|
40
|
+
children: t("scenarioDrawer.measureTab.addMeasureButton")
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
] }),
|
|
32
44
|
fields.map((field, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
33
45
|
/* @__PURE__ */ jsx(Divider, { variant: "fullWidth" }),
|
|
34
46
|
/* @__PURE__ */ jsx(
|
|
@@ -40,16 +52,7 @@ function ActionsSection({
|
|
|
40
52
|
},
|
|
41
53
|
index
|
|
42
54
|
)
|
|
43
|
-
] }, field.id))
|
|
44
|
-
/* @__PURE__ */ jsx(
|
|
45
|
-
Button,
|
|
46
|
-
{
|
|
47
|
-
startIcon: /* @__PURE__ */ jsx(AddCircle, {}),
|
|
48
|
-
color: "primary",
|
|
49
|
-
onClick: () => append(emptyAction()),
|
|
50
|
-
children: t("scenarioDrawer.measureTab.addMeasureButton")
|
|
51
|
-
}
|
|
52
|
-
)
|
|
55
|
+
] }, field.id))
|
|
53
56
|
] });
|
|
54
57
|
}
|
|
55
58
|
return /* @__PURE__ */ jsxs(Paper, { sx: section, children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionsSection.esm.js","sources":["../../../../src/components/scenarioDrawer/components/ActionsSection.tsx"],"sourcesContent":["import { ActionBox } from './ActionBox';\nimport { Fragment } from 'react';\nimport Paper from '@mui/material/Paper';\nimport Typography from '@mui/material/Typography';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { emptyAction } from '../../../contexts/ScenarioContext';\nimport { section } from '../scenarioDrawerComponents';\nimport { emptyState, heading3 } from '../../common/typography';\nimport Divider from '@mui/material/Divider';\nimport { useFieldArray, UseFormReturn } from 'react-hook-form';\nimport { FormScenario } from '../../../utils/types';\nimport { ActionFormItem } from './ActionFormItem';\nimport Button from '@mui/material/Button';\nimport { AddCircle } from '@mui/icons-material';\n\ntype ActionSectionProps = {\n formMethods: UseFormReturn<FormScenario>;\n isEditing: boolean;\n onSubmit: () => void;\n};\n\nexport function ActionsSection({\n formMethods,\n isEditing,\n onSubmit,\n}: ActionSectionProps) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const { control, watch } = formMethods;\n const { fields, append, remove } = useFieldArray({\n control,\n name: 'actions',\n });\n\n const currentActions = watch('actions');\n\n if (isEditing) {\n return (\n <Paper sx={section}>\n <Typography sx={heading3}>{t('dictionary.measure')}</Typography>\n {fields.map((field, index) => (\n <Fragment key={field.id}>\n <Divider variant=\"fullWidth\" />\n <ActionFormItem\n key={index}\n formMethods={formMethods}\n index={index}\n remove={remove}\n />\n </Fragment>\n ))}\n
|
|
1
|
+
{"version":3,"file":"ActionsSection.esm.js","sources":["../../../../src/components/scenarioDrawer/components/ActionsSection.tsx"],"sourcesContent":["import { ActionBox } from './ActionBox';\nimport { Fragment } from 'react';\nimport Paper from '@mui/material/Paper';\nimport Typography from '@mui/material/Typography';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { emptyAction } from '../../../contexts/ScenarioContext';\nimport { section } from '../scenarioDrawerComponents';\nimport { emptyState, heading3 } from '../../common/typography';\nimport Divider from '@mui/material/Divider';\nimport { useFieldArray, UseFormReturn } from 'react-hook-form';\nimport { FormScenario } from '../../../utils/types';\nimport { ActionFormItem } from './ActionFormItem';\nimport Button from '@mui/material/Button';\nimport { AddCircle } from '@mui/icons-material';\nimport Box from '@mui/material/Box';\n\ntype ActionSectionProps = {\n formMethods: UseFormReturn<FormScenario>;\n isEditing: boolean;\n onSubmit: () => void;\n};\n\nexport function ActionsSection({\n formMethods,\n isEditing,\n onSubmit,\n}: ActionSectionProps) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const { control, watch } = formMethods;\n const { fields, append, remove } = useFieldArray({\n control,\n name: 'actions',\n });\n\n const currentActions = watch('actions');\n\n if (isEditing) {\n return (\n <Paper sx={section}>\n <Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>\n <Typography sx={heading3}>{t('dictionary.measure')}</Typography>\n <Button\n startIcon={<AddCircle />}\n color=\"primary\"\n onClick={() => append(emptyAction())}\n >\n {t('scenarioDrawer.measureTab.addMeasureButton')}\n </Button>\n </Box>\n {fields.map((field, index) => (\n <Fragment key={field.id}>\n <Divider variant=\"fullWidth\" />\n <ActionFormItem\n key={index}\n formMethods={formMethods}\n index={index}\n remove={remove}\n />\n </Fragment>\n ))}\n </Paper>\n );\n }\n\n return (\n <Paper sx={section}>\n <Typography sx={heading3}>{t('dictionary.measures')}</Typography>\n\n {fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Divider />\n <ActionBox\n action={currentActions[index]}\n index={index}\n formMethods={formMethods}\n remove={remove}\n onSubmit={onSubmit}\n />\n </Fragment>\n ))\n ) : (\n <Typography sx={emptyState}>\n {t('dictionary.emptyField', {\n field: t('dictionary.measures').toLowerCase(),\n })}\n </Typography>\n )}\n </Paper>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuBO,SAAS,cAAe,CAAA;AAAA,EAC7B,WAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,CAAuB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