Order risks by owner name

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-09-18 13:20:26 +02:00
parent eabc34c3ac
commit 72a581b66b
16 changed files with 272 additions and 64 deletions

View File

@@ -41,6 +41,7 @@ type Props = {
risk?: RiskKey;
connection?: string;
ref?: ReturnType<typeof useDialogRef>;
onSuccess?: () => void;
};
type RiskTemplate = {
@@ -82,6 +83,7 @@ export default function FormRiskDialog({
risk,
connection,
ref: refProps,
onSuccess,
}: Props) {
const { __ } = useTranslate();
const organizationId = useOrganizationId();
@@ -131,6 +133,7 @@ export default function FormRiskDialog({
onSuccess: () => {
ref?.current?.close();
reset();
onSuccess?.();
},
});
});

View File

@@ -40,7 +40,17 @@ export default function RisksPage(props: Props) {
const { snapshotId } = useParams<{ snapshotId?: string }>();
const isSnapshotMode = Boolean(snapshotId);
const { connectionId, risks, refetch } = useRisksQuery(props.queryRef, snapshotId);
const { connectionId, risks, ...pagination } = useRisksQuery(props.queryRef);
const refetch = ({ order }: { order: { direction: string; field: string } }) => {
pagination.refetch({
snapshotId,
order: {
direction: order.direction as "ASC" | "DESC",
field: order.field as "NAME" | "CATEGORY" | "TREATMENT" | "INHERENT_RISK_SCORE" | "RESIDUAL_RISK_SCORE" | "OWNER_FULL_NAME" | "CREATED_AT"
}
}, { fetchPolicy: 'network-only' });
};
usePageTitle(__("Risks"));
@@ -56,6 +66,9 @@ export default function RisksPage(props: Props) {
{!isSnapshotMode && (
<FormRiskDialog
connection={connectionId}
onSuccess={() => {
pagination.refetch({ snapshotId });
}}
trigger={<Button icon={IconPlusLarge}>{__("New Risk")}</Button>}
/>
)}
@@ -73,7 +86,7 @@ export default function RisksPage(props: Props) {
risks={risks}
/>
</div>
<SortableTable refetch={refetch}>
<SortableTable {...pagination} refetch={refetch}>
<Thead>
<Tr>
<SortableTh field="NAME">{__("Risk name")}</SortableTh>
@@ -85,6 +98,9 @@ export default function RisksPage(props: Props) {
<SortableTh field="RESIDUAL_RISK_SCORE">
{__("Residual Risk")}
</SortableTh>
<SortableTh field="OWNER_FULL_NAME">
{__("Owner")}
</SortableTh>
<Th></Th>
</Tr>
</Thead>
@@ -163,6 +179,7 @@ function RiskRow(props: RowProps) {
<Td>
<SeverityBadge score={risk.residualRiskScore} />
</Td>
<Td>{risk.owner?.fullName || __("Unassigned")}</Td>
<Td noLink className="text-end">
{!isSnapshotMode && (
<ActionDropdown>

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<7d5730a1c721f5256e6e0c07199aa0d2>>
* @generated SignedSource<<66f4e8603a811d1fb363ae88ea697b22>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -209,6 +209,20 @@ return {
"name": "residualImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentRiskScore",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualRiskScore",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -256,12 +270,12 @@ return {
]
},
"params": {
"cacheID": "e2131409b62d6cd6bd8a6d008f2ac1f5",
"cacheID": "a6ca4767b2443f6b4d02d6fdd1358600",
"id": null,
"metadata": {},
"name": "FormRiskDialogMutation",
"operationKind": "mutation",
"text": "mutation FormRiskDialogMutation(\n $input: CreateRiskInput!\n) {\n createRisk(input: $input) {\n riskEdge {\n node {\n ...useRiskFormFragment\n id\n }\n }\n }\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n note\n owner {\n id\n }\n}\n"
"text": "mutation FormRiskDialogMutation(\n $input: CreateRiskInput!\n) {\n createRisk(input: $input) {\n riskEdge {\n node {\n ...useRiskFormFragment\n id\n }\n }\n }\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n inherentRiskScore\n residualRiskScore\n note\n owner {\n id\n }\n}\n"
}
};
})();

View File

@@ -1,5 +1,5 @@
/**
* @generated SignedSource<<dc5427f9197a47414ed10738473fdca1>>
* @generated SignedSource<<4122b3e15107bc0f2c5f8b842b882603>>
* @lightSyntaxTransform
* @nogrep
*/
@@ -178,6 +178,20 @@ return {
"name": "residualImpact",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "inherentRiskScore",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "residualRiskScore",
"storageKey": null
},
{
"alias": null,
"args": null,
@@ -206,12 +220,12 @@ return {
]
},
"params": {
"cacheID": "546b1e60a2e87bf71a1851ca76485767",
"cacheID": "59f586a59973ca023df027fdfb0d4bed",
"id": null,
"metadata": {},
"name": "FormRiskDialogUpdateRiskMutation",
"operationKind": "mutation",
"text": "mutation FormRiskDialogUpdateRiskMutation(\n $input: UpdateRiskInput!\n) {\n updateRisk(input: $input) {\n risk {\n ...useRiskFormFragment\n id\n }\n }\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n note\n owner {\n id\n }\n}\n"
"text": "mutation FormRiskDialogUpdateRiskMutation(\n $input: UpdateRiskInput!\n) {\n updateRisk(input: $input) {\n risk {\n ...useRiskFormFragment\n id\n }\n }\n}\n\nfragment useRiskFormFragment on Risk {\n id\n name\n category\n description\n treatment\n inherentLikelihood\n inherentImpact\n residualLikelihood\n residualImpact\n inherentRiskScore\n residualRiskScore\n note\n owner {\n id\n }\n}\n"
}
};
})();