Skip to content
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

Open
wants to merge 14 commits into
base: fix-order-line-metadata
Choose a base branch
from

Conversation

witoszekdev
Copy link
Member

@witoszekdev witoszekdev commented Feb 24, 2025

PR scope

New UI

Improve OrderLine metadata dialog to have information about the order line (SKU, image, quantity, variant name)

CleanShot 2025-02-24 at 17 59 58@2x

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

CleanShot 2025-02-25 at 13 48 53

After

CleanShot 2025-02-25 at 13 36 07

Fetching

Metadata is now fetched on modal open (always refetches latest metadata, due to API constraints it's metadata for all order lines)

@witoszekdev witoszekdev requested a review from a team as a code owner February 24, 2025 17:00
Copy link

changeset-bot bot commented Feb 24, 2025

⚠️ No Changeset found

Latest commit: 945da81

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@witoszekdev witoszekdev changed the base branch from main to fix-order-line-metadata February 24, 2025 17:00
@witoszekdev witoszekdev marked this pull request as draft February 24, 2025 17:01
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 79.68750% with 13 lines in your changes missing coverage. Please review.

Project coverage is 62.38%. Comparing base (5ca48d7) to head (945da81).

Files with missing lines Patch % Lines
src/components/Metadata/Metadata.tsx 64.00% 7 Missing and 2 partials ⚠️
src/components/Modal/Content.tsx 0.00% 2 Missing ⚠️
...onents/OrderMetadataDialog/OrderMetadataDialog.tsx 92.85% 1 Missing ⚠️
...nents/OrderMetadataDialog/VariantSubheaderData.tsx 93.75% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@witoszekdev witoszekdev force-pushed the order-line-metadata-ui-improvements branch from fa88512 to 7cae4db Compare February 26, 2025 16:55
@witoszekdev witoszekdev force-pushed the order-line-metadata-ui-improvements branch from 83ce814 to 945da81 Compare February 26, 2025 17:01
Copy link

Differences Found

✅ No packages or licenses were added.

Summary

Expand
License Name Package Count Packages
0BSD 1
Packages
  • tslib
BlueOak-1.0.0 1
Packages
  • path-scurry
CC0-1.0 1
Packages
  • type-fest
MIT/X11 1
Packages
  • nub
MPL-1.1 1
Packages
  • harmony-reflect
MPL-2.0 1
Packages
  • dompurify
Public Domain 1
Packages
  • jsonify
Python-2.0 1
Packages
  • argparse
WTFPL 1
Packages
  • opener
CC-BY-4.0 2
Packages
  • @saleor/macaw-ui
  • caniuse-lite
<<missing>> 3
Packages
  • busboy
  • saleor-dashboard
  • streamsearch
BSD-2-Clause 24
Packages
  • @typescript-eslint/parser
  • @typescript-eslint/typescript-estree
  • browser-process-hrtime
  • css-select
  • css-what
  • domelementtype
  • domhandler
  • domutils
  • dotenv
  • dotenv-expand
  • entities
  • escodegen
  • eslint-scope
  • espree
  • esprima
  • esrecurse
  • estraverse
  • esutils
  • nth-check
  • stringify-object
  • And 4 more...
BSD-3-Clause 45
Packages
  • @humanwhocodes/object-schema
  • @sentry/cli
  • @sentry/cli-darwin
  • @sentry/cli-linux-arm
  • @sentry/cli-linux-arm64
  • @sentry/cli-linux-i686
  • @sentry/cli-linux-x64
  • @sentry/cli-win32-i686
  • @sentry/cli-win32-x64
  • @sinonjs/commons
  • @sinonjs/fake-timers
  • abab
  • asn1js
  • babel-plugin-istanbul
  • charenc
  • chroma-js
  • crypt
  • diff
  • esquery
  • exenv
  • And 25 more...
Apache-2.0 46
Packages
  • @ampproject/remapping
  • @editorjs/editorjs
  • @humanwhocodes/config-array
  • @humanwhocodes/module-importer
  • @opentelemetry/api
  • @opentelemetry/semantic-conventions
  • @playwright/test
  • @swc/core
  • @swc/core-darwin-arm64
  • @swc/core-darwin-x64
  • @swc/core-linux-arm-gnueabihf
  • @swc/core-linux-arm64-gnu
  • @swc/core-linux-arm64-musl
  • @swc/core-linux-x64-gnu
  • @swc/core-linux-x64-musl
  • @swc/core-win32-arm64-msvc
  • @swc/core-win32-ia32-msvc
  • @swc/core-win32-x64-msvc
  • @swc/counter
  • aria-query
  • And 26 more...
ISC 50
Packages
  • @esbuild-plugins/node-globals-polyfill
  • @istanbuljs/load-nyc-config
  • @saleor/app-sdk
  • anymatch
  • boolbase
  • browser-stdout
  • cli-width
  • cliui
  • electron-to-chromium
  • fastq
  • flatted
  • fs.realpath
  • get-caller-file
  • get-own-enumerable-property-symbols
  • glob
  • glob-parent
  • graceful-fs
  • inflight
  • inherits
  • ini
  • And 30 more...
MIT 1124
Packages
  • @adobe/css-tools
  • @apollo/client
  • @ardatan/relay-compiler
  • @ardatan/sync-fetch
  • @babel/code-frame
  • @babel/compat-data
  • @babel/core
  • @babel/generator
  • @babel/helper-annotate-as-pure
  • @babel/helper-compilation-targets
  • @babel/helper-create-class-features-plugin
  • @babel/helper-member-expression-to-functions
  • @babel/helper-module-imports
  • @babel/helper-module-transforms
  • @babel/helper-optimise-call-expression
  • @babel/helper-plugin-utils
  • @babel/helper-replace-supers
  • @babel/helper-simple-access
  • @babel/helper-skip-transparent-expression-wrappers
  • @babel/helper-string-parser
  • And 1104 more...

const { action, field, fieldIndex, value } = parseEventData(event);
const key = getDataKey(isPrivate);
const dataToUpdate = data[key];
export const MetadataNoMemo: React.FC<MetadataProps> = ({
Copy link
Member

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?

Comment on lines +59 to +77
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),
Copy link
Member

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]

Comment on lines +82 to +96
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)}
/>
Copy link
Member

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

Suggested change
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) && (
Copy link
Member

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 }) => {
Copy link
Member

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants