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

Add dismissable Notice to message the rename of Deposits to Payout #9680

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
5 changes: 5 additions & 0 deletions changelog/add-9673-payouts-rename-notice
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


2 changes: 2 additions & 0 deletions client/deposits/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { __ } from '@wordpress/i18n';
import { TestModeNotice } from 'components/test-mode-notice';
import BannerNotice from 'components/banner-notice';
import DepositSchedule from 'components/deposits-overview/deposit-schedule';
import { PayoutsRenameNotice } from './rename-notice';
import { useAllDepositsOverviews } from 'data';
import { useSettings } from 'wcpay/data';
import DepositsList from './list';
Expand Down Expand Up @@ -149,6 +150,7 @@ const DepositsPage: React.FC = () => {
return (
<Page>
<TestModeNotice currentPage="deposits" />
<PayoutsRenameNotice />
<NextDepositNotice />
<DepositFailureNotice />
<DepositsList />
Expand Down
30 changes: 30 additions & 0 deletions client/deposits/rename-notice/header-image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions client/deposits/rename-notice/index.tsx
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';

Check warning on line 13 in client/deposits/rename-notice/index.tsx

View workflow job for this annotation

GitHub Actions / JS linting

'useDeposits' is defined but never used
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused import.

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
Copy link
Contributor

@shendy-a8c shendy-a8c Nov 10, 2024

Choose a reason for hiding this comment

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

I believe this does not have any effect because the value of isPayoutsRenameNoticeDismissed never changes.

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>
);
};
77 changes: 77 additions & 0 deletions client/deposits/rename-notice/style.scss
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>
`;
52 changes: 52 additions & 0 deletions client/deposits/rename-notice/test/index.tsx
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

View workflow job for this annotation

GitHub Actions / JS linting

'screen' is defined but never used

Check warning on line 6 in client/deposits/rename-notice/test/index.tsx

View workflow job for this annotation

GitHub Actions / JS linting

'waitFor' is defined but never used
import userEvent from '@testing-library/user-event';

Check warning on line 7 in client/deposits/rename-notice/test/index.tsx

View workflow job for this annotation

GitHub Actions / JS linting

'userEvent' is defined but never used
import apiFetch from '@wordpress/api-fetch';

Check warning on line 8 in client/deposits/rename-notice/test/index.tsx

View workflow job for this annotation

GitHub Actions / JS linting

'apiFetch' is defined but never used
import { log, error } from 'console';

Check warning on line 9 in client/deposits/rename-notice/test/index.tsx

View workflow job for this annotation

GitHub Actions / JS linting

'log' is defined but never used

Check warning on line 9 in client/deposits/rename-notice/test/index.tsx

View workflow job for this annotation

GitHub Actions / JS linting

'error' is defined but never used

/**
* 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();
} );
} );
1 change: 1 addition & 0 deletions client/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ declare global {
fraudProtection: {
isWelcomeTourDismissed?: boolean;
};
isPayoutsRenameNoticeDismissed: boolean;
progressiveOnboarding?: {
isEnabled: boolean;
isComplete: boolean;
Expand Down
Loading