Skip to content

Commit

Permalink
Use enum for ad blocking recovery setup steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
nfmohit committed Jun 22, 2023
1 parent 865ac05 commit 4221b6a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { CORE_SITE } from '../../../../../googlesitekit/datastore/site/constants
import {
AD_BLOCKING_RECOVERY_SETUP_CREATE_MESSAGE_CTA_CLICKED,
ENUM_AD_BLOCKING_RECOVERY_SETUP_STATUS,
ENUM_AD_BLOCKING_RECOVERY_SETUP_STEP,
MODULES_ADSENSE,
} from '../../../datastore/constants';
import { CORE_UI } from '../../../../../googlesitekit/datastore/ui/constants';
Expand Down Expand Up @@ -65,11 +66,11 @@ export default function SetupMain() {

switch ( adBlockingRecoverySetupStatus ) {
case '':
return 0;
return ENUM_AD_BLOCKING_RECOVERY_SETUP_STEP.PLACE_TAGS;
case ENUM_AD_BLOCKING_RECOVERY_SETUP_STATUS.TAG_PLACED:
return 1;
return ENUM_AD_BLOCKING_RECOVERY_SETUP_STEP.CREATE_MESSAGE;
case ENUM_AD_BLOCKING_RECOVERY_SETUP_STATUS.SETUP_CONFIRMED:
return 2;
return ENUM_AD_BLOCKING_RECOVERY_SETUP_STEP.COMPLETE;
}
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Data from 'googlesitekit-data';
import { Checkbox, SpinnerButton } from 'googlesitekit-components';
import {
ENUM_AD_BLOCKING_RECOVERY_SETUP_STATUS,
ENUM_AD_BLOCKING_RECOVERY_SETUP_STEP,
MODULES_ADSENSE,
} from '../../../../datastore/constants';
const { useSelect, useDispatch } = Data;
Expand Down Expand Up @@ -73,7 +74,9 @@ export default function PlaceTagsStep( { setActiveStep } ) {
const { error } = await saveSettings();

if ( ! error ) {
setActiveStep( 1 );
setActiveStep(
ENUM_AD_BLOCKING_RECOVERY_SETUP_STEP.CREATE_MESSAGE
);
}
}, [
saveSettings,
Expand Down
7 changes: 7 additions & 0 deletions assets/js/modules/adsense/datastore/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ export const ENUM_AD_BLOCKING_RECOVERY_SETUP_STATUS = {
TAG_PLACED: 'tag-placed',
SETUP_CONFIRMED: 'setup-confirmed',
};

// Zero-based index of the available ad blocking recovery setup steps.
export const ENUM_AD_BLOCKING_RECOVERY_SETUP_STEP = {
PLACE_TAGS: 0,
CREATE_MESSAGE: 1,
COMPLETE: 2,
};

0 comments on commit 4221b6a

Please sign in to comment.