Skip to content

CRDCDH-1094 Create new Data Submission changes. New intention and added dataType #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const baseSubmission: Omit<
conciergeEmail: "",
createdAt: "",
updatedAt: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
};

const baseContext: ContextState = {
Expand Down
3 changes: 2 additions & 1 deletion src/components/DataSubmissions/DataUpload.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const baseSubmission: Omit<Submission, "_id"> = {
history: [],
conciergeName: "",
conciergeEmail: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
createdAt: "",
updatedAt: "",
crossSubmissionStatus: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const baseSubmission: Submission = {
conciergeEmail: "",
createdAt: "",
updatedAt: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
status: "In Progress",
crossSubmissionStatus: "Passed",
otherSubmissions: "",
Expand Down
3 changes: 2 additions & 1 deletion src/components/DataSubmissions/DeleteOrphanFileChip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const baseSubmission: Submission = {
conciergeEmail: "",
createdAt: "",
updatedAt: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
status: "In Progress",
crossSubmissionStatus: "Passed",
otherSubmissions: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ describe("ExportValidationButton cases", () => {
conciergeEmail: "",
createdAt: "",
updatedAt: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
};

const baseQCResult: Omit<QCResult, "submissionID"> = {
Expand Down
3 changes: 2 additions & 1 deletion src/components/DataSubmissions/MetadataUpload.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const baseSubmission: Omit<
conciergeEmail: "",
createdAt: "",
updatedAt: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
status: "New",
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/DataSubmissions/ValidationControls.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const baseSubmission: Omit<
conciergeEmail: "",
createdAt: "",
updatedAt: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
};

const baseContext: ContextState = {
Expand Down
3 changes: 2 additions & 1 deletion src/components/DataSubmissions/ValidationStatistics.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const baseSubmission: Omit<Submission, "_id"> = {
history: [],
conciergeName: "",
conciergeEmail: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
createdAt: "",
updatedAt: "",
crossSubmissionStatus: "New",
Expand Down
115 changes: 85 additions & 30 deletions src/content/dataSubmissions/CreateDataSubmissionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const StyledOutlinedInputMultiline = styled(StyledOutlinedInput)({

type CreateSubmissionParams = Pick<
Submission,
"studyAbbreviation" | "dataCommons" | "name" | "dbGaPID" | "intention"
"studyAbbreviation" | "dataCommons" | "name" | "dbGaPID" | "intention" | "dataType"
>;

type Props = {
Expand All @@ -216,13 +216,15 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
register,
reset,
control,
watch,
formState: { errors },
setValue,
} = useForm<CreateSubmissionParams>({
defaultValues: {
dataCommons: "CDS",
studyAbbreviation: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
dbGaPID: "",
name: "",
},
Expand All @@ -239,6 +241,7 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
name: string;
dbGaPID: string;
intention: SubmissionIntention;
dataType: SubmissionDataType;
}
>(CREATE_SUBMISSION, {
context: { clientName: "backend" },
Expand All @@ -264,13 +267,35 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
});
return result;
}, [approvedStudiesData]);
const intention = watch("intention");

const submissionTypeOptions = [
{ label: "New", value: "New", disabled: false },
{ label: "Update", value: "Update", disabled: false },
{ label: "New/Update", value: "New/Update", disabled: false },
{ label: "Delete", value: "Delete", disabled: false },
];

const submissionDataTypeOptions: {
label: string;
value: SubmissionDataType;
disabled: boolean;
}[] = [
{
label: "Metadata and Data Files",
value: "Metadata and Data Files",
disabled: intention === "Delete",
},
{ label: "Metadata Only", value: "Metadata Only", disabled: false },
];

useEffect(() => {
if (intention === "New/Update") {
setValue("dataType", "Metadata and Data Files");
}
if (intention === "Delete") {
setValue("dataType", "Metadata Only");
}
}, [intention]);

/**
* Updates the default form values after save or initial fetch
*
Expand All @@ -284,6 +309,7 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
"dbGaPID",
"intention",
"studyAbbreviation",
"dataType",
]
) => {
const resetData = {};
Expand All @@ -299,7 +325,8 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
setFormValues({
dataCommons: "CDS",
studyAbbreviation: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
dbGaPID: "",
name: "",
});
Expand All @@ -315,6 +342,7 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
name,
dbGaPID,
intention,
dataType,
}: CreateSubmissionParams) => {
await createDataSubmission({
variables: {
Expand All @@ -323,6 +351,7 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
name,
dbGaPID,
intention,
dataType,
},
})
.then(() => {
Expand All @@ -335,6 +364,7 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
name,
dbGaPID,
intention,
dataType,
});
}
})
Expand Down Expand Up @@ -390,6 +420,56 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
onSubmit={handleSubmit(onSubmit)}
>
<Stack direction="column">
<StyledField>
<Controller
name="intention"
control={control}
rules={{ required: "This field is required" }}
render={({ field }) => (
<Grid container>
<StyledRadioInput
{...field}
id="create-data-submission-dialog-submission-type"
label="Submission Type"
value={field.value || ""}
options={submissionTypeOptions}
gridWidth={12}
required
row
aria-describedby="submission-intention-helper-text"
/>
</Grid>
)}
/>
<StyledHelperText id="submission-intention-helper-text">
{errors?.intention?.message}
</StyledHelperText>
</StyledField>
<StyledField>
<Controller
name="dataType"
control={control}
rules={{ required: "This field is required" }}
render={({ field }) => (
<Grid container>
<StyledRadioInput
{...field}
id="create-data-submission-dialog-data-type"
label="Data Type"
value={field.value || ""}
options={submissionDataTypeOptions}
gridWidth={12}
required
row
aria-describedby="submission-data-type-helper-text"
/>
</Grid>
)}
/>
<StyledHelperText id="submission-data-type-helper-text">
{errors?.intention?.message}
</StyledHelperText>
</StyledField>
<StyledOrganizationField>
<StyledLabel id="organization">Organization</StyledLabel>
<StyledOutlinedInput value={user.organization?.orgName} readOnly />
Expand Down Expand Up @@ -486,31 +566,6 @@ const CreateDataSubmissionDialog: FC<Props> = ({ organizations, onCreate }) => {
{errors?.name?.message}
</StyledHelperText>
</StyledField>
<StyledField>
<Controller
name="intention"
control={control}
rules={{ required: "This field is required" }}
render={({ field }) => (
<Grid container>
<StyledRadioInput
{...field}
id="create-data-submission-dialog-submission-type"
label="Submission Type"
value={field.value || ""}
options={submissionTypeOptions}
gridWidth={12}
required
row
aria-describedby="submission-intention-helper-text"
/>
</Grid>
)}
/>
<StyledHelperText id="submission-intention-helper-text">
{errors?.intention?.message}
</StyledHelperText>
</StyledField>
</Stack>
</form>
</StyledFormWrapper>
Expand Down
2 changes: 2 additions & 0 deletions src/graphql/createSubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ export const mutation = gql`
$name: String!
$dbGaPID: String
$intention: String!
$dataType: String!
) {
createSubmission(
studyAbbreviation: $studyAbbreviation
dataCommons: $dataCommons
name: $name
dbGaPID: $dbGaPID
intention: $intention
dataType: $dataType
) {
_id
status
Expand Down
1 change: 1 addition & 0 deletions src/graphql/getSubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const query = gql`
conciergeName
conciergeEmail
intention
dataType
otherSubmissions
createdAt
updatedAt
Expand Down
5 changes: 4 additions & 1 deletion src/types/Submissions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Submission = {
conciergeName: string; // Concierge name
conciergeEmail: string; // Concierge email
intention: SubmissionIntention;
dataType: SubmissionDataType;
/**
* A JSON string containing information for related submissions. Mapped by SubmissionStatus, related by studyAbbreviation.
*
Expand Down Expand Up @@ -74,7 +75,9 @@ type SubmissionAction =
| "Cancel"
| "Archive";

type SubmissionIntention = "New" | "Update" | "Delete";
type SubmissionIntention = "New/Update" | "Delete";

type SubmissionDataType = "Metadata Only" | "Metadata and Data Files";

type FileInput = {
fileName: string;
Expand Down
7 changes: 4 additions & 3 deletions src/utils/dataSubmissionUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const baseSubmission: Submission = {
history: [],
conciergeName: "",
conciergeEmail: "",
intention: "New",
intention: "New/Update",
dataType: "Metadata and Data Files",
createdAt: "",
updatedAt: "",
};
Expand Down Expand Up @@ -139,12 +140,12 @@ describe("General Submit", () => {
expect(result.isAdminOverride).toBe(false);
});

it("should disable submit when file validation is null and intention is 'Update'", () => {
it("should disable submit when file validation is null and intention is 'New/Update'", () => {
const submission: Submission = {
...baseSubmission,
metadataValidationStatus: "Passed",
fileValidationStatus: null,
intention: "Update",
intention: "New/Update",
};
const result: SubmitInfo = utils.shouldDisableSubmit(submission, "Submitter");
expect(result.disable).toBe(true);
Expand Down
Loading