Skip to content

Commit

Permalink
Improve display of readOnly metadata (#5002)
Browse files Browse the repository at this point in the history
* improve readOnly metadata

* changesets

* simplify code

* simplify code

---------

Co-authored-by: Paweł Chyła <[email protected]>
  • Loading branch information
Cloud11PL and poulch committed Jul 8, 2024
1 parent 116b4df commit c999eb3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-dancers-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Read-only metadata keys and values will now be displayed as regular inputs, making them easier to read and preventing them from looking disabled.
58 changes: 26 additions & 32 deletions src/components/Metadata/MetadataCardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,20 @@ export const MetadataCardTable = ({
{data.map((field, fieldIndex) => (
<TableRowLink data-test-id="field" key={fieldIndex}>
<TableCell width="50%" style={{ paddingLeft: vars.spacing[6] }}>
{readonly ? (
<Text variant="caption" size="large" color="default2">
{field.key}
</Text>
) : (
<Input
data-test-id="metadata-key-input"
width="100%"
size="small"
aria-label={`${nameInputPrefix}${nameSeparator}${fieldIndex}`}
name={`${nameInputPrefix}${nameSeparator}${fieldIndex}`}
onChange={onChange}
value={field.key}
/>
)}
<Input
data-test-id="metadata-key-input"
width="100%"
size="small"
aria-label={`${nameInputPrefix}${nameSeparator}${fieldIndex}`}
name={`${nameInputPrefix}${nameSeparator}${fieldIndex}`}
onChange={onChange}
value={field.key}
readOnly={readonly}
color="default1"
style={{
fontWeight: "bold",
}}
/>
</TableCell>
<TableCell
width="50%"
Expand All @@ -100,23 +99,18 @@ export const MetadataCardTable = ({
paddingBottom: vars.spacing[2],
}}
>
{readonly ? (
<Text variant="caption" size="large" color="default2">
{field.value}
</Text>
) : (
<Textarea
data-test-id="metadata-value-input"
disabled={readonly}
width="100%"
rows={1}
size="small"
aria-label={`${valueInputPrefix}${nameSeparator}${fieldIndex}`}
name={`${valueInputPrefix}${nameSeparator}${fieldIndex}`}
onChange={onChange}
value={field.value}
/>
)}
<Textarea
data-test-id="metadata-value-input"
readOnly={readonly}
width="100%"
rows={1}
size="small"
aria-label={`${valueInputPrefix}${nameSeparator}${fieldIndex}`}
name={`${valueInputPrefix}${nameSeparator}${fieldIndex}`}
onChange={onChange}
value={field.value}
color="default1"
/>
</TableCell>
{!readonly && (
<TableCell style={{ paddingRight: vars.spacing[6] }}>
Expand Down

0 comments on commit c999eb3

Please sign in to comment.