Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Change
Dispute → Details
links toTransaction → Details
#7087Change
Dispute → Details
links toTransaction → Details
#7087Changes from 39 commits
194c9c8
869a449
06b1983
ad5194f
000ac7e
2208df6
37ca6ba
d1b54b3
a245b13
9ae6fe4
7a619d1
011164e
41439cf
2dec45c
c6f10f2
266fe7d
7cc4546
868ab80
6c40af9
90834a7
c85be9b
0d37793
28e14a5
d68f779
030262e
571188f
171fe63
f5bd338
520a379
0b3e851
bebbecd
7efd2ab
2e47bb8
46c8c74
9d7c3d9
ea33d51
cab1be8
27ff3bc
c73ed05
8a17ad2
0a958e5
ba300f7
ee8df38
524d291
c7aaf93
dcae68f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I guess the follow up question is… is it a bad idea to switch all these to
getAdminUrl
now as part of fixing this?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.
Interestingly, I made the choice to change one of these links from
getAdminUrl
→getDetailsURL
since I assumed it was the preferred option for detail screen URLs.I'm not sure if that's a bad idea.
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.
It all depends on what
parentSegment
means, and what value it adds.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.
What do you prefer and why?
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.
To complicate things,
getAdminUrl
is a wrapper foraddQueryArgs
– should this be used instead of the wrapper function?woocommerce-payments/client/utils/index.js
Line 25 in 2e47bb8
I think we leave this PR very specific to the scope of the PR and change links only.
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.
Yeah I agree, probably making extra work to switch over from
DetailsLink
/getDetailsURL
.Here's my take…
getAdminUrl
is a useful, easy to understand API for constructing a url anywhere in Woo admin. We should use it whereever it makes sense.getWooPaymentsAdminUrl
.getDetailsURL
is not an improvement overgetAdminUrl
- makes the code less readable.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.
Bonus points for
getAdminUrl
– if you understand how it works (what the params mean), that knowledge transfers toaddQueryArgs
(and vice versa). Not so forDetailsLink
andgetDetailsURL
.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.
For this PR, I'd prefer if the changes were specific to the goal. 😆
From a code-quality perspective, I'd like to understand if having the
getDetailsUrl
with typed parameters helps us in some way before removing it.Thinking about a developer using
getDetailsUrl
, it might be a helpful abstraction. They won't have to remember if it istransaction/details
,/transactions/details
,/payments/transactions/details
,%2Ftransactions%2Fdetails
etc. The function remembers all of this and TS yells at me if I use the wrong parent (transaction
instead oftransactions
).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.
Fair point - a typed wrapper of
getAdminUrl
orgetWooPaymentsAdminUrl
could add value, though this is orthogonal to my concern thatgetDetailURL( … parentSegment )
is an unintuitve, weird API.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.
I'd find it much easier to read an API like
getWooPaymentsUrl( collection: 'transactions' )
getWooPaymentsUrl( collection: 'transactions', item: transactionId )
Or more transparently
getWooPaymentsUrl( 'transactions' )
getWooPaymentsUrl( 'transactions/details/${ transactionId }' )
If you were designing this API, what would it look like?
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.
I notice one of the URL from the dispute order note has
/
in the query string parameter value. Forward slash should be encoded to%2F
.Screen.Recording.2023-10-06.at.01.48.22.mov
To confirm
encodeURIComponent('/')
in Javascript would return%2F
.I was surprised add_query_arg() does not encode the parameter value but then I read that it expects the parameter value is already encoded.
or
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.
I've tried this and it ends up with a malformed URL with
0.00000
inserted in place of/
/%2F
./wp-admin/admin.php?page=wc-admin&path=0.000000payments0.000000transactions0.000000details&id=ch_3Ny06gC15a3WbJ1t14zIF3QB
This URL is being processed by through
WC_Payments_Utils::esc_interpolated_html()
, so I'll see if there's another way to urlencode.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.
Ow wow. Not sure what's going on there. I only tried it on WP Console.
Let's do it in a separate PR.
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.
I've opened an issue for this: #7399.