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 hiive html attributes to ftc #20678

Merged
merged 38 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0be2bfc
Move steps names here and introduce HIIVE_STEPS_NAMES
pls78 Sep 19, 2023
9b61693
Refactor to pass stepId and build id later in the buttons
pls78 Sep 19, 2023
1b9acd9
Refactor to build buttons ids and hiive attributes
pls78 Sep 19, 2023
42ec4c2
Add hiive data attributes
pls78 Sep 19, 2023
04b6cca
Add filters to trigger event dispatching
pls78 Sep 22, 2023
6f57b11
Refactor method to fetch old values. Add a mapping function to change…
pls78 Sep 25, 2023
8b14974
Add two new events
pls78 Sep 25, 2023
9bb9a87
Changed hook param value
pls78 Sep 25, 2023
7a39acd
Add hooks documentation
pls78 Sep 25, 2023
0041fb2
Fix cs
pls78 Sep 25, 2023
805aec5
Move Hiive-specific code to Newfold data module plugin
pls78 Sep 26, 2023
67da3e9
Fix tests
pls78 Sep 26, 2023
63659a6
Fix cs
pls78 Sep 26, 2023
6c3064f
Fix inwanted import
pls78 Sep 26, 2023
d8c0dd9
Fixed capitalisation
pls78 Oct 6, 2023
cd3ab76
Add some more hiive attributes
pls78 Oct 6, 2023
b3e5795
Remove useless curly brackets
pls78 Oct 6, 2023
b8a9741
Add missing Hiive attribute.
pls78 Oct 6, 2023
19dba25
Update src/actions/configuration/first-time-configuration-action.php
pls78 Oct 9, 2023
447dab2
Update src/actions/configuration/first-time-configuration-action.php
pls78 Oct 9, 2023
7a93fca
Update src/actions/configuration/first-time-configuration-action.php
pls78 Oct 9, 2023
5616de8
Moved constants to FTC root folder
pls78 Oct 9, 2023
e7c7032
Update constants import
pls78 Oct 9, 2023
6247a50
Uniform buttons components props
pls78 Oct 9, 2023
73de897
Update packages/js/src/first-time-configuration/tailwind-components/c…
pls78 Oct 10, 2023
d881210
Update packages/js/src/first-time-configuration/tailwind-components/c…
pls78 Oct 10, 2023
afeadba
Update packages/js/src/first-time-configuration/tailwind-components/c…
pls78 Oct 10, 2023
54811af
Update packages/js/src/first-time-configuration/tailwind-components/c…
pls78 Oct 10, 2023
317a3aa
Update packages/js/src/first-time-configuration/tailwind-components/s…
pls78 Oct 10, 2023
042c33a
Use the right hook name
pls78 Oct 11, 2023
565f3c8
Add @internal annotation to hooks
pls78 Oct 11, 2023
388d887
Do not filter $old_values.
pls78 Oct 11, 2023
dbbaabb
Simplify "Site representation step".
pls78 Oct 11, 2023
7ef5da3
Fix event name
pls78 Oct 11, 2023
457253b
Fix event name in case of replaced image
pls78 Oct 11, 2023
c9ee2d4
Enforce type checking
pls78 Oct 11, 2023
576dd23
Correct order of operations
pls78 Oct 12, 2023
a76b3ea
Fix tests
pls78 Oct 13, 2023
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
12 changes: 12 additions & 0 deletions packages/js/src/first-time-configuration/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const STEPS = {
optimizeSeoData: "optimizeSeoData",
siteRepresentation: "siteRepresentation",
socialProfiles: "socialProfiles",
personalPreferences: "personalPreferences",
};
export const HIIVE_STEPS_NAMES = {
[ STEPS.optimizeSeoData ]: "data optimization",
[ STEPS.siteRepresentation ]: "site representation",
[ STEPS.socialProfiles ]: "social profiles",
[ STEPS.personalPreferences ]: "personal preferences",
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ import IndexationStep from "./tailwind-components/steps/indexation/indexation-st
import SiteRepresentationStep from "./tailwind-components/steps/site-representation/site-representation-step";
import PersonalPreferencesStep from "./tailwind-components/steps/personal-preferences/personal-preferences-step";
import FinishStep from "./tailwind-components/steps/finish/finish-step";

const STEPS = {
optimizeSeoData: "optimizeSeoData",
siteRepresentation: "siteRepresentation",
socialProfiles: "socialProfiles",
personalPreferences: "personalPreferences",
};
import { STEPS } from "./constants";

/* eslint-disable complexity */

Expand Down Expand Up @@ -501,7 +495,7 @@ export default function FirstTimeConfigurationSteps() {
isFinished={ isIndexationStepFinished }
>
<EditButton
id={ `button-${ STEPS.optimizeSeoData }-edit` }
stepId={ STEPS.optimizeSeoData }
beforeGo={ beforeEditing }
isVisible={ showEditButton }
additionalClasses={ "yst-ml-auto" }
Expand All @@ -512,7 +506,7 @@ export default function FirstTimeConfigurationSteps() {
<Step.Content>
<IndexationStep setIndexingState={ setIndexingState } indexingState={ indexingState } showRunIndexationAlert={ showRunIndexationAlert } isStepperFinished={ isStepperFinished } />
<ContinueButton
id={ `button-${ STEPS.optimizeSeoData }-continue` }
stepId={ STEPS.optimizeSeoData }
additionalClasses="yst-mt-12"
beforeGo={ beforeContinueIndexationStep }
destination={ stepperFinishedOnce ? "last" : 1 }
Expand All @@ -527,7 +521,7 @@ export default function FirstTimeConfigurationSteps() {
isFinished={ isStep2Finished }
>
<EditButton
id={ `button-${ STEPS.siteRepresentation }-edit` }
stepId={ STEPS.siteRepresentation }
beforeGo={ beforeEditing }
isVisible={ showEditButton }
additionalClasses={ "yst-ml-auto" }
Expand Down Expand Up @@ -557,7 +551,7 @@ export default function FirstTimeConfigurationSteps() {
isFinished={ isStep3Finished }
>
<EditButton
id={ `button-${ STEPS.socialProfiles }-edit` }
stepId={ STEPS.socialProfiles }
beforeGo={ beforeEditing }
isVisible={ showEditButton }
additionalClasses={ "yst-ml-auto" }
Expand All @@ -582,7 +576,7 @@ export default function FirstTimeConfigurationSteps() {
isFinished={ isStep4Finished }
>
<EditButton
id={ `button-${ STEPS.personalPreferences }-edit` }
stepId={ STEPS.personalPreferences }
beforeGo={ beforeEditing }
isVisible={ showEditButton }
additionalClasses={ "yst-ml-auto" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default function ImageSelect( {
className={ imageClassName }
onClick={ onSelectImageClick }
type="button"
data-hiive-event-name="clicked_select_image"
>
{ renderPreview() }
</button>
Expand All @@ -79,6 +80,7 @@ export default function ImageSelect( {
id={ url ? id + "__replace-image" : id + "__select-image" }
className="yst-button yst-button yst-button--secondary yst-mr-2"
onClick={ onSelectImageClick }
data-hiive-event-name={ url ? "clicked_replace_image" : "clicked_select_image" }
>
{ url ? __( "Replace image", "admin-ui" ) : __( "Select image", "admin-ui" ) }
</button>
Expand All @@ -88,6 +90,7 @@ export default function ImageSelect( {
id={ id + "__remove-image" }
className="yst-button--remove"
onClick={ onRemoveImageClick }
data-hiive-event-name="clicked_remove_image"
>
{ __( "Remove image", "admin-ui" ) }
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from "prop-types";
import { Step } from "./stepper";
import { stepperTimingClasses } from "../stepper-helper";
import classNames from "classnames";
import { HIIVE_STEPS_NAMES } from "../constants";

/**
* A ContinueButton that always goes to the next step.
Expand All @@ -13,18 +14,21 @@ import classNames from "classnames";
*
* @returns {WPElement} The ContinueButton, that always goes to the next step.
*/
export function ContinueButton( { beforeGo, children, additionalClasses, ...restProps } ) {
export function ContinueButton( { stepId, beforeGo, children, additionalClasses, ...restProps } ) {
return ( <Step.GoButton
id={ `button-${ stepId }-continue` }
className={ `yst-button yst-button--primary ${ additionalClasses }` }
destination={ 1 }
beforeGo={ beforeGo }
data-hiive-event-name={ `clicked_continue | ${ HIIVE_STEPS_NAMES[ stepId ] }` }
{ ...restProps }
>
{ children }
</Step.GoButton> );
}

ContinueButton.propTypes = {
stepId: PropTypes.string.isRequired,
additionalClasses: PropTypes.string,
beforeGo: PropTypes.func,
children: PropTypes.node,
Expand All @@ -44,27 +48,30 @@ ContinueButton.defaultProps = {
*
* @returns {WPElement} The EditButton, that always goes to the step it is placed in.
*/
export function EditButton( { beforeGo, isVisible, children, additionalClasses, ...restProps } ) {
export function EditButton( { stepId, beforeGo, isVisible, children, additionalClasses, ...restProps } ) {
const transitionClasses = `yst-transition-opacity ${stepperTimingClasses.slideDuration} yst-ease-out ${ isVisible
? "yst-opacity-100"
: `${stepperTimingClasses.delayBeforeOpening} yst-opacity-0 yst-pointer-events-none yst-hidden` }`;


return ( <Step.GoButton
id={ `button-${ stepId }-edit` }
className={ classNames(
"yst-button yst-button--secondary yst-button--small",
transitionClasses,
additionalClasses
) }
destination={ 0 }
beforeGo={ beforeGo }
data-hiive-event-name={ `clicked_edit | ${ HIIVE_STEPS_NAMES[ stepId ] }` }
{ ...restProps }
>
{ children }
</Step.GoButton> );
}

EditButton.propTypes = {
stepId: PropTypes.string.isRequired,
additionalClasses: PropTypes.string,
isVisible: PropTypes.bool,
beforeGo: PropTypes.func,
Expand All @@ -86,18 +93,21 @@ EditButton.defaultProps = {
*
* @returns {WPElement} The BackButton, that always goes to the previous step.
*/
export function BackButton( { beforeGo, children, additionalClasses, ...restProps } ) {
export function BackButton( { stepId, beforeGo, children, additionalClasses, ...restProps } ) {
return ( <Step.GoButton
id={ `button-${ stepId }-back` }
className={ `yst-button yst-button--secondary ${ additionalClasses }` }
destination={ -1 }
beforeGo={ beforeGo }
data-hiive-event-name={ `clicked_go_back | ${ HIIVE_STEPS_NAMES[ stepId ] }` }
{ ...restProps }
>
{ children }
</Step.GoButton> );
}

BackButton.propTypes = {
stepId: PropTypes.string.isRequired,
additionalClasses: PropTypes.string,
beforeGo: PropTypes.func,
children: PropTypes.node,
Expand All @@ -123,8 +133,19 @@ BackButton.defaultProps = {
*/
export function StepButtons( { stepId, beforeContinue, continueLabel, beforeBack, backLabel } ) {
return <div className="yst-mt-12">
<ContinueButton id={ `button-${ stepId }-continue` } beforeGo={ beforeContinue }>{ continueLabel }</ContinueButton>
<BackButton id={ `button-${ stepId }-back` } additionalClasses="yst-ml-3" beforeGo={ beforeBack }>{ backLabel }</BackButton>
<ContinueButton
stepId={ stepId }
beforeGo={ beforeContinue }
>
{ continueLabel }
</ContinueButton>
<BackButton
stepId={ stepId }
additionalClasses="yst-ml-3"
beforeGo={ beforeBack }
>
{ backLabel }
</BackButton>
</div>;
}

Expand Down Expand Up @@ -162,10 +183,16 @@ export function ConfigurationStepButtons( { stepId, stepperFinishedOnce, saveFun
// If save is not succesful: we are still editing
setEditState( ! saveSuccesful );
return saveSuccesful;
} );
}, [ saveFunction ] );

if ( stepperFinishedOnce ) {
return <Step.GoButton id={ `button-${ stepId }-go` } className="yst-button yst-button--primary yst-mt-12" destination="last" beforeGo={ onSaveClick }>
return <Step.GoButton
id={ `button-${ stepId }-go` }
className="yst-button yst-button--primary yst-mt-12"
destination="last"
beforeGo={ onSaveClick }
data-hiive-event-name={ `clicked_save_changes | ${ HIIVE_STEPS_NAMES[ stepId ] }` }
>
{ __( "Save changes", "wordpress-seo" ) }
</Step.GoButton>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function FinishStep() {
id="button-webinar-seo-dashboard"
href={ webinarIntroFirstTimeConfigUrl }
target="_blank"
data-hiive-event-name="clicked_to_onboarding_page"
>
{ sprintf(
/* translators: 1: Yoast SEO. */
Expand All @@ -51,6 +52,7 @@ export default function FinishStep() {
<Link
id="link-webinar-register"
onClick={ goToSEODashboard }
data-hiive-event-name="clicked_seo_dashboard"
>
{ __( "Or go to your SEO dashboard", "wordpress-seo" ) }
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class Indexation extends Component {
className="yst-button yst-button--secondary"
onClick={ this.startIndexing }
id="indexation-data-optimization"
data-hiive-event-name="clicked_start_data_optimization"
>
{ __( "Start SEO data optimization", "wordpress-seo" ) }
</button>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function NewsletterSignup( { gdprLink } ) {
className="yst-button yst-button--primary yst-h-[45px] yst-items-center yst-mt-[27.5px] yst-shrink-0"
onClick={ onSignUpClick }
disabled={ signUpState === "loading" }
data-hiive-event-name="clicked_signup | personal preferences"
>
{ __( "Sign up!", "wordpress-seo" ) }
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const SocialFieldArray = ( { items, onAddProfile, onRemoveProfile, onChangeProfi
id="add-profile"
className="yst-button yst-button--secondary yst-items-center yst-mt-8"
onClick={ onAddProfile }
data-hiive-event-name="clicked_add_profile"
>
<PlusIcon className="yst-w-5 yst-h-5 yst-mr-1 yst-text-slate-400" />
{ addButtonChildren }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ export default function SocialProfilesStep( { state, dispatch, setErrorFields }
"</a>"

),
{ // eslint-disable-next-line jsx-a11y/anchor-has-content
{ // eslint-disable-next-line jsx-a11y/anchor-has-content
a: <a
id="yoast-configuration-person-social-profiles-user-link"
href={ window.wpseoScriptData.userEditUrl.replace( "{user_id}", state.personId ) }
target="_blank" rel="noopener noreferrer"
data-hiive-event-name="clicked_update_or_add_profile | social profiles"
pls78 marked this conversation as resolved.
Show resolved Hide resolved
/>,
} );

Expand Down
8 changes: 7 additions & 1 deletion packages/js/src/installation-success.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function InstallationSuccessPage() {
id="installation-successful-configuration-link"
href={ window.wpseoInstallationSuccess.firstTimeConfigurationUrl }
className="yst-inline-flex yst-items-center yst-w-full yst-justify-center yst-no-underline yst-px-6 yst-py-3 yst-border yst-border-transparent yst-text-base yst-font-medium yst-rounded-md yst-shadow-none yst-text-primary-500 yst-bg-white hover:yst-bg-gray-50 focus:yst-outline-none focus:yst-ring-2 focus:yst-ring-offset-2 focus:yst-ring-white yst-ring-offset-2 yst-ring-offset-primary-500"
data-hiive-event-name="clicked_start_first_time_configuration"
>
{ __( "Start first-time configuration!", "wordpress-seo" ) }
<svg
Expand All @@ -117,7 +118,12 @@ function InstallationSuccessPage() {
</a>
</div>
</div>
<a id="installation-success-skip-link" className="yst-bottom-12 yst-right-0 yst-mr-5 yst-self-end yst-text-base md:yst-absolute" href={ "/wp-admin/admin.php?page=wpseo_dashboard" }>
<a
id="installation-success-skip-link"
className="yst-bottom-12 yst-right-0 yst-mr-5 yst-self-end yst-text-base md:yst-absolute"
href={ "/wp-admin/admin.php?page=wpseo_dashboard" }
data-hiive-event-name="clicked_skip_button | installation successful screen"
pls78 marked this conversation as resolved.
Show resolved Hide resolved
>
{
/* translators: %s expands to ' »'. */
sprintf( __( "Skip%s", "wordpress-seo" ), " »" )
pls78 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading
Loading