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 Migrate Button to Start Setup #315

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions src/OnboardingSPA/components/Button/ButtonWhite/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Button } from '@wordpress/components';
import { Icon } from '@wordpress/icons';
import classNames from 'classnames';

const ButtonWhite = ( { className, text, onClick = false } ) => {
const ButtonWhite = ( { className, text, onClick, icon } ) => {
return (
<Button
className={ classNames(
Expand All @@ -10,7 +11,10 @@ const ButtonWhite = ( { className, text, onClick = false } ) => {
) }
onClick={ typeof onClick === 'function' && onClick }
>
{ text }
<span className={ `${ className }__text` }>{ text }</span>
{ icon && (
<Icon className={ `${ className }__icon` } icon={ icon } />
) }
</Button>
);
};
Expand Down
18 changes: 15 additions & 3 deletions src/OnboardingSPA/components/Button/NavCardButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import {
} from '../../../utils/analytics/hiive';
import { ACTION_ONBOARDING_COMPLETE } from '../../../utils/analytics/hiive/constants';
import { activateInitialPlugins } from '../../../utils/api/plugins';
import classNames from 'classnames';
import { Icon } from '@wordpress/icons';

/**
* Navigation Button Component on Card
*
* @return
*/

const NavCardButton = ( { text, disabled } ) => {
const NavCardButton = ( { text, disabled, className, icon } ) => {
const navigate = useNavigate();

const { nextStep, currentData } = useSelect( ( select ) => {
Expand Down Expand Up @@ -50,8 +52,18 @@ const NavCardButton = ( { text, disabled } ) => {

return (
<Button
className="nfd-nav-card-button"
text={ text }
className={ classNames( 'nfd-nav-card-button', className ) }
text={
<>
<span className={ `${ className }__text` }>{ text }</span>
{ icon && (
<Icon
className={ `${ className }__icon` }
icon={ icon }
/>
) }
</>
}
handleClick={ handleBtnClick }
disabled={ disabled }
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.nfd-nav-card-button {
display: flex;
justify-content: center;
align-items: center;
color: var(--nfd-onboarding-white);
background-color: var(--wp-admin-theme-color-darker-10);
padding: 16px;
Expand All @@ -8,4 +11,8 @@
border-radius: 4px;
border: none;
outline: 1px solid transparent;

&__icon {
fill: var(--nfd-onboarding-white);
}
}
6 changes: 5 additions & 1 deletion src/OnboardingSPA/steps/GetStarted/Welcome/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const getContents = ( brandName ) => {
__( 'with WordPress and %s.', 'wp-module-onboarding' ),
brandName
),
buttonText: __( 'Start Setup', 'wp-module-onboarding' ),
migrateButtonText: __(
'Migrate a WordPress Site',
'wp-module-onboarding'
),
startButtonText: __( 'Start Setup', 'wp-module-onboarding' ),
tabs: [
{
name: 'tab1',
Expand Down
23 changes: 21 additions & 2 deletions src/OnboardingSPA/steps/GetStarted/Welcome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { useLocation } from 'react-router-dom';
import { useSelect, useDispatch } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import { chevronRight, external } from '@wordpress/icons';

import CommonLayout from '../../../components/Layouts/Common';
import NewfoldLargeCard from '../../../components/NewfoldLargeCard';
Expand All @@ -14,16 +15,18 @@
SIDEBAR_LEARN_MORE,
} from '../../../../constants';
import getContents from './contents';
import ButtonWhite from '../../../components/Button/ButtonWhite';

const StepWelcome = () => {
const location = useLocation();
const { brandName } = useSelect(
const { brandName, migrationUrl } = useSelect(
( select ) => {
return {
brandName: select( nfdOnboardingStore ).getNewfoldBrandName(),
migrationUrl: select( nfdOnboardingStore ).getMigrationUrl(),
};
},
[ location.pathname ]

Check warning on line 29 in src/OnboardingSPA/steps/GetStarted/Welcome/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useSelect has an unnecessary dependency: 'location.pathname'. Either exclude it or remove the dependency array
);
const {
setDrawerActiveView,
Expand All @@ -37,7 +40,7 @@
setIsHeaderNavigationEnabled( true );
setIsDrawerSuppressed( true );
setDrawerActiveView( VIEW_NAV_GET_STARTED );
}, [] );

Check warning on line 43 in src/OnboardingSPA/steps/GetStarted/Welcome/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'setDrawerActiveView', 'setIsDrawerSuppressed', 'setIsHeaderNavigationEnabled', and 'setSidebarActiveView'. Either include them or remove the dependency array

const content = getContents( brandName );

Expand Down Expand Up @@ -69,7 +72,23 @@
>
{ ( tab ) => <div>{ tab.content }</div> }
</TabPanelHover>
<NavCardButton text={ content.buttonText }></NavCardButton>
<div className="nfd-onboarding-overview__buttons">
{ migrationUrl && (
<ButtonWhite
className="nfd-onboarding-overview__buttons--white"
text={ content.migrateButtonText }
icon={ external }
onClick={ () =>
window.open( migrationUrl, '_blank' )
}
/>
) }
<NavCardButton
className="nfd-onboarding-overview__buttons--background"
text={ content.startButtonText }
icon={ chevronRight }
></NavCardButton>
</div>
</div>
</NewfoldLargeCard>
</CommonLayout>
Expand Down
53 changes: 52 additions & 1 deletion src/OnboardingSPA/steps/GetStarted/Welcome/stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,61 @@
padding-bottom: 40px;
color: var(--nfd-onboarding-contrast);
}

&__buttons {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;

@media (max-width: #{ ($break-xlarge) }) {
flex-direction: column-reverse;
}

&--background,
&--white {
height: 76px;
margin: 0 20px;
padding: 0;
width: 100%;
font-weight: 500;
border-radius: 0%;
font-size: clamp(1rem, 0.9091rem + 0.4545vw, 2rem);

@media (max-width: #{ ($break-xlarge) }) {
margin: 10px 0;
width: 100%;
}

&__text {
font-weight: 700;
}
}

&--background {

&__icon {
fill: var(--nfd-onboarding-white);
height: auto;
}
}

&--white {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;

&__icon {
margin-left: 15px;
}
}
}
}

.nfd-step-card-subheading {
margin-bottom: 30px;
display: flex;
justify-content: space-around;
}
Expand Down Expand Up @@ -120,7 +172,6 @@
flex-direction: column;
align-items: center;
justify-content: space-around;
height: clamp(560px, 59vh, 800px);
width: 100%;
padding-bottom: 10px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/OnboardingSPA/steps/WhatNext/stylesheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
}

.nfd-step-card-subheading {
margin-bottom: 30px;
display: flex;
justify-content: space-around;
}
Expand Down Expand Up @@ -123,7 +124,6 @@
flex-direction: column;
align-items: center;
justify-content: space-around;
height: clamp(600px, 59vh, 800px) !important;
width: 100%;
padding-bottom: 10px;
}
Expand Down
14 changes: 14 additions & 0 deletions src/OnboardingSPA/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,20 @@ export function getTechSupportUrl( state ) {
return techSupportUrl;
}

/**
* Gets the link to the migration service.
*
* @param {*} state
* @return {string} migrationUrl
*/
export function getMigrationUrl( state ) {
const migrationInfo = state.runtime.currentBrand.migrationInfo;
const migrationUrl =
addQueryArgs( migrationInfo?.defaultLink, migrationInfo?.queryParams ) +
( migrationInfo?.fragment || '' );
return migrationUrl;
}

/**
* Gets the Plugin Install Hash for security
*
Expand Down