Skip to content

Commit

Permalink
Show SubmitterId on edit page but do not allow it to be edited.
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-parker committed Jul 26, 2024
1 parent 42245d4 commit b4629a8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 22 deletions.
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
61 changes: 40 additions & 21 deletions website/src/components/Edit/EditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ type EditPageProps = {

const logger = getClientLogger('EditPage');

type SubmissionProps = {
submissionId: string;
};

const SubmissionIdRow: FC<SubmissionProps> = ({ submissionId }) => (
<Fragment>

Check failure on line 37 in website/src/components/Edit/EditPage.tsx

View workflow job for this annotation

GitHub Actions / Check format and types

Fragments should contain more than one child - otherwise, there’s no need for a Fragment at all

Check failure on line 37 in website/src/components/Edit/EditPage.tsx

View workflow job for this annotation

GitHub Actions / Check format and types

Prefer fragment shorthand over React.Fragment
<tr>
<td className='w-1/4'>Submission ID:</td>
<td className='pr-3 text-right '></td>
<td className='w-full'>{submissionId}</td>
</tr>
</Fragment>
);

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

<table className='customTable'>
<tbody className='w-full'>
<Subtitle title='Original Data' bold />
<Subtitle title='Non-Editable Metadata' />
<SubmissionIdRow submissionId={dataToEdit.submissionId} />
<EditableOriginalData
editedMetadata={editedMetadata.filter(({ key }) => key !== ACCESSION_FIELD)}
setEditedMetadata={setEditedMetadata}
Expand Down Expand Up @@ -238,26 +253,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

0 comments on commit b4629a8

Please sign in to comment.