@kartverket/backstage-plugin-risk-scorecard 1.0.8 → 1.0.10

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,9 +1,9 @@
1
- import React, { useState, useEffect, createContext, useContext, Fragment, useRef } from 'react';
1
+ import React, { useState, useEffect, useCallback, createContext, useContext, Fragment, useRef } from 'react';
2
2
  import { makeStyles, FormControl, FormLabel, FormHelperText, TextField as TextField$1, Grid, Typography, Box as Box$1, Paper, Button, Radio, CircularProgress, Dialog, DialogTitle, DialogActions, Stepper, Step, StepButton, Divider as Divider$1, Drawer, List, ListSubheader, ListItem, ListItemText as ListItemText$1, ClickAwayListener, Tooltip, DialogContent, DialogContentText, IconButton, Tab } from '@material-ui/core';
3
3
  import { InfoCard, ContentHeader } from '@backstage/core-components';
4
4
  import { useEntity } from '@backstage/plugin-catalog-react';
5
5
  import { useRouteRef, useApi, googleAuthApiRef, identityApiRef, fetchApiRef, configApiRef } from '@backstage/core-plugin-api';
6
- import { s as scenarioRouteRef, r as riScRouteRef, p as pluginRiScTranslationRef } from './index-0a8ff39c.esm.js';
6
+ import { s as scenarioRouteRef, r as riScRouteRef, p as pluginRiScTranslationRef } from './index-aa781c2b.esm.js';
7
7
  import { useNavigate, useLocation, useParams } from 'react-router';
8
8
  import { useEffectOnce } from 'react-use';
9
9
  import { useSearchParams, Routes, Route } from 'react-router-dom';
@@ -25,8 +25,9 @@ import { LocalizationProvider, DatePicker } from '@mui/x-date-pickers';
25
25
  import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
26
26
  import { nb } from 'date-fns/locale/nb';
27
27
  import Button$1 from '@mui/material/Button';
28
- import { KeyboardArrowLeft, KeyboardArrowRight } from '@material-ui/icons';
29
28
  import Alert from '@mui/material/Alert';
29
+ import KeyboardArrowRight from '@material-ui/icons/KeyboardArrowRight';
30
+ import KeyboardArrowLeft from '@material-ui/icons/KeyboardArrowLeft';
30
31
  import Box$2 from '@mui/material/Box';
31
32
  import KeyboardDoubleArrowRightIcon from '@mui/icons-material/KeyboardDoubleArrowRight';
32
33
  import EditIcon from '@mui/icons-material/Edit';
@@ -470,19 +471,24 @@ const requiresNewApproval = (oldRiSc, updatedRiSc) => {
470
471
  return requiresApproval;
471
472
  };
472
473
  function formatNumber(cost, t) {
473
- if (cost < 1e4) {
474
- return formatNOK(cost);
475
- } else {
476
- let { threshold, unit } = [
477
- { threshold: 1e6, unit: "thousand" },
478
- { threshold: 1e9, unit: "million" },
479
- { threshold: 1e12, unit: "billion" },
480
- { threshold: 1e15, unit: "trillion" }
481
- ].find(({ threshold: threshold2 }) => cost < threshold2);
474
+ function getTranslationWithCorrectUnit(costValue, threshold, unit) {
482
475
  return t(`riskMatrix.estimatedRisk.suffix.${unit}`, {
483
- count: Number((cost / threshold * 1e3).toFixed(0))
476
+ count: Number((costValue / threshold * 1e3).toFixed(0))
484
477
  });
485
478
  }
479
+ if (cost < 1e4) {
480
+ return formatNOK(cost);
481
+ }
482
+ if (cost < 1e6) {
483
+ return getTranslationWithCorrectUnit(cost, 1e6, "thousand");
484
+ }
485
+ if (cost < 1e9) {
486
+ return getTranslationWithCorrectUnit(cost, 1e9, "million");
487
+ }
488
+ if (cost < 1e12) {
489
+ return getTranslationWithCorrectUnit(cost, 1e12, "billion");
490
+ }
491
+ return getTranslationWithCorrectUnit(cost, 1e15, "trillion");
486
492
  }
487
493
 
488
494
  function dtoToRiSc(riScDTO) {
@@ -749,7 +755,7 @@ const useScenarioDrawer = (riSc, updateRiSc, scenarioIdFromParams) => {
749
755
  setOriginalScenario(selectedScenario);
750
756
  setScenarioDrawerState(2 /* View */);
751
757
  }
752
- }, [riSc, scenarioIdFromParams]);
758
+ }, [getRiScPath, isNewScenario, navigate, riSc, scenarioIdFromParams, setSearchParams]);
753
759
  const openScenario = (id) => {
754
760
  if (riSc) {
755
761
  navigate(getScenarioPath({ riScId: riSc.id, scenarioId: id }));
@@ -943,7 +949,7 @@ const useFetchRiScs = (riScIdFromParams) => {
943
949
  status: ProcessingStatus.ErrorWhenFetchingRiScs
944
950
  });
945
951
  }
