-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
OrderLine metadata UI improvements #5432
base: fix-order-line-metadata
Are you sure you want to change the base?
OrderLine metadata UI improvements #5432
Conversation
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix-order-line-metadata #5432 +/- ##
===========================================================
+ Coverage 62.31% 62.38% +0.06%
===========================================================
Files 1275 1277 +2
Lines 22107 22140 +33
Branches 4394 4401 +7
===========================================================
+ Hits 13775 13811 +36
+ Misses 8293 8290 -3
Partials 39 39 ☔ View full report in Codecov by Sentry. |
fa88512
to
7cae4db
Compare
83ce814
to
945da81
Compare
Differences Found✅ No packages or licenses were added. SummaryExpand
|
const { action, field, fieldIndex, value } = parseEventData(event); | ||
const key = getDataKey(isPrivate); | ||
const dataToUpdate = data[key]; | ||
export const MetadataNoMemo: React.FC<MetadataProps> = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is it any sens to have exported two component memenoize and not?
action === EventDataAction.update | ||
? updateAtIndex( | ||
{ | ||
...dataToUpdate[fieldIndex], | ||
key: field === EventDataField.name ? value : dataToUpdate[fieldIndex].key, | ||
value: field === EventDataField.value ? value : dataToUpdate[fieldIndex].value, | ||
}, | ||
dataToUpdate, | ||
fieldIndex, | ||
) | ||
: action === EventDataAction.add | ||
? [ | ||
...dataToUpdate, | ||
{ | ||
...dataToUpdate[fieldIndex], | ||
key: field === EventDataField.name ? value : dataToUpdate[fieldIndex].key, | ||
value: field === EventDataField.value ? value : dataToUpdate[fieldIndex].value, | ||
key: "", | ||
value: "", | ||
}, | ||
dataToUpdate, | ||
fieldIndex, | ||
) | ||
: action === EventDataAction.add | ||
? [ | ||
...dataToUpdate, | ||
{ | ||
key: "", | ||
value: "", | ||
}, | ||
] | ||
: removeAtIndex(dataToUpdate, fieldIndex), | ||
}, | ||
}); | ||
}; | ||
] | ||
: removeAtIndex(dataToUpdate, fieldIndex), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: I'd extract this to external function and create at least map action name to handler and then use it like that fun getActionType(type) => map[actionType]
return ( | ||
<Box display="grid" gap={2} paddingBottom={10} {...props}> | ||
{isLoading ? ( | ||
<> | ||
<MetadataLoadingCard /> | ||
{!hidePrivateMetadata && <MetadataLoadingCard isPrivate />} | ||
</> | ||
) : ( | ||
<> | ||
<MetadataCard | ||
data={data?.metadata} | ||
isPrivate={false} | ||
readonly={readonly} | ||
onChange={event => change(event, false)} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: avoid tenary expression inside render
return ( | |
<Box display="grid" gap={2} paddingBottom={10} {...props}> | |
{isLoading ? ( | |
<> | |
<MetadataLoadingCard /> | |
{!hidePrivateMetadata && <MetadataLoadingCard isPrivate />} | |
</> | |
) : ( | |
<> | |
<MetadataCard | |
data={data?.metadata} | |
isPrivate={false} | |
readonly={readonly} | |
onChange={event => change(event, false)} | |
/> | |
if (isLoading) { | |
<Box display="grid" gap={2} paddingBottom={10} {...props}> | |
<MetadataLoadingCard /> | |
{!hidePrivateMetadata && <MetadataLoadingCard isPrivate />} | |
</Box> | |
} | |
return ( | |
<Box display="grid" gap={2} paddingBottom={10} {...props}> | |
... | |
</Box> | |
) |
readonly={readonly} | ||
onChange={event => change(event, false)} | ||
/> | ||
{(data?.privateMetadata || !hidePrivateMetadata) && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: IMO this condition is wrong, shouldn't always show privite metadata even when empty !hidePrivateMetadata
?
import React from "react"; | ||
import { useIntl } from "react-intl"; | ||
|
||
const ListValue = ({ children, last }: { children: React.ReactNode; last?: boolean }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: please use direct import from react import {ReactNode} from "react"
PR scope
New UI
Improve OrderLine metadata dialog to have information about the order line (SKU, image, quantity, variant name)
Modal fixes
Fixes issues with OrderLine metadata dialog not preventing clicks made outside of dialog, when cursor was hovering DataGrid interactive elements (e.g.
View metadata
button):Before
After
Fetching
Metadata is now fetched on modal open (always refetches latest metadata, due to API constraints it's metadata for all order lines)