-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ngs-setup-cta Implement audience settings setup CTA
- Loading branch information
Showing
19 changed files
with
1,077 additions
and
105 deletions.
There are no files selected for viewing
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
77 changes: 77 additions & 0 deletions
77
...alytics-4/components/audience-segmentation/settings/SettingsCardVisitorGroups/SetupCTA.js
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,77 @@ | ||
/** | ||
* SettingsCardVisitorGroups SetupCTA component. | ||
* | ||
* Site Kit by Google, Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { AUDIENCE_SEGMENTATION_SETUP_CTA_NOTIFICATION } from '../../dashboard/AudienceSegmentationSetupCTAWidget'; | ||
import { AUDIENCE_SEGMENTATION_SETUP_SUCCESS_NOTIFICATION } from '../../dashboard/AudienceSegmentationSetupSuccessSubtleNotification'; | ||
import { CORE_USER } from '../../../../../../googlesitekit/datastore/user/constants'; | ||
import { useDispatch, useSelect } from 'googlesitekit-data'; | ||
import useEnableAudienceGroup from '../../../../hooks/useEnableAudienceGroup'; | ||
import { ProgressBar } from 'googlesitekit-components'; | ||
import Link from '../../../../../../components/Link'; | ||
|
||
export default function SetupCTA() { | ||
const { dismissItem } = useDispatch( CORE_USER ); | ||
|
||
const { isSaving, onEnableGroups } = useEnableAudienceGroup( { | ||
redirectURL: global.location.href, | ||
onSuccess: () => { | ||
// Dismiss success notification in dashboard. | ||
dismissItem( AUDIENCE_SEGMENTATION_SETUP_SUCCESS_NOTIFICATION ); | ||
}, | ||
} ); | ||
|
||
const isDismissed = useSelect( ( select ) => | ||
select( CORE_USER ).isPromptDismissed( | ||
AUDIENCE_SEGMENTATION_SETUP_CTA_NOTIFICATION | ||
) | ||
); | ||
|
||
if ( isDismissed === undefined || isDismissed ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="googlesitekit-settings-visitor-groups__setup"> | ||
<p> | ||
{ __( | ||
'To set up new visitor groups for your site, Site Kit needs to update your Google Analytics property.', | ||
'google-site-kit' | ||
) } | ||
</p> | ||
{ isSaving && ( | ||
<div className="googlesitekit-settings-visitor-groups__setup-progress"> | ||
<p>{ __( 'Enabling groups', 'google-site-kit' ) }</p> | ||
<ProgressBar compress /> | ||
</div> | ||
) } | ||
{ ! isSaving && ( | ||
<Link onClick={ onEnableGroups }> | ||
{ __( 'Enable groups', 'google-site-kit' ) } | ||
</Link> | ||
) } | ||
</div> | ||
); | ||
} |
Oops, something went wrong.