946
- }, [location]);
952
+ }, [location, setResponse]);
947
953
  useEffectOnce(() => {
948
954
  fetchRiScs(
949
955
  (res) => {
@@ -983,11 +989,13 @@ const useFetchRiScs = (riScIdFromParams) => {
983
989
  }
984
990
  }
985
991
  }, [riScs, riScIdFromParams]);
986
- const resetRiScStatus = () => setUpdateRiScStatus({
987
- isLoading: false,
988
- isSuccess: false,
989
- isError: false
990
- });
992
+ const resetRiScStatus = useCallback(() => {
993
+ setUpdateRiScStatus({
994
+ isLoading: false,
995
+ isSuccess: false,
996
+ isError: false
997
+ });
998
+ }, []);
991
999
  const selectRiSc = (title) => {
992
1000
  var _a;
993
1001
  const riScId = (_a = riScs == null ? void 0 : riScs.find((riSc) => riSc.content.title === title)) == null ? void 0 : _a.id;
@@ -1542,6 +1550,7 @@ const ActionsStep = () => {
1542
1550
  )), /* @__PURE__ */ React.createElement(Typography, { variant: "h6", className: actionSubtitle }, t("scenarioDrawer.measureTab.plannedMeasures")), scenario.actions.map((action, index) => /* @__PURE__ */ React.createElement(
1543
1551
  ActionEdit,
1544
1552
  {
1553
+ key: action.ID,
1545
1554
  action,
1546
1555
  index: index + 1,
1547
1556
  updateAction,
@@ -1663,11 +1672,11 @@ const RiskStep = ({ riskType, restEqualsInitial }) => {
1663
1672
  useEffect(() => {
1664
1673
  if (restEqualsInitial)
1665
1674
  setRemainingConsequence(getConsequenceLevel(scenario.risk));
1666
- }, [scenario.risk.consequence]);
1675
+ }, [restEqualsInitial, scenario.risk, scenario.risk.consequence, setRemainingConsequence]);
1667
1676
  useEffect(() => {
1668
1677
  if (restEqualsInitial)
1669
1678
  setRemainingProbability(getProbabilityLevel(scenario.risk));
1670
- }, [scenario.risk.probability]);
1679
+ }, [restEqualsInitial, scenario.risk, scenario.risk.probability, setRemainingProbability]);
1671
1680
  const setC = riskType === "initial" ? setConsequence : setRemainingConsequence;
1672
1681
  const setP = riskType === "initial" ? setProbability : setRemainingProbability;
1673
1682
  return /* @__PURE__ */ React.createElement(Fragment, null, /* @__PURE__ */ React.createElement(Box, { className: box }, /* @__PURE__ */ React.createElement(Typography, { className: h2 }, t(`scenarioStepper.${resourceKey}.title`)), /* @__PURE__ */ React.createElement(Typography, { className: subtitle2 }, t(`scenarioStepper.${resourceKey}.subtitle`))), /* @__PURE__ */ React.createElement(Box, { className: box }, /* @__PURE__ */ React.createElement(Typography, { className: h3 }, t("dictionary.probability")), /* @__PURE__ */ React.createElement(Typography, { className: subtitle2 }, t(`scenarioStepper.${resourceKey}.probabilitySubtitle`))), /* @__PURE__ */ React.createElement(Box, { className: box }, /* @__PURE__ */ React.createElement(
@@ -1736,7 +1745,7 @@ const CloseConfirmation = ({
1736
1745
  return /* @__PURE__ */ React.createElement(Dialog, { open: isOpen }, /* @__PURE__ */ React.createElement(DialogTitle, null, t("scenarioDrawer.closeConfirmation")), /* @__PURE__ */ React.createElement(DialogActions, null, /* @__PURE__ */ React.createElement(Button, { style: { textTransform: "none" }, onClick: close }, t("dictionary.discardChanges")), /* @__PURE__ */ React.createElement(Button, { style: { textTransform: "none" }, onClick: save }, t("dictionary.save"))));
1737
1746
  };
1738
1747
 
1739
- const ScenarioWizardSteps = [
1748
+ const scenarioWizardSteps = [
1740
1749
  "scenario",
1741
1750
  "initialRisk",
1742
1751
  "measure",
@@ -1775,6 +1784,10 @@ const ScenarioWizard = ({
1775
1784
  if (step === "restRisk")
1776
1785
  setRestEqualsInitial(false);
1777
1786
  }, [step]);
1787
+ const close = useCallback(() => {
1788
+ closeScenario();
1789
+ setShowCloseConfirmation(false);
1790
+ }, [closeScenario]);
1778
1791
  useEffect(() => {
1779
1792
  if (updateStatus.isSuccess) {
1780
1793
  close();
@@ -1782,11 +1795,7 @@ const ScenarioWizard = ({
1782
1795
  setShowCloseConfirmation(false);
1783
1796
  wizardRef.current.scrollIntoView({ behavior: "smooth", block: "end" });
1784
1797
  }
1785
- }, [updateStatus]);
1786
- const close = () => {
1787
- closeScenario();
1788
- setShowCloseConfirmation(false);
1789
- };
1798
+ }, [close, updateStatus]);
1790
1799
  const saveAndClose = () => {
1791
1800
  saveScenario();
1792
1801
  };
@@ -1800,32 +1809,32 @@ const ScenarioWizard = ({
1800
1809
  const nextStep = () => {
1801
1810
  const isValidScenario = validateScenario();
1802
1811
  if (isValidScenario) {
1803
- const currentIndex = ScenarioWizardSteps.indexOf(step);
1804
- if (currentIndex < ScenarioWizardSteps.length - 1) {
1805
- editScenario(ScenarioWizardSteps[currentIndex + 1]);
1812
+ const currentIndex = scenarioWizardSteps.indexOf(step);
1813
+ if (currentIndex < scenarioWizardSteps.length - 1) {
1814
+ editScenario(scenarioWizardSteps[currentIndex + 1]);
1806
1815
  }
1807
1816
  }
1808
1817
  };
1809
1818
  const previousStep = () => {
1810
- const currentIndex = ScenarioWizardSteps.indexOf(step);
1819
+ const currentIndex = scenarioWizardSteps.indexOf(step);
1811
1820
  if (currentIndex > 0) {
1812
- editScenario(ScenarioWizardSteps[currentIndex - 1]);
1821
+ editScenario(scenarioWizardSteps[currentIndex - 1]);
1813
1822
  }
1814
1823
  };
1815
1824
  const isFirstStep = () => {
1816
- return ScenarioWizardSteps.indexOf(step) === 0;
1825
+ return scenarioWizardSteps.indexOf(step) === 0;
1817
1826
  };
1818
1827
  const isLastStep = () => {
1819
- return ScenarioWizardSteps.indexOf(step) === ScenarioWizardSteps.length - 1;
1828
+ return scenarioWizardSteps.indexOf(step) === scenarioWizardSteps.length - 1;
1820
1829
  };
1821
1830
  return /* @__PURE__ */ React.createElement("div", { ref: wizardRef }, /* @__PURE__ */ React.createElement(Box, { className: root }, /* @__PURE__ */ React.createElement(Box, { className: container }, /* @__PURE__ */ React.createElement(Box, { className: header }, /* @__PURE__ */ React.createElement(Typography, { className: h1 }, t("scenarioDrawer.title")), /* @__PURE__ */ React.createElement(Button$1, { variant: "outlined", onClick: handleCloseStepper }, t("dictionary.cancel"))), /* @__PURE__ */ React.createElement(
1822
1831
  Stepper,
1823
1832
  {
1824
1833
  className: stepper,
1825
- activeStep: ScenarioWizardSteps.indexOf(step),
1834
+ activeStep: scenarioWizardSteps.indexOf(step),
1826
1835
  alternativeLabel: true
1827
1836
  },
1828
- ScenarioWizardSteps.map((wizardStep) => /* @__PURE__ */ React.createElement(Step, { key: wizardStep, completed: false }, /* @__PURE__ */ React.createElement(
1837
+ scenarioWizardSteps.map((wizardStep) => /* @__PURE__ */ React.createElement(Step, { key: wizardStep, completed: false }, /* @__PURE__ */ React.createElement(
1829
1838
  StepButton,
1830
1839
  {
1831
1840
  disabled: false,
@@ -1840,16 +1849,16 @@ const ScenarioWizard = ({
1840
1849
  " "
1841
1850
  )))
1842
1851
  ), /* @__PURE__ */ React.createElement(Divider, null), isFetching ? /* @__PURE__ */ React.createElement(Spinner, { size: 80 }) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box, { className: steps }, {
1843
- [ScenarioWizardSteps[0]]: /* @__PURE__ */ React.createElement(ScenarioStep, null),
1844
- [ScenarioWizardSteps[1]]: /* @__PURE__ */ React.createElement(
1852
+ [scenarioWizardSteps[0]]: /* @__PURE__ */ React.createElement(ScenarioStep, null),
1853
+ [scenarioWizardSteps[1]]: /* @__PURE__ */ React.createElement(
1845
1854
  RiskStep,
1846
1855
  {
1847
1856
  riskType: "initial",
1848
1857
  restEqualsInitial
1849
1858
  }
1850
1859
  ),
1851
- [ScenarioWizardSteps[2]]: /* @__PURE__ */ React.createElement(ActionsStep, null),
1852
- [ScenarioWizardSteps[3]]: /* @__PURE__ */ React.createElement(RiskStep, { riskType: "rest" })
1860
+ [scenarioWizardSteps[2]]: /* @__PURE__ */ React.createElement(ActionsStep, null),
1861
+ [scenarioWizardSteps[3]]: /* @__PURE__ */ React.createElement(RiskStep, { riskType: "rest" })
1853
1862
  }[step]), updateStatus.isError && /* @__PURE__ */ React.createElement(Alert, { style: { marginBottom: "1rem" }, severity: "error" }, /* @__PURE__ */ React.createElement(Typography, null, t("dictionary.saveError"))), /* @__PURE__ */ React.createElement(
1854
1863
  Box,
1855
1864
  {
@@ -2146,7 +2155,7 @@ const ActionsSection = () => {
2146
2155
  startIcon: /* @__PURE__ */ React.createElement(EditIcon, { className: editIcon, "aria-label": "Edit" })
2147
2156
  }
2148
2157
  )
2149
- ), scenario.actions.map((action, index) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
2158
+ ), scenario.actions.map((action, index) => /* @__PURE__ */ React.createElement(Fragment, { key: action.ID }, /* @__PURE__ */ React.createElement(
2150
2159
  ActionBox,
2151
2160
  {
2152
2161
  action,
@@ -2177,7 +2186,7 @@ const ScopeSection = () => {
2177
2186
  onClick: () => editScenario("scenario"),
2178
2187
  startIcon: /* @__PURE__ */ React.createElement(EditIcon, { className: editIcon, "aria-label": "Edit" })
2179
2188
  }
2180
- )), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { className: h1 }, scenario.title)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { className: label }, t("dictionary.description")), /* @__PURE__ */ React.createElement(Typography, { className: body2 }, scenario.description)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Divider, { variant: "fullWidth" })), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6 }, /* @__PURE__ */ React.createElement(Typography, { className: label }, t("dictionary.threatActors")), scenario.threatActors.map((threatActor) => /* @__PURE__ */ React.createElement(Typography, { className: body2 }, threatActor))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6 }, /* @__PURE__ */ React.createElement(Typography, { className: label }, t("dictionary.vulnerabilities")), scenario.vulnerabilities.map((vulnerability) => /* @__PURE__ */ React.createElement(Typography, { className: body2 }, vulnerability))))));
2189
+ )), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { className: h1 }, scenario.title)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Typography, { className: label }, t("dictionary.description")), /* @__PURE__ */ React.createElement(Typography, { className: body2 }, scenario.description)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 12 }, /* @__PURE__ */ React.createElement(Divider, { variant: "fullWidth" })), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6 }, /* @__PURE__ */ React.createElement(Typography, { className: label }, t("dictionary.threatActors")), scenario.threatActors.map((threatActor) => /* @__PURE__ */ React.createElement(Typography, { key: threatActor, className: body2 }, threatActor))), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6 }, /* @__PURE__ */ React.createElement(Typography, { className: label }, t("dictionary.vulnerabilities")), scenario.vulnerabilities.map((vulnerability) => /* @__PURE__ */ React.createElement(Typography, { key: vulnerability, className: body2 }, vulnerability))))));
2181
2190
  };
