logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: b65a89c8225289708fc0e97f3c2cbe66511473cb
parent 25e628efe265db583797fe1c10fdcab2f0d9cc9d
Author: tusooa <tusooa@kazv.moe>
Date:   Sat, 24 Dec 2022 12:17:09 -0500

Make announcements available to all with privileges

Diffstat:

Msrc/components/announcement/announcement.js3+++
Msrc/components/announcement/announcement.vue4++--
Msrc/components/announcements_page/announcements_page.js3+++
Msrc/components/announcements_page/announcements_page.vue2+-
Msrc/modules/announcements.js2+-
5 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/components/announcement/announcement.js b/src/components/announcement/announcement.js @@ -27,6 +27,9 @@ const Announcement = { ...mapState({ currentUser: state => state.users.currentUser }), + canEditAnnouncement () { + return this.currentUser && this.currentUser.privileges.includes('announcements_manage_announcements') + }, content () { return this.announcement.content }, diff --git a/src/components/announcement/announcement.vue b/src/components/announcement/announcement.vue @@ -45,14 +45,14 @@ {{ $t('announcements.mark_as_read_action') }} </button> <button - v-if="currentUser && currentUser.role === 'admin'" + v-if="canEditAnnouncement" class="btn button-default" @click="enterEditMode" > {{ $t('announcements.edit_action') }} </button> <button - v-if="currentUser && currentUser.role === 'admin'" + v-if="canEditAnnouncement" class="btn button-default" @click="deleteAnnouncement" > diff --git a/src/components/announcements_page/announcements_page.js b/src/components/announcements_page/announcements_page.js @@ -28,6 +28,9 @@ const AnnouncementsPage = { }), announcements () { return this.$store.state.announcements.announcements + }, + canPostAnnouncement () { + return this.currentUser && this.currentUser.privileges.includes('announcements_manage_announcements') } }, methods: { diff --git a/src/components/announcements_page/announcements_page.vue b/src/components/announcements_page/announcements_page.vue @@ -7,7 +7,7 @@ </div> <div class="panel-body"> <section - v-if="currentUser && currentUser.role === 'admin'" + v-if="canPostAnnouncement" > <div class="post-form"> <div class="heading"> diff --git a/src/modules/announcements.js b/src/modules/announcements.js @@ -49,7 +49,7 @@ const announcements = { } const currentUser = store.rootState.users.currentUser - const isAdmin = currentUser && currentUser.role === 'admin' + const isAdmin = currentUser && currentUser.privileges.includes('announcements_manage_announcements') const getAnnouncements = async () => { if (!isAdmin) {