@kartverket/backstage-plugin-risk-scorecard 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,39 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
3
3
  import { pluginRiScTranslationRef } from '../../utils/translations.esm.js';
4
- import { Card, CardBody, Text, TableRoot, TableHeader, Column, TableBody, Row, CellText } from '@backstage/ui';
4
+ import { useTable, Card, CardBody, Text, Table, CellText } from '@backstage/ui';
5
5
  import { useSystemChildComponents } from '../../utils/entityRelations.esm.js';
6
6
 
7
7
  function RiScRelationComponent() {
8
8
  const { t } = useTranslationRef(pluginRiScTranslationRef);
9
9
  const componentRelations = useSystemChildComponents();
10
+ const columns = [
11
+ {
12
+ id: "name",
13
+ label: "Name",
14
+ isRowHeader: true,
15
+ cell: (item) => /* @__PURE__ */ jsx(
16
+ CellText,
17
+ {
18
+ title: item.name,
19
+ href: item.riscUrl,
20
+ leadingIcon: /* @__PURE__ */ jsx("i", { className: "ri-link" })
21
+ }
22
+ )
23
+ },
24
+ { id: "kind", label: "Kind", cell: (item) => /* @__PURE__ */ jsx(CellText, { title: item.kind }) }
25
+ ];
26
+ const { tableProps } = useTable({
27
+ mode: "complete",
28
+ paginationOptions: {
29
+ pageSize: 5,
30
+ showPageSizeOptions: false
31
+ },
32
+ getData: () => componentRelations.map((item) => ({
33
+ id: item.entityRef,
34
+ ...item
35
+ }))
36
+ });
10
37
  return /* @__PURE__ */ jsx(Fragment, { children: componentRelations.length > 0 && /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardBody, { children: [
11
38
  /* @__PURE__ */ jsx(
12
39
  Text,
@@ -18,23 +45,7 @@ function RiScRelationComponent() {
18
45
  children: t("dictionary.relatedComponents")
19
46
  }
20
47
  ),
21
- /* @__PURE__ */ jsxs(TableRoot, { "aria-label": "Related Components", children: [
22
- /* @__PURE__ */ jsxs(TableHeader, { children: [
23
- /* @__PURE__ */ jsx(Column, { isRowHeader: true, children: "Name" }),
24
- /* @__PURE__ */ jsx(Column, { children: "Kind" })
25
- ] }),
26
- /* @__PURE__ */ jsx(TableBody, { children: componentRelations.map((comp) => /* @__PURE__ */ jsxs(Row, { children: [
27
- /* @__PURE__ */ jsx(
28
- CellText,
29
- {
30
- title: comp.name,
31
- leadingIcon: /* @__PURE__ */ jsx("i", { className: "ri-link" }),
32
- href: comp.riscUrl
33
- }
34
- ),
35
- /* @__PURE__ */ jsx(CellText, { title: comp.kind })
36
- ] }, comp.entityRef)) })
37
- ] })
48
+ /* @__PURE__ */ jsx(Table, { columnConfig: columns, ...tableProps })
38
49
  ] }) }) });
39
50
  }
40
51
 