2182
2191
 
2183
2192
  const ScenarioDrawer = () => {
@@ -2334,6 +2343,11 @@ const RiskMatrixScenarioCount = ({
2334
2343
  tooltipText
2335
2344
  } = useRiskMatrixStyles();
2336
2345
  const [tooltipOpen, setTooltipOpen] = useState(false);
2346
+ const { openScenario } = useContext(ScenarioContext);
2347
+ const handleScenarioClick = (ID) => {
2348
+ setTooltipOpen(false);
2349
+ openScenario(ID);
2350
+ };
2337
2351
  const scenarios = riSc.scenarios.filter(
2338
2352
  (scenario) => probabilityOptions.indexOf(
2339
2353
  initialRisk ? scenario.risk.probability : scenario.remainingRisk.probability
@@ -2344,7 +2358,9 @@ const RiskMatrixScenarioCount = ({
2344
2358
  if (scenarios.length === 0) {
2345
2359
  return null;
2346
2360
  }
2347
- const tooltipList = /* @__PURE__ */ React.createElement(List, { dense: true }, /* @__PURE__ */ React.createElement(ListSubheader, { className: tooltipText }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6", className: tooltipText }, t("riskMatrix.tooltip.title"))), scenarios.map((s) => /* @__PURE__ */ React.createElement(ListItem, { button: true, disableGutters: true, className: tooltipText }, /* @__PURE__ */ React.createElement(CircleIcon, { className: tooltipText, style: { width: "10px" } }), /* @__PURE__ */ React.createElement(
2361
+ const tooltipList = /* @__PURE__ */ React.createElement(List, { dense: true }, /* @__PURE__ */ React.createElement(ListSubheader, { className: tooltipText }, /* @__PURE__ */ React.createElement(Typography, { variant: "h6", className: tooltipText }, t("riskMatrix.tooltip.title"))), scenarios.map((s) => /* @__PURE__ */ React.createElement(ListItem, { key: s.ID, button: true, disableGutters: true, className: tooltipText, onClick: () => {
2362
+ handleScenarioClick(s.ID);
2363
+ } }, /* @__PURE__ */ React.createElement(CircleIcon, { className: tooltipText, style: { width: "10px" } }), /* @__PURE__ */ React.createElement(
2348
2364
  ListItemText$1,
2349
2365
  {
2350
2366
  className: tooltipText,
@@ -2355,6 +2371,7 @@ const RiskMatrixScenarioCount = ({
2355
2371
  return /* @__PURE__ */ React.createElement(ClickAwayListener, { onClickAway: () => setTooltipOpen(false) }, /* @__PURE__ */ React.createElement(
2356
2372
  Tooltip,
2357
2373
  {
2374
+ interactive: true,
2358
2375
  classes: { tooltip, arrow: tooltipArrow },
2359
2376
  title: tooltipList,
2360
2377
  placement: "right",
@@ -2392,7 +2409,7 @@ const EstimatedRiskInfoDialog = ({
2392
2409
  }) => {
2393
2410
  const { t } = useTranslationRef(pluginRiScTranslationRef);
2394
2411
  const { paper, title, text } = useEstimatedRiskInfoDialogStyles();
2395
- return /* @__PURE__ */ React.createElement(Dialog, { open: isOpen, onClose, maxWidth: "xs" }, /* @__PURE__ */ React.createElement(Paper, { className: paper }, /* @__PURE__ */ React.createElement(DialogTitle, { className: title }, t("infoDialog.title")), /* @__PURE__ */ React.createElement(DialogContent, { className: text, dividers: true }, /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, t("infoDialog.description")), /* @__PURE__ */ React.createElement(Typography, { style: { fontWeight: "bold" } }, t("infoDialog.calculatedHowTitle")), /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, t("infoDialog.calculatedHow")), /* @__PURE__ */ React.createElement(Typography, { style: { fontWeight: "bold" } }, t("infoDialog.consequenceTitle")), /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, consequenceOptions.map((option, index) => /* @__PURE__ */ React.createElement(React.Fragment, null, index + 1, ": ", formatNOK(option), /* @__PURE__ */ React.createElement("br", null)))), /* @__PURE__ */ React.createElement(Typography, { style: { fontWeight: "bold" } }, t("infoDialog.probabilityTitle")), /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, probabilityOptions.map((option, index) => /* @__PURE__ */ React.createElement(React.Fragment, null, index + 1, ": ", option, ", ", t(`infoDialog.probabilityDescription.${index}`), /* @__PURE__ */ React.createElement("br", null)))), /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, t("infoDialog.example")))));
2412
+ return /* @__PURE__ */ React.createElement(Dialog, { open: isOpen, onClose, maxWidth: "xs" }, /* @__PURE__ */ React.createElement(Paper, { className: paper }, /* @__PURE__ */ React.createElement(DialogTitle, { className: title }, t("infoDialog.title")), /* @__PURE__ */ React.createElement(DialogContent, { className: text, dividers: true }, /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, t("infoDialog.description")), /* @__PURE__ */ React.createElement(Typography, { style: { fontWeight: "bold" } }, t("infoDialog.calculatedHowTitle")), /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, t("infoDialog.calculatedHow")), /* @__PURE__ */ React.createElement(Typography, { style: { fontWeight: "bold" } }, t("infoDialog.consequenceTitle")), /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, consequenceOptions.map((option, index) => /* @__PURE__ */ React.createElement(Fragment, { key: option }, index + 1, ": ", formatNOK(option), /* @__PURE__ */ React.createElement("br", null)))), /* @__PURE__ */ React.createElement(Typography, { style: { fontWeight: "bold" } }, t("infoDialog.probabilityTitle")), /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, probabilityOptions.map((option, index) => /* @__PURE__ */ React.createElement(Fragment, { key: option }, index + 1, ": ", option, ", ", t(`infoDialog.probabilityDescription.${index}`), /* @__PURE__ */ React.createElement("br", null)))), /* @__PURE__ */ React.createElement(DialogContentText, { className: text }, t("infoDialog.example")))));
2396
2413
  };
2397
2414
 
2398
2415
  const useAggregatedCostStyles = makeStyles({
@@ -2489,22 +2506,23 @@ const RiskMatrix = ({ riSc }) => {
2489
2506
  riSc,
2490
2507
  initialRisk: tab === "initialRisk" /* initialRisk */
2491
2508
  }
2492
- )), /* @__PURE__ */ React.createElement(Box$2, { className: gridWrapper }, /* @__PURE__ */ React.createElement(Box$2, { className: grid }, /* @__PURE__ */ React.createElement(Box$2, { className: konsekvens }, /* @__PURE__ */ React.createElement(Typography, { className: `${centered} ${label2}` }, t("dictionary.consequence"))), riskMatrix.map((_, row) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box$2, { className: centered }, /* @__PURE__ */ React.createElement(Typography, { className: text }, 5 - row)), riskMatrix[0].map((_2, col) => /* @__PURE__ */ React.createElement(
2509
+ )), /* @__PURE__ */ React.createElement(Box$2, { className: gridWrapper }, /* @__PURE__ */ React.createElement(Box$2, { className: grid }, /* @__PURE__ */ React.createElement(Box$2, { className: konsekvens }, /* @__PURE__ */ React.createElement(Typography, { className: `${centered} ${label2}` }, t("dictionary.consequence"))), riskMatrix.map((row, rowIndex) => /* @__PURE__ */ React.createElement(Fragment, { key: rowIndex }, /* @__PURE__ */ React.createElement(Box$2, { className: centered }, /* @__PURE__ */ React.createElement(Typography, { className: text }, 5 - rowIndex)), row.map((col, colIndex) => /* @__PURE__ */ React.createElement(
2493
2510
  Box$2,
2494
2511
  {
2495
2512
  className: `${square} ${centered}`,
2496
- style: { backgroundColor: riskMatrix[row][col] }
2513
+ style: { backgroundColor: col },
2514
+ key: colIndex
2497
2515
  },
2498
2516
  /* @__PURE__ */ React.createElement(
2499
2517
  RiskMatrixScenarioCount,
2500
2518
  {
2501
2519
  riSc,
2502
- probability: col,
2503
- consequence: 4 - row,
2520
+ probability: colIndex,
2521
+ consequence: 4 - rowIndex,
2504
2522
  initialRisk: tab === "initialRisk" /* initialRisk */
2505
2523
  }
2506
2524
  )
2507
- )))), /* @__PURE__ */ React.createElement(Box$2, { className: centered }), /* @__PURE__ */ React.createElement(Box$2, { className: centered }), riskMatrix.map((_, col) => /* @__PURE__ */ React.createElement(Box$2, { className: centered }, /* @__PURE__ */ React.createElement(Typography, { className: text }, col + 1))), /* @__PURE__ */ React.createElement(Box$2, { className: sannsynlighet }, /* @__PURE__ */ React.createElement(Typography, { className: `${centered} ${label2}` }, t("dictionary.probability")))))));
2525
+ )))), /* @__PURE__ */ React.createElement(Box$2, { className: centered }), /* @__PURE__ */ React.createElement(Box$2, { className: centered }), riskMatrix.map((_, col) => /* @__PURE__ */ React.createElement(Box$2, { className: centered, key: col }, /* @__PURE__ */ React.createElement(Typography, { className: text }, col + 1))), /* @__PURE__ */ React.createElement(Box$2, { className: sannsynlighet }, /* @__PURE__ */ React.createElement(Typography, { className: `${centered} ${label2}` }, t("dictionary.probability")))))));
2508
2526
  };
