-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Reader: Update action button link of an empty list of a user profile #98706
base: trunk
Are you sure you want to change the base?
Changes from 4 commits
6140385
6a41d2c
ac8eff3
f91cb69
376a54f
1249bb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { useTranslate } from 'i18n-calypso'; | ||
import EmptyContent from 'calypso/components/empty-content'; | ||
import { recordAction, recordGaEvent } from 'calypso/reader/stats'; | ||
import { useDispatch } from 'calypso/state'; | ||
import { recordReaderTracksEvent } from 'calypso/state/reader/analytics/actions'; | ||
|
||
export default function ListEmptyContent(): JSX.Element { | ||
const dispatch = useDispatch(); | ||
const translate = useTranslate(); | ||
const queryParams = new URLSearchParams( location.search ); | ||
const lastPageLink = queryParams.get( 'last_page' ) ?? ''; | ||
|
||
function onClickActionBtn(): void { | ||
if ( lastPageLink ) { | ||
return; | ||
} | ||
|
||
recordAction( 'clicked_following_on_empty' ); | ||
recordGaEvent( 'Clicked Following on EmptyContent' ); | ||
dispatch( recordReaderTracksEvent( 'calypso_reader_following_on_empty_list_stream_clicked' ) ); | ||
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. It looks like we are avoiding firing the events around clicking for the following feed. I wonder if there is any value to these types of events, and if we should consider sending separate ones in the case of profile (or alternatively removing them all if not valuable). 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 also thought of removing this. Let me know if we need to remove this. For now I am just removing the 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. Addressed in 376a54f |
||
} | ||
|
||
function lastPageIsUserProfileLists(): boolean { | ||
return /^\/read\/users\/[a-z0-9]+\/lists$/.test( lastPageLink ); | ||
} | ||
|
||
function getActionBtnLink(): string { | ||
return lastPageIsUserProfileLists() ? encodeURIComponent( lastPageLink ) : '/read'; | ||
} | ||
|
||
function getActionBtnText(): string { | ||
return lastPageIsUserProfileLists() | ||
? translate( 'Back to User Profile' ) | ||
: translate( 'Back to Following' ); | ||
} | ||
|
||
const action = ( | ||
<a | ||
className="empty-content__action button is-primary" | ||
onClick={ onClickActionBtn } | ||
href={ getActionBtnLink() } | ||
|
||
> | ||
{ getActionBtnText() } | ||
</a> | ||
); | ||
|
||
return ( | ||
<EmptyContent | ||
title={ translate( 'No recent posts' ) } | ||
line={ translate( 'The sites in this list have not posted anything recently.' ) } | ||
action={ action } | ||
illustration="/calypso/images/illustrations/illustration-empty-results.svg" | ||
illustrationWidth={ 400 } | ||
/> | ||
); | ||
} |
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.
Can we pull this out of the URL and avoid keeping extra query params in the URL? We could probably look for the value on mount, remove it from the url, and use that initial info for the text/href.
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.
I avoided it because it will create a new entry in the browser history.