Skip to content
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

Do not allow submissionId to be editable #2334

Merged
merged 8 commits into from
Jul 27, 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 @@ -113,6 +113,7 @@ data class SequenceEntryVersionToEdit(
"Issues where data is not necessarily wrong, but the user might want to look into those warnings.",
)
val warnings: List<PreprocessingAnnotation>? = null,
val submissionId: String,
) : AccessionVersionInterface

typealias SegmentName = String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ class SubmissionDatabaseService(
SequenceEntriesView.errorsColumn,
SequenceEntriesView.warningsColumn,
SequenceEntriesView.isRevocationColumn,
SequenceEntriesView.submissionIdColumn,
)
.where { SequenceEntriesView.accessionVersionEquals(accessionVersion) }
.first()
Expand All @@ -901,6 +902,7 @@ class SubmissionDatabaseService(
),
errors = selectedSequenceEntry[SequenceEntriesView.errorsColumn],
warnings = selectedSequenceEntry[SequenceEntriesView.warningsColumn],
submissionId = selectedSequenceEntry[SequenceEntriesView.submissionIdColumn],
)
}

Expand Down
2 changes: 1 addition & 1 deletion kubernetes/loculus/templates/_inputFieldsFromValues.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{- $data := . }}
{{- $metadata := $data.metadata }}
{{- $extraFields := $data.extraInputFields }}
{{- $TO_KEEP := list "name" "displayName" "definition" "guidance" "example" "required" }}
{{- $TO_KEEP := list "name" "displayName" "definition" "guidance" "example" "required" "noEdit"}}


{{- $fieldsDict := dict }}
Expand Down
1 change: 1 addition & 0 deletions kubernetes/loculus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ defaultOrganismConfig: &defaultOrganismConfig
guidance: Used to match the sequence(s) to the metadata
example: GJP123
position: first
noEdit: true
preprocessing:
- &preprocessing
version: 1
Expand Down
58 changes: 37 additions & 21 deletions website/src/components/Edit/EditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ type EditPageProps = {

const logger = getClientLogger('EditPage');

type SubmissionProps = {
submissionId: string;
};

const SubmissionIdRow: FC<SubmissionProps> = ({ submissionId }) => (
<tr>
<td className='w-1/4'>Submission ID:</td>
<td className='pr-3 text-right '></td>
<td className='w-full'>{submissionId}</td>
</tr>
);

const InnerEditPage: FC<EditPageProps> = ({
organism,
dataToEdit,
Expand Down Expand Up @@ -102,10 +114,10 @@ const InnerEditPage: FC<EditPageProps> = ({
onConfirmation={submitEditedDataForAccessionVersion}
/>
</dialog>

<table className='customTable'>
<tbody className='w-full'>
<Subtitle title='Original Data' bold />
<SubmissionIdRow submissionId={dataToEdit.submissionId} />
<EditableOriginalData
editedMetadata={editedMetadata.filter(({ key }) => key !== ACCESSION_FIELD)}
setEditedMetadata={setEditedMetadata}
Expand Down Expand Up @@ -238,26 +250,30 @@ const EditableOriginalData: FC<EditableOriginalDataProps> = ({ editedMetadata, s
};
}

return (
<EditableDataRow
label={inputField.displayName ?? sentenceCase(inputField.name)}
key={'raw_metadata' + inputField.name}
row={field}
onChange={(editedRow: Row) =>
setEditedMetadata((prevRows: Row[]) => {
const relevantOldRow = prevRows.find((oldRow) => oldRow.key === editedRow.key);

if (relevantOldRow !== undefined) {
return prevRows.map((prevRow) =>
prevRow.key === editedRow.key ? { ...prevRow, value: editedRow.value } : prevRow,
);
} else {
return [...prevRows, editedRow];
}
})
}
/>
);
if (!(inputField.noEdit !== undefined && inputField.noEdit === true)) {
return (
<EditableDataRow
label={inputField.displayName ?? sentenceCase(inputField.name)}
key={'raw_metadata' + inputField.name}
row={field}
onChange={(editedRow: Row) =>
setEditedMetadata((prevRows: Row[]) => {
const relevantOldRow = prevRows.find((oldRow) => oldRow.key === editedRow.key);

if (relevantOldRow !== undefined) {
return prevRows.map((prevRow) =>
prevRow.key === editedRow.key
? { ...prevRow, value: editedRow.value }
: prevRow,
);
} else {
return [...prevRows, editedRow];
}
})
}
/>
);
}
})}
</>
);
Expand Down
1 change: 1 addition & 0 deletions website/src/types/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export const sequenceEntryToEdit = accessionVersion.merge(
z.object({
status: statusThatAllowsEditing,
groupId: z.number(),
submissionId: z.string(),
errors: z.array(processingAnnotation).nullable(),
warnings: z.array(processingAnnotation).nullable(),
originalData: z.object({
Expand Down
1 change: 1 addition & 0 deletions website/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const metadata = z.object({
export const inputField = z.object({
name: z.string(),
displayName: z.string().optional(),
noEdit: z.boolean().optional(),
});

export type InputField = z.infer<typeof inputField>;
Expand Down
1 change: 1 addition & 0 deletions website/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const defaultReviewData: SequenceEntryToEdit = {
processedInsertionGeneName: ['aminoAcidInsertion1', 'aminoAcidInsertion2'],
},
},
submissionId: 'defaultSubmitter',
};

export const testOrganism = 'testOrganism';
Expand Down
Loading