Skip to content
Closed
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
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Replace `Button`, `TextControl`, and `ExternalLink` from `@wordpress/components` with equivalents from `@wordpress/ui`, and replace `Spinner` from `@automattic/jetpack-components` with `Spinner` from `@wordpress/components`.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import jetpackAnalytics from '@automattic/jetpack-analytics';
import { JetpackLogo } from '@automattic/jetpack-components';
import { Button, TextControl, SelectControl, Spinner } from '@wordpress/components';
import { SelectControl } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { sprintf, __ } from '@wordpress/i18n';
import { Button, InputControl, Stack, Text } from '@wordpress/ui';
import PropTypes from 'prop-types';
import { useCallback, useEffect, useMemo, useState } from 'react';
import ActivationScreenError from '../activation-screen-error';
import { LICENSE_ERRORS } from '../activation-screen-error/constants';
import './style.scss';

/**
Expand All @@ -22,14 +22,14 @@ import './style.scss';
const ManualLicenseKeyInput = props => {
const { className, disabled, onChange, value } = props;

const handleChange = useCallback( e => onChange( e.target.value ), [ onChange ] );

return (
<TextControl
__nextHasNoMarginBottom={ true }
__next40pxDefaultSize
<InputControl
className={ className }
label={ __( 'License key', 'jetpack-licensing' ) }
value={ value }
onChange={ onChange }
onChange={ handleChange }
disabled={ disabled }
/>
);
Expand All @@ -51,6 +51,8 @@ const SelectableLicenseKeyInput = props => {
const [ selectedOption, setSelectedOption ] = useState( '' );
const isFetching = availableLicenses === null;

const handleChange = useCallback( e => onChange( e.target.value ), [ onChange ] );

const options = useMemo( () => {
if ( isFetching ) {
return [
Expand Down Expand Up @@ -110,13 +112,11 @@ const SelectableLicenseKeyInput = props => {
/>

{ ! isFetching && ! selectedOption && (
<TextControl
__nextHasNoMarginBottom={ true }
__next40pxDefaultSize
<InputControl
className={ className }
label={ __( 'Input a license key', 'jetpack-licensing' ) }
value={ value }
onChange={ onChange }
onChange={ handleChange }
disabled={ disabled }
/>
) }
Expand Down Expand Up @@ -157,27 +157,20 @@ const ActivationScreenControls = props => {
typeof licenseError === 'string' ? licenseError?.match( /\[[a-z_]+\]/ ) : null;
const errorType = errorTypeMatch && errorTypeMatch[ 0 ];

const { ACTIVE_ON_SAME_SITE } = LICENSE_ERRORS;
const isLicenseAlreadyAttached = ACTIVE_ON_SAME_SITE === errorType;
const className = useMemo( () => {
if ( ! licenseError ) {
return 'jp-license-activation-screen-controls--license-field';
}
if ( isLicenseAlreadyAttached ) {
return 'jp-license-activation-screen-controls--license-field-with-success';
}

return 'jp-license-activation-screen-controls--license-field-with-error';
}, [ licenseError, isLicenseAlreadyAttached ] );

const hasAvailableLicenseKey = availableLicenses && availableLicenses.length;

return (
<div className="jp-license-activation-screen-controls">
<div className="jp-license-activation-screen-controls--content">
<JetpackLogo showText={ false } height={ 48 } />
<h1>{ __( 'Add a license key', 'jetpack-licensing' ) }</h1>
<p>
<Stack
className="jp-license-activation-screen-controls"
direction="column"
justify="space-between"
>
<Stack align="stretch" direction="column" gap="xl" style={ { margin: 'auto 0' } }>
<JetpackLogo showText={ false } height={ 48 } style={ { alignSelf: 'flex-start' } } />
<Text variant="heading-2xl" render={ <h1 /> }>
{ __( 'Add a license key', 'jetpack-licensing' ) }
</Text>
<Text variant="body-lg">
{ createInterpolateElement(
__(
'<strong>Purchased a plan?</strong><br />Check your email for your license key and paste it below.',
Expand All @@ -188,18 +181,16 @@ const ActivationScreenControls = props => {
br: <br />,
}
) }
</p>
</Text>
{ fetchingAvailableLicenses || hasAvailableLicenseKey ? (
<SelectableLicenseKeyInput
className={ className }
disabled={ fetchingAvailableLicenses || isActivating }
onChange={ onLicenseChange }
availableLicenses={ fetchingAvailableLicenses ? null : availableLicenses }
value={ license }
/>
) : (
<ManualLicenseKeyInput
className={ className }
disabled={ isActivating }
onChange={ onLicenseChange }
value={ license }
Expand All @@ -208,17 +199,11 @@ const ActivationScreenControls = props => {
{ licenseError && (
<ActivationScreenError licenseError={ licenseError } errorType={ errorType } />
) }
</div>
<div>
<Button
className="jp-license-activation-screen-controls--button"
onClick={ activateLicense }
disabled={ ! license }
>
{ isActivating ? <Spinner /> : __( 'Activate', 'jetpack-licensing' ) }
</Button>
</div>
</div>
</Stack>
<Button onClick={ activateLicense } disabled={ ! license } loading={ isActivating }>
{ __( 'Activate', 'jetpack-licensing' ) }
</Button>
</Stack>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,130 +1,8 @@
@use "@automattic/jetpack-base-styles/style";
@use "sass:meta";
@include meta.load-css("pkg:@wordpress/theme/design-tokens.css");

.jp-license-activation-screen-controls {
background: var(--jp-white);
padding: 32px;
display: flex;
flex-direction: column;
justify-content: space-between;

h1 {
// typography-exception
font-size: 44px;
font-weight: 700;

// This is inherited in the Jetpack plugin from the top-level
// Jetpack page. Doesn't carry over to My Jetpack.
line-height: 1.4;

// Exception here due to being overridden by Text component
// styles when used in My Jetpack.
margin: 0.67em 0;
}

p {
font-size: var(--font-body);

// Exception here due to being overridden by Text component
// styles when used in My Jetpack.
margin: 1em 0;
}

label {
font-weight: 600;
font-size: var(--font-body);
}

@media screen and (min-width: 780px) {
padding: 64px;
}


.jp-license-activation-screen-controls--license-field,
.jp-license-activation-screen-controls--license-field-with-error,
.jp-license-activation-screen-controls--license-field-with-success {
max-width: 500px;
margin-top: 10px;

.components-input-control__label.components-input-control__label.components-input-control__label {
font-weight: 600;
font-size: var(--font-body);
}

input.components-text-control__input,
select.components-select-control__input {
border-radius: var(--jp-border-radius);
font-size: 18px;
line-height: 24px;
margin: 0;
min-height: 48px;
}
}

.jp-license-activation-screen-controls--license-field {

input.components-text-control__input {
border: 1px solid var(--jp-gray-40);
}
}

.jp-license-activation-screen-controls--license-field-with-error {

input.components-text-control__input,
select.components-select-control__input {
border: 1px solid var(--jp-red);
}
}

.jp-license-activation-screen-controls--license-field-with-success {

input.components-text-control__input,
select.components-select-control__input {
border: 1px solid var(--jp-green);
}
}

.jp-license-activation-screen-controls--button,
.jp-license-activation-screen-controls--button:active {
background-color: var(--jp-black);
border-radius: 4px;
color: var(--jp-white);
display: flex;
font-size: 16px;
font-size: var(--font-body);
font-style: normal;
font-weight: 600;
justify-content: center;
line-height: 24px;
margin-top: 24px;
min-height: 48px;
min-width: 158px;
padding: 13.5px 45px 13.5px 45px;
width: 100%;

@media screen and (min-width: 480px) {
width: auto;
}

&.components-button:hover {
background-color: var(--jp-black-80);
color: var(--jp-white);
}

&:focus {
background-color: var(--jp-black-80);
border: 1px solid var(--jp-white);
color: var(--jp-white);
}

&[disabled],
&:disabled {
background-color: var(--jp-gray);
color: var(--jp-gray-20);
}

.jp-components-spinner,
.components-spinner {
width: 100%;
}
}
padding: 0 var(--wp-ui-card-padding);
min-width: 320px;
width: 50%;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import jetpackAnalytics from '@automattic/jetpack-analytics';
import { Icon, cautionFilled as warning, check } from '@wordpress/icons';
import { Notice } from '@wordpress/ui';
import { useEffect } from 'react';
import { LICENSE_ERRORS } from './constants';
import { useGetErrorContent } from './use-get-error-content';
import type { FC } from 'react';

import './style.scss';

type LicenseErrorKeysType = keyof typeof LICENSE_ERRORS;
type LicenseErrorValuesType = ( typeof LICENSE_ERRORS )[ LicenseErrorKeysType ];

Expand Down Expand Up @@ -34,18 +32,11 @@ const ActivationScreenError: FC< Props > = ( { licenseError, errorType } ) => {
const { ACTIVE_ON_SAME_SITE } = LICENSE_ERRORS;
const isLicenseAlreadyAttached = ACTIVE_ON_SAME_SITE === errorType;

const errorMessageClass = isLicenseAlreadyAttached
? 'activation-screen-error__message--success'
: 'activation-screen-error__message--error';

return (
<>
<div className={ `activation-screen-error__message ${ errorMessageClass }` }>
<Icon icon={ isLicenseAlreadyAttached ? check : warning } size={ 20 } />
<span>{ errorMessage }</span>
</div>
{ errorInfo && <div className="activation-screen-error__info">{ errorInfo }</div> }
</>
<Notice.Root intent={ isLicenseAlreadyAttached ? 'success' : 'error' }>
<Notice.Title>{ errorMessage }</Notice.Title>
{ errorInfo && <Notice.Description>{ errorInfo }</Notice.Description> }
</Notice.Root>
);
};

Expand Down
Loading
Loading