Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3512083
D6820.id23061.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6820.id23061.diff
View Options
diff --git a/web/modals/push-notif-modal.css b/web/modals/push-notif-modal.css
new file mode 100644
--- /dev/null
+++ b/web/modals/push-notif-modal.css
@@ -0,0 +1,14 @@
+.container {
+ padding: 0 40px 32px;
+ border-radius: 8px;
+ color: var(--modal-fg);
+}
+.text {
+ font-size: var(--xl-font-20);
+ padding: 5px 0px 20px;
+}
+.buttonContainer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 24px;
+}
diff --git a/web/modals/push-notif-modal.react.js b/web/modals/push-notif-modal.react.js
new file mode 100644
--- /dev/null
+++ b/web/modals/push-notif-modal.react.js
@@ -0,0 +1,57 @@
+// @flow
+
+import * as React from 'react';
+
+import { useModalContext } from 'lib/components/modal-provider.react.js';
+
+import Modal from './modal.react.js';
+import css from './push-notif-modal.css';
+import Button from '../components/button.react.js';
+import { useCreatePushSubscription } from '../push-notif/push-notifs-handler.js';
+
+const PushNotifModal: React.ComponentType<{}> = React.memo(
+ function PushNotifModal(): React.Node {
+ const { popModal } = useModalContext();
+
+ const createPushSubscription = useCreatePushSubscription();
+
+ const onEnable = React.useCallback(async () => {
+ popModal();
+
+ if (Notification.permission !== 'granted') {
+ const permissionResult = await Notification.requestPermission();
+ if (permissionResult !== 'granted') {
+ return;
+ }
+ }
+
+ await createPushSubscription();
+ }, [createPushSubscription, popModal]);
+
+ return (
+ <Modal
+ size="fit-content"
+ name="Notifications"
+ icon="bell"
+ withCloseButton={false}
+ onClose={popModal}
+ >
+ <div className={css.container}>
+ <p className={css.text}>
+ Would you like to enable push notifications?
+ </p>
+ <div className={css.buttonContainer}>
+ <Button variant="outline" onClick={popModal}>
+ No
+ </Button>
+ <Button variant="filled" onClick={onEnable} type="submit">
+ Yes
+ </Button>
+ </div>
+ </div>
+ </Modal>
+ );
+ },
+);
+
+export { PushNotifModal };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 6:03 PM (18 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692069
Default Alt Text
D6820.id23061.diff (2 KB)
Attached To
Mode
D6820: [web] Add notification permission modal
Attached
Detach File
Event Timeline
Log In to Comment