Skip to content

Commit

Permalink
fix(website): separate key and label on edit page (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
bh-ethz authored Mar 21, 2024
1 parent c508bc8 commit f3ad919
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions website/src/components/Edit/DataRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import WarningAmberIcon from '~icons/ic/baseline-warning-amber';
import DangerousTwoToneIcon from '~icons/ic/twotone-dangerous';

type EditableRowProps = {
label?: string;
row: Row;
onChange: (editedRow: Row) => void;
};

export const EditableDataRow: FC<EditableRowProps> = ({ row, onChange }) => {
export const EditableDataRow: FC<EditableRowProps> = ({ label, row, onChange }) => {
const colorClassName = row.errors.length > 0 ? 'text-red-600' : row.warnings.length > 0 ? 'text-yellow-600' : '';

return (
<tr>
<td className={`w-1/4 ${colorClassName}`}>{row.key}:</td>
<td className={`w-1/4 ${colorClassName}`}>{label ?? row.key}:</td>
<td className='pr-3 text-right '>
<ErrorAndWarningIcons row={row} />
</td>
Expand Down Expand Up @@ -49,12 +50,13 @@ const ErrorAndWarningIcons: FC<ErrorAndWarningIconsProps> = ({ row }) => {
};

type ProcessedDataRowProps = {
label?: string;
row: KeyValuePair;
};

export const ProcessedDataRow: FC<ProcessedDataRowProps> = ({ row }) => (
export const ProcessedDataRow: FC<ProcessedDataRowProps> = ({ label, row }) => (
<tr>
<td className={`w-1/4 `}>{row.key}:</td>
<td className={`w-1/4 `}>{label ?? row.key}:</td>
<td />
<td className='w-full'>
<div className='px-3'>{row.value}</div>
Expand Down
3 changes: 2 additions & 1 deletion website/src/components/Edit/EditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ const EditableOriginalData: FC<EditableOriginalDataProps> = ({ editedMetadata, s
<>
<Subtitle title='Metadata' />
{editedMetadata.map((field) => {
field.key = sentenceCase(field.key);
return (
<EditableDataRow
label={sentenceCase(field.key)}
key={'raw_metadata' + field.key}
row={field}
onChange={(editedRow: Row) =>
Expand Down Expand Up @@ -250,6 +250,7 @@ const ProcessedMetadata: FC<ProcessedMetadataProps> = ({ processedMetadata }) =>
<Subtitle title='Metadata' customKey='preprocessing_metadata' />
{Object.entries(processedMetadata).map(([key, value]) => (
<ProcessedDataRow
label={sentenceCase(key)}
key={'processed' + key}
row={{ key: sentenceCase(key), value: displayMetadataField(value) }}
/>
Expand Down

0 comments on commit f3ad919

Please sign in to comment.