-
Notifications
You must be signed in to change notification settings - Fork 286
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
Enhancement/8981 Refactor RRM Setup Success Notification #9367
base: develop
Are you sure you want to change the base?
Changes from all commits
3cd8bb8
fd98e95
dedf402
b79d4d7
bb6c8ad
69410c9
d009d06
4f12f9f
e90e228
5a2af0f
81fca07
427d080
d226224
7349a9f
cfa1191
8b11d79
0ee7585
8d1bc10
5428eb1
edfadd9
71bc135
3ad16ee
efedf0d
bbd619b
a19e6fd
523770f
5fe4d30
d0c48cf
478701c
31d0654
cff9f4c
a5282c3
541ad91
f54affb
339fd10
5b4fe9a
b835233
9c0e918
e6a961b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,83 @@ | ||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||
* 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. | ||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||
* External dependencies | ||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||
import PropTypes from 'prop-types'; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||
* Internal dependencies | ||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||
import { useDispatch } from 'googlesitekit-data'; | ||||||||||||||||||||||||||||||||||||||||
import { CORE_LOCATION } from '../../../datastore/location/constants'; | ||||||||||||||||||||||||||||||||||||||||
import useNotificationEvents from '../../hooks/useNotificationEvents'; | ||||||||||||||||||||||||||||||||||||||||
import { Button } from 'googlesitekit-components'; | ||||||||||||||||||||||||||||||||||||||||
import ExternalSVG from '../../../../../svg/icons/external.svg'; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
export default function CTALinkSubtle( { | ||||||||||||||||||||||||||||||||||||||||
id, | ||||||||||||||||||||||||||||||||||||||||
ctaLink, | ||||||||||||||||||||||||||||||||||||||||
ctaLabel, | ||||||||||||||||||||||||||||||||||||||||
onCTAClick, | ||||||||||||||||||||||||||||||||||||||||
isCTALinkExternal = false, | ||||||||||||||||||||||||||||||||||||||||
gaConfirmEventLabel, | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thoughts as |
||||||||||||||||||||||||||||||||||||||||
} ) { | ||||||||||||||||||||||||||||||||||||||||
const trackEvents = useNotificationEvents( id ); | ||||||||||||||||||||||||||||||||||||||||
const { navigateTo } = useDispatch( CORE_LOCATION ); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
const handleCTAClick = async ( event ) => { | ||||||||||||||||||||||||||||||||||||||||
if ( ! event.defaultPrevented ) { | ||||||||||||||||||||||||||||||||||||||||
event.preventDefault(); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
await onCTAClick?.( event ); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
await trackEvents.confirm( gaConfirmEventLabel ); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
if ( isCTALinkExternal ) { | ||||||||||||||||||||||||||||||||||||||||
global.open( ctaLink, '_blank' ); | ||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||
navigateTo( ctaLink ); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+42
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd vote to keep this natural, as
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||
<Button | ||||||||||||||||||||||||||||||||||||||||
className="googlesitekit-subtle-notification__cta" | ||||||||||||||||||||||||||||||||||||||||
href={ ctaLink } | ||||||||||||||||||||||||||||||||||||||||
onClick={ handleCTAClick } | ||||||||||||||||||||||||||||||||||||||||
target={ isCTALinkExternal ? '_blank' : '_self' } | ||||||||||||||||||||||||||||||||||||||||
trailingIcon={ | ||||||||||||||||||||||||||||||||||||||||
isCTALinkExternal ? ( | ||||||||||||||||||||||||||||||||||||||||
<ExternalSVG width={ 14 } height={ 14 } /> | ||||||||||||||||||||||||||||||||||||||||
) : undefined | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||
{ ctaLabel } | ||||||||||||||||||||||||||||||||||||||||
</Button> | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
// eslint-disable-next-line sitekit/acronym-case | ||||||||||||||||||||||||||||||||||||||||
CTALinkSubtle.propTypes = { | ||||||||||||||||||||||||||||||||||||||||
id: PropTypes.string, | ||||||||||||||||||||||||||||||||||||||||
ctaLink: PropTypes.string, | ||||||||||||||||||||||||||||||||||||||||
ctaLabel: PropTypes.string, | ||||||||||||||||||||||||||||||||||||||||
onCTAClick: PropTypes.func, | ||||||||||||||||||||||||||||||||||||||||
isCTALinkExternal: PropTypes.bool, | ||||||||||||||||||||||||||||||||||||||||
gaConfirmEventLabel: PropTypes.string, | ||||||||||||||||||||||||||||||||||||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,11 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -34,14 +39,15 @@ export default function Dismiss( { | |
dismissExpires = 0, | ||
disabled, | ||
onDismiss = () => {}, | ||
gaDismissEventLabel, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thoughts as |
||
} ) { | ||
const trackEvents = useNotificationEvents( id ); | ||
|
||
const { dismissNotification } = useDispatch( CORE_NOTIFICATIONS ); | ||
|
||
const handleDismiss = async ( event ) => { | ||
await onDismiss?.( event ); | ||
trackEvents.dismiss(); | ||
trackEvents.dismiss( gaDismissEventLabel ); | ||
dismissNotification( id, { expiresInSeconds: dismissExpires } ); | ||
}; | ||
|
||
|
@@ -55,3 +61,13 @@ export default function Dismiss( { | |
</Button> | ||
); | ||
} | ||
|
||
Dismiss.propTypes = { | ||
id: PropTypes.string, | ||
primary: PropTypes.bool, | ||
dismissLabel: PropTypes.string, | ||
dismissExpires: PropTypes.number, | ||
disabled: PropTypes.bool, | ||
onDismiss: PropTypes.func, | ||
gaDismissEventLabel: PropTypes.string, | ||
}; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This component has a few styling discrepancies when compared to its predecessor Item 1The Original This Item 2In smaller viewports, the positioning of buttons does not match the designs. Original This Could we update these to match? Thanks! |
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.
One question regarding this
gaViewEventLabel
prop: Looking at thetrackEvent
function, it also supports an additionalvalue
parameter:site-kit-wp/assets/js/util/tracking/createTrackEvent.js
Line 37 in 14545e4
Instead of accepting a
gaViewEventLabel
prop here, what if we received an array prop, saygaEventArgs
, and spread that in the function, e.g.trackEvents.view( ...gaEventArgs )
?This will ensure that this mechanism is future proof and we do not need to make any changes in case an event also requires the
value
parameter.What do you think?