From 3792f1d7edbfb9d417459b8b4f777206a7b3ec8b Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 21 May 2024 13:54:34 -0400 Subject: [PATCH] MM-52219 Add announcement bar to prompt users for notification permission (#26849) * MM-52219 Add announcement bar to prompt users for notification permission * Update i18n strings * Only show NotificationPermissionsBar when logged in * Update text * Remove z-index from AnnouncementBar --------- Co-authored-by: Mattermost Build --- .../announcement_bar_controller.tsx | 2 + .../notification_permission_bar/index.tsx | 57 +++++++++++++++++++ webapp/channels/src/i18n/en.json | 2 + .../sass/components/_announcement-bar.scss | 1 - 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 webapp/channels/src/components/announcement_bar/notification_permission_bar/index.tsx diff --git a/webapp/channels/src/components/announcement_bar/announcement_bar_controller.tsx b/webapp/channels/src/components/announcement_bar/announcement_bar_controller.tsx index 6609d43d81..2072732385 100644 --- a/webapp/channels/src/components/announcement_bar/announcement_bar_controller.tsx +++ b/webapp/channels/src/components/announcement_bar/announcement_bar_controller.tsx @@ -12,6 +12,7 @@ import CloudTrialAnnouncementBar from './cloud_trial_announcement_bar'; import CloudTrialEndAnnouncementBar from './cloud_trial_ended_announcement_bar'; import ConfigurationAnnouncementBar from './configuration_bar'; import AnnouncementBar from './default_announcement_bar'; +import NotificationPermissionBar from './notification_permission_bar'; import OverageUsersBanner from './overage_users_banner'; import PaymentAnnouncementBar from './payment_announcement_bar'; import AutoStartTrialModal from './show_start_trial_modal/show_start_trial_modal'; @@ -99,6 +100,7 @@ class AnnouncementBarController extends React.PureComponent { // Even if all Foo, Bar and Baz render, only Baz is visible as it's further down. return ( <> + {adminConfiguredAnnouncementBar} {errorBar} { + // If the user closes the bar, don't show the notification bar any more for the rest of the session, but + // show it again after refresh. + setShow(false); + }, []); + + const handleClick = useCallback(() => { + Notification.requestPermission().then(() => { + setShow(false); + }); + }, []); + + if (!show || !isLoggedIn) { + return null; + } + + return ( + + } + ctaText={ + + } + showCTA={true} + showLinkAsButton={true} + onButtonClick={handleClick} + /> + ); +} diff --git a/webapp/channels/src/i18n/en.json b/webapp/channels/src/i18n/en.json index d25541720c..2e454d0337 100644 --- a/webapp/channels/src/i18n/en.json +++ b/webapp/channels/src/i18n/en.json @@ -2797,6 +2797,8 @@ "announcement_bar.error.trial_license_expiring_last_day": "This is the last day of your free trial. Purchase a license now to continue using Mattermost Professional and Enterprise features.", "announcement_bar.error.trial_license_expiring_last_day.short": "This is the last day of your free trial.", "announcement_bar.notification.email_verified": "Email verified", + "announcement_bar.notification.enable_notifications": "Enable notifications", + "announcement_bar.notification.needs_permisson": "We need your permission to show desktop notifications.", "announcement_bar.warn.contact_support_text": "To renew your license, contact support at support@mattermost.com.", "announcement_bar.warn.email_support": "[Contact support](!{email}).", "announcement_bar.warn.no_internet_connection": "Looks like you do not have access to the internet.", diff --git a/webapp/channels/src/sass/components/_announcement-bar.scss b/webapp/channels/src/sass/components/_announcement-bar.scss index e2addc6cbb..e3139f6aca 100644 --- a/webapp/channels/src/sass/components/_announcement-bar.scss +++ b/webapp/channels/src/sass/components/_announcement-bar.scss @@ -1,7 +1,6 @@ @charset 'UTF-8'; .announcement-bar { - z-index: 999; display: flex; overflow: hidden; width: 100vw;