Skip to content

Commit

Permalink
Update RRM SettingsEdit to handle missing ID error.
Browse files Browse the repository at this point in the history
  • Loading branch information
juniovitorino committed Feb 13, 2025
1 parent 91fb322 commit c00ba9d
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ import SettingsNotice, {
TYPE_INFO,
} from '../../../../components/SettingsNotice';
import WarningIcon from '../../../../../../assets/svg/icons/warning-icon.svg';
import StoreErrorNotices from '../../../../components/StoreErrorNotices';

export default function SettingsEdit() {
const isRRMv2Enabled = useFeature( 'rrmModuleV2' );

const productIDs = useSelect( ( select ) => {
return select( MODULES_READER_REVENUE_MANAGER ).getProductIDs();
} );

const isDoingSubmitChanges = useSelect( ( select ) =>
select( MODULES_READER_REVENUE_MANAGER ).isDoingSubmitChanges()
);

const hasModuleAccess = useSelect( ( select ) => {
const { hasModuleOwnershipOrAccess, getErrorForAction } =
select( CORE_MODULES );
Expand Down Expand Up @@ -83,9 +89,15 @@ export default function SettingsEdit() {

return false;
} );

const publicationID = useSelect( ( select ) =>
select( MODULES_READER_REVENUE_MANAGER ).getPublicationID()
);

const isCurrentProductMissing = productIDs
? ! productIDs.includes( publicationID )
: true;

const publicationAvailable = useSelect( ( select ) => {
if ( hasModuleAccess === undefined ) {
return undefined;
Expand Down Expand Up @@ -128,6 +140,11 @@ export default function SettingsEdit() {
return (
<div className="googlesitekit-setup-module googlesitekit-setup-module--reader-revenue-manager googlesitekit-rrm-settings-edit">
<div className="googlesitekit-settings-module__fields-group">
<StoreErrorNotices
moduleSlug={ READER_REVENUE_MANAGER_MODULE_SLUG }
storeName={ MODULES_READER_REVENUE_MANAGER }
/>

{ hasModuleAccess && false === publicationAvailable && (
<ErrorText
message={ sprintf(
Expand All @@ -140,6 +157,22 @@ export default function SettingsEdit() {
) }
/>
) }
{ isRRMv2Enabled &&
hasModuleAccess &&
publicationAvailable &&
isCurrentProductMissing && (
<ErrorText
message={ sprintf(
/* translators: 1: Publication ID. */
__(
'The previously selected product ID %s was not found. Please select a new product ID.',
'google-site-kit'
),
publicationID
) }
/>
) }

<div className="googlesitekit-setup-module__inputs">
<PublicationSelect hasModuleAccess={ hasModuleAccess } />
</div>
Expand Down

0 comments on commit c00ba9d

Please sign in to comment.