@@ -1 +1 @@
1
- {"version":3,"file":"RiScRelationComponent.esm.js","sources":["../../../src/components/riScInfo/RiScRelationComponent.tsx"],"sourcesContent":["import { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { pluginRiScTranslationRef } from '../../utils/translations.ts';\nimport {\n Card,\n CardBody,\n Text,\n TableHeader,\n Column,\n TableBody,\n CellText,\n Row,\n TableRoot,\n} from '@backstage/ui';\nimport { useSystemChildComponents } from '../../utils/entityRelations.ts';\n\nexport function RiScRelationComponent() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n const componentRelations = useSystemChildComponents();\n\n return (\n <>\n {componentRelations.length > 0 && (\n <Card>\n <CardBody>\n <Text\n variant=\"title-small\"\n as=\"h6\"\n weight=\"bold\"\n style={{ marginBottom: '12px' }}\n >\n {t('dictionary.relatedComponents')}\n </Text>\n <TableRoot aria-label=\"Related Components\">\n <TableHeader>\n <Column isRowHeader>Name</Column>\n <Column>Kind</Column>\n </TableHeader>\n <TableBody>\n {componentRelations.map(comp => (\n <Row key={comp.entityRef}>\n <CellText\n title={comp.name}\n leadingIcon={<i className=\"ri-link\" />}\n href={comp.riscUrl}\n />\n <CellText title={comp.kind} />\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,SACb;AAAA,wBACA,GAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAO,IAAA,CAAK,IAAA,EAAM;AAAA,OAAA,EAAA,EANpB,IAAA,CAAK,SAOf,CACD,CAAA,EACH;AAAA,KAAA,EACF;AAAA,GAAA,EACF,GACF,CAAA,EAEJ,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"RiScRelationComponent.esm.js","sources":["../../../src/components/riScInfo/RiScRelationComponent.tsx"],"sourcesContent":["import { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { pluginRiScTranslationRef } from '../../utils/translations.ts';\nimport {\n Card,\n CardBody,\n Text,\n Table,\n useTable,\n type ColumnConfig,\n CellText,\n} from '@backstage/ui';\nimport { useSystemChildComponents } from '../../utils/entityRelations.ts';\n\nexport function RiScRelationComponent() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n const componentRelations = useSystemChildComponents();\n const columns: ColumnConfig<any>[] = [\n {\n id: 'name',\n label: 'Name',\n isRowHeader: true,\n cell: item => (\n <CellText\n title={item.name}\n href={item.riscUrl}\n leadingIcon={<i className=\"ri-link\" />}\n />\n ),\n },\n { id: 'kind', label: 'Kind', cell: item => <CellText title={item.kind} /> },\n ];\n\n const { tableProps } = useTable({\n mode: 'complete',\n paginationOptions: {\n pageSize: 5,\n showPageSizeOptions: false,\n },\n getData: () =>\n componentRelations.map(item => ({\n id: item.entityRef,\n ...item,\n })),\n });\n\n return (\n <>\n {componentRelations.length > 0 && (\n <Card>\n <CardBody>\n <Text\n variant=\"title-small\"\n as=\"h6\"\n weight=\"bold\"\n style={{ marginBottom: '12px' }}\n >\n {t('dictionary.relatedComponents')}\n </Text>\n <Table columnConfig={columns} {...tableProps} />\n </CardBody>\n </Card>\n )}\n </>\n );\n}\n"],"names":[],"mappings":";;;;;;AAaO,SAAS,qBAAA,GAAwB;AACtC,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAA,MAAM,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MAAA,EAAO;AAAA,QAE7B,YAAE,8BAA8B;AAAA;AAAA,KACnC;AAAA,oBACA,GAAA,CAAC,KAAA,EAAA,EAAM,YAAA,EAAc,OAAA,EAAU,GAAG,UAAA,EAAY;AAAA,GAAA,EAChD,GACF,CAAA,EAEJ,CAAA;AAEJ;;;;"}
@@ -1,12 +1,10 @@
1
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { pluginRiScTranslationRef } from '../../../utils/translations.esm.js';
3
3
  import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
4
- import { useController } from 'react-hook-form';
5
- import { RiskRadioButton } from './RiskRadioButton.esm.js';
6
- import RadioGroup from '@mui/material/RadioGroup';
7
4
  import { consequenceOptions } from '../../../utils/constants.esm.js';
8
5
  import { Box, Text } from '@backstage/ui';
9
6
  import styles from '../ScenarioWizardTable.module.css.esm.js';
7
+ import { createInfoWithHeadersComponent, RiskTableBase } from './RiskTableBase.esm.js';
10
8
 
11
9
  function ConsequenceTableInfo() {
12
10
  const { t } = useTranslationRef(pluginRiScTranslationRef);
@@ -16,107 +14,66 @@ function ConsequenceTableInfo() {
16
14
  function getRow(resourceKey, cellType) {
17
15
  return /* @__PURE__ */ jsxs(Fragment, { children: [
18
16
  /* @__PURE__ */ jsx(Box, { className: styles.riskLabelCell, children: /* @__PURE__ */ jsx(Text, { as: "p", variant: "body-large", weight: "bold", children: t(`consequenceTable.columns.${resourceKey}`) }) }),
19
- getTextCell(resourceKey, 0, cellType[0]),
20
- getTextCell(resourceKey, 1, cellType[1]),
21
- getTextCell(resourceKey, 2, cellType[2]),
22
- getTextCell(resourceKey, 3, cellType[3]),
23
- getTextCell(resourceKey, 4, cellType[4])
17
+ Array.from(
18
+ { length: 5 },
19
+ (_, i) => getTextCell(resourceKey, i, cellType[i])
20
+ )
24
21
  ] });
25
22
  }
26
- return /* @__PURE__ */ jsxs(Box, { className: styles.consequenceGrid, children: [
27
- getRow("economical", [
28
- "riskCell",
29
- "riskCell",
30
- "riskCell",
31
- "riskCell",
32
- "riskCell"
33
- ]),
34
- getRow("privacy", [
35
- "riskCell",
36
- "riskCell",
37
- "riskCell",
38
- "riskCell",
39
- "riskVoidCell"
40
- ]),
41
- getRow("reputation", [
42
- "riskCell",
43
- "riskCell",
44
- "riskCell",
45
- "riskVoidCell",
46
- "riskVoidCell"
47
- ]),
48
- getRow("health", [
49
- "riskVoidCell",
50
- "riskVoidCell",
51
- "riskCell",
52
- "riskCell",
53
- "riskCell"
54
- ])
55
- ] });
23
+ const consequenceRows = [
24
+ {
25
+ key: "economical",
26
+ cells: ["riskCell", "riskCell", "riskCell", "riskCell", "riskCell"]
27
+ },
28
+ {
29
+ key: "privacy",
30
+ cells: ["riskCell", "riskCell", "riskCell", "riskCell", "riskVoidCell"]
31
+ },
32
+ {
33
+ key: "reputation",
34
+ cells: [
35
+ "riskCell",
36
+ "riskCell",
37
+ "riskCell",
38
+ "riskVoidCell",
39
+ "riskVoidCell"
40
+ ]
41
+ },
42
+ {
43
+ key: "health",
44
+ cells: [
45
+ "riskVoidCell",
46
+ "riskVoidCell",
47
+ "riskCell",
48
+ "riskCell",
49
+ "riskCell"
50
+ ]
51
+ }
52
+ ];
53
+ return /* @__PURE__ */ jsx(Box, { className: styles.consequenceGrid, children: consequenceRows.map((row) => getRow(row.key, row.cells)) });
56
54
  }
57
55
  function ConsequenceTable({
58
56
  formMethods,
59
57
  riskType
60
58
  }) {
61
- const { t } = useTranslationRef(pluginRiScTranslationRef);
62
- const { field } = useController({
63
- name: `${riskType}.consequence`,
64
- control: formMethods.control
65
- });
66
- function getRadioLabel(row) {
67
- return `${row}: ${t(`consequenceTable.rows.${row}`)}`;
68
- }
69
- function getRadioCell(row) {
70
- return /* @__PURE__ */ jsx(
71
- RiskRadioButton,
72
- {
73
- value: consequenceOptions[row],
74
- ref: field.ref,
75
- label: getRadioLabel(row + 1)
76
- }
77
- );
78
- }
79
- return /* @__PURE__ */ jsxs(Box, { className: styles.riskTable, children: [
80
- /* @__PURE__ */ jsxs(
81
- RadioGroup,
82
- {
83
- ...field,
84
- className: `${styles.riskRow} ${styles.consequenceRow}`,
85
- children: [
86
- /* @__PURE__ */ jsx(Box, { className: styles.riskLabelCell }),
87
- getRadioCell(0),
88
- getRadioCell(1),
89
- getRadioCell(2),
90
- getRadioCell(3),
91
- getRadioCell(4)
92
- ]
93
- }
94
- ),
95
- /* @__PURE__ */ jsx(ConsequenceTableInfo, {})
96
- ] });
97
- }
98
- function ConsequenceTableInfoWithHeaders() {
99
- const { t } = useTranslationRef(pluginRiScTranslationRef);
100
- function getRadioLabel(row) {
101
- return (
102
- /* @ts-ignore Because ts can't typecheck strings agains our keys */
103
- /* @__PURE__ */ jsx(Text, { as: "p", variant: "body-large", children: `${row}: ${t(
104
- `consequenceTable.rows.${row}`
105
- )}` })
106
- );
107
- }
108
- return /* @__PURE__ */ jsxs(Box, { className: styles.riskTable, children: [
109
- /* @__PURE__ */ jsxs(Box, { className: styles.consequenceGrid, children: [
110
- /* @__PURE__ */ jsx(Box, { className: styles.riskLabelCell }),
111
- getRadioLabel(1),
112
- getRadioLabel(2),
113
- getRadioLabel(3),
114
- getRadioLabel(4),
115
- getRadioLabel(5)
116
- ] }),
117
- /* @__PURE__ */ jsx(ConsequenceTableInfo, {})
118
- ] });
59
+ return /* @__PURE__ */ jsx(
60
+ RiskTableBase,
61
+ {
62
+ formMethods,
63
+ riskType,
64
+ fieldName: "consequence",
65
+ options: consequenceOptions,
66
+ additionalClassName: styles.consequenceRow,
67
+ translationPrefix: "consequenceTable",
68
+ InfoComponent: ConsequenceTableInfo
69
+ }
70
+ );
119
71
  }
72
+ const ConsequenceTableInfoWithHeaders = createInfoWithHeadersComponent(
73
+ "consequenceTable",
74
+ ConsequenceTableInfo,
75
+ true
76
+ );
120
77
 
121
78
  export { ConsequenceTable, ConsequenceTableInfoWithHeaders };
122
79
  //# sourceMappingURL=ConsequenceTable.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConsequenceTable.esm.js","sources":["../../../../src/components/scenarioWizard/components/ConsequenceTable.tsx"],"sourcesContent":["import { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { useController, UseFormReturn } from 'react-hook-form';\nimport { FormScenario } from '../../../utils/types';\nimport { RiskRadioButton } from './RiskRadioButton';\nimport RadioGroup from '@mui/material/RadioGroup';\nimport { consequenceOptions } from '../../../utils/constants';\nimport { Text, Box } from '@backstage/ui';\nimport styles from '../ScenarioWizardTable.module.css';\n\nfunction ConsequenceTableInfo() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n function getTextCell(\n resourceKey: string,\n row: number,\n cellType: keyof typeof styles,\n ) {\n return (\n <Box className={styles[cellType]}>\n {/* @ts-ignore */}\n {t(`consequenceTable.cells.${resourceKey}.${row + 1}`)}\n </Box>\n );\n }\n\n function getRow(resourceKey: string, cellType: Array<keyof typeof styles>) {\n return (\n <>\n <Box className={styles.riskLabelCell}>\n <Text as=\"p\" variant=\"body-large\" weight=\"bold\">\n {/* @ts-ignore */}\n {t(`consequenceTable.columns.${resourceKey}`)}\n </Text>\n </Box>\n {getTextCell(resourceKey, 0, cellType[0])}\n {getTextCell(resourceKey, 1, cellType[1])}\n {getTextCell(resourceKey, 2, cellType[2])}\n {getTextCell(resourceKey, 3, cellType[3])}\n {getTextCell(resourceKey, 4, cellType[4])}\n </>\n );\n }\n\n return (\n <Box className={styles.consequenceGrid}>\n {getRow('economical', [\n 'riskCell',\n 'riskCell',\n 'riskCell',\n 'riskCell',\n 'riskCell',\n ])}\n {getRow('privacy', [\n 'riskCell',\n 'riskCell',\n 'riskCell',\n 'riskCell',\n 'riskVoidCell',\n ])}\n {getRow('reputation', [\n 'riskCell',\n 'riskCell',\n 'riskCell',\n 'riskVoidCell',\n 'riskVoidCell',\n ])}\n {getRow('health', [\n 'riskVoidCell',\n 'riskVoidCell',\n 'riskCell',\n 'riskCell',\n 'riskCell',\n ])}\n </Box>\n );\n}\n\nexport function ConsequenceTable({\n formMethods,\n riskType,\n}: {\n formMethods: UseFormReturn<FormScenario>;\n riskType: keyof Pick<FormScenario, 'risk' | 'remainingRisk'>;\n}) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const { field } = useController({\n name: `${riskType}.consequence`,\n control: formMethods.control,\n });\n\n function getRadioLabel(row: number) {\n /* @ts-ignore Because ts can't typecheck strings agains our keys */\n return `${row}: ${t(`consequenceTable.rows.${row}`)}`;\n }\n\n function getRadioCell(row: number) {\n return (\n <RiskRadioButton\n value={consequenceOptions[row]}\n ref={field.ref}\n label={getRadioLabel(row + 1)}\n />\n );\n }\n\n return (\n <Box className={styles.riskTable}>\n <RadioGroup\n {...field}\n className={`${styles.riskRow} ${styles.consequenceRow}`}\n >\n <Box className={styles.riskLabelCell} />\n {getRadioCell(0)}\n {getRadioCell(1)}\n {getRadioCell(2)}\n {getRadioCell(3)}\n {getRadioCell(4)}\n </RadioGroup>\n <ConsequenceTableInfo />\n </Box>\n );\n}\n\nexport function ConsequenceTableInfoWithHeaders() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n function getRadioLabel(row: number) {\n return (\n /* @ts-ignore Because ts can't typecheck strings agains our keys */\n <Text as=\"p\" variant=\"body-large\">{`${row}: ${t(\n `consequenceTable.rows.${row}`,\n )}`}</Text>\n );\n }\n return (\n <Box className={styles.riskTable}>\n <Box className={styles.consequenceGrid}>\n <Box className={styles.riskLabelCell} />\n {getRadioLabel(1)}\n {getRadioLabel(2)}\n {getRadioLabel(3)}\n {getRadioLabel(4)}\n {getRadioLabel(5)}\n </Box>\n <ConsequenceTableInfo />\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AAUA,SAAS,oBAAA,GAAuB;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,SAAS,WAAA,CACP,WAAA,EACA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AAAA,MACf,cAAc,CAAC;AAAA,KAAA,EAClB,CAAA;AAAA,wBACC,oBAAA,EAAA,EAAqB;AAAA,GAAA,EACxB,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ConsequenceTable.esm.js","sources":["../../../../src/components/scenarioWizard/components/ConsequenceTable.tsx"],"sourcesContent":["import { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { UseFormReturn } from 'react-hook-form';\nimport { FormScenario } from '../../../utils/types';\nimport { consequenceOptions } from '../../../utils/constants';\nimport { Text, Box } from '@backstage/ui';\nimport styles from '../ScenarioWizardTable.module.css';\nimport { createInfoWithHeadersComponent, RiskTableBase } from './RiskTableBase';\n\nfunction ConsequenceTableInfo() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n function getTextCell(\n resourceKey: string,\n row: number,\n cellType: keyof typeof styles,\n ) {\n return (\n <Box className={styles[cellType]}>\n {/* @ts-ignore */}\n {t(`consequenceTable.cells.${resourceKey}.${row + 1}`)}\n </Box>\n );\n }\n\n function getRow(resourceKey: string, cellType: Array<keyof typeof styles>) {\n return (\n <>\n <Box className={styles.riskLabelCell}>\n <Text as=\"p\" variant=\"body-large\" weight=\"bold\">\n {/* @ts-ignore */}\n {t(`consequenceTable.columns.${resourceKey}`)}\n </Text>\n </Box>\n {Array.from({ length: 5 }, (_, i) =>\n getTextCell(resourceKey, i, cellType[i]),\n )}\n </>\n );\n }\n\n const consequenceRows = [\n {\n key: 'economical',\n cells: ['riskCell', 'riskCell', 'riskCell', 'riskCell', 'riskCell'],\n },\n {\n key: 'privacy',\n cells: ['riskCell', 'riskCell', 'riskCell', 'riskCell', 'riskVoidCell'],\n },\n {\n key: 'reputation',\n cells: [\n 'riskCell',\n 'riskCell',\n 'riskCell',\n 'riskVoidCell',\n 'riskVoidCell',\n ],\n },\n {\n key: 'health',\n cells: [\n 'riskVoidCell',\n 'riskVoidCell',\n 'riskCell',\n 'riskCell',\n 'riskCell',\n ],\n },\n ];\n\n return (\n <Box className={styles.consequenceGrid}>\n {consequenceRows.map(row => getRow(row.key, row.cells))}\n </Box>\n );\n}\n\nexport function ConsequenceTable({\n formMethods,\n riskType,\n}: {\n formMethods: UseFormReturn<FormScenario>;\n riskType: keyof Pick<FormScenario, 'risk' | 'remainingRisk'>;\n}) {\n return (\n <RiskTableBase\n formMethods={formMethods}\n riskType={riskType}\n fieldName=\"consequence\"\n options={consequenceOptions}\n additionalClassName={styles.consequenceRow}\n translationPrefix=\"consequenceTable\"\n InfoComponent={ConsequenceTableInfo}\n />\n );\n}\n\nexport const ConsequenceTableInfoWithHeaders = createInfoWithHeadersComponent(\n 'consequenceTable',\n ConsequenceTableInfo,\n true,\n);\n"],"names":[],"mappings":";;;;;;;;AASA,SAAS,oBAAA,GAAuB;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,SAAS,WAAA,CACP,WAAA,EACA,GAAA,EACA,QAAA,EACA;AACA,IAAA,uBACE,GAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,QAAQ,CAAA,EAE5B,QAAA,EAAA,CAAA,CAAE,CAAA,uBAAA,EAA0B,WAAW,CAAA,CAAA,EAAI,GAAA,GAAM,CAAC,EAAE,CAAA,EACvD,CAAA;AAAA,EAEJ;AAEA,EAAA,SAAS,MAAA,CAAO,aAAqB,QAAA,EAAsC;AACzE,IAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,OAAI,SAAA,EAAW,MAAA,CAAO,aAAA,EACrB,QAAA,kBAAA,GAAA,CAAC,QAAK,EAAA,EAAG,GAAA,EAAI,OAAA,EAAQ,YAAA,EAAa,QAAO,MAAA,EAEtC,QAAA,EAAA,CAAA,CAAE,4BAA4B,WAAW,CAAA,CAAE,GAC9C,CAAA,EACF,CAAA;AAAA,MACC,KAAA,CAA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,MAAA,CAAO,cAAA;AAAA,MAC5B,iBAAA,EAAkB,kBAAA;AAAA,MAClB,aAAA,EAAe;AAAA;AAAA,GACjB;AAEJ;AAEO,MAAM,+BAAA,GAAkC,8BAAA;AAAA,EAC7C,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF;;;;"}
@@ -1,79 +1,39 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { pluginRiScTranslationRef } from '../../../utils/translations.esm.js';
3
3
  import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
4
- import { useController } from 'react-hook-form';
5
- import { RiskRadioButton } from './RiskRadioButton.esm.js';
6
- import RadioGroup from '@mui/material/RadioGroup';
7
4
  import { probabilityOptions } from '../../../utils/constants.esm.js';
8
- import { Box, Text } from '@backstage/ui';
5
+ import { Box } from '@backstage/ui';
9
6
  import styles from '../ScenarioWizardTable.module.css.esm.js';
7
+ import { createInfoWithHeadersComponent, RiskTableBase } from './RiskTableBase.esm.js';
10
8
 
11
9
  function ProbabilityTableInfo() {
12
10
  const { t } = useTranslationRef(pluginRiScTranslationRef);
13
11
  function getContentCell(row) {
14
12
  return /* @__PURE__ */ jsx(Box, { className: styles.riskCell, children: t(`probabilityTable.cells.${row + 1}`) });
15
13
  }
16
- return /* @__PURE__ */ jsxs(Box, { className: styles.riskRow, children: [
17
- getContentCell(0),
18
- getContentCell(1),
19
- getContentCell(2),
20
- getContentCell(3),
21
- getContentCell(4)
22
- ] });
14
+ return /* @__PURE__ */ jsx(Box, { className: styles.riskRow, children: Array.from({ length: 5 }, (_, i) => getContentCell(i)) });
23
15
  }
24
16
  function ProbabilityTable({
25
17
  formMethods,
26
18
  riskType
27
19
  }) {
28
- const { t } = useTranslationRef(pluginRiScTranslationRef);
29
- const { field } = useController({
30
- name: `${riskType}.probability`,
31
- control: formMethods.control
32
- });
33
- function getRadioLabel(row) {
34
- return `${row}: ${t(`probabilityTable.rows.${row}`)}`;
35
- }
36
- function getRadioCell(row) {
37
- return /* @__PURE__ */ jsx(
38
- RiskRadioButton,
39
- {
40
- value: probabilityOptions[row],
41
- ref: field.ref,
42
- label: getRadioLabel(row + 1)
43
- }
44
- );
45
- }
46
- return /* @__PURE__ */ jsxs(Box, { className: styles.riskTable, children: [
47
- /* @__PURE__ */ jsxs(RadioGroup, { ...field, className: styles.riskRow, children: [
48
- getRadioCell(0),
49
- getRadioCell(1),
50
- getRadioCell(2),
51
- getRadioCell(3),
52
- getRadioCell(4)
53
- ] }),
54
- /* @__PURE__ */ jsx(ProbabilityTableInfo, {})
55
- ] });
56
- }
57
- function ProbabilityTableInfoWithHeaders() {
58
- const { t } = useTranslationRef(pluginRiScTranslationRef);
59
- function getRadioLabel(row) {
60
- return (
61
- /* @ts-ignore Because ts can't typecheck strings agains our keys */
62
- /* @__PURE__ */ jsx(Text, { children: `${row}: ${t(`probabilityTable.rows.${row}`)}` })
63
- );
64
- }
65
- return /* @__PURE__ */ jsxs(Box, { className: styles.riskTable, children: [
66
- /* @__PURE__ */ jsxs(Box, { className: styles.consequenceGrid, children: [
67
- /* @__PURE__ */ jsx(Box, { className: styles.riskLabelCell }),
68
- getRadioLabel(1),
69
- getRadioLabel(2),
70
- getRadioLabel(3),
71
- getRadioLabel(4),
72
- getRadioLabel(5)
73
- ] }),
74
- /* @__PURE__ */ jsx(ProbabilityTableInfo, {})
75
- ] });
20
+ return /* @__PURE__ */ jsx(
21
+ RiskTableBase,
22
+ {
23
+ formMethods,
24
+ riskType,
25
+ fieldName: "probability",
26
+ options: probabilityOptions,
27
+ translationPrefix: "probabilityTable",
28
+ InfoComponent: ProbabilityTableInfo
29
+ }
30
+ );
76
31
  }
32
+ const ProbabilityTableInfoWithHeaders = createInfoWithHeadersComponent(
33
+ "probabilityTable",
34
+ ProbabilityTableInfo,
35
+ false
36
+ );
77
37
 
78
38
  export { ProbabilityTable, ProbabilityTableInfoWithHeaders };
79
39
  //# sourceMappingURL=ProbabilityTable.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProbabilityTable.esm.js","sources":["../../../../src/components/scenarioWizard/components/ProbabilityTable.tsx"],"sourcesContent":["import { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { useController, UseFormReturn } from 'react-hook-form';\nimport { FormScenario } from '../../../utils/types';\nimport { RiskRadioButton } from './RiskRadioButton';\nimport RadioGroup from '@mui/material/RadioGroup';\nimport { probabilityOptions } from '../../../utils/constants';\nimport { Text, Box } from '@backstage/ui';\nimport styles from '../ScenarioWizardTable.module.css';\n\nfunction ProbabilityTableInfo() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n function getContentCell(row: number) {\n return (\n <Box className={styles.riskCell}>\n {/* @ts-ignore */}\n {t(`probabilityTable.cells.${row + 1}`)}\n </Box>\n );\n }\n\n return (\n <Box className={styles.riskRow}>\n {getContentCell(0)}\n {getContentCell(1)}\n {getContentCell(2)}\n {getContentCell(3)}\n {getContentCell(4)}\n </Box>\n );\n}\n\nexport function ProbabilityTable({\n formMethods,\n riskType,\n}: {\n formMethods: UseFormReturn<FormScenario>;\n riskType: keyof Pick<FormScenario, 'risk' | 'remainingRisk'>;\n}) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const { field } = useController({\n name: `${riskType}.probability`,\n control: formMethods.control,\n });\n\n function getRadioLabel(row: number) {\n /* @ts-ignore Because ts can't typecheck strings agains our keys */\n return `${row}: ${t(`probabilityTable.rows.${row}`)}`;\n }\n\n function getRadioCell(row: number) {\n return (\n <RiskRadioButton\n value={probabilityOptions[row]}\n ref={field.ref}\n label={getRadioLabel(row + 1)}\n />\n );\n }\n\n return (\n <Box className={styles.riskTable}>\n <RadioGroup {...field} className={styles.riskRow}>\n {getRadioCell(0)}\n {getRadioCell(1)}\n {getRadioCell(2)}\n {getRadioCell(3)}\n {getRadioCell(4)}\n </RadioGroup>\n <ProbabilityTableInfo />\n </Box>\n );\n}\n\nexport function ProbabilityTableInfoWithHeaders() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n function getRadioLabel(row: number) {\n return (\n /* @ts-ignore Because ts can't typecheck strings agains our keys */\n <Text>{`${row}: ${t(`probabilityTable.rows.${row}`)}`}</Text>\n );\n }\n return (\n <Box className={styles.riskTable}>\n <Box className={styles.consequenceGrid}>\n <Box className={styles.riskLabelCell} />\n {getRadioLabel(1)}\n {getRadioLabel(2)}\n {getRadioLabel(3)}\n {getRadioLabel(4)}\n {getRadioLabel(5)}\n </Box>\n <ProbabilityTableInfo />\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AAUA,SAAS,oBAAA,GAAuB;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAA,SAAS,eAAe,GAAA,EAAa;AACnC,IAAA,uBACE,GAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,QAAA,EAEpB,YAAE,CAAA,uBAAA,EAA0B,GAAA,GAAM,CAAC,CAAA,CAAE,CAAA,EACxC,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACE,IAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,OAAA,EACpB,QAAA,EAAA;AAAA,IAAA,cAAA,CAAe,CAAC,CAAA;AAAA,IAChB,eAAe,CAAC,CAAA;AAAA,IAChB,eAAe,CAAC,CAAA;AAAA,IAChB,eAAe,CAAC,CAAA;AAAA,IAChB,eAAe,CAAC;AAAA,GAAA,EACnB,CAAA;AAEJ;AAEO,SAAS,gBAAA,CAAiB;AAAA,EAC/B,WAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,aAAA,CAAc;AAAA,IAC9B,IAAA,EAAM,GAAG,QAAQ,CAAA,YAAA,CAAA;AA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E,IAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,SAAA,EACrB,QAAA,EAAA;AAAA,oBAAA,IAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,eAAA,EACrB,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,aAAA,EAAe,CAAA;AAAA,MACrC,cAAc,CAAC,CAAA;AAAA,MACf,cAAc,CAAC,CAAA;AAAA,MACf,cAAc,CAAC,CAAA;AAAA,MACf,cAAc,CAAC,CAAA;AAAA,MACf,cAAc,CAAC;AAAA,KAAA,EAClB,CAAA;AAAA,wBACC,oBAAA,EAAA,EAAqB;AAAA,GAAA,EACxB,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ProbabilityTable.esm.js","sources":["../../../../src/components/scenarioWizard/components/ProbabilityTable.tsx"],"sourcesContent":["import { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { UseFormReturn } from 'react-hook-form';\nimport { FormScenario } from '../../../utils/types';\nimport { probabilityOptions } from '../../../utils/constants';\nimport { Box } from '@backstage/ui';\nimport styles from '../ScenarioWizardTable.module.css';\nimport { createInfoWithHeadersComponent, RiskTableBase } from './RiskTableBase';\n\nfunction ProbabilityTableInfo() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n function getContentCell(row: number) {\n return (\n <Box className={styles.riskCell}>\n {/* @ts-ignore */}\n {t(`probabilityTable.cells.${row + 1}`)}\n </Box>\n );\n }\n\n return (\n <Box className={styles.riskRow}>\n {Array.from({ length: 5 }, (_, i) => getContentCell(i))}\n </Box>\n );\n}\n\nexport function ProbabilityTable({\n formMethods,\n riskType,\n}: {\n formMethods: UseFormReturn<FormScenario>;\n riskType: keyof Pick<FormScenario, 'risk' | 'remainingRisk'>;\n}) {\n return (\n <RiskTableBase\n formMethods={formMethods}\n riskType={riskType}\n fieldName=\"probability\"\n options={probabilityOptions}\n translationPrefix=\"probabilityTable\"\n InfoComponent={ProbabilityTableInfo}\n />\n );\n}\n\nexport const ProbabilityTableInfoWithHeaders = createInfoWithHeadersComponent(\n 'probabilityTable',\n ProbabilityTableInfo,\n false,\n);\n"],"names":[],"mappings":";;;;;;;;AASA,SAAS,oBAAA,GAAuB;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AACxD,EAAA,SAAS,eAAe,GAAA,EAAa;AACnC,IAAA,uBACE,GAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,QAAA,EAEpB,YAAE,CAAA,uBAAA,EAA0B,GAAA,GAAM,CAAC,CAAA,CAAE,CAAA,EACxC,CAAA;AAAA,EAEJ;AAEA,EAAA,2BACG,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,OAAA,EACpB,gBAAM,IAAA,CAAK,EAAE,MAAA,EAAQ,CAAA,IAAK,CAAC,CAAA,EAAG,MAAM,cAAA,CAAe,CAAC,CAAC,CAAA,EACxD,CAAA;AAEJ;AAEO,SAAS,gBAAA,CAAiB;AAAA,EAC/B,WAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,uBACE,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,WAAA;AAAA,MACA,QAAA;AAAA,MACA,SAAA,EAAU,aAAA;AAAA,MACV,OAAA,EAAS,kBAAA;AAAA,MACT,iBAAA,EAAkB,kBAAA;AAAA,MAClB,aAAA,EAAe;AAAA;AAAA,GACjB;AAEJ;AAEO,MAAM,+BAAA,GAAkC,8BAAA;AAAA,EAC7C,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF;;;;"}
@@ -0,0 +1,63 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { pluginRiScTranslationRef } from '../../../utils/translations.esm.js';
3
+ import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
4
+ import { useController } from 'react-hook-form';
5
+ import { RiskRadioButton } from './RiskRadioButton.esm.js';
6
+ import RadioGroup from '@mui/material/RadioGroup';
7
+ import { Box, Text } from '@backstage/ui';
8
+ import styles from '../ScenarioWizardTable.module.css.esm.js';
9
+
10
+ function RiskTableBase({
11
+ formMethods,
12
+ riskType,
13
+ fieldName,
14
+ options,
15
+ additionalClassName = "",
16
+ translationPrefix,
17
+ InfoComponent
18
+ }) {
19
+ const { t } = useTranslationRef(pluginRiScTranslationRef);
20
+ const { field } = useController({
21
+ name: `${riskType}.${fieldName}`,
22
+ control: formMethods.control
23
+ });
24
+ function getRadioLabel(row) {
25
+ return `${row}: ${t(`${translationPrefix}.rows.${row}`)}`;
26
+ }
27
+ function getRadioCell(row) {
28
+ return /* @__PURE__ */ jsx(
29
+ RiskRadioButton,
30
+ {
31
+ value: options[row],
32
+ ref: field.ref,
33
+ label: getRadioLabel(row + 1)
34
+ }
35
+ );
36
+ }
37
+ const radioGroupClassName = additionalClassName ? `${styles.riskRow} ${additionalClassName}` : styles.riskRow;
38
+ return /* @__PURE__ */ jsxs(Box, { className: styles.riskTable, children: [
39
+ /* @__PURE__ */ jsxs(RadioGroup, { ...field, className: radioGroupClassName, children: [
40
+ fieldName === "consequence" && /* @__PURE__ */ jsx(Box, { className: styles.riskLabelCell }),
41
+ Array.from({ length: 5 }, (_, i) => getRadioCell(i))
42
+ ] }),
43
+ /* @__PURE__ */ jsx(InfoComponent, {})
44
+ ] });
45
+ }
46
+ function createInfoWithHeadersComponent(translationPrefix, InfoComponent, includeLabel = false) {
47
+ return function InfoWithHeaders() {
48
+ const { t } = useTranslationRef(pluginRiScTranslationRef);
49
+ function getRadioLabel(row) {
50
+ return /* @__PURE__ */ jsx(Text, { as: "p", variant: "body-large", children: `${row}: ${t(`${translationPrefix}.rows.${row}`)}` });
51
+ }
52
+ return /* @__PURE__ */ jsxs(Box, { className: styles.riskTable, children: [
53
+ /* @__PURE__ */ jsxs(Box, { className: styles.consequenceGrid, children: [
54
+ includeLabel && /* @__PURE__ */ jsx(Box, { className: styles.riskLabelCell }),
55
+ Array.from({ length: 5 }, (_, i) => getRadioLabel(i))
56
+ ] }),
57
+ /* @__PURE__ */ jsx(InfoComponent, {})
58
+ ] });
59
+ };
60
+ }
61
+
62
+ export { RiskTableBase, createInfoWithHeadersComponent };
63
+ //# sourceMappingURL=RiskTableBase.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RiskTableBase.esm.js","sources":["../../../../src/components/scenarioWizard/components/RiskTableBase.tsx"],"sourcesContent":["import { pluginRiScTranslationRef } from '../../../utils/translations';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { useController, UseFormReturn } from 'react-hook-form';\nimport { FormScenario } from '../../../utils/types';\nimport { RiskRadioButton } from './RiskRadioButton';\nimport RadioGroup from '@mui/material/RadioGroup';\nimport { Text, Box } from '@backstage/ui';\nimport styles from '../ScenarioWizardTable.module.css';\nimport React from 'react';\n\ntype RiskTableBaseProps = {\n formMethods: UseFormReturn<FormScenario>;\n riskType: keyof Pick<FormScenario, 'risk' | 'remainingRisk'>;\n fieldName: 'probability' | 'consequence';\n translationPrefix: 'probabilityTable' | 'consequenceTable';\n options: readonly number[];\n additionalClassName?: string;\n InfoComponent: React.ComponentType;\n};\n\nexport function RiskTableBase({\n formMethods,\n riskType,\n fieldName,\n options,\n additionalClassName = '',\n translationPrefix,\n InfoComponent,\n}: RiskTableBaseProps) {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n const { field } = useController({\n name: `${riskType}.${fieldName}`,\n control: formMethods.control,\n });\n\n function getRadioLabel(row: number) {\n /* @ts-ignore Because ts can't typecheck strings against our keys */\n return `${row}: ${t(`${translationPrefix}.rows.${row}`)}`;\n }\n\n function getRadioCell(row: number) {\n return (\n <RiskRadioButton\n value={options[row]}\n ref={field.ref}\n label={getRadioLabel(row + 1)}\n />\n );\n }\n\n const radioGroupClassName = additionalClassName\n ? `${styles.riskRow} ${additionalClassName}`\n : styles.riskRow;\n\n return (\n <Box className={styles.riskTable}>\n <RadioGroup {...field} className={radioGroupClassName}>\n {fieldName === 'consequence' && (\n <Box className={styles.riskLabelCell} />\n )}\n {Array.from({ length: 5 }, (_, i) => getRadioCell(i))}\n </RadioGroup>\n <InfoComponent />\n </Box>\n );\n}\n\nexport function createInfoWithHeadersComponent(\n translationPrefix: 'probabilityTable' | 'consequenceTable',\n InfoComponent: React.ComponentType,\n includeLabel: boolean = false,\n) {\n return function InfoWithHeaders() {\n const { t } = useTranslationRef(pluginRiScTranslationRef);\n\n function getRadioLabel(row: number) {\n return (\n <Text as=\"p\" variant=\"body-large\">\n {/* @ts-ignore Because ts can't typecheck strings against our keys */}\n {`${row}: ${t(`${translationPrefix}.rows.${row}`)}`}\n </Text>\n );\n }\n return (\n <Box className={styles.riskTable}>\n <Box className={styles.consequenceGrid}>\n {includeLabel && <Box className={styles.riskLabelCell} />}\n {Array.from({ length: 5 }, (_, i) => getRadioLabel(i))}\n </Box>\n <InfoComponent />\n </Box>\n );\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAoBO,SAAS,aAAA,CAAc;AAAA,EAC5B,WAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,mBAAA,GAAsB,EAAA;AAAA,EACtB,iBAAA;AAAA,EACA;AACF,CAAA,EAAuB;AACrB,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,wBAAwB,CAAA;AAExD,EAAA,MAAM,EAAE,KAAA,EAAM,GAAI,aAAA,CAAc;AAAA,IAC9B,IAAA,EAAM,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA;AAAA,IAC9B,SAAS,WAAA,CAAY;AAAA,GACtB,CAAA;AAED,EAAA,SAAS,cAAc,GAAA,EAAa;AAElC,IAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAA,EAAK,CAAA,CAAE,GAAG,iBAAiB,CAAA,MAA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cAElB,QAAA,EAAA,CAAA,EAAG,GAAG,CAAA,EAAA,EAAK,CAAA,CAAE,GAAG,iBAAiB,CAAA,MAAA,EAAS,GAAG,CAAA,CAAE,CAAC,CAAA,CAAA,EACnD,CAAA;AAAA,IAEJ;AACA,IAAA,uBACE,IAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,SAAA,EACrB,QAAA,EAAA;AAAA,sBAAA,IAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,eAAA,EACpB,QAAA,EAAA;AAAA,QAAA,YAAA,oBAAgB,GAAA,CAAC,GAAA,EAAA,EAAI,SAAA,EAAW,MAAA,CAAO,aAAA,EAAe,CAAA;AAAA,QACtD,KAAA,CAAM,IAAA,CAAK,EAAE,MAAA,EAAQ,CAAA,EAAE,EAAG,CAAC,CAAA,EAAG,CAAA,KAAM,aAAA,CAAc,CAAC,CAAC;AAAA,OAAA,EACvD,CAAA;AAAA,0BACC,aAAA,EAAA,EAAc;AAAA,KAAA,EACjB,CAAA;AAAA,EAEJ,CAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kartverket/backstage-plugin-risk-scorecard",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "main": "dist/index.esm.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "MIT",