Check snapshot type and id from url
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -15,7 +15,7 @@ export { certificationCategoryLabel, certifications } from "./certifications";
|
||||
export { availableFrameworks } from "./frameworks";
|
||||
export { getDocumentTypeLabel, documentTypes } from "./documents";
|
||||
export { getAssetTypeVariant, getCriticityVariant } from "./assets";
|
||||
export { getSnapshotTypeLabel, getSnapshotTypeUrlPath, snapshotTypes } from "./snapshots";
|
||||
export { getSnapshotTypeLabel, getSnapshotTypeUrlPath, snapshotTypes, validateSnapshotConsistency } from "./snapshots";
|
||||
export { getAuditStateLabel, getAuditStateVariant, auditStates } from "./audits";
|
||||
export { getStatusVariant, getStatusLabel, getNonconformityRegistryStatusOptions, getComplianceRegistryStatusOptions, registryStatuses } from "./registryStatus";
|
||||
export { promisifyMutation } from "./relay";
|
||||
|
||||
@@ -38,3 +38,16 @@ export function getSnapshotTypeUrlPath(type?: string): string {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
export interface SnapshotableResource {
|
||||
snapshotId?: string | null | undefined;
|
||||
}
|
||||
|
||||
export function validateSnapshotConsistency(
|
||||
resource: SnapshotableResource | null | undefined,
|
||||
urlSnapshotId?: string | null | undefined
|
||||
): void {
|
||||
if (resource && resource.snapshotId !== (urlSnapshotId ?? null)) {
|
||||
throw new Error("PAGE_NOT_FOUND");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user