-
Notifications
You must be signed in to change notification settings - Fork 805
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
License activation: Add helpful error messages & display help steps on error response. #39333
Merged
elliottprogrammer
merged 6 commits into
trunk
from
update/license-activate-error-messages
Sep 12, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dfe09f7
Add License: Update error messages & add error help info.
elliottprogrammer 70de4dd
changelog
elliottprogrammer d1e2b18
Update unit test.
elliottprogrammer 6db728b
Various final touch ups.
elliottprogrammer 3ae949e
Fix tiny css style.
elliottprogrammer d3d0a2d
Address all feedback points.
elliottprogrammer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/js-packages/licensing/changelog/update-license-activate-error-messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: changed | ||
|
||
Add more helpful error messages and help steps on license key activation error. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
projects/js-packages/licensing/components/activation-screen-error/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const LICENSE_ERRORS = { | ||
NOT_SAME_OWNER: '[not_same_owner]', | ||
ACTIVE_ON_SAME_SITE: '[active_on_same_site]', | ||
ATTACHED_LICENSE: '[attached_license]', | ||
PRODUCT_INCOMPATIBILITY: '[product_incompatibility]', | ||
REVOKED_LICENSE: '[revoked_license]', | ||
INVALID_INPUT: '[invalid_input]', | ||
MULTISITE_INCOMPATIBILITY: '[multisite_incompatibility]', | ||
} as const; |
52 changes: 52 additions & 0 deletions
52
projects/js-packages/licensing/components/activation-screen-error/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import jetpackAnalytics from '@automattic/jetpack-analytics'; | ||
import { Icon, warning, check } from '@wordpress/icons'; | ||
import React, { 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 ]; | ||
|
||
interface Props { | ||
licenseError: string; | ||
errorType: LicenseErrorValuesType; | ||
} | ||
|
||
const ActivationScreenError: FC< Props > = ( { licenseError, errorType } ) => { | ||
useEffect( () => { | ||
if ( licenseError ) { | ||
jetpackAnalytics.tracks.recordEvent( 'jetpack_wpa_license_activation_error_view', { | ||
error: licenseError, | ||
error_type: errorType, | ||
} ); | ||
} | ||
}, [ licenseError, errorType ] ); | ||
|
||
const { errorMessage, errorInfo } = useGetErrorContent( licenseError, errorType ); | ||
|
||
if ( ! licenseError ) { | ||
return null; | ||
} | ||
|
||
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> } | ||
</> | ||
); | ||
}; | ||
|
||
export default ActivationScreenError; |
75 changes: 75 additions & 0 deletions
75
projects/js-packages/licensing/components/activation-screen-error/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
.activation-screen-error__message { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: flex-start; | ||
max-width: 500px; | ||
margin-top: calc(var(--spacing-base)*.5); | ||
|
||
svg { | ||
margin-left: -3px; | ||
} | ||
|
||
span { | ||
font-size: 13px; | ||
line-height: 20px; | ||
font-weight: 500; | ||
letter-spacing: -0.044em; | ||
} | ||
} | ||
|
||
.activation-screen-error__message--error { | ||
color: var(--jp-red); | ||
svg { | ||
fill: var(--jp-red); | ||
} | ||
} | ||
|
||
.activation-screen-error__message--success { | ||
color: var(--jp-green); | ||
svg { | ||
fill: var(--jp-green); | ||
} | ||
} | ||
|
||
.activation-screen-error__info { | ||
background-color: var(--jp-gray-0); | ||
color: var(--jp-gray-80); | ||
font-size: var(--font-body-small); | ||
line-height: calc(var(--font-title-small) - 2px); | ||
border: 1px solid var(--jp-green-0); | ||
border-radius: var(--jp-border-radius); | ||
padding: var(--jp-modal-padding-small); | ||
margin: 32px 0 8px; | ||
|
||
> p { | ||
margin: 0 0 1em; | ||
font-size: var(--font-body-small); | ||
} | ||
> p:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
ol > li::marker { | ||
font-weight: bold; | ||
} | ||
|
||
a { | ||
color: var(--jp-green-50); | ||
} | ||
a:hover, | ||
a:active { | ||
color: var(--jp-green-70); | ||
} | ||
} | ||
|
||
.jp-license-activation-screen-controls { | ||
.activation-screen-error__info { | ||
> p { | ||
margin: 0 0 1em; | ||
font-size: var(--font-body-small); | ||
} | ||
> p:last-child { | ||
margin-bottom: 0; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I see we have a
--font-body-extra-small
which is 12px and--font-body-small
which is 14px. My gut tells me we should use one of those just to avoid having too many different font sizes. I understand if design thinks differently thoughThere 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.
Yeah, my only hesitation here is that I believe Design used this specific font size along with the reduced letter spacing so that all errors remain within one line (on desktop anyway). If I change the font size up to 14px, a couple of the errors span over 2 lines (with orphan), and if I drop down the size to 12px, then the error seems a bit too small.
I think i'll stick with the Design specified font size in this instance.. Just because of the reason above, and also because (as mentioned in another comment), this change may not remain in the codebase too long due to the upcoming related project.
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.
In my experience updating font size just to avoid lines overlapping is not best practices, but like you said this will be changing soon so I think it's fine for now 😅