Skip to content

Commit

Permalink
fix(website, backend): Show submissionId on edit page but do not allo…
Browse files Browse the repository at this point in the history
…w submissionId to be editable (#2334)

- Pass submissionId to website from backend
- Remove submissionId from original, editable metadata list by adding a `noEdit` field in the config. 
- Add submissionId as a non-editable field
---------

Co-authored-by: Theo Sanderson <theo@theo.io>
Co-authored-by: Loculus bot <bot@loculus.org>
  • Loading branch information
3 people committed Jul 27, 2024
1 parent 2b7e592 commit 568a34c
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 22 deletions.
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

0 comments on commit 568a34c

Please sign in to comment.