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

Change Dispute → Details links to Transaction → Details #7087

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
194c9c8
Migrate DetailsLink component to TS to improve code quality
Jinksi Aug 29, 2023
869a449
Add changelog entry
Jinksi Aug 29, 2023
06b1983
Add JSDoc annotations for improved devex
Jinksi Aug 29, 2023
ad5194f
Change URL for order notes created on dispute webhook
Jinksi Aug 29, 2023
000ac7e
Update DisputesList rows to link to transaction details
Jinksi Aug 29, 2023
2208df6
Update disputes order notice link to transaction details
Jinksi Aug 29, 2023
37ca6ba
Update the Payments Overview dispute URL to transaction details
Jinksi Aug 29, 2023
d1b54b3
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
Jinksi Sep 15, 2023
a245b13
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
Jinksi Sep 25, 2023
9ae6fe4
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
Jinksi Oct 4, 2023
7a619d1
Update WC home dispute task link to transaction details
Jinksi Oct 4, 2023
011164e
Remove "disputes" from getAdminUrl parentSegment
Jinksi Oct 4, 2023
41439cf
Update PHP tests for marking disputed orders
Jinksi Oct 4, 2023
2dec45c
Fix PHPCS error
Jinksi Oct 4, 2023
c6f10f2
Add changelog entry
Jinksi Oct 4, 2023
266fe7d
Remove transaction dispute details feature flag to enable feature by …
Jinksi Oct 4, 2023
7cc4546
Remove redundant payment details summary test
Jinksi Oct 4, 2023
868ab80
Group dispute-related payment details summary tests
Jinksi Oct 4, 2023
6c40af9
Update snapshot for dispute-reversal test
Jinksi Oct 4, 2023
90834a7
Merge branch 'add/7289-remove-transaction-dispute-details-feature-fla…
Jinksi Oct 4, 2023
c85be9b
Remove unused import
Jinksi Oct 4, 2023
0d37793
Merge branch 'add/7289-remove-transaction-dispute-details-feature-fla…
Jinksi Oct 4, 2023
28e14a5
Fix PHPCS errors
Jinksi Oct 4, 2023
d68f779
Merge branch 'add/7289-remove-transaction-dispute-details-feature-fla…
Jinksi Oct 4, 2023
030262e
Merge branch 'develop' into add/7289-remove-transaction-dispute-detai…
Jinksi Oct 4, 2023
571188f
Merge branch 'add/7289-remove-transaction-dispute-details-feature-fla…
Jinksi Oct 4, 2023
171fe63
Add changelog entry
Jinksi Oct 4, 2023
f5bd338
Merge branch 'add/7289-remove-transaction-dispute-details-feature-fla…
haszari Oct 4, 2023
520a379
Merge branch 'develop' into add/7289-remove-transaction-dispute-detai…
Jinksi Oct 4, 2023
0b3e851
Merge branch 'add/7289-remove-transaction-dispute-details-feature-fla…
haszari Oct 4, 2023
bebbecd
Merge branch 'develop' into add/7289-remove-transaction-dispute-detai…
Jinksi Oct 5, 2023
7efd2ab
Merge branch 'add/7289-remove-transaction-dispute-details-feature-fla…
Jinksi Oct 5, 2023
2e47bb8
Revert changes to DetailsLink component
Jinksi Oct 5, 2023
46c8c74
Revert change of getAdminUrl → getDetailsUrl to simplify PR scope
Jinksi Oct 5, 2023
9d7c3d9
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
Jinksi Oct 5, 2023
ea33d51
Fix PHPCS errors
Jinksi Oct 5, 2023
cab1be8
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
shendy-a8c Oct 5, 2023
27ff3bc
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
shendy-a8c Oct 5, 2023
c73ed05
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
shendy-a8c Oct 5, 2023
8a17ad2
Improve wording of changelog entry
Jinksi Oct 5, 2023
0a958e5
CHange disputed order notice link to transaction details screen
Jinksi Oct 5, 2023
ba300f7
Prefer single quote rather than backtick
Jinksi Oct 5, 2023
ee8df38
Improve `$charge_id` description in docblock
Jinksi Oct 5, 2023
524d291
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
Jinksi Oct 6, 2023
c7aaf93
Merge branch 'develop' into fix/6929-change-dispute-details-links-to-…
Jinksi Oct 6, 2023
dcae68f
Remove unused `$event_type` variables
Jinksi Oct 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Update links that pointed to the dispute details screen to point to the transaction details screen
17 changes: 13 additions & 4 deletions client/disputes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,17 @@ export const DisputesList = (): JSX.Element => {
const rows = disputes.map( ( dispute ) => {
const clickable = ( children: React.ReactNode ): JSX.Element => (
<ClickableCell
href={ getDetailsURL( dispute.dispute_id, 'disputes' ) }
href={ getDetailsURL( dispute.charge_id, 'transactions' ) }
>
{ children }
</ClickableCell>
);

const detailsLink = (
<DetailsLink id={ dispute.dispute_id } parentSegment="disputes" />
<DetailsLink
id={ dispute.charge_id }
parentSegment="transactions"
/>
Jinksi marked this conversation as resolved.
Show resolved Hide resolved
);

const reasonMapping = reasons[ dispute.reason ];
Expand Down Expand Up @@ -303,7 +306,10 @@ export const DisputesList = (): JSX.Element => {
display: (
<Button
variant={ needsResponse ? 'secondary' : 'tertiary' }
href={ getDetailsURL( dispute.dispute_id, 'disputes' ) }
href={ getDetailsURL(
dispute.charge_id,
'transactions'
) }
onClick={ (
e: React.MouseEvent< HTMLAnchorElement >
) => {
Expand All @@ -314,7 +320,10 @@ export const DisputesList = (): JSX.Element => {
);
const history = getHistory();
history.push(
getDetailsURL( dispute.dispute_id, 'disputes' )
getDetailsURL(
dispute.charge_id,
'transactions'
)
Copy link
Contributor

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?

Copy link
Member Author

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 getAdminUrlgetDetailsURL since I assumed it was the preferred option for detail screen URLs.

I'm not sure if that's a bad idea.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed it was the preferred option for detail screen URLs.

What do you prefer and why?

Copy link
Member Author

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 for addQueryArgs – should this be used instead of the wrapper function?

export const getAdminUrl = ( args ) => addQueryArgs( 'admin.php', args );

I think we leave this PR very specific to the scope of the PR and change links only.

Copy link
Contributor

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.

To complicate things, getAdminUrl is a wrapper for addQueryArgs – should this be used instead of the wrapper function?

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.
  • If we have specific boilerplate we end up doing a lot, it might make sense to have our own API, e.g. getWooPaymentsAdminUrl.
    • getDetailsURL is not an improvement over getAdminUrl - makes the code less readable.

Copy link
Contributor

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 to addQueryArgs (and vice versa). Not so for DetailsLink and getDetailsURL.

Copy link
Member Author

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?

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 is transaction/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 of transactions).

Copy link
Contributor

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 or getWooPaymentsAdminUrl could add value, though this is orthogonal to my concern that getDetailURL( … parentSegment ) is an unintuitve, weird API.

Copy link
Contributor

@haszari haszari Oct 5, 2023

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?

);
} }
>
Expand Down
46 changes: 23 additions & 23 deletions client/disputes/test/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ exports[`Disputes list renders correctly 1`] = `
>
<a
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_asdfghjkl"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
>
<svg
class="gridicon gridicons-info-outline needs-offset"
Expand All @@ -361,7 +361,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_asdfghjkl"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
$10.00
Expand All @@ -373,7 +373,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_asdfghjkl"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
<span
Expand All @@ -389,7 +389,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_asdfghjkl"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
Transaction unauthorized
Expand All @@ -401,7 +401,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_asdfghjkl"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
<span
Expand Down Expand Up @@ -435,7 +435,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_asdfghjkl"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
<span
Expand Down Expand Up @@ -463,7 +463,7 @@ exports[`Disputes list renders correctly 1`] = `
>
<a
class="components-button is-secondary"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_asdfghjkl"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
>
Respond
</a>
Expand All @@ -476,7 +476,7 @@ exports[`Disputes list renders correctly 1`] = `
>
<a
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_zxcvbnm"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
>
<svg
class="gridicon gridicons-info-outline needs-offset"
Expand All @@ -499,7 +499,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_zxcvbnm"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
$10.50
Expand All @@ -511,7 +511,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_zxcvbnm"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
<span
Expand All @@ -527,7 +527,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_zxcvbnm"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
General
Expand All @@ -539,7 +539,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_zxcvbnm"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
<span
Expand All @@ -560,7 +560,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_zxcvbnm"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
/>
</td>
Expand All @@ -570,7 +570,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_zxcvbnm"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
/>
</td>
Expand All @@ -579,7 +579,7 @@ exports[`Disputes list renders correctly 1`] = `
>
<a
class="components-button is-tertiary"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_zxcvbnm"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
>
See details
</a>
Expand All @@ -592,7 +592,7 @@ exports[`Disputes list renders correctly 1`] = `
>
<a
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_rstyuoi"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
>
<svg
class="gridicon gridicons-info-outline needs-offset"
Expand All @@ -615,7 +615,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_rstyuoi"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
$20.00
Expand All @@ -627,7 +627,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_rstyuoi"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
<span
Expand All @@ -643,7 +643,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_rstyuoi"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
General
Expand All @@ -655,7 +655,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_rstyuoi"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
<span
Expand All @@ -679,7 +679,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_rstyuoi"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
Mock customer
Expand All @@ -691,7 +691,7 @@ exports[`Disputes list renders correctly 1`] = `
<a
class="woocommerce-table__clickable-cell"
data-link-type="wc-admin"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_rstyuoi"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
tabindex="-1"
>
<span
Expand Down Expand Up @@ -719,7 +719,7 @@ exports[`Disputes list renders correctly 1`] = `
>
<a
class="components-button is-secondary"
href="admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=dp_rstyuoi"
href="admin.php?page=wc-admin&path=%2Fpayments%2Ftransactions%2Fdetails&id=ch_mock"
>
Respond
</a>
Expand Down
9 changes: 6 additions & 3 deletions client/order/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ const DisputeNotice = ( { chargeId } ) => {
// Disable the refund button.
refundButton.disabled = true;

const disputeDetailsLink = getDetailsURL( dispute.id, 'disputes' );
const disputeDetailsLink = getDetailsURL(
chargeId,
'transactions'
);

let tooltipText = '';

Expand Down Expand Up @@ -315,8 +318,8 @@ const DisputeNotice = ( { chargeId } ) => {
}
);
window.location = getDetailsURL(
dispute.id,
'disputes'
chargeId,
'transactions'
);
},
},
Expand Down
8 changes: 4 additions & 4 deletions client/overview/task-list/tasks/dispute-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ export const getDisputeResolutionTask = (
} );
const history = getHistory();
if ( activeDisputeCount === 1 ) {
// Redirect to the dispute details page if there is only one dispute.
const disputeId = activeDisputes[ 0 ].dispute_id;
// Redirect to the transaction details page if there is only one dispute.
const chargeId = activeDisputes[ 0 ].charge_id;
history.push(
getAdminUrl( {
page: 'wc-admin',
path: '/payments/disputes/details',
id: disputeId,
path: '/payments/transactions/details',
id: chargeId,
} )
);
} else {
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/tasks/class-wc-payments-task-disputes.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ public function get_action_url() {
add_query_arg(
[
'page' => 'wc-admin',
'path' => '%2Fpayments%2Fdisputes%2Fdetails',
'id' => $dispute['dispute_id'],
'path' => '%2Fpayments%2Ftransactions%2Fdetails',
'id' => $dispute['charge_id'],
],
'admin.php'
)
Expand Down
Loading
Loading