-
Notifications
You must be signed in to change notification settings - Fork 330
Closed
Labels
P0High priorityHigh priorityTeam SIssues for Squad 1Issues for Squad 1Type: EnhancementImprovement of an existing featureImprovement of an existing feature
Description
Feature Description
We need to add a new SelectionPanel to the proactive user notification namespace. This panel should wrap the base SideSheet component and will contain other components related to the user's email reporting settings.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- New
UserSettingsSelectionPanelcomponent is added inassets/js/components/proactive-user-engagement/, implementing aSelectionPanel. - This component will handle the retrieval and storage of user-level settings.
- The component will consist of the following sections:
- Header - displays title line
Email reports subscriptionand subheadingYou can always deactivate this feature in Settings - Content: Includes a brief note, "You'll receive the report to your WordPress user email," and dynamically displays the user's email address (e.g.,
[email protected]) as portrayed in Figma.- The user's WordPress account email will be used.
FrequencySelectorComponent: This nested component will receive the retrieved frequency settings and the settings saving callback function as props.- Footer: Displays a static description, "This email is generated by Site Kit using data from your dashboard and sent to your WordPress email, so all your data stays with you." and surfaces error/success notifications when actions (like subscribing) are triggered.
- Header - displays title line
- Invite others to subscribe section can be ignored as it is not going to be implemented in this phase
- Also, notification area will be implemented in separate issue (together with notification types)
- Appropriate tests and stories (with only main panel VRT included) are added
- A new UI state will be defined to control the opening and closing of the selection panel. The panel's opening action will be triggered by menu item implemented in Update plugin user menu and add email reports link #11423.
- The UI state value will be retrieved in the main entry point component, which wraps the new SelectionPanel with an
InViewProviderto manage its opening state. - New Selection Panel is wired in
assets/js/components/DashboardMainApp.jswhenproactiveUserEngagementfeature flag is enabled
Implementation Brief
You can check KMW selection panel for some additional examples
- Add
assets/js/components/proactive-user-engagement/constants.js- Define a new dedicated UI key constant, say
USER_SETTINGS_SELECTION_PANEL_OPENED_KEY
- Define a new dedicated UI key constant, say
Add assets/js/components/proactive-user-engagement/UserSettingsSelectionPanel/Header.js
- Return
SelectionPanelHeaderas child component with following props:title- "Email reports subscription"- children - Conditionally include
Pcomponent (js/components/Typography/P) when not in view only context, with contentYou can always deactivate this feature in Settings,Settingsshould link to the admin settings screen
Add assets/js/components/proactive-user-engagement/UserSettingsSelectionPanel/Footer.js
- It should accept prop
noticeof type object, in formatnotice.text- string,notice.type- string enuminfo|success|error - It should accept
onNoticeDismissprop callback - Conditionally render
Noticecomponent (assets/js/components/Notice/index.js) whennoticeprop is passed, and map the props -type={notice.type}, anddescription={notice.text}- Include
dismissButtonprop withlabel"Got it" andonClickinvokeonNoticeDismissprop callback
- Include
- Or
Pcomponent with contentThis email is generated by Site Kit using data from your dashboard and sent to your WordPress email, so all your data stays with youif notice prop is not passed
Add assets/js/components/proactive-user-engagement/UserSettingsSelectionPanel/PanelContent.js
- It should accept following props:
savedFrequency,noticeobject, andonUnsubscribeandonSaveCallbackfunctions - Output components/markup in following order:
Header- Explanatory copy "You'll receive the report to your WordPress user email," plus dynamic user email extracted from
getUser()selector ofCORE_USERdatastore. FrequencySelectorcomponent implemented in Implement the '<FrequencySelector>' component #11155, and passonSaveCallbackcallback andsavedFrequencyFootercomponent, passnoticeprop, andonNoticeDismisscallback
Add assets/js/components/proactive-user-engagement/UserSettingsSelectionPanel/index.js
- When retrieving the settings, include
isOpencheck, so settings are fetched when panel is open - Define/track local state for notice data
- Include
onSaveCallbackcallback:- It should include an argument -
settingto be saved. - Invoke
saveProactiveUserEngagementSettingsaction fromCORE_USERdatastore - If there is no error in saving, set success type notice with text from Figma to the local state
- If there is an error, set error type notice, with content extracted from error object
- It should include an argument -
- Include
onUnsubscribecallback- Invoke
saveProactiveUserEngagementSettingsaction fromCORE_USERdatastore and passsubscribedsetting with valuefalse - If there is no error in saving, set info type notice with text from Figma to the local state
- If there is an error, set error type notice, with content extracted from error object
- Invoke
- Include
onNoticeDismisscallback, which resets thenoticelocal state to null or empty object - Return newly created
PanelContentwrapped withSelectionPanelgeneral component (assets/js/components/SelectionPanel)- Pass
isOpento theSelectionPanel, checking the value from new UI key - Pass
onSaveCallback, localnoticestate, retrieve saved frequency from the settings and pass it assavedFrequencyandonUnsubscribeandonNoticeDismisscallbacks to thePanelContent
- Pass
- Wire new selection panel to the main and entity dashboards, as well as admin settings screen when
proactiveUserEngagementfeature flag is enabled
Test Coverage
- Add jest test coverage, verifying different content between view only and admin view, and mock settings saving to verify info|success|error notices showing
- Add basic stories, displaying component in full view for admin and view only users, and save their respective VRT's
QA Brief
- Enable
proactiveUserEngagementfeature flag - Visit Site Kit dashboard and under user menu click on
Manage email reports - When Panel opens, verify that:
- By default when user is not subscribed - default
weeklyfrequency is pre-selected but not showing green tick - Clicking
SubscribeCTA disabled the CTA, showing the spinner - upon saving notice is shown in the footer, and tertiaryUnsubscribeCTA shows next to theSubscribeCTA- Selected frequency that was selected is now showing a green tick
- Clicking
UnsubscribeCTA disables both buttons and shows spinner onUnsubscribe- upon unsubscribing green tick is removed from saved frequency and onlySubscribeCTA is shown
- By default when user is not subscribed - default
- Choose different frequency - close the panel, and re-open it
- Verify that settings were reset - default
Weeklyfrequency should be pre-selected again
- Verify that settings were reset - default
- Verify that selection panel matches Figma (minus the invite users list - this is for. phase 1)
- Same should work for view-only users
Changelog entry
- Add the email reporting settings selection panel.
Metadata
Metadata
Assignees
Labels
P0High priorityHigh priorityTeam SIssues for Squad 1Issues for Squad 1Type: EnhancementImprovement of an existing featureImprovement of an existing feature