Fix nonconformity pages permission handling
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<310dfd9974ac15af86b8e8ecf21d2b5c>>
|
||||
* @generated SignedSource<<8137b73b0ad40930966c6feb6370420b>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -25,6 +25,8 @@ export type NonconformitiesPageFragment$data = {
|
||||
readonly id: string;
|
||||
readonly name: string | null | undefined;
|
||||
} | null | undefined;
|
||||
readonly canDelete: boolean;
|
||||
readonly canUpdate: boolean;
|
||||
readonly correctiveAction: string | null | undefined;
|
||||
readonly createdAt: any;
|
||||
readonly dateIdentified: any | null | undefined;
|
||||
@@ -292,6 +294,32 @@ return {
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": "canUpdate",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:update"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:update\")"
|
||||
},
|
||||
{
|
||||
"alias": "canDelete",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:delete"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:delete\")"
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -358,6 +386,6 @@ return {
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "0043855d2410d9ab1fd8fceda53f7c5a";
|
||||
(node as any).hash = "57f7e0fb2efff357af936edf90e14876";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<5e8c575bf254c267b0694d9c7dd20a82>>
|
||||
* @generated SignedSource<<c51c49b6699276336c3e5a4cc9a43998>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -315,6 +315,32 @@ return {
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": "canUpdate",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:update"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:update\")"
|
||||
},
|
||||
{
|
||||
"alias": "canDelete",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:delete"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:delete\")"
|
||||
},
|
||||
(v8/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -390,16 +416,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "d0fe732fcd104cafd8dec7748d5f3971",
|
||||
"cacheID": "3876389521eec8e9737e5939cff3d95a",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformitiesPageRefetchQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query NonconformitiesPageRefetchQuery(\n $after: CursorKey\n $first: Int = 10\n $snapshotId: ID = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...NonconformitiesPageFragment_35e0S5\n id\n }\n}\n\nfragment NonconformitiesPageFragment_35e0S5 on Organization {\n id\n nonconformities(first: $first, after: $after, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n referenceId\n snapshotId\n description\n status\n dateIdentified\n dueDate\n rootCause\n correctiveAction\n effectivenessCheck\n audit {\n id\n name\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
|
||||
"text": "query NonconformitiesPageRefetchQuery(\n $after: CursorKey\n $first: Int = 10\n $snapshotId: ID = null\n $id: ID!\n) {\n node(id: $id) {\n __typename\n ...NonconformitiesPageFragment_35e0S5\n id\n }\n}\n\nfragment NonconformitiesPageFragment_35e0S5 on Organization {\n id\n nonconformities(first: $first, after: $after, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n referenceId\n snapshotId\n description\n status\n dateIdentified\n dueDate\n rootCause\n correctiveAction\n effectivenessCheck\n audit {\n id\n name\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n canUpdate: permission(action: \"core:nonconformity:update\")\n canDelete: permission(action: \"core:nonconformity:delete\")\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "0043855d2410d9ab1fd8fceda53f7c5a";
|
||||
(node as any).hash = "57f7e0fb2efff357af936edf90e14876";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<db7fca9f154989ebab9e5c9b0f5bfd85>>
|
||||
* @generated SignedSource<<77c22921ec67a1fb75f743dba1685698>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -37,6 +37,8 @@ export type NonconformityGraphCreateMutation$data = {
|
||||
};
|
||||
readonly id: string;
|
||||
} | null | undefined;
|
||||
readonly canDelete: boolean;
|
||||
readonly canUpdate: boolean;
|
||||
readonly createdAt: any;
|
||||
readonly dateIdentified: any | null | undefined;
|
||||
readonly description: string | null | undefined;
|
||||
@@ -157,6 +159,32 @@ v12 = {
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
v13 = {
|
||||
"alias": "canUpdate",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:update"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:update\")"
|
||||
},
|
||||
v14 = {
|
||||
"alias": "canDelete",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:delete"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:delete\")"
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
@@ -224,7 +252,9 @@ return {
|
||||
"storageKey": null
|
||||
},
|
||||
(v11/*: any*/),
|
||||
(v12/*: any*/)
|
||||
(v12/*: any*/),
|
||||
(v13/*: any*/),
|
||||
(v14/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -304,7 +334,9 @@ return {
|
||||
"storageKey": null
|
||||
},
|
||||
(v11/*: any*/),
|
||||
(v12/*: any*/)
|
||||
(v12/*: any*/),
|
||||
(v13/*: any*/),
|
||||
(v14/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -333,16 +365,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "ad0967f3684a882d198eaa853a691d34",
|
||||
"cacheID": "a6643ead6aba7ef0e9e25dcf889c51e5",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformityGraphCreateMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation NonconformityGraphCreateMutation(\n $input: CreateNonconformityInput!\n) {\n createNonconformity(input: $input) {\n nonconformityEdge {\n node {\n id\n referenceId\n description\n status\n dateIdentified\n dueDate\n rootCause\n audit {\n id\n framework {\n name\n id\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n }\n }\n }\n}\n"
|
||||
"text": "mutation NonconformityGraphCreateMutation(\n $input: CreateNonconformityInput!\n) {\n createNonconformity(input: $input) {\n nonconformityEdge {\n node {\n id\n referenceId\n description\n status\n dateIdentified\n dueDate\n rootCause\n audit {\n id\n framework {\n name\n id\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n canUpdate: permission(action: \"core:nonconformity:update\")\n canDelete: permission(action: \"core:nonconformity:delete\")\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "2a62fc6f16eb6677eecd1cd35de01a16";
|
||||
(node as any).hash = "198593806928185e34490d5c656e70ca";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<8cce006e13ed2bf7b80b12faab4034c0>>
|
||||
* @generated SignedSource<<0da0e157ba973f1ae3e2a60d750b8c0d>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -16,6 +16,7 @@ export type NonconformityGraphListQuery$variables = {
|
||||
};
|
||||
export type NonconformityGraphListQuery$data = {
|
||||
readonly node: {
|
||||
readonly canCreateNonconformity?: boolean;
|
||||
readonly " $fragmentSpreads": FragmentRefs<"NonconformitiesPageFragment">;
|
||||
};
|
||||
};
|
||||
@@ -44,30 +45,43 @@ v1 = [
|
||||
"variableName": "organizationId"
|
||||
}
|
||||
],
|
||||
v2 = [
|
||||
v2 = {
|
||||
"alias": "canCreateNonconformity",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:create"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:create\")"
|
||||
},
|
||||
v3 = [
|
||||
{
|
||||
"kind": "Variable",
|
||||
"name": "snapshotId",
|
||||
"variableName": "snapshotId"
|
||||
}
|
||||
],
|
||||
v3 = {
|
||||
v4 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "__typename",
|
||||
"storageKey": null
|
||||
},
|
||||
v4 = {
|
||||
v5 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "id",
|
||||
"storageKey": null
|
||||
},
|
||||
v5 = [
|
||||
v6 = [
|
||||
{
|
||||
"fields": (v2/*: any*/),
|
||||
"fields": (v3/*: any*/),
|
||||
"kind": "ObjectValue",
|
||||
"name": "filter"
|
||||
},
|
||||
@@ -77,7 +91,7 @@ v5 = [
|
||||
"value": 10
|
||||
}
|
||||
],
|
||||
v6 = {
|
||||
v7 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
@@ -102,8 +116,9 @@ return {
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"args": (v2/*: any*/),
|
||||
"args": (v3/*: any*/),
|
||||
"kind": "FragmentSpread",
|
||||
"name": "NonconformitiesPageFragment"
|
||||
}
|
||||
@@ -132,14 +147,15 @@ return {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v3/*: any*/),
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"kind": "InlineFragment",
|
||||
"selections": [
|
||||
(v2/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v5/*: any*/),
|
||||
"args": (v6/*: any*/),
|
||||
"concreteType": "NonconformityConnection",
|
||||
"kind": "LinkedField",
|
||||
"name": "nonconformities",
|
||||
@@ -168,7 +184,7 @@ return {
|
||||
"name": "node",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -240,8 +256,8 @@ return {
|
||||
"name": "audit",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v5/*: any*/),
|
||||
(v7/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -250,8 +266,8 @@ return {
|
||||
"name": "framework",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v6/*: any*/)
|
||||
(v5/*: any*/),
|
||||
(v7/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
}
|
||||
@@ -266,7 +282,7 @@ return {
|
||||
"name": "owner",
|
||||
"plural": false,
|
||||
"selections": [
|
||||
(v4/*: any*/),
|
||||
(v5/*: any*/),
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -291,7 +307,33 @@ return {
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
(v3/*: any*/)
|
||||
{
|
||||
"alias": "canUpdate",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:update"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:update\")"
|
||||
},
|
||||
{
|
||||
"alias": "canDelete",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:delete"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:delete\")"
|
||||
},
|
||||
(v4/*: any*/)
|
||||
],
|
||||
"storageKey": null
|
||||
},
|
||||
@@ -347,7 +389,7 @@ return {
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": (v5/*: any*/),
|
||||
"args": (v6/*: any*/),
|
||||
"filters": [
|
||||
"filter"
|
||||
],
|
||||
@@ -366,16 +408,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "59c8bf68d04fd47f3d5e3e7d452e2e5e",
|
||||
"cacheID": "96b967c48f7366ffeab39d39fa7221b2",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformityGraphListQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query NonconformityGraphListQuery(\n $organizationId: ID!\n $snapshotId: ID\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n ...NonconformitiesPageFragment_3iomuz\n }\n id\n }\n}\n\nfragment NonconformitiesPageFragment_3iomuz on Organization {\n id\n nonconformities(first: 10, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n referenceId\n snapshotId\n description\n status\n dateIdentified\n dueDate\n rootCause\n correctiveAction\n effectivenessCheck\n audit {\n id\n name\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
|
||||
"text": "query NonconformityGraphListQuery(\n $organizationId: ID!\n $snapshotId: ID\n) {\n node(id: $organizationId) {\n __typename\n ... on Organization {\n canCreateNonconformity: permission(action: \"core:nonconformity:create\")\n ...NonconformitiesPageFragment_3iomuz\n }\n id\n }\n}\n\nfragment NonconformitiesPageFragment_3iomuz on Organization {\n id\n nonconformities(first: 10, filter: {snapshotId: $snapshotId}) {\n totalCount\n edges {\n node {\n id\n referenceId\n snapshotId\n description\n status\n dateIdentified\n dueDate\n rootCause\n correctiveAction\n effectivenessCheck\n audit {\n id\n name\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n createdAt\n updatedAt\n canUpdate: permission(action: \"core:nonconformity:update\")\n canDelete: permission(action: \"core:nonconformity:delete\")\n __typename\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "4b416f25dfb07189adceb1cdec2df4e3";
|
||||
(node as any).hash = "535dfc28b086e0f5a0ffb2f40cac2d89";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<526115183274c5c81a5a70c16012591e>>
|
||||
* @generated SignedSource<<97f85a5e54306b3b401a123c1d0fc41c>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -22,6 +22,8 @@ export type NonconformityGraphNodeQuery$data = {
|
||||
};
|
||||
readonly id: string;
|
||||
} | null | undefined;
|
||||
readonly canDelete?: boolean;
|
||||
readonly canUpdate?: boolean;
|
||||
readonly correctiveAction?: string | null | undefined;
|
||||
readonly createdAt?: any;
|
||||
readonly dateIdentified?: any | null | undefined;
|
||||
@@ -208,6 +210,32 @@ v17 = {
|
||||
"kind": "ScalarField",
|
||||
"name": "updatedAt",
|
||||
"storageKey": null
|
||||
},
|
||||
v18 = {
|
||||
"alias": "canUpdate",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:update"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:update\")"
|
||||
},
|
||||
v19 = {
|
||||
"alias": "canDelete",
|
||||
"args": [
|
||||
{
|
||||
"kind": "Literal",
|
||||
"name": "action",
|
||||
"value": "core:nonconformity:delete"
|
||||
}
|
||||
],
|
||||
"kind": "ScalarField",
|
||||
"name": "permission",
|
||||
"storageKey": "permission(action:\"core:nonconformity:delete\")"
|
||||
};
|
||||
return {
|
||||
"fragment": {
|
||||
@@ -241,7 +269,9 @@ return {
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/),
|
||||
(v16/*: any*/),
|
||||
(v17/*: any*/)
|
||||
(v17/*: any*/),
|
||||
(v18/*: any*/),
|
||||
(v19/*: any*/)
|
||||
],
|
||||
"type": "Nonconformity",
|
||||
"abstractKey": null
|
||||
@@ -291,7 +321,9 @@ return {
|
||||
(v14/*: any*/),
|
||||
(v15/*: any*/),
|
||||
(v16/*: any*/),
|
||||
(v17/*: any*/)
|
||||
(v17/*: any*/),
|
||||
(v18/*: any*/),
|
||||
(v19/*: any*/)
|
||||
],
|
||||
"type": "Nonconformity",
|
||||
"abstractKey": null
|
||||
@@ -302,16 +334,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "e394317a8e7661c374224c08c6fd5b0b",
|
||||
"cacheID": "f917aa1ad5d7628a6193743a18c9aab9",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NonconformityGraphNodeQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query NonconformityGraphNodeQuery(\n $nonconformityId: ID!\n) {\n node(id: $nonconformityId) {\n __typename\n ... on Nonconformity {\n id\n snapshotId\n referenceId\n description\n dateIdentified\n rootCause\n correctiveAction\n dueDate\n status\n effectivenessCheck\n audit {\n id\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n organization {\n id\n name\n }\n createdAt\n updatedAt\n }\n id\n }\n}\n"
|
||||
"text": "query NonconformityGraphNodeQuery(\n $nonconformityId: ID!\n) {\n node(id: $nonconformityId) {\n __typename\n ... on Nonconformity {\n id\n snapshotId\n referenceId\n description\n dateIdentified\n rootCause\n correctiveAction\n dueDate\n status\n effectivenessCheck\n audit {\n id\n framework {\n id\n name\n }\n }\n owner {\n id\n fullName\n }\n organization {\n id\n name\n }\n createdAt\n updatedAt\n canUpdate: permission(action: \"core:nonconformity:update\")\n canDelete: permission(action: \"core:nonconformity:delete\")\n }\n id\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "e57a600fda9f0f5a0178818df75b0436";
|
||||
(node as any).hash = "6d1ecfb7df432a591c7e16461842796d";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -5,12 +5,14 @@ import { useTranslate } from "@probo/i18n";
|
||||
import { promisifyMutation, sprintf } from "@probo/helpers";
|
||||
import { useMutationWithToasts } from "../useMutationWithToasts";
|
||||
|
||||
export const NonconformitiesConnectionKey = "NonconformitiesPage_nonconformities";
|
||||
export const NonconformitiesConnectionKey =
|
||||
"NonconformitiesPage_nonconformities";
|
||||
|
||||
export const nonconformitiesQuery = graphql`
|
||||
query NonconformityGraphListQuery($organizationId: ID!, $snapshotId: ID) {
|
||||
node(id: $organizationId) {
|
||||
... on Organization {
|
||||
canCreateNonconformity: permission(action: "core:nonconformity:create")
|
||||
...NonconformitiesPageFragment @arguments(snapshotId: $snapshotId)
|
||||
}
|
||||
}
|
||||
@@ -48,6 +50,8 @@ export const nonconformityNodeQuery = graphql`
|
||||
}
|
||||
createdAt
|
||||
updatedAt
|
||||
canUpdate: permission(action: "core:nonconformity:update")
|
||||
canDelete: permission(action: "core:nonconformity:delete")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,6 +83,8 @@ export const createNonconformityMutation = graphql`
|
||||
fullName
|
||||
}
|
||||
createdAt
|
||||
canUpdate: permission(action: "core:nonconformity:update")
|
||||
canDelete: permission(action: "core:nonconformity:delete")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +134,7 @@ export const deleteNonconformityMutation = graphql`
|
||||
|
||||
export const useDeleteNonconformity = (
|
||||
nonconformity: { id: string; referenceId: string },
|
||||
connectionId: string
|
||||
connectionId: string,
|
||||
) => {
|
||||
const { __ } = useTranslate();
|
||||
const [mutate] = useMutationWithToasts(deleteNonconformityMutation, {
|
||||
@@ -151,11 +157,11 @@ export const useDeleteNonconformity = (
|
||||
{
|
||||
message: sprintf(
|
||||
__(
|
||||
"This will permanently delete the nonconformity %s. This action cannot be undone."
|
||||
"This will permanently delete the nonconformity %s. This action cannot be undone.",
|
||||
),
|
||||
nonconformity.referenceId
|
||||
nonconformity.referenceId,
|
||||
),
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -178,16 +184,22 @@ export const useCreateNonconformity = (connectionId: string) => {
|
||||
effectivenessCheck?: string;
|
||||
}) => {
|
||||
if (!input.organizationId) {
|
||||
return alert(__("Failed to create nonconformity: organization is required"));
|
||||
return alert(
|
||||
__("Failed to create nonconformity: organization is required"),
|
||||
);
|
||||
}
|
||||
if (!input.referenceId) {
|
||||
return alert(__("Failed to create nonconformity: reference ID is required"));
|
||||
return alert(
|
||||
__("Failed to create nonconformity: reference ID is required"),
|
||||
);
|
||||
}
|
||||
if (!input.ownerId) {
|
||||
return alert(__("Failed to create nonconformity: owner is required"));
|
||||
}
|
||||
if (!input.rootCause) {
|
||||
return alert(__("Failed to create nonconformity: root cause is required"));
|
||||
return alert(
|
||||
__("Failed to create nonconformity: root cause is required"),
|
||||
);
|
||||
}
|
||||
|
||||
return promisifyMutation(mutate)({
|
||||
|
||||
@@ -45,8 +45,6 @@ import type {
|
||||
NonconformitiesPageFragment$key,
|
||||
NonconformitiesPageFragment$data,
|
||||
} from "/__generated__/core/NonconformitiesPageFragment.graphql";
|
||||
import { use } from "react";
|
||||
import { PermissionsContext } from "/providers/PermissionsContext";
|
||||
import type { NonconformityGraphListQuery } from "/__generated__/core/NonconformityGraphListQuery.graphql";
|
||||
|
||||
type Nonconformity =
|
||||
@@ -102,6 +100,8 @@ const nonconformitiesPageFragment = graphql`
|
||||
}
|
||||
createdAt
|
||||
updatedAt
|
||||
canUpdate: permission(action: "core:nonconformity:update")
|
||||
canDelete: permission(action: "core:nonconformity:delete")
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
@@ -119,7 +119,6 @@ export default function NonconformitiesPage({
|
||||
const organizationId = useOrganizationId();
|
||||
const { snapshotId } = useParams<{ snapshotId?: string }>();
|
||||
const isSnapshotMode = Boolean(snapshotId);
|
||||
const { isAuthorized } = use(PermissionsContext);
|
||||
|
||||
usePageTitle(__("Nonconformities"));
|
||||
|
||||
@@ -144,8 +143,7 @@ export default function NonconformitiesPage({
|
||||
|
||||
const hasAnyAction =
|
||||
!isSnapshotMode &&
|
||||
(isAuthorized("Nonconformity", "updateNonconformity") ||
|
||||
isAuthorized("Nonconformity", "deleteNonconformity"));
|
||||
nonconformities.some(({ canDelete, canUpdate }) => canDelete || canUpdate);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -154,15 +152,14 @@ export default function NonconformitiesPage({
|
||||
title={__("Nonconformities")}
|
||||
description={__("Manage your organization's non conformities.")}
|
||||
>
|
||||
{!isSnapshotMode &&
|
||||
isAuthorized("Organization", "createNonconformity") && (
|
||||
<CreateNonconformityDialog
|
||||
organizationId={organizationId}
|
||||
connection={connectionId}
|
||||
>
|
||||
<Button icon={IconPlusLarge}>{__("Add nonconformity")}</Button>
|
||||
</CreateNonconformityDialog>
|
||||
)}
|
||||
{!isSnapshotMode && organization.node.canCreateNonconformity && (
|
||||
<CreateNonconformityDialog
|
||||
organizationId={organizationId}
|
||||
connection={connectionId}
|
||||
>
|
||||
<Button icon={IconPlusLarge}>{__("Add nonconformity")}</Button>
|
||||
</CreateNonconformityDialog>
|
||||
)}
|
||||
</PageHeader>
|
||||
|
||||
{nonconformities.length === 0 ? (
|
||||
@@ -238,7 +235,6 @@ function NonconformityRow({
|
||||
const { __ } = useTranslate();
|
||||
const confirm = useConfirm();
|
||||
const [deleteNonconformity] = useMutation(deleteNonconformityMutation);
|
||||
const { isAuthorized } = use(PermissionsContext);
|
||||
|
||||
const nonconformityDetailUrl = isSnapshotMode
|
||||
? `/organizations/${organizationId}/snapshots/${snapshotId}/nonconformities/${nonconformity.id}`
|
||||
@@ -310,7 +306,7 @@ function NonconformityRow({
|
||||
{hasAnyAction && (
|
||||
<Td noLink width={50} className="text-end">
|
||||
<ActionDropdown>
|
||||
{isAuthorized("Nonconformity", "deleteNonconformity") && (
|
||||
{nonconformity.canDelete && (
|
||||
<DropdownItem
|
||||
icon={IconTrashCan}
|
||||
variant="danger"
|
||||
|
||||
@@ -42,8 +42,6 @@ import {
|
||||
type GraphQLError,
|
||||
} from "@probo/helpers";
|
||||
import type { NonconformityGraphNodeQuery } from "/__generated__/core/NonconformityGraphNodeQuery.graphql";
|
||||
import { PermissionsContext } from "/providers/PermissionsContext";
|
||||
import { use } from "react";
|
||||
|
||||
const updateNonconformitySchema = z.object({
|
||||
referenceId: z.string().min(1, "Reference ID is required"),
|
||||
@@ -63,16 +61,15 @@ type Props = {
|
||||
};
|
||||
|
||||
export default function NonconformityDetailsPage(props: Props) {
|
||||
const data = usePreloadedQuery<NonconformityGraphNodeQuery>(
|
||||
nonconformityNodeQuery,
|
||||
props.queryRef,
|
||||
);
|
||||
const nonconformity = data.node;
|
||||
const { node: nonconformity } =
|
||||
usePreloadedQuery<NonconformityGraphNodeQuery>(
|
||||
nonconformityNodeQuery,
|
||||
props.queryRef,
|
||||
);
|
||||
const { __ } = useTranslate();
|
||||
const organizationId = useOrganizationId();
|
||||
const { snapshotId } = useParams<{ snapshotId?: string }>();
|
||||
const isSnapshotMode = Boolean(snapshotId);
|
||||
const { isAuthorized } = use(PermissionsContext);
|
||||
|
||||
validateSnapshotConsistency(nonconformity, snapshotId);
|
||||
|
||||
@@ -171,7 +168,7 @@ export default function NonconformityDetailsPage(props: Props) {
|
||||
</div>
|
||||
{!isSnapshotMode && (
|
||||
<ActionDropdown variant="secondary">
|
||||
{isAuthorized("Nonconformity", "deleteNonconformity") && (
|
||||
{nonconformity.canDelete && (
|
||||
<DropdownItem
|
||||
variant="danger"
|
||||
icon={IconTrashCan}
|
||||
@@ -296,7 +293,7 @@ export default function NonconformityDetailsPage(props: Props) {
|
||||
<div className="flex justify-end">
|
||||
{formState.isDirty &&
|
||||
!isSnapshotMode &&
|
||||
isAuthorized("Nonconformity", "updateNonconformity") && (
|
||||
nonconformity.canUpdate && (
|
||||
<Button type="submit" disabled={formState.isSubmitting}>
|
||||
{formState.isSubmitting ? __("Updating...") : __("Update")}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user