-
Notifications
You must be signed in to change notification settings - Fork 509
feat(ban): add endpoints for ban handling #12434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
04b1d46
feat(ban): add endpoints for ban handling
Antreesy db3a2ed
feat(ban): ban participant from RightSidebar
Antreesy c3c27d7
feat(ban): list existing bans per conversation
Antreesy 6d21260
feat(ban): implement forbidden view for banned users
Antreesy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
src/components/ConversationSettings/BanSettings/BanSettings.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
|
|
||
| <template> | ||
| <div class="conversation-ban__settings"> | ||
| <h4 class="app-settings-section__subtitle"> | ||
| {{ t('spreed', 'Banned users') }} | ||
| </h4> | ||
| <div class="app-settings-section__hint"> | ||
| {{ t('spreed', 'Manage the list of banned users in this conversation.') }} | ||
| </div> | ||
| <NcButton @click="modal = true"> | ||
| {{ t('spreed', 'Manage bans') }} | ||
| </NcButton> | ||
|
|
||
| <NcModal v-if="modal" | ||
| container=".conversation-ban__settings" | ||
| @close="modal = false"> | ||
| <div class="conversation-ban__content"> | ||
| <h2 class="conversation-ban__title"> | ||
| {{ t('spreed', 'Banned users') }} | ||
| </h2> | ||
|
|
||
| <ul v-if="banList.length" class="conversation-ban__list"> | ||
| <BannedItem v-for="ban in banList" | ||
| :key="ban.id" | ||
| :ban="ban" | ||
| @unban-participant="handleUnban(ban.id)" /> | ||
| </ul> | ||
|
|
||
| <NcEmptyContent v-else> | ||
| <template #icon> | ||
| <NcLoadingIcon v-if="isLoading" /> | ||
| <AccountCancel v-else /> | ||
| </template> | ||
|
|
||
| <template #description> | ||
| <p>{{ isLoading ? t('spreed', 'Loading …') : t('spreed', 'No banned users') }}</p> | ||
| </template> | ||
| </NcEmptyContent> | ||
| </div> | ||
| </NcModal> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import AccountCancel from 'vue-material-design-icons/AccountCancel.vue' | ||
|
|
||
| import { t } from '@nextcloud/l10n' | ||
|
|
||
| import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' | ||
| import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js' | ||
| import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js' | ||
| import NcModal from '@nextcloud/vue/dist/Components/NcModal.js' | ||
|
|
||
| import BannedItem from './BannedItem.vue' | ||
|
|
||
| import { getConversationBans, unbanActor } from '../../../services/banService.ts' | ||
|
|
||
| export default { | ||
| name: 'BanSettings', | ||
|
|
||
| components: { | ||
| NcButton, | ||
| NcEmptyContent, | ||
| NcLoadingIcon, | ||
| NcModal, | ||
| BannedItem, | ||
| // Icons | ||
| AccountCancel, | ||
| }, | ||
|
|
||
| props: { | ||
| token: { | ||
| type: String, | ||
| required: true, | ||
| }, | ||
| }, | ||
|
|
||
| data() { | ||
| return { | ||
| banList: [], | ||
| isLoading: true, | ||
| modal: false, | ||
| } | ||
| }, | ||
|
|
||
| watch: { | ||
| modal(value) { | ||
| if (value) { | ||
| this.getList() | ||
| } | ||
| } | ||
| }, | ||
|
|
||
| methods: { | ||
| t, | ||
|
|
||
| async getList() { | ||
| this.isLoading = true | ||
| const response = await getConversationBans(this.token) | ||
| this.banList = response.data.ocs.data | ||
| this.isLoading = false | ||
| }, | ||
|
|
||
| async handleUnban(id) { | ||
| await unbanActor(this.token, id) | ||
| this.banList = this.banList.filter(ban => ban.id !== id) | ||
| } | ||
| }, | ||
| } | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .conversation-ban { | ||
| &__content { | ||
| min-height: 250px; | ||
| } | ||
|
|
||
| &__title { | ||
| text-align: center; | ||
| } | ||
|
|
||
| &__list { | ||
| overflow: auto; | ||
| height: calc(100% - 45px - 12px); | ||
| padding: calc(var(--default-grid-baseline) * 2); | ||
| } | ||
| } | ||
| </style> |
101 changes: 101 additions & 0 deletions
101
src/components/ConversationSettings/BanSettings/BannedItem.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
|
|
||
| <template> | ||
| <li :key="ban.id" class="ban-item"> | ||
| <div class="ban-item__header"> | ||
| <span class="ban-item__caption">{{ ban.bannedId }}</span> | ||
| <div class="ban-item__buttons"> | ||
| <NcButton type="tertiary" @click="showDetails = !showDetails"> | ||
| {{ showDetails ? t('spreed', 'Hide details') : t('spreed', 'Show details') }} | ||
| </NcButton> | ||
| <NcButton @click="$emit('unban-participant')"> | ||
| {{ t('spreed', 'Unban') }} | ||
| </NcButton> | ||
| </div> | ||
| </div> | ||
| <ul v-if="showDetails" class="ban-item__hint"> | ||
| <!-- eslint-disable-next-line vue/no-v-html --> | ||
| <li v-for="(item, index) in banInfo" :key="index" v-html="item" /> | ||
| </ul> | ||
| </li> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { t } from '@nextcloud/l10n' | ||
| import moment from '@nextcloud/moment' | ||
|
|
||
| import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' | ||
|
|
||
| export default { | ||
| name: 'BannedItem', | ||
|
|
||
| components: { | ||
| NcButton, | ||
| }, | ||
|
|
||
| props: { | ||
| ban: { | ||
| type: Object, | ||
| required: true, | ||
| }, | ||
| }, | ||
|
|
||
| emits: ['unban-participant'], | ||
|
|
||
| data() { | ||
| return { | ||
| showDetails: false, | ||
| } | ||
| }, | ||
|
|
||
| computed: { | ||
| banInfo() { | ||
| return [ | ||
| t('spreed', '<strong>Banned by:</strong> {actor}', { actor: this.ban.actorId }, | ||
| undefined, { escape: false, sanitize: false }), | ||
| t('spreed', '<strong>Date:</strong> {date}', { date: moment(this.ban.bannedTime * 1000).format('lll') }, | ||
| undefined, { escape: false, sanitize: false }), | ||
| t('spreed', '<strong>Note:</strong> {note}', { note: this.ban.internalNote }, | ||
| undefined, { escape: false, sanitize: false }), | ||
| ] | ||
| }, | ||
| }, | ||
|
|
||
| methods: { | ||
| t, | ||
| }, | ||
| } | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
|
|
||
| .ban-item { | ||
| padding: 4px 0; | ||
| &:not(:last-child) { | ||
| border-bottom: 1px solid var(--color-border); | ||
| } | ||
|
|
||
| &__header { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| } | ||
|
|
||
| &__caption { | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| &__hint { | ||
| word-wrap: break-word; | ||
| color: var(--color-text-maxcontrast); | ||
| margin-bottom: 4px; | ||
| } | ||
|
|
||
| &__buttons { | ||
| display: flex; | ||
| } | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.