Show Admin Notifications in Activity Center (#14748)

* [Feature][#14713] Added Admin Notifications in Activity Center

* [Feature][#14713] Admin Notification UI fixes

* [Feature][#14713] Admin Notification PR Feedbacks

* [Feature][#14713] Admin Notification PR Feedbacks

* [Feature][#14713] Admin Notification accessiblity label update
This commit is contained in:
Mohamed Javid 2023-01-13 23:44:02 +05:30 committed by GitHub
parent 64ec49c9c4
commit 2f52cb1f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 3 deletions

View File

@ -40,7 +40,9 @@
(set/rename-keys {:lastMessage :last-message
:replyMessage :reply-message
:chatId :chat-id
:contactVerificationStatus :contact-verification-status})
:contactVerificationStatus :contact-verification-status
:communityId :community-id
:membershipStatus :membership-status})
(update :last-message #(when % (messages/<-rpc %)))
(update :message #(when % (messages/<-rpc %)))
(update :reply-message #(when % (messages/<-rpc %)))

View File

@ -31,6 +31,11 @@
(def ^:const contact-verification-status-trusted 5)
(def ^:const contact-verification-status-untrustworthy 6)
(def ^:const activity-center-membership-status-idle 0)
(def ^:const activity-center-membership-status-pending 1)
(def ^:const activity-center-membership-status-accepted 2)
(def ^:const activity-center-membership-status-declined 3)
(def ^:const emoji-reaction-love 1)
(def ^:const emoji-reaction-thumbs-up 2)
(def ^:const emoji-reaction-thumbs-down 3)

View File

@ -0,0 +1,55 @@
(ns status-im2.contexts.activity-center.notification.admin.view
(:require [i18n.i18n :as i18n]
[quo2.core :as quo]
[quo2.foundations.colors :as colors]
[status-im2.common.constants :as constants]
[status-im2.contexts.activity-center.notification.common.style :as style]
[status-im2.contexts.activity-center.notification.common.view :as common]
[utils.datetime :as datetime]
[utils.re-frame :as rf]))
(defn view
[{:keys [author community-id id membership-status read timestamp]}]
(let [community (rf/sub [:communities/community community-id])
community-name (:name community)
community-image (get-in community [:images :thumbnail :uri])]
[quo/activity-log
(merge
{:title (i18n/label :t/join-request)
:icon :i/add-user
:timestamp (datetime/timestamp->relative timestamp)
:unread? (not read)
:context [[common/user-avatar-tag author]
(i18n/label :t/wants-to-join)
[quo/context-tag
{:size :small
:override-theme :dark
:color colors/primary-50
:style style/user-avatar-tag
:text-style style/user-avatar-tag-text}
{:uri community-image} community-name]]
:status (case membership-status
constants/activity-center-membership-status-accepted
{:type :positive :label (i18n/label :t/accepted)}
constants/activity-center-membership-status-declined
{:type :negative :label (i18n/label :t/declined)}
nil)}
(case membership-status
constants/activity-center-membership-status-pending
{:button-1 {:label (i18n/label :t/decline)
:accessibility-label :decline-join-request
:type :danger
:on-press (fn []
(rf/dispatch [:communities.ui/decline-request-to-join-pressed
community-id id])
(rf/dispatch [:activity-center.notifications/mark-as-read
id]))}
:button-2 {:label (i18n/label :t/accept)
:accessibility-label :accept-join-request
:type :positive
:on-press (fn []
(rf/dispatch [:communities.ui/accept-request-to-join-pressed
community-id id])
(rf/dispatch [:activity-center.notifications/mark-as-read
id]))}}
nil))]))

View File

@ -6,10 +6,10 @@
(def ^:const mention 3)
(def ^:const reply 4)
(def ^:const contact-request 5)
(def ^:const admin 8)
(def ^:const contact-verification 10)
;; TODO: Replace with correct enum values once status-go implements them.
(def ^:const admin 66610)
(def ^:const tx 66612)
(def ^:const membership 66613)
(def ^:const system 66614)

View File

@ -5,6 +5,7 @@
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im2.contexts.activity-center.notification-types :as types]
[status-im2.contexts.activity-center.notification.admin.view :as admin]
[status-im2.contexts.activity-center.notification.contact-request.view :as contact-request]
[status-im2.contexts.activity-center.notification.contact-verification.view :as
contact-verification]
@ -112,6 +113,9 @@
types/reply
[reply/view notification]
types/admin
[admin/view notification]
nil)])
(defn view

View File

@ -1939,5 +1939,7 @@
"selected-count-from-max": "{{selected}}/{{max}}",
"online": "Online",
"contact-request-chat-pending": "Your contact request is pending",
"contact-request-chat-add": "Add {{name}} to send a message"
"contact-request-chat-add": "Add {{name}} to send a message",
"join-request": "Join request",
"wants-to-join": "wants to join"
}