2509
2527
 
2510
2528
  const useTableStyles = makeStyles((theme) => ({
@@ -2512,7 +2530,9 @@ const useTableStyles = makeStyles((theme) => ({
2512
2530
  display: "flex",
2513
2531
  alignItems: "center",
2514
2532
  justifyContent: "center",
2515
- padding: theme.spacing(1)
2533
+ padding: theme.spacing(1),
2534
+ width: theme.spacing(1),
2535
+ height: theme.spacing(1)
2516
2536
  },
2517
2537
  rowBackground: {
2518
2538
  display: "flex",
@@ -2521,7 +2541,8 @@ const useTableStyles = makeStyles((theme) => ({
2521
2541
  border: "none",
2522
2542
  padding: 0,
2523
2543
  "&.MuiTableRow-root": {
2524
- backgroundColor: theme.palette.type === "dark" ? "#424242" : "white"
2544
+ backgroundColor: theme.palette.type === "dark" ? "#424242" : "white",
2545
+ border: "none"
2525
2546
  },
2526
2547
  transition: "background-color 0.3s",
2527
2548
  "&:hover": {
@@ -2537,15 +2558,37 @@ const useTableStyles = makeStyles((theme) => ({
2537
2558
  rowBorder: {
2538
2559
  display: "flex",
2539
2560
  alignItems: "center",
2540
- borderBottom: theme.palette.type === "dark" ? "1px solid #616161" : "1px solid #0000001f"
2561
+ "&.MuiTableRow-root": {
2562
+ borderBottom: theme.palette.type === "dark" ? "1px solid #616161" : "1px solid #0000001f"
2563
+ }
2541
2564
  },
2542
2565
  tableCell: {
2566
+ minWidth: "120px",
2567
+ padding: "20px 10px 20px 16px",
2568
+ width: "15%",
2569
+ gap: "0.4rem",
2570
+ "&.MuiTableCell-root": {
2571
+ fontSize: theme.spacing(2),
2572
+ color: theme.palette.type === "dark" ? "#F8F8F8" : "rgba(0, 0, 0, 0.87)",
2573
+ border: "none"
2574
+ }
2575
+ },
2576
+ tableCellTitle: {
2543
2577
  display: "flex",
2544
- width: "20%",
2545
2578
  minWidth: "120px",
2546
2579
  padding: "20px 10px 20px 16px",
2547
2580
  gap: "0.4rem",
2548
- fontSize: theme.spacing(2)
2581
+ width: "55%",
2582
+ "&.MuiTableCell-root": {
2583
+ fontSize: theme.spacing(2),
2584
+ color: theme.palette.type === "dark" ? "#F8F8F8" : "rgba(0, 0, 0, 0.87)",
2585
+ border: "none"
2586
+ }
2587
+ },
2588
+ tableCellContainer: {
2589
+ display: "flex",
2590
+ gap: theme.spacing(1),
2591
+ alignItems: "center"
2549
2592
  }
2550
2593
  }));
2551
2594
 
@@ -2555,7 +2598,14 @@ const ScenarioTableRow = ({
2555
2598
  isLastRow
2556
2599
  }) => {
2557
2600
  const { t } = useTranslationRef(pluginRiScTranslationRef);
2558
- const { riskColor, rowBackground, rowBorder, tableCell } = useTableStyles();
2601
+ const {
2602
+ riskColor,
2603
+ rowBackground,
2604
+ rowBorder,
2605
+ tableCell,
2606
+ tableCellTitle,
2607
+ tableCellContainer
2608
+ } = useTableStyles();
2559
2609
  const remainingActions = scenario.actions.filter(
2560
2610
  (a) => a.status !== "Completed"
2561
2611
  );
@@ -2565,18 +2615,8 @@ const ScenarioTableRow = ({
2565
2615
  className: `${isLastRow ? void 0 : rowBorder} ${rowBackground}`,
2566
2616
  onClick: () => viewRow(scenario.ID)
2567
2617
  },
2568
- /* @__PURE__ */ React.createElement(
2569
- TableCell,
2570
- {
2571
- className: tableCell,
2572
- style: {
2573
- width: "40%",
2574
- minWidth: "200px"
2575
- }
2576
- },
2577
- /* @__PURE__ */ React.createElement(Typography, { color: "primary", style: { fontWeight: 600 } }, scenario.title)
2578
- ),
2579
- /* @__PURE__ */ React.createElement(TableCell, { className: tableCell }, /* @__PURE__ */ React.createElement(
2618
+ /* @__PURE__ */ React.createElement(TableCell, { className: tableCellTitle }, /* @__PURE__ */ React.createElement(Typography, { color: "primary", style: { fontWeight: 600 } }, scenario.title)),
2619
+ /* @__PURE__ */ React.createElement(TableCell, { className: tableCell }, /* @__PURE__ */ React.createElement("div", { className: tableCellContainer }, /* @__PURE__ */ React.createElement(
2580
2620
  Paper,
2581
2621
  {
2582
2622
  className: riskColor,
@@ -2584,9 +2624,9 @@ const ScenarioTableRow = ({
2584
2624
  backgroundColor: getRiskMatrixColor(scenario.risk)
2585
2625
  }
2586
2626
  }
2587
- ), t("scenarioTable.columns.probabilityChar"), ":", getProbabilityLevel(scenario.risk), " ", t("scenarioTable.columns.consequenceChar"), ":", getConsequenceLevel(scenario.risk)),
2588
- /* @__PURE__ */ React.createElement(TableCell, { className: tableCell }, remainingActions.length > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, remainingActions.length, " ", t("dictionary.planned").toLowerCase()) : t("dictionary.completed")),
2589
- /* @__PURE__ */ React.createElement(TableCell, { className: tableCell }, /* @__PURE__ */ React.createElement(
2627
+ ), t("scenarioTable.columns.probabilityChar"), ":", getProbabilityLevel(scenario.risk), " ", t("scenarioTable.columns.consequenceChar"), ":", getConsequenceLevel(scenario.risk))),
2628
+ /* @__PURE__ */ React.createElement(TableCell, { className: tableCell }, /* @__PURE__ */ React.createElement("div", { className: tableCellContainer }, remainingActions.length > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, remainingActions.length, " ", t("dictionary.planned").toLowerCase()) : t("dictionary.completed"))),
2629
+ /* @__PURE__ */ React.createElement(TableCell, { className: tableCell }, /* @__PURE__ */ React.createElement("div", { className: tableCellContainer }, /* @__PURE__ */ React.createElement(
2590
2630
  Paper,
2591
2631
  {
2592
2632
  className: riskColor,
@@ -2594,13 +2634,13 @@ const ScenarioTableRow = ({
2594
2634
  backgroundColor: getRiskMatrixColor(scenario.remainingRisk)
2595
2635
  }
2596
2636
  }
2597
- ), t("scenarioTable.columns.probabilityChar"), ":", getProbabilityLevel(scenario.remainingRisk), " ", t("scenarioTable.columns.consequenceChar"), ":", getConsequenceLevel(scenario.remainingRisk))
2637
+ ), t("scenarioTable.columns.probabilityChar"), ":", getProbabilityLevel(scenario.remainingRisk), " ", t("scenarioTable.columns.consequenceChar"), ":", getConsequenceLevel(scenario.remainingRisk)))
2598
2638
  );
2599
2639
  };
2600
2640
 
2601
2641
  const ScenarioTable = ({ riSc }) => {
2602
2642
  const { t } = useTranslationRef(pluginRiScTranslationRef);
2603
- const { titleBox, rowBorder, tableCell } = useTableStyles();
2643
+ const { titleBox, rowBorder, tableCell, tableCellTitle } = useTableStyles();
2604
2644
  const { newScenario, openScenario } = useContext(ScenarioContext);
2605
2645
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Paper, null, /* @__PURE__ */ React.createElement(Box$1, { className: titleBox }, /* @__PURE__ */ React.createElement(Typography, { variant: "h5", style: { padding: "1rem" } }, t("scenarioTable.title")), riSc.scenarios.length > 0 && /* @__PURE__ */ React.createElement(
2606
2646
  Box$1,
@@ -2646,24 +2686,14 @@ const ScenarioTable = ({ riSc }) => {
2646
2686
  },
2647
2687
  t("scenarioTable.addScenarioButton")
2648
2688
  )
2649
- ) : /* @__PURE__ */ React.createElement(TableContainer, { style: { overflow: "auto" }, component: Paper }, /* @__PURE__ */ React.createElement(Table, null, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, { className: rowBorder }, /* @__PURE__ */ React.createElement(
2650
- TableCell,
2689
+ ) : /* @__PURE__ */ React.createElement(TableContainer, { style: { overflow: "auto" }, component: Paper }, /* @__PURE__ */ React.createElement(Table, null, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, { className: rowBorder }, /* @__PURE__ */ React.createElement(TableCell, { className: tableCellTitle }, /* @__PURE__ */ React.createElement(
2690
+ Typography,
2651
2691
  {
2652
- className: tableCell,
2653
- style: {
2654
- width: "40%",
2655
- minWidth: "200px"
2656
- }
2692
+ variant: "subtitle1",
2693
+ style: { fontWeight: "bold", textTransform: "uppercase" }
2657
2694
  },
2658
- /* @__PURE__ */ React.createElement(
2659
- Typography,
2660
- {
2661
- variant: "subtitle1",
2662
- style: { fontWeight: "bold", textTransform: "uppercase" }
2663
- },
2664
- t("dictionary.title")
2665
- )
2666
- ), /* @__PURE__ */ React.createElement(TableCell, { className: tableCell }, /* @__PURE__ */ React.createElement(
2695
+ t("dictionary.title")
2696
+ )), /* @__PURE__ */ React.createElement(TableCell, { className: tableCell }, /* @__PURE__ */ React.createElement(
2667
2697
  Typography,
2668
2698
  {
2669
2699
  variant: "subtitle1",
@@ -2681,7 +2711,10 @@ const ScenarioTable = ({ riSc }) => {
2681
2711
  Typography,
2682
2712
  {
2683
2713
  variant: "subtitle1",
2684
- style: { fontWeight: "bold", textTransform: "uppercase" }
2714
+ style: {
2715
+ fontWeight: "bold",
2716
+ textTransform: "uppercase"
2717
+ }
2685
2718
  },
2686
2719
  t("dictionary.restRisk")
2687
2720
  )))), /* @__PURE__ */ React.createElement(TableBody, null, riSc.scenarios.map((scenario, idx) => /* @__PURE__ */ React.createElement(
@@ -2888,7 +2921,7 @@ const getChipColor = (status, classes) => {
2888
2921
  return classes.riScDraft;
2889
2922
  }
2890
2923
  };
2891
- const chipText = (status) => {
2924
+ const useChipText = (status) => {
2892
2925
  const { t } = useTranslationRef(pluginRiScTranslationRef);
2893
2926
  switch (status) {
2894
2927
  case RiScStatus.Draft:
@@ -2900,11 +2933,15 @@ const chipText = (status) => {
2900
2933
  return t("rosStatus.statusBadge.error");
2901
2934
  }
2902
2935
  };
2903
- const getChipTextStatus = (status) => {
2936
+ function ChipTextStatus({ status }) {
2904
2937
  const { statusChipText } = useStatusChipStyles();
2905
- return /* @__PURE__ */ React.createElement("span", { className: statusChipText }, chipText(status));
2906
- };
2907
- const getPRStatus = (status, classes) => {
2938
+ const chipText = useChipText(status);
2939
+ return /* @__PURE__ */ React.createElement("span", { className: statusChipText }, chipText);
2940
+ }
2941
+ function PRStatus({
2942
+ status,
2943
+ classes
2944
+ }) {
2908
2945
  const { t } = useTranslationRef(pluginRiScTranslationRef);
2909
2946
  switch (status) {
2910
2947
  case RiScStatus.SentForApproval:
@@ -2914,7 +2951,7 @@ const getPRStatus = (status, classes) => {
2914
2951
  default:
2915
2952
  return null;
2916
2953
  }
2917
- };
2954
+ }
2918
2955
  const StatusChip = ({ currentRiScStatus }) => {
2919
2956
  const chipClasses = useStatusChipStyles();
2920
2957
  const textClasses = useStatusTextStyles();
@@ -2937,12 +2974,12 @@ const StatusChip = ({ currentRiScStatus }) => {
2937
2974
  color: "primary",
2938
2975
  size: "medium",
2939
2976
  variant: "outlined",
2940
- label: getChipTextStatus(currentRiScStatus),
2977
+ label: /* @__PURE__ */ React.createElement(ChipTextStatus, { status: currentRiScStatus }),
2941
2978
  icon: /* @__PURE__ */ React.createElement(CircleIcon$1, { className: chipClasses.statusIcon }),
2942
2979
  className: [chipColorClass, chipClasses.statusChip].join(" ")
2943
2980
  }
2944
2981
  )),
2945
- /* @__PURE__ */ React.createElement(Grid, { item: true }, getPRStatus(currentRiScStatus, textClasses))
2982
+ /* @__PURE__ */ React.createElement(Grid, { item: true }, /* @__PURE__ */ React.createElement(PRStatus, { status: currentRiScStatus, classes: textClasses }))
2946
2983
  );
2947
2984
  };
2948
2985
 
@@ -3096,7 +3133,7 @@ const Plugin = () => {
3096
3133
  useEffect(() => {
3097
3134
  if (scenarioWizardStep !== null)
3098
3135
  resetRiScStatus();
3099
- }, [scenarioWizardStep]);
3136
+ }, [resetRiScStatus, scenarioWizardStep]);
3100
3137
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ScenarioContext.Provider, { value: scenario }, response && /* @__PURE__ */ React.createElement(Alert, { severity: getAlertSeverity(response.status) }, /* @__PURE__ */ React.createElement(Typography, null, response.statusMessage)), scenarioWizardStep !== null ? /* @__PURE__ */ React.createElement(
3101
3138
  ScenarioWizard,
3102
3139
  {
@@ -3159,4 +3196,4 @@ const RiScPlugin = () => {
3159
3196
  };
3160
3197
 
3161
3198
  export { RiScPlugin };
3162
- //# sourceMappingURL=index-2ef3f54b.esm.js.map
3199
+ //# sourceMappingURL=index-32d8d9ac.esm.js.map