Implement deleting announcement
This commit is contained in:
parent
efb76dcb03
commit
e877fedb0e
|
@ -1,9 +1,13 @@
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
const Announcement = {
|
const Announcement = {
|
||||||
props: {
|
props: {
|
||||||
announcement: Object
|
announcement: Object
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
currentUser: state => state.users.currentUser
|
||||||
|
}),
|
||||||
content () {
|
content () {
|
||||||
return this.announcement.content
|
return this.announcement.content
|
||||||
},
|
},
|
||||||
|
@ -16,6 +20,9 @@ const Announcement = {
|
||||||
if (!this.isRead) {
|
if (!this.isRead) {
|
||||||
return this.$store.dispatch('markAnnouncementAsRead', this.announcement.id)
|
return this.$store.dispatch('markAnnouncementAsRead', this.announcement.id)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
deleteAnnouncement () {
|
||||||
|
return this.$store.dispatch('deleteAnnouncement', this.announcement.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,20 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<button
|
<button
|
||||||
|
v-if="currentUser"
|
||||||
class="btn button-default"
|
class="btn button-default"
|
||||||
:class="{ toggled: isRead }"
|
:class="{ toggled: isRead }"
|
||||||
@click="markAsRead"
|
@click="markAsRead"
|
||||||
>
|
>
|
||||||
{{ $t('announcements.mark_as_read_action') }}
|
{{ $t('announcements.mark_as_read_action') }}
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="currentUser && currentUser.role === 'admin'"
|
||||||
|
class="btn button-default"
|
||||||
|
@click="deleteAnnouncement"
|
||||||
|
>
|
||||||
|
{{ $t('announcements.delete_action') }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -37,5 +45,15 @@
|
||||||
.heading, .body {
|
.heading, .body {
|
||||||
margin-bottom: var(--status-margin, $status-margin);
|
margin-bottom: var(--status-margin, $status-margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-around;
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
min-width: 10em;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -59,6 +59,12 @@ const announcements = {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return store.dispatch('fetchAnnouncements')
|
return store.dispatch('fetchAnnouncements')
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
deleteAnnouncement (store, id) {
|
||||||
|
return store.rootState.api.backendInteractor.deleteAnnouncement({ id })
|
||||||
|
.then(() => {
|
||||||
|
return store.dispatch('fetchAnnouncements')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ const PLEROMA_DELETE_CHAT_MESSAGE_URL = (chatId, messageId) => `/api/v1/pleroma/
|
||||||
const PLEROMA_ADMIN_REPORTS = '/api/pleroma/admin/reports'
|
const PLEROMA_ADMIN_REPORTS = '/api/pleroma/admin/reports'
|
||||||
const PLEROMA_BACKUP_URL = '/api/v1/pleroma/backups'
|
const PLEROMA_BACKUP_URL = '/api/v1/pleroma/backups'
|
||||||
const PLEROMA_POST_ANNOUNCEMENT_URL = '/api/v1/pleroma/admin/announcements'
|
const PLEROMA_POST_ANNOUNCEMENT_URL = '/api/v1/pleroma/admin/announcements'
|
||||||
|
const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}`
|
||||||
|
|
||||||
const oldfetch = window.fetch
|
const oldfetch = window.fetch
|
||||||
|
|
||||||
|
@ -1399,6 +1400,14 @@ const postAnnouncement = ({ credentials, content, startsAt, endsAt, allDay }) =>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deleteAnnouncement = ({ id, credentials }) => {
|
||||||
|
return promisedRequest({
|
||||||
|
url: PLEROMA_DELETE_ANNOUNCEMENT_URL(id),
|
||||||
|
credentials,
|
||||||
|
method: 'DELETE'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const getMastodonSocketURI = ({ credentials, stream, args = {} }) => {
|
export const getMastodonSocketURI = ({ credentials, stream, args = {} }) => {
|
||||||
return Object.entries({
|
return Object.entries({
|
||||||
...(credentials
|
...(credentials
|
||||||
|
@ -1728,7 +1737,8 @@ const apiService = {
|
||||||
fetchUserInLists,
|
fetchUserInLists,
|
||||||
fetchAnnouncements,
|
fetchAnnouncements,
|
||||||
dismissAnnouncement,
|
dismissAnnouncement,
|
||||||
postAnnouncement
|
postAnnouncement,
|
||||||
|
deleteAnnouncement
|
||||||
}
|
}
|
||||||
|
|
||||||
export default apiService
|
export default apiService
|
||||||
|
|
Loading…
Reference in a new issue