synapse-react-client 4.0.44 → 4.0.45
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.
- package/dist/SWC.index.d.ts +1 -1
- package/dist/SWC.index.js +2 -2
- package/dist/SWC.index.js.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementList.d.ts +2 -1
- package/dist/components/AccessRequirementList/AccessRequirementList.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementList.js +126 -125
- package/dist/components/AccessRequirementList/AccessRequirementList.js.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementListItem.d.ts +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementListItem.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementListItem.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.js +28 -16
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManualUploadDucStep/ManualUploadDucStep.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManualUploadDucStep/ManualUploadDucStep.js +99 -97
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/ManualUploadDucStep/ManualUploadDucStep.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/requestFlowTypes.d.ts +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/requestFlowTypes.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/RequestDataStep.d.ts +1 -4
- package/dist/components/AccessRequirementList/RequestDataStep.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/RequestDataStep.js +15 -18
- package/dist/components/AccessRequirementList/RequestDataStep.js.map +1 -1
- package/dist/components/CreateOrUpdateAccessRequirementWizard/CreateOrUpdateAccessRequirementWizard.d.ts.map +1 -1
- package/dist/components/CreateOrUpdateAccessRequirementWizard/CreateOrUpdateAccessRequirementWizard.js +52 -49
- package/dist/components/CreateOrUpdateAccessRequirementWizard/CreateOrUpdateAccessRequirementWizard.js.map +1 -1
- package/dist/components/FormTemplateEditor/useSaveFormTemplate.d.ts.map +1 -1
- package/dist/components/FormTemplateEditor/useSaveFormTemplate.js.map +1 -1
- package/dist/components/FormTemplateReferenceField/FormTemplatePreviewDialog.d.ts +9 -0
- package/dist/components/FormTemplateReferenceField/FormTemplatePreviewDialog.d.ts.map +1 -0
- package/dist/components/FormTemplateReferenceField/FormTemplatePreviewDialog.js +45 -0
- package/dist/components/FormTemplateReferenceField/FormTemplatePreviewDialog.js.map +1 -0
- package/dist/components/FormTemplateReferenceField/FormTemplateReferenceField.d.ts +22 -0
- package/dist/components/FormTemplateReferenceField/FormTemplateReferenceField.d.ts.map +1 -0
- package/dist/components/FormTemplateReferenceField/FormTemplateReferenceField.js +139 -0
- package/dist/components/FormTemplateReferenceField/FormTemplateReferenceField.js.map +1 -0
- package/dist/components/Forum/ForumTable.d.ts +17 -5
- package/dist/components/Forum/ForumTable.d.ts.map +1 -1
- package/dist/components/Forum/ForumTable.js +94 -77
- package/dist/components/Forum/ForumTable.js.map +1 -1
- package/dist/components/SetAccessRequirementCommonFields/SetAccessRequirementCommonFields.d.ts.map +1 -1
- package/dist/components/SetAccessRequirementCommonFields/SetAccessRequirementCommonFields.js +142 -108
- package/dist/components/SetAccessRequirementCommonFields/SetAccessRequirementCommonFields.js.map +1 -1
- package/dist/components/SetBasicAccessRequirementFields/AccessorRequirements.d.ts.map +1 -1
- package/dist/components/SetBasicAccessRequirementFields/AccessorRequirements.js +15 -15
- package/dist/components/SetBasicAccessRequirementFields/AccessorRequirements.js.map +1 -1
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.d.ts.map +1 -1
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js +57 -55
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js.map +1 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.d.ts.map +1 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.js +4 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.js.map +1 -1
- package/dist/mocks/accessRequirement/mockJsonSchemaAccessRequirements.d.ts +5 -0
- package/dist/mocks/accessRequirement/mockJsonSchemaAccessRequirements.d.ts.map +1 -1
- package/dist/mocks/accessRequirement/mockJsonSchemaAccessRequirements.js +37 -26
- package/dist/mocks/accessRequirement/mockJsonSchemaAccessRequirements.js.map +1 -1
- package/dist/mocks/msw/handlers/discussionHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/discussionHandlers.js +40 -33
- package/dist/mocks/msw/handlers/discussionHandlers.js.map +1 -1
- package/dist/synapse-client/SynapseClient.d.ts +10 -0
- package/dist/synapse-client/SynapseClient.d.ts.map +1 -1
- package/dist/synapse-client/SynapseClient.js +486 -482
- package/dist/synapse-client/SynapseClient.js.map +1 -1
- package/dist/synapse-client/index.js +3 -3
- package/dist/synapse-queries/KeyFactory.d.ts +13 -1
- package/dist/synapse-queries/KeyFactory.d.ts.map +1 -1
- package/dist/synapse-queries/KeyFactory.js +11 -1
- package/dist/synapse-queries/KeyFactory.js.map +1 -1
- package/dist/synapse-queries/dataaccess/index.js +4 -4
- package/dist/synapse-queries/dataaccess/useAccessRequirements.d.ts.map +1 -1
- package/dist/synapse-queries/dataaccess/useAccessRequirements.js +4 -1
- package/dist/synapse-queries/dataaccess/useAccessRequirements.js.map +1 -1
- package/dist/synapse-queries/dataaccess/useEDuc.d.ts +19 -5
- package/dist/synapse-queries/dataaccess/useEDuc.d.ts.map +1 -1
- package/dist/synapse-queries/dataaccess/useEDuc.js +29 -21
- package/dist/synapse-queries/dataaccess/useEDuc.js.map +1 -1
- package/dist/synapse-queries/dataaccess/useFormTemplate.d.ts +12 -0
- package/dist/synapse-queries/dataaccess/useFormTemplate.d.ts.map +1 -1
- package/dist/synapse-queries/dataaccess/useFormTemplate.js +52 -30
- package/dist/synapse-queries/dataaccess/useFormTemplate.js.map +1 -1
- package/dist/synapse-queries/forum/useForum.d.ts +5 -1
- package/dist/synapse-queries/forum/useForum.d.ts.map +1 -1
- package/dist/synapse-queries/forum/useForum.js +23 -1
- package/dist/synapse-queries/forum/useForum.js.map +1 -1
- package/dist/synapse-queries/index.js +185 -184
- package/dist/synapse-queries/jsonschema/useCreateJsonSchema.d.ts +5 -3
- package/dist/synapse-queries/jsonschema/useCreateJsonSchema.d.ts.map +1 -1
- package/dist/synapse-queries/jsonschema/useCreateJsonSchema.js +12 -15
- package/dist/synapse-queries/jsonschema/useCreateJsonSchema.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/featureflag/FeatureFlags.d.ts.map +1 -1
- package/dist/utils/featureflag/FeatureFlags.js.map +1 -1
- package/dist/utils/functions/getEndpoint.d.ts +1 -0
- package/dist/utils/functions/getEndpoint.d.ts.map +1 -1
- package/dist/utils/functions/getEndpoint.js +3 -3
- package/dist/utils/functions/getEndpoint.js.map +1 -1
- package/dist/utils/types/RequestableAccessRequirement.d.ts +8 -0
- package/dist/utils/types/RequestableAccessRequirement.d.ts.map +1 -0
- package/dist/utils/types/RequestableAccessRequirement.js +9 -0
- package/dist/utils/types/RequestableAccessRequirement.js.map +1 -0
- package/package.json +2 -2
- package/dist/testutils/ReactQueryMockUtils.js +0 -676
- package/dist/testutils/ReactQueryMockUtils.js.map +0 -1
package/dist/components/SetAccessRequirementCommonFields/SetAccessRequirementCommonFields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetAccessRequirementCommonFields.js","names":[],"sources":["../../../src/components/SetAccessRequirementCommonFields/SetAccessRequirementCommonFields.tsx"],"sourcesContent":["import {\n useCreateAccessRequirement,\n useGetAccessRequirements,\n useUpdateAccessRequirement,\n} from '@/synapse-queries'\nimport { spreadSx } from '@/theme/spreadSx'\nimport { HelpOutlineTwoTone } from '@mui/icons-material'\nimport {\n Alert,\n Checkbox,\n FormControlLabel,\n Radio,\n RadioGroup,\n Skeleton,\n Stack,\n TextField,\n Tooltip,\n Typography,\n TypographyProps,\n} from '@mui/material'\nimport { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'\nimport {\n ACCESS_REQUIREMENT_CONCRETE_TYPE,\n ACCESS_TYPE,\n AccessRequirement,\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n RestrictableObjectDescriptor,\n RestrictableObjectType,\n SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n} from '@sage-bionetworks/synapse-types'\nimport pluralize from 'pluralize'\nimport {\n ForwardedRef,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\nimport EntitySubjectsSelector from '../EntitySubjectsSelector'\nimport { SynapseErrorBoundary } from '../error'\nimport TeamSubjectsSelector from '../TeamSubjectsSelector'\n\nexport const EMPTY_SUBJECT_LIST_ERROR_MESSAGE =\n 'Please select at least one resource for this Access Requirement to be associated with.'\nexport const UNSAVED_SUBJECTS_ERROR_MESSAGE = (\n subjectsType: RestrictableObjectType,\n) => {\n const idsText =\n subjectsType === RestrictableObjectType.ENTITY ? 'Synapse' : 'Team'\n const typeText =\n subjectsType[0].toUpperCase() + subjectsType.slice(1).toLowerCase()\n return `${idsText} IDs were specified but not added to the subjects list. Please either clear out the Add ${idsText} IDs textbox or click the Add ${pluralize(\n typeText,\n )} button.`\n}\nconst NAME_HELP_TEXT =\n \"Enter access requirement name. This will also be used when sending notifications for expiring or revoked approval. For example, 'The approval for the name access requirement was revoked...'\"\n\nconst headerProps: Partial<TypographyProps> = {\n variant: 'body1',\n fontWeight: 700,\n}\n\nfunction getAccessType(subjectType: RestrictableObjectType) {\n switch (subjectType) {\n case RestrictableObjectType.ENTITY:\n return ACCESS_TYPE.DOWNLOAD\n case RestrictableObjectType.TEAM:\n return ACCESS_TYPE.PARTICIPATE\n default:\n throw new Error(\n `RestrictableObjectType ${subjectType} does not have an access type specified.`,\n )\n }\n}\n\nexport type SetAccessRequirementCommonFieldsHandle = {\n /* Allow the parent component to trigger saving the AR, so this may be embedded in an arbitrary modal. */\n save: () => void\n}\n\nexport type SetAccessRequirementCommonFieldsProps = {\n /* Provided when creating a new AR */\n subject?: RestrictableObjectDescriptor\n /* Provided when editing an existing AR */\n accessRequirementId?: string\n /* Called when AR has been saved successfully */\n onSave: (\n accessRequirementId: string,\n accessRequirementConreteType: ACCESS_REQUIREMENT_CONCRETE_TYPE,\n ) => void\n /* Called when error saving AR */\n onError: () => void\n}\n\nexport const SetAccessRequirementCommonFields = forwardRef(\n function SetAccessRequirementCommonFields(\n props: SetAccessRequirementCommonFieldsProps,\n ref: ForwardedRef<SetAccessRequirementCommonFieldsHandle>,\n ) {\n const { subject, accessRequirementId, onSave, onError } = props\n\n const isEditing = !subject\n\n const [subjects, setSubjects] = useState<RestrictableObjectDescriptor[]>(\n subject ? [subject] : [],\n )\n const [hasPendingSubjects, setHasPendingSubjects] = useState<boolean>(false)\n const [subjectsError, setSubjectsError] = useState<string | null>(null)\n const [name, setName] = useState<string>('')\n const [subjectsDefinedByAnnotations, setSubjectsDefinedByAnnotations] =\n useState<boolean>(false)\n const [arType, setArType] = useState<ACCESS_REQUIREMENT_CONCRETE_TYPE>(\n subject?.type === RestrictableObjectType.TEAM\n ? SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE\n : MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n )\n const [clientError, setClientError] = useState<string | null>(null)\n\n const onMutationSuccess = (ar: AccessRequirement) => {\n setClientError(null)\n onSave(ar.id.toString(), ar.concreteType)\n }\n\n const onMutationError = (error: SynapseClientError) => {\n setClientError(error.reason)\n onError()\n }\n\n const { mutate: createAccessRequirement } = useCreateAccessRequirement({\n onSuccess: newAr => onMutationSuccess(newAr),\n onError: error => onMutationError(error),\n })\n\n const { mutate: updateAccessRequirement } = useUpdateAccessRequirement({\n onSuccess: updatedAr => onMutationSuccess(updatedAr),\n onError: error => onMutationError(error),\n })\n\n const {\n data: accessRequirement,\n isLoading: isLoadingAr,\n error: getArError,\n } = useGetAccessRequirements(accessRequirementId!, {\n enabled: Boolean(accessRequirementId),\n })\n\n useEffect(() => {\n if (accessRequirement) {\n setArType(accessRequirement.concreteType)\n setName(accessRequirement.name)\n setSubjects(accessRequirement.subjectIds)\n setSubjectsDefinedByAnnotations(\n accessRequirement.subjectsDefinedByAnnotations,\n )\n }\n }, [accessRequirement])\n\n const subjectsType = useMemo(() => {\n if (subject) {\n return subject.type\n }\n if (accessRequirement) {\n const initialSubjects = accessRequirement.subjectIds\n if (initialSubjects.length > 0) {\n return initialSubjects[0].type\n }\n }\n if (subjectsDefinedByAnnotations) {\n return RestrictableObjectType.ENTITY\n }\n return null\n }, [subject, accessRequirement, subjectsDefinedByAnnotations])\n\n const selectorContent = useMemo(() => {\n if (!subjectsType) return <></>\n\n function onUpdate(subjects: RestrictableObjectDescriptor[]) {\n setSubjectsError(null)\n setSubjects(subjects)\n }\n\n function onUpdateIdsTextbox(value: string) {\n setSubjectsError(null)\n setHasPendingSubjects(value.trim() !== '')\n }\n\n if (subjectsDefinedByAnnotations) {\n return <></>\n }\n switch (subjectsType) {\n case RestrictableObjectType.TEAM:\n return (\n <TeamSubjectsSelector\n subjects={subjects}\n onUpdate={subjects => onUpdate(subjects)}\n onUpdateTeamIDsTextbox={value => onUpdateIdsTextbox(value)}\n />\n )\n case RestrictableObjectType.ENTITY:\n return (\n <EntitySubjectsSelector\n subjects={subjects}\n onUpdate={subjects => onUpdate(subjects)}\n onUpdateEntityIDsTextbox={value => onUpdateIdsTextbox(value)}\n />\n )\n default:\n console.error(\n `RestrictableObjectType ${subjectsType} does not have a selector implemented.`,\n )\n return <></>\n }\n }, [subjectsType, subjects, subjectsDefinedByAnnotations])\n\n useImperativeHandle(ref, () => {\n return {\n save() {\n const isStillLoading =\n (isEditing && !accessRequirement) || !subjectsType\n const hasSubjectsError =\n !subjectsDefinedByAnnotations &&\n (hasPendingSubjects || subjects.length === 0)\n if (isStillLoading || hasSubjectsError) {\n if (hasSubjectsError && !isStillLoading) {\n if (hasPendingSubjects) {\n setSubjectsError(UNSAVED_SUBJECTS_ERROR_MESSAGE(subjectsType))\n } else if (subjects.length === 0) {\n setSubjectsError(EMPTY_SUBJECT_LIST_ERROR_MESSAGE)\n }\n }\n\n onError()\n return\n }\n\n const newAccessType = getAccessType(subjectsType)\n if (!isEditing) {\n const newAr: Partial<AccessRequirement> = {\n concreteType: arType,\n subjectIds: subjects,\n name: name,\n accessType: newAccessType,\n subjectsDefinedByAnnotations: subjectsDefinedByAnnotations,\n }\n createAccessRequirement(newAr)\n }\n\n if (isEditing && accessRequirement) {\n updateAccessRequirement({\n ...accessRequirement,\n subjectIds: subjects,\n name: name,\n accessType: newAccessType,\n subjectsDefinedByAnnotations: subjectsDefinedByAnnotations,\n })\n }\n },\n }\n }, [\n hasPendingSubjects,\n subjectsType,\n subjects,\n name,\n arType,\n accessRequirement,\n isEditing,\n onError,\n createAccessRequirement,\n updateAccessRequirement,\n subjectsDefinedByAnnotations,\n ])\n\n if (isLoadingAr || !subjectsType) {\n return (\n <>\n <Skeleton width={100} height={30} />\n <Skeleton width={125} height={30} />\n <Skeleton width=\"100%\">\n <TextField />\n </Skeleton>\n <Skeleton width={100} height={30} />\n <Skeleton width=\"100%\">\n <TextField />\n </Skeleton>\n </>\n )\n }\n\n if (getArError) {\n return <Alert severity=\"error\">{getArError.reason}</Alert>\n }\n\n return (\n <>\n <Typography {...headerProps}>Resources</Typography>\n {subjectsType !== RestrictableObjectType.TEAM && (\n <FormControlLabel\n control={<Checkbox />}\n label=\"Associated entities should be defined by annotations (DUO)\"\n checked={subjectsDefinedByAnnotations}\n onChange={() => {\n setSubjectsError(null)\n // if we are switching from DUO to manually defining the subjects (and the AR has been retrieved), then\n // reset to the AR subject IDs or the original subject ID. Otherwise, clear out the subjects.\n let newSubjectIds: RestrictableObjectDescriptor[] = []\n if (subjectsDefinedByAnnotations) {\n if (accessRequirement) {\n newSubjectIds = accessRequirement.subjectIds\n } else if (subject) {\n newSubjectIds = [subject]\n }\n }\n setSubjects(newSubjectIds)\n setSubjectsDefinedByAnnotations(!subjectsDefinedByAnnotations)\n }}\n />\n )}\n <SynapseErrorBoundary>{selectorContent}</SynapseErrorBoundary>\n {subjectsError && <Alert severity=\"error\">{subjectsError}</Alert>}\n <Stack\n direction=\"row\"\n sx={{\n gap: 1,\n alignItems: 'center',\n mb: 1,\n mt: 2,\n }}\n >\n <Typography component=\"label\" htmlFor=\"arName\" {...headerProps}>\n Name\n </Typography>\n <Tooltip title={NAME_HELP_TEXT} placement=\"right\">\n <HelpOutlineTwoTone sx={{ color: 'grey.600' }} />\n </Tooltip>\n </Stack>\n <TextField\n id=\"arName\"\n name=\"arName\"\n value={name}\n placeholder=\"Access requirement name\"\n fullWidth\n onChange={event => setName(event.target.value)}\n />\n {!isEditing && subjectsType !== RestrictableObjectType.TEAM && (\n <>\n <Typography\n {...headerProps}\n sx={spreadSx(\n {\n mt: 2,\n },\n headerProps.sx,\n )}\n >\n Access requirement type\n </Typography>\n <RadioGroup\n value={arType}\n onChange={(_event, value) =>\n setArType(value as ACCESS_REQUIREMENT_CONCRETE_TYPE)\n }\n >\n <FormControlLabel\n value={MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE}\n control={<Radio />}\n label=\"Controlled - requests are in Synapse\"\n />\n <FormControlLabel\n value={SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE}\n control={<Radio />}\n label=\"Click wrap\"\n />\n </RadioG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AI,EAAE,WAAW,EAAE;aACxC;EACI,CAAA;CAET,EAAA,CAAA;AAEN,CACF"}
|
|
1
|
+
{"version":3,"file":"SetAccessRequirementCommonFields.js","names":[],"sources":["../../../src/components/SetAccessRequirementCommonFields/SetAccessRequirementCommonFields.tsx"],"sourcesContent":["import {\n useCreateAccessRequirement,\n useGetAccessRequirements,\n useUpdateAccessRequirement,\n} from '@/synapse-queries'\nimport { spreadSx } from '@/theme/spreadSx'\nimport { HelpOutlineTwoTone } from '@mui/icons-material'\nimport {\n Alert,\n Box,\n Checkbox,\n FormControlLabel,\n Radio,\n RadioGroup,\n Skeleton,\n Stack,\n TextField,\n Tooltip,\n Typography,\n TypographyProps,\n} from '@mui/material'\nimport { SynapseClientError } from '@sage-bionetworks/synapse-client/util/SynapseClientError'\nimport {\n ACCESS_REQUIREMENT_CONCRETE_TYPE,\n ACCESS_TYPE,\n AccessRequirement,\n JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n RestrictableObjectDescriptor,\n RestrictableObjectType,\n SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n} from '@sage-bionetworks/synapse-types'\nimport pluralize from 'pluralize'\nimport { FormTemplateReference } from '@sage-bionetworks/synapse-client'\nimport { useGetFeatureFlag } from '@/synapse-queries/featureflags/useGetFeatureFlag'\nimport { FeatureFlagEnum } from '@/utils/featureflag/FeatureFlags'\nimport {\n FormTemplateReferenceField,\n useFormTemplateReferenceError,\n} from '../FormTemplateReferenceField/FormTemplateReferenceField'\nimport {\n ForwardedRef,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\nimport EntitySubjectsSelector from '../EntitySubjectsSelector'\nimport { SynapseErrorBoundary } from '../error'\nimport TeamSubjectsSelector from '../TeamSubjectsSelector'\n\nexport const EMPTY_SUBJECT_LIST_ERROR_MESSAGE =\n 'Please select at least one resource for this Access Requirement to be associated with.'\nexport const UNSAVED_SUBJECTS_ERROR_MESSAGE = (\n subjectsType: RestrictableObjectType,\n) => {\n const idsText =\n subjectsType === RestrictableObjectType.ENTITY ? 'Synapse' : 'Team'\n const typeText =\n subjectsType[0].toUpperCase() + subjectsType.slice(1).toLowerCase()\n return `${idsText} IDs were specified but not added to the subjects list. Please either clear out the Add ${idsText} IDs textbox or click the Add ${pluralize(\n typeText,\n )} button.`\n}\nconst NAME_HELP_TEXT =\n \"Enter access requirement name. This will also be used when sending notifications for expiring or revoked approval. For example, 'The approval for the name access requirement was revoked...'\"\n\nconst headerProps: Partial<TypographyProps> = {\n variant: 'body1',\n fontWeight: 700,\n}\n\nfunction getAccessType(subjectType: RestrictableObjectType) {\n switch (subjectType) {\n case RestrictableObjectType.ENTITY:\n return ACCESS_TYPE.DOWNLOAD\n case RestrictableObjectType.TEAM:\n return ACCESS_TYPE.PARTICIPATE\n default:\n throw new Error(\n `RestrictableObjectType ${subjectType} does not have an access type specified.`,\n )\n }\n}\n\nexport type SetAccessRequirementCommonFieldsHandle = {\n /* Allow the parent component to trigger saving the AR, so this may be embedded in an arbitrary modal. */\n save: () => void\n}\n\nexport type SetAccessRequirementCommonFieldsProps = {\n /* Provided when creating a new AR */\n subject?: RestrictableObjectDescriptor\n /* Provided when editing an existing AR */\n accessRequirementId?: string\n /* Called when AR has been saved successfully */\n onSave: (\n accessRequirementId: string,\n accessRequirementConreteType: ACCESS_REQUIREMENT_CONCRETE_TYPE,\n ) => void\n /* Called when error saving AR */\n onError: () => void\n}\n\nexport const SetAccessRequirementCommonFields = forwardRef(\n function SetAccessRequirementCommonFields(\n props: SetAccessRequirementCommonFieldsProps,\n ref: ForwardedRef<SetAccessRequirementCommonFieldsHandle>,\n ) {\n const { subject, accessRequirementId, onSave, onError } = props\n\n const isEditing = !subject\n\n const [subjects, setSubjects] = useState<RestrictableObjectDescriptor[]>(\n subject ? [subject] : [],\n )\n const [hasPendingSubjects, setHasPendingSubjects] = useState<boolean>(false)\n const [subjectsError, setSubjectsError] = useState<string | null>(null)\n const [name, setName] = useState<string>('')\n const [subjectsDefinedByAnnotations, setSubjectsDefinedByAnnotations] =\n useState<boolean>(false)\n const [arType, setArType] = useState<ACCESS_REQUIREMENT_CONCRETE_TYPE>(\n subject?.type === RestrictableObjectType.TEAM\n ? SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE\n : MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n )\n const [clientError, setClientError] = useState<string | null>(null)\n const isSchemaDrivenEnabled = useGetFeatureFlag(\n FeatureFlagEnum.ACT_DASHBOARD_FORM_TEMPLATES,\n )\n const [formTemplateRef, setFormTemplateRef] = useState<\n FormTemplateReference | undefined\n >(undefined)\n const [showFormTemplateError, setShowFormTemplateError] =\n useState<boolean>(false)\n const isSchemaDrivenTypeSelected =\n isSchemaDrivenEnabled &&\n arType === JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE\n const formTemplateReferenceError = useFormTemplateReferenceError(\n isSchemaDrivenTypeSelected ? formTemplateRef : undefined,\n )\n\n const onMutationSuccess = (ar: AccessRequirement) => {\n setClientError(null)\n onSave(ar.id.toString(), ar.concreteType)\n }\n\n const onMutationError = (error: SynapseClientError) => {\n setClientError(error.reason)\n onError()\n }\n\n const { mutate: createAccessRequirement } = useCreateAccessRequirement({\n onSuccess: newAr => onMutationSuccess(newAr),\n onError: error => onMutationError(error),\n })\n\n const { mutate: updateAccessRequirement } = useUpdateAccessRequirement({\n onSuccess: updatedAr => onMutationSuccess(updatedAr),\n onError: error => onMutationError(error),\n })\n\n const {\n data: accessRequirement,\n isLoading: isLoadingAr,\n error: getArError,\n } = useGetAccessRequirements(accessRequirementId!, {\n enabled: Boolean(accessRequirementId),\n })\n\n useEffect(() => {\n if (accessRequirement) {\n setArType(accessRequirement.concreteType)\n if (\n accessRequirement.concreteType ===\n JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE\n ) {\n setFormTemplateRef(accessRequirement.formTemplateRef)\n }\n setName(accessRequirement.name)\n setSubjects(accessRequirement.subjectIds)\n setSubjectsDefinedByAnnotations(\n accessRequirement.subjectsDefinedByAnnotations,\n )\n }\n }, [accessRequirement])\n\n const subjectsType = useMemo(() => {\n if (subject) {\n return subject.type\n }\n if (accessRequirement) {\n const initialSubjects = accessRequirement.subjectIds\n if (initialSubjects.length > 0) {\n return initialSubjects[0].type\n }\n }\n if (subjectsDefinedByAnnotations) {\n return RestrictableObjectType.ENTITY\n }\n return null\n }, [subject, accessRequirement, subjectsDefinedByAnnotations])\n\n const selectorContent = useMemo(() => {\n if (!subjectsType) return <></>\n\n function onUpdate(subjects: RestrictableObjectDescriptor[]) {\n setSubjectsError(null)\n setSubjects(subjects)\n }\n\n function onUpdateIdsTextbox(value: string) {\n setSubjectsError(null)\n setHasPendingSubjects(value.trim() !== '')\n }\n\n if (subjectsDefinedByAnnotations) {\n return <></>\n }\n switch (subjectsType) {\n case RestrictableObjectType.TEAM:\n return (\n <TeamSubjectsSelector\n subjects={subjects}\n onUpdate={subjects => onUpdate(subjects)}\n onUpdateTeamIDsTextbox={value => onUpdateIdsTextbox(value)}\n />\n )\n case RestrictableObjectType.ENTITY:\n return (\n <EntitySubjectsSelector\n subjects={subjects}\n onUpdate={subjects => onUpdate(subjects)}\n onUpdateEntityIDsTextbox={value => onUpdateIdsTextbox(value)}\n />\n )\n default:\n console.error(\n `RestrictableObjectType ${subjectsType} does not have a selector implemented.`,\n )\n return <></>\n }\n }, [subjectsType, subjects, subjectsDefinedByAnnotations])\n\n useImperativeHandle(ref, () => {\n return {\n save() {\n const isStillLoading =\n (isEditing && !accessRequirement) || !subjectsType\n const hasSubjectsError =\n !subjectsDefinedByAnnotations &&\n (hasPendingSubjects || subjects.length === 0)\n if (isStillLoading || hasSubjectsError) {\n if (hasSubjectsError && !isStillLoading) {\n if (hasPendingSubjects) {\n setSubjectsError(UNSAVED_SUBJECTS_ERROR_MESSAGE(subjectsType))\n } else if (subjects.length === 0) {\n setSubjectsError(EMPTY_SUBJECT_LIST_ERROR_MESSAGE)\n }\n }\n\n onError()\n return\n }\n\n if (isSchemaDrivenTypeSelected && formTemplateReferenceError) {\n setShowFormTemplateError(true)\n onError()\n return\n }\n\n const newAccessType = getAccessType(subjectsType)\n if (!isEditing) {\n const newAr: Partial<AccessRequirement> = {\n concreteType: arType,\n subjectIds: subjects,\n name: name,\n accessType: newAccessType,\n subjectsDefinedByAnnotations: subjectsDefinedByAnnotations,\n ...(isSchemaDrivenTypeSelected ? { formTemplateRef } : {}),\n }\n createAccessRequirement(newAr)\n }\n\n if (isEditing && accessRequirement) {\n updateAccessRequirement({\n ...accessRequirement,\n subjectIds: subjects,\n name: name,\n accessType: newAccessType,\n subjectsDefinedByAnnotations: subjectsDefinedByAnnotations,\n ...(isSchemaDrivenTypeSelected ? { formTemplateRef } : {}),\n })\n }\n },\n }\n }, [\n hasPendingSubjects,\n subjectsType,\n subjects,\n name,\n arType,\n accessRequirement,\n isEditing,\n onError,\n createAccessRequirement,\n updateAccessRequirement,\n subjectsDefinedByAnnotations,\n isSchemaDrivenTypeSelected,\n formTemplateRef,\n formTemplateReferenceError,\n ])\n\n if (isLoadingAr || !subjectsType) {\n return (\n <>\n <Skeleton width={100} height={30} />\n <Skeleton width={125} height={30} />\n <Skeleton width=\"100%\">\n <TextField />\n </Skeleton>\n <Skeleton width={100} height={30} />\n <Skeleton width=\"100%\">\n <TextField />\n </Skeleton>\n </>\n )\n }\n\n if (getArError) {\n return <Alert severity=\"error\">{getArError.reason}</Alert>\n }\n\n return (\n <>\n <Typography {...headerProps}>Resources</Typography>\n {subjectsType !== RestrictableObjectType.TEAM && (\n <FormControlLabel\n control={<Checkbox />}\n label=\"Associated entities should be defined by annotations (DUO)\"\n checked={subjectsDefinedByAnnotations}\n onChange={() => {\n setSubjectsError(null)\n // if we are switching from DUO to manually defining the subjects (and the AR has been retrieved), then\n // reset to the AR subject IDs or the original subject ID. Otherwise, clear out the subjects.\n let newSubjectIds: RestrictableObjectDescriptor[] = []\n if (subjectsDefinedByAnnotations) {\n if (accessRequirement) {\n newSubjectIds = accessRequirement.subjectIds\n } else if (subject) {\n newSubjectIds = [subject]\n }\n }\n setSubjects(newSubjectIds)\n setSubjectsDefinedByAnnotations(!subjectsDefinedByAnnotations)\n }}\n />\n )}\n <SynapseErrorBoundary>{selectorContent}</SynapseErrorBoundary>\n {subjectsError && <Alert severity=\"error\">{subjectsError}</Alert>}\n <Stack\n direction=\"row\"\n sx={{\n gap: 1,\n alignItems: 'center',\n mb: 1,\n mt: 2,\n }}\n >\n <Typography component=\"label\" htmlFor=\"arName\" {...headerProps}>\n Name\n </Typography>\n <Tooltip title={NAME_HELP_TEXT} placement=\"right\">\n <HelpOutlineTwoTone sx={{ color: 'grey.600' }} />\n </Tooltip>\n </Stack>\n <TextField\n id=\"arName\"\n name=\"arName\"\n value={name}\n placeholder=\"Access requirement name\"\n fullWidth\n onChange={event => setName(event.target.value)}\n />\n {!isEditing && subjectsType !== RestrictableObjectType.TEAM && (\n <>\n <Typography\n {...headerProps}\n sx={spreadSx(\n {\n mt: 2,\n },\n headerProps.sx,\n )}\n >\n Access requirement type\n </Typography>\n <RadioGroup\n value={arType}\n onChange={(_event, value) =>\n setArType(value as ACCESS_REQUIREMENT_CONCRETE_TYPE)\n }\n >\n <FormControlLabel\n value={MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE}\n control={<Radio />}\n label=\"Controlled - requests are in Synapse\"\n />\n <FormControlLabel\n value={SELF_SIGN_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE}\n control={<Radio />}\n label=\"Click wrap\"\n />\n {isSchemaDrivenEnabled && (\n <FormControlLabel\n value={JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE}\n control={<Radio />}\n label=\"Schema-driven - requests are in Synapse, using a form template\"\n />\n )}\n </RadioGroup>\n </>\n )}\n {isSchemaDrivenTypeSelected && (\n <Box sx={{ mt: 2 }}>\n <Typography\n {...headerProps}\n sx={spreadSx({ mb: 1 }, headerProps.sx)}\n >\n Form presented to requesters\n </Typography>\n <FormTemplateReferenceField\n value={formTemplateRef}\n onChange={reference => {\n setShowFormTemplateError(false)\n setFormTemplateRef(reference)\n }}\n error={showFormTemplateError ? formTemplateReferenceError : null}\n />\n </Box>\n )}\n {clientError && (\n <Alert severity=\"error\" sx={{ marginTop: 2 }}>\n {clientError}\n </Alert>\n )}\n </>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;;;;;;AAoDA,IAAa,IACX,0FACW,KACX,MACG;CACH,IAAM,IACJ,MAAiB,EAAuB,SAAS,YAAY;CAG/D,OAAO,GAAG,EAAQ,0FAA0F,EAAQ,gCAAgC,EADlJ,EAAa,GAAG,YAAY,IAAI,EAAa,MAAM,CAAC,EAAE,YAAY,CAGpE,EAAE;AACJ,GACM,KACJ,iMAEI,IAAwC;CAC5C,SAAS;CACT,YAAY;AACd;AAEA,SAAS,GAAc,GAAqC;CAC1D,QAAQ,GAAR;EACE,KAAK,EAAuB,QAC1B,OAAO,EAAY;EACrB,KAAK,EAAuB,MAC1B,OAAO,EAAY;EACrB,SACE,MAAU,MACR,0BAA0B,EAAY,yCACxC;CACJ;AACF;AAqBA,IAAa,IAAmC,EAC9C,SACE,GACA,GACA;CACA,IAAM,EAAE,YAAS,wBAAqB,YAAQ,eAAY,GAEpD,IAAY,CAAC,GAEb,CAAC,GAAU,KAAe,EAC9B,IAAU,CAAC,CAAO,IAAI,CAAC,CACzB,GACM,CAAC,GAAoB,MAAyB,EAAkB,EAAK,GACrE,CAAC,GAAe,KAAoB,EAAwB,IAAI,GAChE,CAAC,GAAM,KAAW,EAAiB,EAAE,GACrC,CAAC,GAA8B,KACnC,EAAkB,EAAK,GACnB,CAAC,GAAQ,KAAa,EAC1B,GAAS,SAAS,EAAuB,OACrC,IACA,CACN,GACM,CAAC,GAAa,KAAkB,EAAw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AAoB,IAAI,EAAE,OAAO,WAAW,EAAI,CAAA;GACzC,CAAA,CACJ;;EACP,kBAAC,GAAD;GACE,IAAG;GACH,MAAK;GACL,OAAO;GACP,aAAY;GACZ,WAAA;GACA,WAAU,MAAS,EAAQ,EAAM,OAAO,KAAK;EAC9C,CAAA;EACA,CAAC,KAAa,MAAiB,EAAuB,QACrD,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;GACE,GAAI;GACJ,IAAI,EACF,EACE,IAAI,EACN,GACA,EAAY,EACd;aACD;EAEW,CAAA,GACZ,kBAAC,IAAD;GACE,OAAO;GACP,WAAW,GAAQ,MACjB,EAAU,CAAyC;aAHvD;IAME,kBAAC,GAAD;KACE,OAAO;KACP,SAAS,kBAAC,GAAD,CAAQ,CAAA;KACjB,OAAM;IACP,CAAA;IACD,kBAAC,GAAD;KACE,OAAO;KACP,SAAS,kBAAC,GAAD,CAAQ,CAAA;KACjB,OAAM;IACP,CAAA;IACA,KACC,kBAAC,GAAD;KACE,OAAO;KACP,SAAS,kBAAC,GAAD,CAAQ,CAAA;KACjB,OAAM;IACP,CAAA;GAEO;IACZ,EAAA,CAAA;EAEH,KACC,kBAAC,IAAD;GAAK,IAAI,EAAE,IAAI,EAAE;aAAjB,CACE,kBAAC,GAAD;IACE,GAAI;IACJ,IAAI,EAAS,EAAE,IAAI,EAAE,GAAG,EAAY,EAAE;cACvC;GAEW,CAAA,GACZ,kBAAC,IAAD;IACE,OAAO;IACP,WAAU,MAAa;KAErB,AADA,EAAyB,EAAK,GAC9B,EAAmB,CAAS;IAC9B;IACA,OAAO,KAAwB,IAA6B;GAC7D,CAAA,CACE;;EAEN,KACC,kBAAC,GAAD;GAAO,UAAS;GAAQ,IAAI,EAAE,WAAW,EAAE;aACxC;EACI,CAAA;CAET,EAAA,CAAA;AAEN,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessorRequirements.d.ts","sourceRoot":"","sources":["../../../src/components/SetBasicAccessRequirementFields/AccessorRequirements.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AccessorRequirements.d.ts","sourceRoot":"","sources":["../../../src/components/SetBasicAccessRequirementFields/AccessorRequirements.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGlB,MAAM,iCAAiC,CAAA;AAIxC,KAAK,yBAAyB,GAAG;IAC/B,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,QAAQ,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAA;CACjD,CAAA;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,2CA+DpE"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { hasAccessorRequirement as e } from "./GovernanceUtils.js";
|
|
2
2
|
import { Box as t, Checkbox as n, FormControlLabel as r, Typography as i } from "@mui/material";
|
|
3
3
|
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
4
|
+
import { JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as c, MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as l } from "@sage-bionetworks/synapse-types";
|
|
5
5
|
//#region src/components/SetBasicAccessRequirementFields/AccessorRequirements.tsx
|
|
6
|
-
function
|
|
7
|
-
let { accessRequirement:
|
|
8
|
-
return /* @__PURE__ */ o(a, { children: e(
|
|
6
|
+
function u(u) {
|
|
7
|
+
let { accessRequirement: d, onChange: f } = u;
|
|
8
|
+
return /* @__PURE__ */ o(a, { children: e(d) && /* @__PURE__ */ o(a, { children: /* @__PURE__ */ s(t, {
|
|
9
9
|
sx: { mb: 2 },
|
|
10
10
|
children: [
|
|
11
11
|
/* @__PURE__ */ o(i, {
|
|
@@ -16,27 +16,27 @@ function l(l) {
|
|
|
16
16
|
/* @__PURE__ */ o(r, {
|
|
17
17
|
control: /* @__PURE__ */ o(n, {}),
|
|
18
18
|
label: "Accessors must be certified.",
|
|
19
|
-
checked:
|
|
20
|
-
onChange: (e, t) =>
|
|
21
|
-
...
|
|
19
|
+
checked: d.isCertifiedUserRequired,
|
|
20
|
+
onChange: (e, t) => f({
|
|
21
|
+
...d,
|
|
22
22
|
isCertifiedUserRequired: t
|
|
23
23
|
})
|
|
24
24
|
}),
|
|
25
25
|
/* @__PURE__ */ o(r, {
|
|
26
26
|
control: /* @__PURE__ */ o(n, {}),
|
|
27
27
|
label: "Accessors must have a validated profile.",
|
|
28
|
-
checked:
|
|
29
|
-
onChange: (e, t) =>
|
|
30
|
-
...
|
|
28
|
+
checked: d.isValidatedProfileRequired,
|
|
29
|
+
onChange: (e, t) => f({
|
|
30
|
+
...d,
|
|
31
31
|
isValidatedProfileRequired: t
|
|
32
32
|
})
|
|
33
33
|
}),
|
|
34
|
-
|
|
34
|
+
(d.concreteType === l || d.concreteType === c) && /* @__PURE__ */ o(r, {
|
|
35
35
|
control: /* @__PURE__ */ o(n, {}),
|
|
36
36
|
label: "Accessors must use two-factor authentication (2FA).",
|
|
37
|
-
checked:
|
|
38
|
-
onChange: (e, t) =>
|
|
39
|
-
...
|
|
37
|
+
checked: d.isTwoFaRequired,
|
|
38
|
+
onChange: (e, t) => f({
|
|
39
|
+
...d,
|
|
40
40
|
isTwoFaRequired: t
|
|
41
41
|
})
|
|
42
42
|
})
|
|
@@ -44,6 +44,6 @@ function l(l) {
|
|
|
44
44
|
}) }) });
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
|
-
export {
|
|
47
|
+
export { u as AccessorRequirements };
|
|
48
48
|
|
|
49
49
|
//# sourceMappingURL=AccessorRequirements.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessorRequirements.js","names":[],"sources":["../../../src/components/SetBasicAccessRequirementFields/AccessorRequirements.tsx"],"sourcesContent":["import {\n AccessRequirement,\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n} from '@sage-bionetworks/synapse-types'\nimport { hasAccessorRequirement } from './GovernanceUtils'\nimport { Box, Checkbox, FormControlLabel, Typography } from '@mui/material'\n\ntype AccessorRequirementsProps = {\n accessRequirement: AccessRequirement\n onChange: (updatedAr: AccessRequirement) => void\n}\n\nexport function AccessorRequirements(props: AccessorRequirementsProps) {\n const { accessRequirement, onChange } = props\n\n return (\n <>\n {hasAccessorRequirement(accessRequirement) && (\n <>\n <Box\n sx={{\n mb: 2,\n }}\n >\n <Typography\n variant=\"body1\"\n sx={{\n fontWeight: 700,\n }}\n >\n Accessor requirements\n </Typography>\n <FormControlLabel\n control={<Checkbox />}\n label=\"Accessors must be certified.\"\n checked={accessRequirement.isCertifiedUserRequired}\n onChange={(_event, checked: boolean) =>\n onChange({\n ...accessRequirement,\n isCertifiedUserRequired: checked,\n })\n }\n />\n <FormControlLabel\n control={<Checkbox />}\n label=\"Accessors must have a validated profile.\"\n checked={accessRequirement.isValidatedProfileRequired}\n onChange={(_event, checked: boolean) =>\n onChange({\n ...accessRequirement,\n isValidatedProfileRequired: checked,\n })\n }\n />\n {accessRequirement.concreteType ===\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE && (\n <FormControlLabel\n control={<Checkbox />}\n label=\"Accessors must use two-factor authentication (2FA).\"\n checked={accessRequirement.isTwoFaRequired}\n onChange={(_event, checked: boolean) =>\n onChange({\n ...accessRequirement,\n isTwoFaRequired: checked,\n })\n }\n />\n )}\n </Box>\n </>\n )}\n </>\n )\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AccessorRequirements.js","names":[],"sources":["../../../src/components/SetBasicAccessRequirementFields/AccessorRequirements.tsx"],"sourcesContent":["import {\n AccessRequirement,\n JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE,\n} from '@sage-bionetworks/synapse-types'\nimport { hasAccessorRequirement } from './GovernanceUtils'\nimport { Box, Checkbox, FormControlLabel, Typography } from '@mui/material'\n\ntype AccessorRequirementsProps = {\n accessRequirement: AccessRequirement\n onChange: (updatedAr: AccessRequirement) => void\n}\n\nexport function AccessorRequirements(props: AccessorRequirementsProps) {\n const { accessRequirement, onChange } = props\n\n return (\n <>\n {hasAccessorRequirement(accessRequirement) && (\n <>\n <Box\n sx={{\n mb: 2,\n }}\n >\n <Typography\n variant=\"body1\"\n sx={{\n fontWeight: 700,\n }}\n >\n Accessor requirements\n </Typography>\n <FormControlLabel\n control={<Checkbox />}\n label=\"Accessors must be certified.\"\n checked={accessRequirement.isCertifiedUserRequired}\n onChange={(_event, checked: boolean) =>\n onChange({\n ...accessRequirement,\n isCertifiedUserRequired: checked,\n })\n }\n />\n <FormControlLabel\n control={<Checkbox />}\n label=\"Accessors must have a validated profile.\"\n checked={accessRequirement.isValidatedProfileRequired}\n onChange={(_event, checked: boolean) =>\n onChange({\n ...accessRequirement,\n isValidatedProfileRequired: checked,\n })\n }\n />\n {(accessRequirement.concreteType ===\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE ||\n accessRequirement.concreteType ===\n JSON_SCHEMA_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE) && (\n <FormControlLabel\n control={<Checkbox />}\n label=\"Accessors must use two-factor authentication (2FA).\"\n checked={accessRequirement.isTwoFaRequired}\n onChange={(_event, checked: boolean) =>\n onChange({\n ...accessRequirement,\n isTwoFaRequired: checked,\n })\n }\n />\n )}\n </Box>\n </>\n )}\n </>\n )\n}\n"],"mappings":";;;;;AAaA,SAAgB,EAAqB,GAAkC;CACrE,IAAM,EAAE,sBAAmB,gBAAa;CAExC,OACE,kBAAA,GAAA,EAAA,UACG,EAAuB,CAAiB,KACvC,kBAAA,GAAA,EAAA,UACE,kBAAC,GAAD;EACE,IAAI,EACF,IAAI,EACN;YAHF;GAKE,kBAAC,GAAD;IACE,SAAQ;IACR,IAAI,EACF,YAAY,IACd;cACD;GAEW,CAAA;GACZ,kBAAC,GAAD;IACE,SAAS,kBAAC,GAAD,CAAW,CAAA;IACpB,OAAM;IACN,SAAS,EAAkB;IAC3B,WAAW,GAAQ,MACjB,EAAS;KACP,GAAG;KACH,yBAAyB;IAC3B,CAAC;GAEJ,CAAA;GACD,kBAAC,GAAD;IACE,SAAS,kBAAC,GAAD,CAAW,CAAA;IACpB,OAAM;IACN,SAAS,EAAkB;IAC3B,WAAW,GAAQ,MACjB,EAAS;KACP,GAAG;KACH,4BAA4B;IAC9B,CAAC;GAEJ,CAAA;IACC,EAAkB,iBAClB,KACA,EAAkB,iBAChB,MACF,kBAAC,GAAD;IACE,SAAS,kBAAC,GAAD,CAAW,CAAA;IACpB,OAAM;IACN,SAAS,EAAkB;IAC3B,WAAW,GAAQ,MACjB,EAAS;KACP,GAAG;KACH,iBAAiB;IACnB,CAAC;GAEJ,CAAA;EAEA;IACL,CAAA,EAEJ,CAAA;AAEN"}
|
package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetManagedAccessRequirementFields.d.ts","sourceRoot":"","sources":["../../../src/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SetManagedAccessRequirementFields.d.ts","sourceRoot":"","sources":["../../../src/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.tsx"],"names":[],"mappings":"AAgCA,MAAM,MAAM,uCAAuC,GAAG;IAEpD,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,sCAAsC,GAAG;IACnD,mBAAmB,EAAE,MAAM,CAAA;IAE3B,MAAM,EAAE,MAAM,IAAI,CAAA;IAElB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,iCAAiC,4JA2M7C,CAAA"}
|
package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js
CHANGED
|
@@ -10,31 +10,37 @@ import { ExpirationPeriodField as s, getValidExpirationPeriodOrErrorMessage as c
|
|
|
10
10
|
import { forwardRef as l, useEffect as u, useImperativeHandle as d, useState as f } from "react";
|
|
11
11
|
import { Alert as p, Box as m, Checkbox as h, FormControlLabel as g, Typography as _ } from "@mui/material";
|
|
12
12
|
import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
13
|
+
import { MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE as x } from "@sage-bionetworks/synapse-types";
|
|
13
14
|
//#region src/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.tsx
|
|
14
|
-
var
|
|
15
|
-
let { accessRequirementId:
|
|
15
|
+
var S = l(function(l, S) {
|
|
16
|
+
let { accessRequirementId: C, onSave: w, onError: T } = l, { data: E, error: D } = n(C, { staleTime: Infinity });
|
|
16
17
|
u(() => {
|
|
17
|
-
|
|
18
|
-
}, [
|
|
19
|
-
let [
|
|
20
|
-
onSuccess: () =>
|
|
21
|
-
onError: () =>
|
|
18
|
+
E && (j(E), N((E.expirationPeriod / e).toString()));
|
|
19
|
+
}, [E]);
|
|
20
|
+
let [O, k] = f(null), [A, j] = f(null), [M, N] = f(""), { mutate: P, isPending: F, error: I } = r({
|
|
21
|
+
onSuccess: () => w(),
|
|
22
|
+
onError: () => T()
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
let e = c(
|
|
26
|
-
typeof e == "string" ? (
|
|
27
|
-
...
|
|
24
|
+
if (d(S, () => ({ save() {
|
|
25
|
+
if (A) {
|
|
26
|
+
let e = c(M);
|
|
27
|
+
typeof e == "string" ? (k(e), T()) : P({
|
|
28
|
+
...A,
|
|
28
29
|
expirationPeriod: e
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
} }), [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
]),
|
|
37
|
-
|
|
33
|
+
M,
|
|
34
|
+
A,
|
|
35
|
+
P,
|
|
36
|
+
T
|
|
37
|
+
]), !A) return D ? /* @__PURE__ */ y(p, {
|
|
38
|
+
severity: "error",
|
|
39
|
+
children: D.reason
|
|
40
|
+
}) : /* @__PURE__ */ y(t, {});
|
|
41
|
+
let L = A.concreteType === x;
|
|
42
|
+
return /* @__PURE__ */ b(v, { children: [
|
|
43
|
+
/* @__PURE__ */ y(i, { accessRequirement: A }),
|
|
38
44
|
/* @__PURE__ */ b(m, { children: [/* @__PURE__ */ y(_, {
|
|
39
45
|
sx: {
|
|
40
46
|
bgcolor: "#f5f5f5",
|
|
@@ -50,61 +56,60 @@ var x = l(function(l, x) {
|
|
|
50
56
|
mb: 4
|
|
51
57
|
},
|
|
52
58
|
children: [/* @__PURE__ */ y(a, {
|
|
53
|
-
accessRequirement:
|
|
54
|
-
onChange: (e) =>
|
|
59
|
+
accessRequirement: A,
|
|
60
|
+
onChange: (e) => j(e)
|
|
55
61
|
}), /* @__PURE__ */ b(m, {
|
|
56
62
|
sx: { mb: 2 },
|
|
57
63
|
children: [
|
|
58
64
|
/* @__PURE__ */ y(o, {
|
|
59
|
-
accessRequirement:
|
|
60
|
-
isLoading:
|
|
61
|
-
onChange: (e) =>
|
|
62
|
-
...
|
|
65
|
+
accessRequirement: A,
|
|
66
|
+
isLoading: F,
|
|
67
|
+
onChange: (e) => j({
|
|
68
|
+
...A,
|
|
63
69
|
...e
|
|
64
70
|
})
|
|
65
71
|
}),
|
|
66
|
-
/* @__PURE__ */ y(g, {
|
|
72
|
+
L && /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(g, {
|
|
67
73
|
label: "IRB approval is required.",
|
|
68
|
-
checked:
|
|
74
|
+
checked: A.isIRBApprovalRequired,
|
|
69
75
|
control: /* @__PURE__ */ y(h, {}),
|
|
70
|
-
onChange: (e, t) =>
|
|
71
|
-
...
|
|
76
|
+
onChange: (e, t) => j({
|
|
77
|
+
...A,
|
|
72
78
|
isIRBApprovalRequired: t
|
|
73
79
|
}),
|
|
74
80
|
sx: { ml: 0 }
|
|
75
|
-
}),
|
|
76
|
-
/* @__PURE__ */ y(g, {
|
|
81
|
+
}), /* @__PURE__ */ y(g, {
|
|
77
82
|
control: /* @__PURE__ */ y(h, {}),
|
|
78
83
|
label: "Other documents are required.",
|
|
79
|
-
checked:
|
|
80
|
-
onChange: (e, t) =>
|
|
81
|
-
...
|
|
84
|
+
checked: A.areOtherAttachmentsRequired,
|
|
85
|
+
onChange: (e, t) => j({
|
|
86
|
+
...A,
|
|
82
87
|
areOtherAttachmentsRequired: t
|
|
83
88
|
})
|
|
84
|
-
}),
|
|
89
|
+
})] }),
|
|
85
90
|
/* @__PURE__ */ y(s, {
|
|
86
|
-
days:
|
|
87
|
-
error:
|
|
91
|
+
days: M,
|
|
92
|
+
error: O,
|
|
88
93
|
onChange: (e) => {
|
|
89
|
-
|
|
94
|
+
k(null), N(e);
|
|
90
95
|
},
|
|
91
96
|
onBlur: () => {
|
|
92
|
-
let e = c(
|
|
93
|
-
typeof e == "string" &&
|
|
97
|
+
let e = c(M);
|
|
98
|
+
typeof e == "string" && k(e);
|
|
94
99
|
}
|
|
95
100
|
}),
|
|
96
|
-
/* @__PURE__ */ b(m, {
|
|
101
|
+
L && /* @__PURE__ */ b(m, {
|
|
97
102
|
sx: { mt: 1 },
|
|
98
103
|
children: [/* @__PURE__ */ y(g, {
|
|
99
104
|
control: /* @__PURE__ */ y(h, {}),
|
|
100
105
|
label: "Intended Data Use statement is required.",
|
|
101
|
-
checked:
|
|
106
|
+
checked: A.isIDURequired,
|
|
102
107
|
onChange: (e, t) => {
|
|
103
|
-
|
|
104
|
-
...
|
|
108
|
+
j(t ? {
|
|
109
|
+
...A,
|
|
105
110
|
isIDURequired: !0
|
|
106
111
|
} : {
|
|
107
|
-
...
|
|
112
|
+
...A,
|
|
108
113
|
isIDURequired: !1,
|
|
109
114
|
isIDUPublic: !1
|
|
110
115
|
});
|
|
@@ -112,10 +117,10 @@ var x = l(function(l, x) {
|
|
|
112
117
|
}), /* @__PURE__ */ y(g, {
|
|
113
118
|
control: /* @__PURE__ */ y(h, {}),
|
|
114
119
|
label: "Intended Data Use statements will be publicly available.",
|
|
115
|
-
checked:
|
|
116
|
-
disabled: !
|
|
117
|
-
onChange: (e, t) =>
|
|
118
|
-
...
|
|
120
|
+
checked: A.isIDUPublic,
|
|
121
|
+
disabled: !A.isIDURequired,
|
|
122
|
+
onChange: (e, t) => j({
|
|
123
|
+
...A,
|
|
119
124
|
isIDUPublic: t
|
|
120
125
|
})
|
|
121
126
|
})]
|
|
@@ -123,17 +128,14 @@ var x = l(function(l, x) {
|
|
|
123
128
|
]
|
|
124
129
|
})]
|
|
125
130
|
})] }),
|
|
126
|
-
|
|
131
|
+
I && /* @__PURE__ */ y(p, {
|
|
127
132
|
severity: "error",
|
|
128
133
|
sx: { marginTop: 2 },
|
|
129
|
-
children:
|
|
134
|
+
children: I.reason
|
|
130
135
|
})
|
|
131
|
-
] })
|
|
132
|
-
severity: "error",
|
|
133
|
-
children: E.reason
|
|
134
|
-
}) : /* @__PURE__ */ y(t, {});
|
|
136
|
+
] });
|
|
135
137
|
});
|
|
136
138
|
//#endregion
|
|
137
|
-
export {
|
|
139
|
+
export { S as SetManagedAccessRequirementFields };
|
|
138
140
|
|
|
139
141
|
//# sourceMappingURL=SetManagedAccessRequirementFields.js.map
|
package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetManagedAccessRequirementFields.js","names":[],"sources":["../../../src/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.tsx"],"sourcesContent":["import {\n useGetAccessRequirements,\n useUpdateAccessRequirement,\n} from '@/synapse-queries'\nimport { DAY_IN_MS } from '@/utils/SynapseConstants'\nimport {\n Alert,\n Box,\n Checkbox,\n FormControlLabel,\n Typography,\n} from '@mui/material'\nimport { ManagedACTAccessRequirement } from '@sage-bionetworks/synapse-types'\nimport {\n ForwardedRef,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react'\nimport { SynapseSpinner } from '../LoadingScreen/LoadingScreen'\nimport {\n AccessorRequirements,\n AccessRequirementWikiInstructions,\n} from '../SetBasicAccessRequirementFields'\nimport { DataUseCertificateFields } from './DataUseCertificateFields'\nimport {\n ExpirationPeriodField,\n getValidExpirationPeriodOrErrorMessage,\n} from './ExpirationPeriodField'\n\nexport type SetManagedAccessRequirementFieldsHandle = {\n /* Allow the parent component to trigger saving the AR, so this may be embedded in an arbitrary modal. */\n save: () => void\n}\n\nexport type SetManagedAccessRequirementFieldsProps = {\n accessRequirementId: string\n /* Called when AR has been saved successfully */\n onSave: () => void\n /* Called when error saving AR */\n onError: () => void\n}\n\nexport const SetManagedAccessRequirementFields = forwardRef(\n function SetManagedAccessRequirementFields(\n props: SetManagedAccessRequirementFieldsProps,\n ref: ForwardedRef<SetManagedAccessRequirementFieldsHandle>,\n ) {\n const { accessRequirementId, onSave, onError } = props\n\n const { data: accessRequirement, error: getArError } =\n useGetAccessRequirements<ManagedACTAccessRequirement>(\n accessRequirementId,\n { staleTime: Infinity },\n )\n useEffect(() => {\n if (accessRequirement) {\n setUpdatedAr(accessRequirement)\n setExpirationPeriodDays(\n (accessRequirement.expirationPeriod / DAY_IN_MS).toString(),\n )\n }\n }, [accessRequirement])\n\n const [expirationPeriodError, setExpirationPeriodError] = useState<\n string | null\n >(null)\n\n const [updatedAr, setUpdatedAr] =\n useState<ManagedACTAccessRequirement | null>(null)\n const [expirationPeriodDays, setExpirationPeriodDays] = useState<string>('')\n\n const {\n mutate: updateAccessRequirement,\n isPending: isUpdatingAccessRequirement,\n error: updateArError,\n } = useUpdateAccessRequirement<ManagedACTAccessRequirement>({\n onSuccess: () => onSave(),\n onError: () => onError(),\n })\n\n useImperativeHandle(ref, () => {\n return {\n save() {\n if (updatedAr) {\n const expirationPeriodOrErrorMessage =\n getValidExpirationPeriodOrErrorMessage(expirationPeriodDays)\n if (typeof expirationPeriodOrErrorMessage === 'string') {\n setExpirationPeriodError(expirationPeriodOrErrorMessage)\n onError()\n } else {\n updateAccessRequirement({\n ...updatedAr,\n expirationPeriod: expirationPeriodOrErrorMessage,\n })\n }\n }\n },\n }\n }, [expirationPeriodDays, updatedAr, updateAccessRequirement, onError])\n\n if (!updatedAr) {\n if (getArError) {\n return <Alert severity=\"error\">{getArError.reason}</Alert>\n } else {\n return <SynapseSpinner />\n }\n }\n\n return (\n <>\n <AccessRequirementWikiInstructions accessRequirement={updatedAr} />\n <Box>\n <Typography\n sx={{\n bgcolor: '#f5f5f5',\n borderBottom: '1px solid #ddd',\n color: '#333',\n px: 2,\n py: 1,\n }}\n >\n Data Access Request Parameters\n </Typography>\n <Box\n sx={{\n mt: 2,\n mb: 4,\n }}\n >\n <AccessorRequirements\n accessRequirement={updatedAr}\n onChange={updatedAr =>\n setUpdatedAr(updatedAr as ManagedACTAccessRequirement)\n }\n />\n <Box\n sx={{\n mb: 2,\n }}\n >\n <DataUseCertificateFields\n accessRequirement={updatedAr}\n isLoading={isUpdatingAccessRequirement}\n onChange={changes => setUpdatedAr({ ...updatedAr, ...changes })}\n />\n <FormControlLabel\n label=\"IRB approval is required.\"\n checked={updatedAr.isIRBApprovalRequired}\n control={<Checkbox />}\n onChange={(_event, checked: boolean) =>\n setUpdatedAr({\n ...updatedAr,\n isIRBApprovalRequired: checked,\n })\n }\n sx={{ ml: 0 }}\n />\n <FormControlLabel\n control={<Checkbox />}\n label=\"Other documents are required.\"\n checked={updatedAr.areOtherAttachmentsRequired}\n onChange={(_event, checked: boolean) =>\n setUpdatedAr({\n ...updatedAr,\n areOtherAttachmentsRequired: checked,\n })\n }\n />\n <ExpirationPeriodField\n days={expirationPeriodDays}\n error={expirationPeriodError}\n onChange={days => {\n setExpirationPeriodError(null)\n setExpirationPeriodDays(days)\n }}\n onBlur={() => {\n const expirationPeriodOrErrorMessage =\n getValidExpirationPeriodOrErrorMessage(expirationPeriodDays)\n if (typeof expirationPeriodOrErrorMessage === 'string') {\n setExpirationPeriodError(expirationPeriodOrErrorMessage)\n }\n }}\n />\n <Box\n sx={{\n mt: 1,\n }}\n >\n <FormControlLabel\n control={<Checkbox />}\n label=\"Intended Data Use statement is required.\"\n checked={updatedAr.isIDURequired}\n onChange={(_event, checked: boolean) => {\n if (checked) {\n setUpdatedAr({\n ...updatedAr,\n isIDURequired: true,\n })\n } else {\n setUpdatedAr({\n ...updatedAr,\n isIDURequired: false,\n isIDUPublic: false,\n })\n }\n }}\n />\n <FormControlLabel\n control={<Checkbox />}\n label=\"Intended Data Use statements will be publicly available.\"\n checked={updatedAr.isIDUPublic}\n disabled={!updatedAr.isIDURequired}\n onChange={(_event, checked: boolean) =>\n setUpdatedAr({\n ...updatedAr,\n isIDUPublic: checked,\n })\n }\n />\n </Box>\n </Box>\n </Box>\n </Box>\n {updateArError && (\n <Alert severity=\"error\" sx={{ marginTop: 2 }}>\n {updateArError.reason}\n </Alert>\n )}\n </>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;;AA4CA,IAAa,IAAoC,EAC/C,SACE,GACA,GACA;CACA,IAAM,EAAE,wBAAqB,WAAQ,eAAY,GAE3C,EAAE,MAAM,GAAmB,OAAO,MACtC,EACE,GACA,EAAE,WAAW,SAAS,CACxB;CACF,QAAgB;EACd,AAAI,MACF,EAAa,CAAiB,GAC9B,GACG,EAAkB,mBAAmB,GAAW,SAAS,CAC5D;CAEJ,GAAG,CAAC,CAAiB,CAAC;CAEtB,IAAM,CAAC,GAAuB,KAA4B,EAExD,IAAI,GAEA,CAAC,GAAW,KAChB,EAA6C,IAAI,GAC7C,CAAC,GAAsB,KAA2B,EAAiB,EAAE,GAErE,EACJ,QAAQ,GACR,WAAW,GACX,OAAO,MACL,EAAwD;EAC1D,iBAAiB,EAAO;EACxB,eAAe,EAAQ;CACzB,CAAC;CA8BD,OA5BA,EAAoB,UACX,EACL,OAAO;EACL,IAA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AAuC,CAAoB;OAC7D,AAAI,OAAO,KAAmC,YAC5C,EAAyB,CAA8B;MAE3D;KACD,CAAA;KACD,kBAAC,GAAD;MACE,IAAI,EACF,IAAI,EACN;gBAHF,CAKE,kBAAC,GAAD;OACE,SAAS,kBAAC,GAAD,CAAW,CAAA;OACpB,OAAM;OACN,SAAS,EAAU;OACnB,WAAW,GAAQ,MAAqB;QACtC,AACE,EADE,IACW;SACX,GAAG;SACH,eAAe;QACjB,IAEa;SACX,GAAG;SACH,eAAe;SACf,aAAa;QACf,CAAC;OAEL;MACD,CAAA,GACD,kBAAC,GAAD;OACE,SAAS,kBAAC,GAAD,CAAW,CAAA;OACpB,OAAM;OACN,SAAS,EAAU;OACnB,UAAU,CAAC,EAAU;OACrB,WAAW,GAAQ,MACjB,EAAa;QACX,GAAG;QACH,aAAa;OACf,CAAC;MAEJ,CAAA,CACE;;IACF;KACF;IACF,EAAA,CAAA;EACJ,KACC,kBAAC,GAAD;GAAO,UAAS;GAAQ,IAAI,EAAE,WAAW,EAAE;aACxC,EAAc;EACV,CAAA;CAET,EAAA,CAAA,IA/HE,IACK,kBAAC,GAAD;EAAO,UAAS;YAAS,EAAW;CAAc,CAAA,IAElD,kBAAC,GAAD,CAAiB,CAAA;AA8H9B,CACF"}
|
|
1
|
+
{"version":3,"file":"SetManagedAccessRequirementFields.js","names":[],"sources":["../../../src/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.tsx"],"sourcesContent":["import {\n useGetAccessRequirements,\n useUpdateAccessRequirement,\n} from '@/synapse-queries'\nimport { DAY_IN_MS } from '@/utils/SynapseConstants'\nimport {\n Alert,\n Box,\n Checkbox,\n FormControlLabel,\n Typography,\n} from '@mui/material'\nimport { RequestableAccessRequirement } from '@/utils/types/RequestableAccessRequirement'\nimport { MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE } from '@sage-bionetworks/synapse-types'\nimport {\n ForwardedRef,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react'\nimport { SynapseSpinner } from '../LoadingScreen/LoadingScreen'\nimport {\n AccessorRequirements,\n AccessRequirementWikiInstructions,\n} from '../SetBasicAccessRequirementFields'\nimport { DataUseCertificateFields } from './DataUseCertificateFields'\nimport {\n ExpirationPeriodField,\n getValidExpirationPeriodOrErrorMessage,\n} from './ExpirationPeriodField'\n\nexport type SetManagedAccessRequirementFieldsHandle = {\n /* Allow the parent component to trigger saving the AR, so this may be embedded in an arbitrary modal. */\n save: () => void\n}\n\nexport type SetManagedAccessRequirementFieldsProps = {\n accessRequirementId: string\n /* Called when AR has been saved successfully */\n onSave: () => void\n /* Called when error saving AR */\n onError: () => void\n}\n\nexport const SetManagedAccessRequirementFields = forwardRef(\n function SetManagedAccessRequirementFields(\n props: SetManagedAccessRequirementFieldsProps,\n ref: ForwardedRef<SetManagedAccessRequirementFieldsHandle>,\n ) {\n const { accessRequirementId, onSave, onError } = props\n\n const { data: accessRequirement, error: getArError } =\n useGetAccessRequirements<RequestableAccessRequirement>(\n accessRequirementId,\n {\n staleTime: Infinity,\n },\n )\n useEffect(() => {\n if (accessRequirement) {\n setUpdatedAr(accessRequirement)\n setExpirationPeriodDays(\n (accessRequirement.expirationPeriod / DAY_IN_MS).toString(),\n )\n }\n }, [accessRequirement])\n\n const [expirationPeriodError, setExpirationPeriodError] = useState<\n string | null\n >(null)\n\n const [updatedAr, setUpdatedAr] =\n useState<RequestableAccessRequirement | null>(null)\n const [expirationPeriodDays, setExpirationPeriodDays] = useState<string>('')\n\n const {\n mutate: updateAccessRequirement,\n isPending: isUpdatingAccessRequirement,\n error: updateArError,\n } = useUpdateAccessRequirement<RequestableAccessRequirement>({\n onSuccess: () => onSave(),\n onError: () => onError(),\n })\n\n useImperativeHandle(ref, () => {\n return {\n save() {\n if (updatedAr) {\n const expirationPeriodOrErrorMessage =\n getValidExpirationPeriodOrErrorMessage(expirationPeriodDays)\n if (typeof expirationPeriodOrErrorMessage === 'string') {\n setExpirationPeriodError(expirationPeriodOrErrorMessage)\n onError()\n } else {\n updateAccessRequirement({\n ...updatedAr,\n expirationPeriod: expirationPeriodOrErrorMessage,\n })\n }\n }\n },\n }\n }, [expirationPeriodDays, updatedAr, updateAccessRequirement, onError])\n\n if (!updatedAr) {\n if (getArError) {\n return <Alert severity=\"error\">{getArError.reason}</Alert>\n } else {\n return <SynapseSpinner />\n }\n }\n\n // A JsonSchemaAccessRequirement collects its remaining requirements through its form template,\n // so IRB approval, other documents, and Intended Data Use only apply to a Managed ACT AR.\n const isManagedAr =\n updatedAr.concreteType ===\n MANAGED_ACT_ACCESS_REQUIREMENT_CONCRETE_TYPE_VALUE\n\n return (\n <>\n <AccessRequirementWikiInstructions accessRequirement={updatedAr} />\n <Box>\n <Typography\n sx={{\n bgcolor: '#f5f5f5',\n borderBottom: '1px solid #ddd',\n color: '#333',\n px: 2,\n py: 1,\n }}\n >\n Data Access Request Parameters\n </Typography>\n <Box\n sx={{\n mt: 2,\n mb: 4,\n }}\n >\n <AccessorRequirements\n accessRequirement={updatedAr}\n onChange={updatedAr =>\n setUpdatedAr(updatedAr as RequestableAccessRequirement)\n }\n />\n <Box\n sx={{\n mb: 2,\n }}\n >\n <DataUseCertificateFields\n accessRequirement={updatedAr}\n isLoading={isUpdatingAccessRequirement}\n onChange={changes => setUpdatedAr({ ...updatedAr, ...changes })}\n />\n {isManagedAr && (\n <>\n <FormControlLabel\n label=\"IRB approval is required.\"\n checked={updatedAr.isIRBApprovalRequired}\n control={<Checkbox />}\n onChange={(_event, checked: boolean) =>\n setUpdatedAr({\n ...updatedAr,\n isIRBApprovalRequired: checked,\n })\n }\n sx={{ ml: 0 }}\n />\n <FormControlLabel\n control={<Checkbox />}\n label=\"Other documents are required.\"\n checked={updatedAr.areOtherAttachmentsRequired}\n onChange={(_event, checked: boolean) =>\n setUpdatedAr({\n ...updatedAr,\n areOtherAttachmentsRequired: checked,\n })\n }\n />\n </>\n )}\n <ExpirationPeriodField\n days={expirationPeriodDays}\n error={expirationPeriodError}\n onChange={days => {\n setExpirationPeriodError(null)\n setExpirationPeriodDays(days)\n }}\n onBlur={() => {\n const expirationPeriodOrErrorMessage =\n getValidExpirationPeriodOrErrorMessage(expirationPeriodDays)\n if (typeof expirationPeriodOrErrorMessage === 'string') {\n setExpirationPeriodError(expirationPeriodOrErrorMessage)\n }\n }}\n />\n {isManagedAr && (\n <Box\n sx={{\n mt: 1,\n }}\n >\n <FormControlLabel\n control={<Checkbox />}\n label=\"Intended Data Use statement is required.\"\n checked={updatedAr.isIDURequired}\n onChange={(_event, checked: boolean) => {\n if (checked) {\n setUpdatedAr({\n ...updatedAr,\n isIDURequired: true,\n })\n } else {\n setUpdatedAr({\n ...updatedAr,\n isIDURequired: false,\n isIDUPublic: false,\n })\n }\n }}\n />\n <FormControlLabel\n control={<Checkbox />}\n label=\"Intended Data Use statements will be publicly available.\"\n checked={updatedAr.isIDUPublic}\n disabled={!updatedAr.isIDURequired}\n onChange={(_event, checked: boolean) =>\n setUpdatedAr({\n ...updatedAr,\n isIDUPublic: checked,\n })\n }\n />\n </Box>\n )}\n </Box>\n </Box>\n </Box>\n {updateArError && (\n <Alert severity=\"error\" sx={{ marginTop: 2 }}>\n {updateArError.reason}\n </Alert>\n )}\n </>\n )\n },\n)\n"],"mappings":";;;;;;;;;;;;;;AA6CA,IAAa,IAAoC,EAC/C,SACE,GACA,GACA;CACA,IAAM,EAAE,wBAAqB,WAAQ,eAAY,GAE3C,EAAE,MAAM,GAAmB,OAAO,MACtC,EACE,GACA,EACE,WAAW,SACb,CACF;CACF,QAAgB;EACd,AAAI,MACF,EAAa,CAAiB,GAC9B,GACG,EAAkB,mBAAmB,GAAW,SAAS,CAC5D;CAEJ,GAAG,CAAC,CAAiB,CAAC;CAEtB,IAAM,CAAC,GAAuB,KAA4B,EAExD,IAAI,GAEA,CAAC,GAAW,KAChB,EAA8C,IAAI,GAC9C,CAAC,GAAsB,KAA2B,EAAiB,EAAE,GAErE,EACJ,QAAQ,GACR,WAAW,GACX,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AD;MACE,SAAS,kBAAC,GAAD,CAAW,CAAA;MACpB,OAAM;MACN,SAAS,EAAU;MACnB,WAAW,GAAQ,MACjB,EAAa;OACX,GAAG;OACH,6BAA6B;MAC/B,CAAC;KAEJ,CAAA,CACD,EAAA,CAAA;KAEJ,kBAAC,GAAD;MACE,MAAM;MACN,OAAO;MACP,WAAU,MAAQ;OAEhB,AADA,EAAyB,IAAI,GAC7B,EAAwB,CAAI;MAC9B;MACA,cAAc;OACZ,IAAM,IACJ,EAAuC,CAAoB;OAC7D,AAAI,OAAO,KAAmC,YAC5C,EAAyB,CAA8B;MAE3D;KACD,CAAA;KACA,KACC,kBAAC,GAAD;MACE,IAAI,EACF,IAAI,EACN;gBAHF,CAKE,kBAAC,GAAD;OACE,SAAS,kBAAC,GAAD,CAAW,CAAA;OACpB,OAAM;OACN,SAAS,EAAU;OACnB,WAAW,GAAQ,MAAqB;QACtC,AACE,EADE,IACW;SACX,GAAG;SACH,eAAe;QACjB,IAEa;SACX,GAAG;SACH,eAAe;SACf,aAAa;QACf,CAAC;OAEL;MACD,CAAA,GACD,kBAAC,GAAD;OACE,SAAS,kBAAC,GAAD,CAAW,CAAA;OACpB,OAAM;OACN,SAAS,EAAU;OACnB,UAAU,CAAC,EAAU;OACrB,WAAW,GAAQ,MACjB,EAAa;QACX,GAAG;QACH,aAAa;OACf,CAAC;MAEJ,CAAA,CACE;;IAEJ;KACF;IACF,EAAA,CAAA;EACJ,KACC,kBAAC,GAAD;GAAO,UAAS;GAAQ,IAAI,EAAE,WAAW,EAAE;aACxC,EAAc;EACV,CAAA;CAET,EAAA,CAAA;AAEN,CACF"}
|
package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InFlightEDucSignaturesTable.d.ts","sourceRoot":"","sources":["../../../../src/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InFlightEDucSignaturesTable.d.ts","sourceRoot":"","sources":["../../../../src/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.tsx"],"names":[],"mappings":"AA+IA;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,mDAsK1C"}
|
|
@@ -184,7 +184,10 @@ function I() {
|
|
|
184
184
|
color: "error",
|
|
185
185
|
loading: R,
|
|
186
186
|
onClick: () => {
|
|
187
|
-
O?.requestId && L(
|
|
187
|
+
O?.requestId && O.accessRequirementId && L({
|
|
188
|
+
requestId: O.requestId,
|
|
189
|
+
accessRequirementId: O.accessRequirementId
|
|
190
|
+
});
|
|
188
191
|
},
|
|
189
192
|
children: "Cancel Request"
|
|
190
193
|
})] })
|
package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InFlightEDucSignaturesTable.js","names":[],"sources":["../../../../src/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.tsx"],"sourcesContent":["import AccessRequirementList from '@/components/AccessRequirementList/AccessRequirementList'\nimport {\n getFirstRequestStep,\n RequestableAccessRequirement,\n} from '@/components/AccessRequirementList/RequestDataStep'\nimport { SkeletonTable } from '@/components/Skeleton'\nimport ColumnHeader from '@/components/TanStackTable/ColumnHeader'\nimport StyledTanStackTable from '@/components/TanStackTable/StyledTanStackTable'\nimport { displayToast } from '@/components/ToastMessage/ToastMessage'\nimport {\n useListAllUserDataAccessRequests,\n useVoidDataAccessRequestSignature,\n} from '@/synapse-queries'\nimport { useGetAccessRequirements } from '@/synapse-queries/dataaccess/useAccessRequirements'\nimport {\n Alert,\n Box,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Link as MuiLink,\n Stack,\n Typography,\n} from '@mui/material'\nimport {\n AccessRequestSummary,\n AccessRequestSummaryStatusEnum,\n} from '@sage-bionetworks/synapse-client'\nimport {\n createColumnHelper,\n getCoreRowModel,\n useReactTable,\n} from '@tanstack/react-table'\nimport { useEffect, useMemo, useState } from 'react'\nimport { Link as RouterLink } from 'react-router'\nimport {\n USER_ACCESS_HISTORY_REQUEST_SIGNATURE_SUBPATH,\n USER_ACCESS_HISTORY_REQUEST_SUBPATH,\n} from './RouteConstants'\n\nconst IN_FLIGHT_STATUSES: readonly AccessRequestSummaryStatusEnum[] = [\n 'sent',\n 'delivered',\n 'declined',\n 'completed',\n] as const\n\nconst STATUS_DISPLAY: Record<string, string> = {\n sent: 'Signatures pending',\n delivered: 'Signatures pending',\n declined: 'Signature declined',\n completed: 'Ready to submit',\n}\n\nconst signatureDeepLink = (requestId: string) =>\n `/${USER_ACCESS_HISTORY_REQUEST_SUBPATH}/${requestId}/${USER_ACCESS_HISTORY_REQUEST_SIGNATURE_SUBPATH}`\n\nconst columnHelper = createColumnHelper<AccessRequestSummary>()\n\ntype ActionCallbacks = {\n onModify: (summary: AccessRequestSummary) => void\n onCancel: (summary: AccessRequestSummary) => void\n modifyLoadingArId: string | undefined\n}\n\nfunction buildColumns(actions: ActionCallbacks) {\n return [\n columnHelper.accessor('accessRequirementName', {\n header: props => <ColumnHeader {...props} title={'Request type'} />,\n enableSorting: false,\n enableColumnFilter: false,\n }),\n columnHelper.display({\n id: 'signatureProgress',\n header: props => <ColumnHeader {...props} title={'Signature progress'} />,\n enableSorting: false,\n cell: ctx => {\n const acquired = ctx.row.original.signaturesAcquired ?? 0\n const requested = ctx.row.original.signaturesRequested ?? 0\n return `${acquired} of ${requested}`\n },\n enableColumnFilter: false,\n size: 150,\n }),\n columnHelper.accessor('status', {\n header: props => <ColumnHeader {...props} title={'Current status'} />,\n enableSorting: false,\n cell: ctx => {\n const status = ctx.getValue()\n return status ? (STATUS_DISPLAY[status] ?? status) : ''\n },\n enableColumnFilter: false,\n size: 150,\n }),\n columnHelper.display({\n id: 'actions',\n header: props => <ColumnHeader {...props} title={'Actions'} />,\n enableSorting: false,\n enableColumnFilter: false,\n cell: ctx => {\n const summary = ctx.row.original\n const requestId = summary.requestId\n if (!requestId) return null\n const isModifyLoading =\n actions.modifyLoadingArId !== undefined &&\n actions.modifyLoadingArId === summary.accessRequirementId\n return (\n <Stack\n direction={'column'}\n sx={{ alignItems: 'flex-start', gap: 0.5 }}\n >\n <MuiLink component={RouterLink} to={signatureDeepLink(requestId)}>\n Review Signatures and Submit\n </MuiLink>\n <MuiLink\n component={'button'}\n type={'button'}\n onClick={() => actions.onModify(summary)}\n disabled={\n !summary.accessRequirementId ||\n actions.modifyLoadingArId !== undefined\n }\n sx={{ textAlign: 'left' }}\n >\n {isModifyLoading ? 'Loading…' : 'Modify Request'}\n </MuiLink>\n <MuiLink\n component={'button'}\n type={'button'}\n onClick={() => actions.onCancel(summary)}\n sx={{ textAlign: 'left' }}\n >\n Cancel Request\n </MuiLink>\n </Stack>\n )\n },\n size: 220,\n }),\n ]\n}\n\n/**\n * Lists the requester's active eDUC signatures (routed / signed but not yet submitted).\n *\n * The underlying query walks every page of `POST /dataAccessRequest/list` inside its `queryFn`,\n * pushing the `isEDuc: true` filter to the server so the walk skips non-eDUC requests. Status is\n * still filtered client-side because the list endpoint has no server-side status filter.\n *\n * Renders nothing when the fully-loaded, filtered list is empty.\n */\nexport function InFlightEDucSignaturesTable() {\n const {\n data: summaries,\n isLoading,\n error,\n } = useListAllUserDataAccessRequests({ isEDuc: true })\n\n const [modifyingArId, setModifyingArId] = useState<string | undefined>()\n const [cancellingSummary, setCancellingSummary] = useState<\n AccessRequestSummary | undefined\n >()\n\n const {\n data: modifyAccessRequirement,\n isFetching: isFetchingModifyAr,\n error: modifyArError,\n } = useGetAccessRequirements<RequestableAccessRequirement>(\n modifyingArId ?? '',\n {\n enabled: Boolean(modifyingArId),\n staleTime: Infinity,\n },\n )\n\n // Bail out of the Modify flow if the AR fetch fails so the user isn't stuck on a disabled button.\n useEffect(() => {\n if (modifyArError && modifyingArId) {\n displayToast(\n `Sorry, we couldn't load your request. ${modifyArError.reason ?? ''}`.trim(),\n 'danger',\n )\n setModifyingArId(undefined)\n }\n }, [modifyArError, modifyingArId])\n\n const { mutate: voidSignature, isPending: isVoiding } =\n useVoidDataAccessRequestSignature({\n onSuccess: () => {\n displayToast('Your access request has been cancelled.', 'success')\n setCancellingSummary(undefined)\n },\n onError: e => {\n displayToast(\n `Sorry, we couldn't cancel your request. ${e.reason ?? ''}`.trim(),\n 'danger',\n )\n },\n })\n\n const modifyLoadingArId = isFetchingModifyAr ? modifyingArId : undefined\n\n const columns = useMemo(\n () =>\n buildColumns({\n onModify: summary => {\n if (summary.accessRequirementId) {\n setModifyingArId(summary.accessRequirementId)\n }\n },\n onCancel: summary => setCancellingSummary(summary),\n modifyLoadingArId,\n }),\n [modifyLoadingArId],\n )\n\n const rows = useMemo(\n () =>\n (summaries ?? []).filter(\n summary =>\n summary.status !== undefined &&\n (IN_FLIGHT_STATUSES as readonly string[]).includes(summary.status),\n ),\n [summaries],\n )\n\n const table = useReactTable({\n data: rows,\n columns,\n getCoreRowModel: getCoreRowModel(),\n columnResizeMode: 'onChange',\n })\n\n if (error) {\n return (\n <Alert severity={'error'}>\n <strong>\n Sorry, we couldn't load your in-flight eDUC signatures.\n </strong>\n <br />\n {error.reason}\n </Alert>\n )\n }\n\n if (isLoading) {\n return <SkeletonTable numCols={columns.length} fullWidthCells />\n }\n\n if (rows.length === 0) {\n return null\n }\n\n return (\n <Box>\n <Stack sx={{ gap: 2 }}>\n <Typography variant=\"headline1\" gutterBottom>\n In-flight eDUC signatures\n </Typography>\n <StyledTanStackTable table={table} fullWidth={true} />\n </Stack>\n {modifyAccessRequirement && (\n <AccessRequirementList\n renderAsModal\n onHide={() => setModifyingArId(undefined)}\n initialWizardEntry={{\n step: getFirstRequestStep(modifyAccessRequirement),\n accessRequirement: modifyAccessRequirement,\n }}\n />\n )}\n <Dialog\n open={Boolean(cancellingSummary)}\n onClose={() => setCancellingSummary(undefined)}\n >\n <DialogTitle>Cancel request?</DialogTitle>\n <DialogContent>\n <DialogContentText>\n Cancelling this request will void the electronic signature envelope\n for{' '}\n <strong>\n {cancellingSummary?.accessRequirementName ?? 'this request'}\n </strong>\n . Any signatures already collected will be discarded. You can start\n a new request at any time. This action cannot be undone.\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button\n variant={'outlined'}\n onClick={() => setCancellingSummary(undefined)}\n disabled={isVoiding}\n >\n Keep Request\n </Button>\n <Button\n variant={'contained'}\n color={'error'}\n loading={isVoiding}\n onClick={() => {\n if (cancellingSummary?.requestId) {\n voidSignature(cancellingSummary.requestId)\n }\n }}\n >\n Cancel Request\n </Button>\n </DialogActions>\n </Dialog>\n </Box>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA2CA,IAAM,IAAgE;CACpE;CACA;CACA;CACA;AACF,GAEM,IAAyC;CAC7C,MAAM;CACN,WAAW;CACX,UAAU;CACV,WAAW;AACb,GAEM,KAAqB,MACzB,IAAI,EAAoC,GAAG,EAAU,GAAG,KAEpD,IAAe,EAAyC;AAQ9D,SAAS,EAAa,GAA0B;CAC9C,OAAO;EACL,EAAa,SAAS,yBAAyB;GAC7C,SAAQ,MAAS,kBAAC,GAAD;IAAc,GAAI;IAAO,OAAO;GAAiB,CAAA;GAClE,eAAe;GACf,oBAAoB;EACtB,CAAC;EACD,EAAa,QAAQ;GACnB,IAAI;GACJ,SAAQ,MAAS,kBAAC,GAAD;IAAc,GAAI;IAAO,OAAO;GAAuB,CAAA;GACxE,eAAe;GACf,OAAM,MAGG,GAFU,EAAI,IAAI,SAAS,sBAAsB,EAErC,MADD,EAAI,IAAI,SAAS,uBAAuB;GAG5D,oBAAoB;GACpB,MAAM;EACR,CAAC;EACD,EAAa,SAAS,UAAU;GAC9B,SAAQ,MAAS,kBAAC,GAAD;IAAc,GAAI;IAAO,OAAO;GAAmB,CAAA;GACpE,eAAe;GACf,OAAM,MAAO;IACX,IAAM,IAAS,EAAI,SAAS;IAC5B,OAAO,IAAU,EAAe,MAAW,IAAU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AA;EAEH,kBAAC,GAAD;GACE,MAAM,EAAQ;GACd,eAAe,EAAqB,KAAA,CAAS;aAF/C;IAIE,kBAAC,GAAD,EAAA,UAAa,kBAA4B,CAAA;IACzC,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UAAA;KAAmB;KAEb;KACJ,kBAAC,UAAD,EAAA,UACG,GAAmB,yBAAyB,eACvC,CAAA;KAAC;IAGQ,EAAA,CAAA,EACN,CAAA;IACf,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;KACE,SAAS;KACT,eAAe,EAAqB,KAAA,CAAS;KAC7C,UAAU;eACX;IAEO,CAAA,GACR,kBAAC,GAAD;KACE,SAAS;KACT,OAAO;KACP,SAAS;KACT,eAAe;MACb,AAAI,GAAmB,aACrB,EAAc,EAAkB,SAAS;KAE7C;eACD;IAEO,CAAA,CACK,EAAA,CAAA;GACT;;CACL,EAAA,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"InFlightEDucSignaturesTable.js","names":[],"sources":["../../../../src/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.tsx"],"sourcesContent":["import AccessRequirementList from '@/components/AccessRequirementList/AccessRequirementList'\nimport { getFirstRequestStep } from '@/components/AccessRequirementList/RequestDataStep'\nimport { RequestableAccessRequirement } from '@/utils/types/RequestableAccessRequirement'\nimport { SkeletonTable } from '@/components/Skeleton'\nimport ColumnHeader from '@/components/TanStackTable/ColumnHeader'\nimport StyledTanStackTable from '@/components/TanStackTable/StyledTanStackTable'\nimport { displayToast } from '@/components/ToastMessage/ToastMessage'\nimport {\n useListAllUserDataAccessRequests,\n useVoidDataAccessRequestSignature,\n} from '@/synapse-queries'\nimport { useGetAccessRequirements } from '@/synapse-queries/dataaccess/useAccessRequirements'\nimport {\n Alert,\n Box,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Link as MuiLink,\n Stack,\n Typography,\n} from '@mui/material'\nimport {\n AccessRequestSummary,\n AccessRequestSummaryStatusEnum,\n} from '@sage-bionetworks/synapse-client'\nimport {\n createColumnHelper,\n getCoreRowModel,\n useReactTable,\n} from '@tanstack/react-table'\nimport { useEffect, useMemo, useState } from 'react'\nimport { Link as RouterLink } from 'react-router'\nimport {\n USER_ACCESS_HISTORY_REQUEST_SIGNATURE_SUBPATH,\n USER_ACCESS_HISTORY_REQUEST_SUBPATH,\n} from './RouteConstants'\n\nconst IN_FLIGHT_STATUSES: readonly AccessRequestSummaryStatusEnum[] = [\n 'sent',\n 'delivered',\n 'declined',\n 'completed',\n] as const\n\nconst STATUS_DISPLAY: Record<string, string> = {\n sent: 'Signatures pending',\n delivered: 'Signatures pending',\n declined: 'Signature declined',\n completed: 'Ready to submit',\n}\n\nconst signatureDeepLink = (requestId: string) =>\n `/${USER_ACCESS_HISTORY_REQUEST_SUBPATH}/${requestId}/${USER_ACCESS_HISTORY_REQUEST_SIGNATURE_SUBPATH}`\n\nconst columnHelper = createColumnHelper<AccessRequestSummary>()\n\ntype ActionCallbacks = {\n onModify: (summary: AccessRequestSummary) => void\n onCancel: (summary: AccessRequestSummary) => void\n modifyLoadingArId: string | undefined\n}\n\nfunction buildColumns(actions: ActionCallbacks) {\n return [\n columnHelper.accessor('accessRequirementName', {\n header: props => <ColumnHeader {...props} title={'Request type'} />,\n enableSorting: false,\n enableColumnFilter: false,\n }),\n columnHelper.display({\n id: 'signatureProgress',\n header: props => <ColumnHeader {...props} title={'Signature progress'} />,\n enableSorting: false,\n cell: ctx => {\n const acquired = ctx.row.original.signaturesAcquired ?? 0\n const requested = ctx.row.original.signaturesRequested ?? 0\n return `${acquired} of ${requested}`\n },\n enableColumnFilter: false,\n size: 150,\n }),\n columnHelper.accessor('status', {\n header: props => <ColumnHeader {...props} title={'Current status'} />,\n enableSorting: false,\n cell: ctx => {\n const status = ctx.getValue()\n return status ? (STATUS_DISPLAY[status] ?? status) : ''\n },\n enableColumnFilter: false,\n size: 150,\n }),\n columnHelper.display({\n id: 'actions',\n header: props => <ColumnHeader {...props} title={'Actions'} />,\n enableSorting: false,\n enableColumnFilter: false,\n cell: ctx => {\n const summary = ctx.row.original\n const requestId = summary.requestId\n if (!requestId) return null\n const isModifyLoading =\n actions.modifyLoadingArId !== undefined &&\n actions.modifyLoadingArId === summary.accessRequirementId\n return (\n <Stack\n direction={'column'}\n sx={{ alignItems: 'flex-start', gap: 0.5 }}\n >\n <MuiLink component={RouterLink} to={signatureDeepLink(requestId)}>\n Review Signatures and Submit\n </MuiLink>\n <MuiLink\n component={'button'}\n type={'button'}\n onClick={() => actions.onModify(summary)}\n disabled={\n !summary.accessRequirementId ||\n actions.modifyLoadingArId !== undefined\n }\n sx={{ textAlign: 'left' }}\n >\n {isModifyLoading ? 'Loading…' : 'Modify Request'}\n </MuiLink>\n <MuiLink\n component={'button'}\n type={'button'}\n onClick={() => actions.onCancel(summary)}\n sx={{ textAlign: 'left' }}\n >\n Cancel Request\n </MuiLink>\n </Stack>\n )\n },\n size: 220,\n }),\n ]\n}\n\n/**\n * Lists the requester's active eDUC signatures (routed / signed but not yet submitted).\n *\n * The underlying query walks every page of `POST /dataAccessRequest/list` inside its `queryFn`,\n * pushing the `isEDuc: true` filter to the server so the walk skips non-eDUC requests. Status is\n * still filtered client-side because the list endpoint has no server-side status filter.\n *\n * Renders nothing when the fully-loaded, filtered list is empty.\n */\nexport function InFlightEDucSignaturesTable() {\n const {\n data: summaries,\n isLoading,\n error,\n } = useListAllUserDataAccessRequests({ isEDuc: true })\n\n const [modifyingArId, setModifyingArId] = useState<string | undefined>()\n const [cancellingSummary, setCancellingSummary] = useState<\n AccessRequestSummary | undefined\n >()\n\n const {\n data: modifyAccessRequirement,\n isFetching: isFetchingModifyAr,\n error: modifyArError,\n } = useGetAccessRequirements<RequestableAccessRequirement>(\n modifyingArId ?? '',\n {\n enabled: Boolean(modifyingArId),\n staleTime: Infinity,\n },\n )\n\n // Bail out of the Modify flow if the AR fetch fails so the user isn't stuck on a disabled button.\n useEffect(() => {\n if (modifyArError && modifyingArId) {\n displayToast(\n `Sorry, we couldn't load your request. ${modifyArError.reason ?? ''}`.trim(),\n 'danger',\n )\n setModifyingArId(undefined)\n }\n }, [modifyArError, modifyingArId])\n\n const { mutate: voidSignature, isPending: isVoiding } =\n useVoidDataAccessRequestSignature({\n onSuccess: () => {\n displayToast('Your access request has been cancelled.', 'success')\n setCancellingSummary(undefined)\n },\n onError: e => {\n displayToast(\n `Sorry, we couldn't cancel your request. ${e.reason ?? ''}`.trim(),\n 'danger',\n )\n },\n })\n\n const modifyLoadingArId = isFetchingModifyAr ? modifyingArId : undefined\n\n const columns = useMemo(\n () =>\n buildColumns({\n onModify: summary => {\n if (summary.accessRequirementId) {\n setModifyingArId(summary.accessRequirementId)\n }\n },\n onCancel: summary => setCancellingSummary(summary),\n modifyLoadingArId,\n }),\n [modifyLoadingArId],\n )\n\n const rows = useMemo(\n () =>\n (summaries ?? []).filter(\n summary =>\n summary.status !== undefined &&\n (IN_FLIGHT_STATUSES as readonly string[]).includes(summary.status),\n ),\n [summaries],\n )\n\n const table = useReactTable({\n data: rows,\n columns,\n getCoreRowModel: getCoreRowModel(),\n columnResizeMode: 'onChange',\n })\n\n if (error) {\n return (\n <Alert severity={'error'}>\n <strong>\n Sorry, we couldn't load your in-flight eDUC signatures.\n </strong>\n <br />\n {error.reason}\n </Alert>\n )\n }\n\n if (isLoading) {\n return <SkeletonTable numCols={columns.length} fullWidthCells />\n }\n\n if (rows.length === 0) {\n return null\n }\n\n return (\n <Box>\n <Stack sx={{ gap: 2 }}>\n <Typography variant=\"headline1\" gutterBottom>\n In-flight eDUC signatures\n </Typography>\n <StyledTanStackTable table={table} fullWidth={true} />\n </Stack>\n {modifyAccessRequirement && (\n <AccessRequirementList\n renderAsModal\n onHide={() => setModifyingArId(undefined)}\n initialWizardEntry={{\n step: getFirstRequestStep(modifyAccessRequirement),\n accessRequirement: modifyAccessRequirement,\n }}\n />\n )}\n <Dialog\n open={Boolean(cancellingSummary)}\n onClose={() => setCancellingSummary(undefined)}\n >\n <DialogTitle>Cancel request?</DialogTitle>\n <DialogContent>\n <DialogContentText>\n Cancelling this request will void the electronic signature envelope\n for{' '}\n <strong>\n {cancellingSummary?.accessRequirementName ?? 'this request'}\n </strong>\n . Any signatures already collected will be discarded. You can start\n a new request at any time. This action cannot be undone.\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button\n variant={'outlined'}\n onClick={() => setCancellingSummary(undefined)}\n disabled={isVoiding}\n >\n Keep Request\n </Button>\n <Button\n variant={'contained'}\n color={'error'}\n loading={isVoiding}\n onClick={() => {\n if (\n cancellingSummary?.requestId &&\n cancellingSummary.accessRequirementId\n ) {\n voidSignature({\n requestId: cancellingSummary.requestId,\n accessRequirementId: cancellingSummary.accessRequirementId,\n })\n }\n }}\n >\n Cancel Request\n </Button>\n </DialogActions>\n </Dialog>\n </Box>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,IAAM,IAAgE;CACpE;CACA;CACA;CACA;AACF,GAEM,IAAyC;CAC7C,MAAM;CACN,WAAW;CACX,UAAU;CACV,WAAW;AACb,GAEM,KAAqB,MACzB,IAAI,EAAoC,GAAG,EAAU,GAAG,KAEpD,IAAe,EAAyC;AAQ9D,SAAS,EAAa,GAA0B;CAC9C,OAAO;EACL,EAAa,SAAS,yBAAyB;GAC7C,SAAQ,MAAS,kBAAC,GAAD;IAAc,GAAI;IAAO,OAAO;GAAiB,CAAA;GAClE,eAAe;GACf,oBAAoB;EACtB,CAAC;EACD,EAAa,QAAQ;GACnB,IAAI;GACJ,SAAQ,MAAS,kBAAC,GAAD;IAAc,GAAI;IAAO,OAAO;GAAuB,CAAA;GACxE,eAAe;GACf,OAAM,MAGG,GAFU,EAAI,IAAI,SAAS,sBAAsB,EAErC,MADD,EAAI,IAAI,SAAS,uBAAuB;GAG5D,oBAAoB;GACpB,MAAM;EACR,CAAC;EACD,EAAa,SAAS,UAAU;GAC9B,SAAQ,MAAS,kBAAC,GAAD;IAAc,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C,kBAAC,GAAD;GACE,eAAA;GACA,cAAc,EAAiB,KAAA,CAAS;GACxC,oBAAoB;IAClB,MAAM,EAAoB,CAAuB;IACjD,mBAAmB;GACrB;EACD,CAAA;EAEH,kBAAC,GAAD;GACE,MAAM,EAAQ;GACd,eAAe,EAAqB,KAAA,CAAS;aAF/C;IAIE,kBAAC,GAAD,EAAA,UAAa,kBAA4B,CAAA;IACzC,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UAAA;KAAmB;KAEb;KACJ,kBAAC,UAAD,EAAA,UACG,GAAmB,yBAAyB,eACvC,CAAA;KAAC;IAGQ,EAAA,CAAA,EACN,CAAA;IACf,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;KACE,SAAS;KACT,eAAe,EAAqB,KAAA,CAAS;KAC7C,UAAU;eACX;IAEO,CAAA,GACR,kBAAC,GAAD;KACE,SAAS;KACT,OAAO;KACP,SAAS;KACT,eAAe;MACb,AACE,GAAmB,aACnB,EAAkB,uBAElB,EAAc;OACZ,WAAW,EAAkB;OAC7B,qBAAqB,EAAkB;MACzC,CAAC;KAEL;eACD;IAEO,CAAA,CACK,EAAA,CAAA;GACT;;CACL,EAAA,CAAA;AAET"}
|
|
@@ -5,6 +5,11 @@ export declare const mockJsonSchemaAR1: JsonSchemaAccessRequirement;
|
|
|
5
5
|
/** AR 2: Clinical Trial Data Access — references the Clinical Trial FormTemplate. Requires an uploaded DUC. */
|
|
6
6
|
export declare const mockJsonSchemaAR2: JsonSchemaAccessRequirement;
|
|
7
7
|
export declare const mockJsonSchemaAccessRequirements: JsonSchemaAccessRequirement[];
|
|
8
|
+
/**
|
|
9
|
+
* {@link mockJsonSchemaAR2} with the subjects, access type, and whole-day expiration period that the
|
|
10
|
+
* access requirement editor needs to load an existing AR.
|
|
11
|
+
*/
|
|
12
|
+
export declare const mockEditableJsonSchemaAR: JsonSchemaAccessRequirement;
|
|
8
13
|
/**
|
|
9
14
|
* A wiki for {@link mockJsonSchemaAR1}. It is intentionally not registered with the shared access requirement wiki
|
|
10
15
|
* mocks, so that the AR is wiki-less by default.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockJsonSchemaAccessRequirements.d.ts","sourceRoot":"","sources":["../../../src/mocks/accessRequirement/mockJsonSchemaAccessRequirements.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,
|
|
1
|
+
{"version":3,"file":"mockJsonSchemaAccessRequirements.d.ts","sourceRoot":"","sources":["../../../src/mocks/accessRequirement/mockJsonSchemaAccessRequirements.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAI5B,MAAM,kCAAkC,CAAA;AAIzC,OAAO,EAEL,QAAQ,EACR,WAAW,EACZ,MAAM,iCAAiC,CAAA;AAKxC,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,EAAE,2BAiB/B,CAAA;AAED,+GAA+G;AAC/G,eAAO,MAAM,iBAAiB,EAAE,2BAkB/B,CAAA;AAED,eAAO,MAAM,gCAAgC,EAAE,2BAA2B,EAGzE,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,2BAWtC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,QAWvC,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,WAI1C,CAAA"}
|