-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add dismissable Notice to message the rename of Deposits to Payout #9680
Changes from 7 commits
edf839c
7ad20ac
cd85572
c2868a3
f8f32c3
76e9556
391b931
c79624c
278f60d
45b4c4e
ba2ffea
420321a
d09cff8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: add | ||
Comment: Added notice to indicate the rename of Deposits to Payouts. User facing changelog will be added as part of feature branch | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import React, { useState, useEffect } from 'react'; | ||
import { TourKit } from '@woocommerce/components'; | ||
import { useDispatch } from '@wordpress/data'; | ||
import { createInterpolateElement } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useDeposits } from 'wcpay/data'; | ||
import './style.scss'; | ||
|
||
export const PayoutsRenameNotice = () => { | ||
const isPayoutsRenameNoticeDismissed = | ||
wcpaySettings.isPayoutsRenameNoticeDismissed; | ||
const { updateOptions } = useDispatch( 'wc/admin/options' ); | ||
const [ showTour, setShowTour ] = useState( false ); | ||
|
||
const onClose = () => { | ||
updateOptions( { | ||
wcpay_payouts_rename_notice_dismissed: true, | ||
} ); | ||
setShowTour( false ); | ||
wcpaySettings.isPayoutsRenameNoticeDismissed = true; | ||
}; | ||
|
||
useEffect( () => { | ||
if ( ! isPayoutsRenameNoticeDismissed ) { | ||
setShowTour( true ); | ||
} | ||
}, [ isPayoutsRenameNoticeDismissed ] ); | ||
Comment on lines
+29
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this does not have any effect because the value of What do you think @Jinksi ? |
||
|
||
if ( ! showTour ) return null; | ||
|
||
return ( | ||
<TourKit | ||
config={ { | ||
placement: 'bottom', | ||
options: { | ||
effects: { | ||
overlay: false, | ||
autoScroll: { | ||
behavior: 'smooth', | ||
}, | ||
}, | ||
classNames: | ||
'wc-admin-payments-overview-payouts-rename-tour', | ||
}, | ||
steps: [ | ||
{ | ||
referenceElements: { | ||
desktop: | ||
'#toplevel_page_wc-admin-path--payments-overview ul.wp-submenu li a[href*="payouts"]', | ||
}, | ||
meta: { | ||
name: 'deposits-now-payouts', | ||
heading: __( | ||
'Deposits are now Payouts!', | ||
'woocommerce-payments' | ||
), | ||
descriptions: { | ||
desktop: createInterpolateElement( | ||
__( | ||
"Heads up! We've given Deposits a new industry approved alias: Payouts! Don't worry, it's still the same reliable function, just with a little more style. <link>Learn More.</link>", | ||
'woocommerce' | ||
shendy-a8c marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
{ | ||
link: ( | ||
// eslint-disable-next-line jsx-a11y/anchor-has-content | ||
<a | ||
href="https://woocommerce.com/document/woopayments/payouts/deposits-and-payouts/" | ||
target="_blank" | ||
rel="noreferrer" | ||
/> | ||
), | ||
} | ||
), | ||
}, | ||
}, | ||
}, | ||
], | ||
closeHandler: onClose, | ||
} } | ||
></TourKit> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
.wc-admin-payments-overview-payouts-rename-tour { | ||
color: #1e1e1e; | ||
|
||
.woocommerce-tour-kit-step { | ||
border-radius: 8px; | ||
border: 1px solid #dcdcdc; | ||
|
||
/* Shadow / Popover */ | ||
box-shadow: 0 2px 6px 0 rgba( 0, 0, 0, 0.05 ); | ||
width: 257px; | ||
padding-bottom: 0; | ||
} | ||
|
||
.components-card__footer { | ||
display: none; | ||
} | ||
|
||
.tour-kit-frame__container { | ||
box-shadow: none; | ||
background: none; | ||
} | ||
|
||
.components-elevation { | ||
display: none; | ||
} | ||
|
||
.woocommerce-tour-kit-step__body { | ||
background-image: url( './header-image.svg' ); | ||
background-repeat: no-repeat; | ||
background-position-x: center; | ||
background-position-y: 5px; | ||
padding-bottom: 24px; | ||
} | ||
.woocommerce-tour-kit-step-navigation { | ||
display: none; | ||
} | ||
h2 { | ||
padding-top: 100px; | ||
font-size: 14px; | ||
line-height: 24px; | ||
} | ||
p.woocommerce-tour-kit-step__description { | ||
font-size: 13px; | ||
line-height: 18px; | ||
margin-top: 8px; | ||
} | ||
.tour-kit-frame__arrow::before { | ||
box-shadow: none !important; | ||
} | ||
|
||
.tour-kit-frame__container[data-popper-placement^='bottom'] { | ||
& > .tour-kit-frame__arrow { | ||
background: #fff; | ||
&::before { | ||
border-top: 1px solid var( --gutenberg-gray-300, #ddd ); | ||
border-left: 1px solid var( --gutenberg-gray-300, #ddd ); | ||
} | ||
} | ||
} | ||
|
||
.tour-kit-frame__container[data-popper-placement^='right'] { | ||
& > .tour-kit-frame__arrow { | ||
background: #fff; | ||
&::before { | ||
border-bottom: 1px solid var( --gutenberg-gray-300, #ddd ); | ||
border-left: 1px solid var( --gutenberg-gray-300, #ddd ); | ||
} | ||
} | ||
} | ||
|
||
a { | ||
display: block; | ||
text-decoration: none; | ||
margin-top: 12px; | ||
padding-block: 11px; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PayoutsRenameNotice should render notice if isPayoutsRenameNoticeDismissed is false 1`] = ` | ||
<div> | ||
<div> | ||
Tour Component | ||
</div> | ||
</div> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** @format */ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
Check warning on line 6 in client/deposits/rename-notice/test/index.tsx GitHub Actions / JS linting
|
||
import userEvent from '@testing-library/user-event'; | ||
import apiFetch from '@wordpress/api-fetch'; | ||
import { log, error } from 'console'; | ||
Check warning on line 9 in client/deposits/rename-notice/test/index.tsx GitHub Actions / JS linting
|
||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { PayoutsRenameNotice } from '..'; | ||
|
||
jest.mock( '@wordpress/api-fetch', () => jest.fn() ); | ||
|
||
jest.mock( '@wordpress/data', () => ( { | ||
useDispatch: jest.fn().mockReturnValue( { updateOptions: jest.fn() } ), | ||
} ) ); | ||
|
||
jest.mock( '@woocommerce/components', () => ( { | ||
TourKit: () => <div>Tour Component</div>, | ||
} ) ); | ||
|
||
declare const global: { | ||
wcpaySettings: { | ||
isPayoutsRenameNoticeDismissed: boolean; | ||
}; | ||
}; | ||
|
||
describe( 'PayoutsRenameNotice', () => { | ||
afterEach( () => { | ||
jest.clearAllMocks(); | ||
} ); | ||
|
||
test( 'should render null if isPayoutsRenameNoticeDismissed is true', () => { | ||
global.wcpaySettings = { | ||
isPayoutsRenameNoticeDismissed: true, | ||
}; | ||
const { container } = render( <PayoutsRenameNotice /> ); | ||
expect( container.firstChild ).toBeNull(); | ||
} ); | ||
|
||
test( 'should render notice if isPayoutsRenameNoticeDismissed is false', () => { | ||
global.wcpaySettings = { | ||
isPayoutsRenameNoticeDismissed: false, | ||
}; | ||
const { container } = render( <PayoutsRenameNotice /> ); | ||
expect( container ).toMatchSnapshot(); | ||
} ); | ||
} ); |
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.
Unused import.