Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/components/RightSidebar/Participants/Participant.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import VideoIcon from 'vue-material-design-icons/Video.vue'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionText from '@nextcloud/vue/dist/Components/NcActionText.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'

import Participant from './Participant.vue'
import AvatarWrapper from '../../AvatarWrapper/AvatarWrapper.vue'

import { ATTENDEE, PARTICIPANT } from '../../../constants.js'
import storeConfig from '../../../store/storeConfig.js'
import { findNcActionButton } from '../../../test-helpers.js'
import { findNcActionButton, findNcButton } from '../../../test-helpers.js'

describe('Participant.vue', () => {
let conversation
Expand Down Expand Up @@ -104,6 +106,8 @@ describe('Participant.vue', () => {
},
stubs: {
NcActionButton,
NcButton,
NcDialog,
},
directives: {
tooltip: tooltipMock,
Expand Down Expand Up @@ -626,6 +630,12 @@ describe('Participant.vue', () => {

await actionButton.find('button').trigger('click')

const dialog = wrapper.findComponent(NcDialog)
expect(dialog.exists()).toBeTruthy()

const button = findNcButton(dialog, 'Remove')
await button.find('button').trigger('click')

expect(removeAction).toHaveBeenCalledWith(expect.anything(), {
token: 'current-token',
attendeeId: 'alice-attendee-id',
Expand Down
44 changes: 42 additions & 2 deletions src/components/RightSidebar/Participants/Participant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,15 @@
</template>
{{ t('spreed', 'Edit permissions') }}
</NcActionButton>
<NcActionSeparator />
</template>

<!-- Remove -->
<NcActionSeparator v-if="canBeModerated && showPermissionsOptions" />
<NcActionButton v-if="canBeModerated"
key="remove-participant"
class="critical"
close-after-click
@click="removeParticipant">
@click="isRemoveDialogOpen = true">
<template #icon>
<Delete :size="20" />
</template>
Expand All @@ -306,6 +307,22 @@
:token="token"
@close="hidePermissionsEditor" />

<!-- Confirmation required to remove participant -->
<NcDialog v-if="isRemoveDialogOpen"
:open.sync="isRemoveDialogOpen"
:name="removeParticipantLabel"
:container="container">
<p> {{ removeDialogMessage }} </p>
<template #actions>
<NcButton type="tertiary" @click="isRemoveDialogOpen = false">
{{ t('spreed', 'Dismiss') }}
</NcButton>
<NcButton type="error" @click="removeParticipant">
{{ t('spreed', 'Remove') }}
</NcButton>
</template>
</NcDialog>

<!-- Checkmark in case the current participant is selected -->
<div v-if="isSelected" class="icon-checkmark participant-row__utils utils__checkmark" />
</component>
Expand Down Expand Up @@ -346,6 +363,7 @@ import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.js'
import NcActionText from '@nextcloud/vue/dist/Components/NcActionText.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'

import ParticipantPermissionsEditor from './ParticipantPermissionsEditor.vue'
Expand Down Expand Up @@ -378,6 +396,7 @@ export default {
NcActionText,
NcActionSeparator,
NcButton,
NcDialog,
ParticipantPermissionsEditor,
// Icons
Account,
Expand Down Expand Up @@ -450,6 +469,7 @@ export default {
isUserNameTooltipVisible: false,
isStatusTooltipVisible: false,
permissionsEditor: false,
isRemoveDialogOpen: false,
disabled: false,
}
},
Expand Down Expand Up @@ -775,6 +795,21 @@ export default {
}
},

removeDialogMessage() {
switch (this.participant.actorType) {
case ATTENDEE.ACTOR_TYPE.GROUPS:
return t('spreed', 'Do you really want to remove group "{displayName}" and its members from this conversation?',
this.participant, undefined, { escape: false, sanitize: false })
case ATTENDEE.ACTOR_TYPE.CIRCLES:
return t('spreed', 'Do you really want to remove team "{displayName}" and its members from this conversation?',
this.participant, undefined, { escape: false, sanitize: false })
case ATTENDEE.ACTOR_TYPE.USERS:
default:
return t('spreed', 'Do you really want to remove {displayName} from this conversation?',
this.participant, undefined, { escape: false, sanitize: false })
}
},

showModeratorLabel() {
return this.isModerator
&& ![CONVERSATION.TYPE.ONE_TO_ONE, CONVERSATION.TYPE.ONE_TO_ONE_FORMER, CONVERSATION.TYPE.CHANGELOG].includes(this.conversation.type)
Expand Down Expand Up @@ -943,6 +978,7 @@ export default {
token: this.token,
attendeeId: this.attendeeId,
})
this.isRemoveDialogOpen = false
},

grantAllPermissions() {
Expand Down Expand Up @@ -1201,4 +1237,8 @@ export default {
}
}

.critical > :deep(.action-button) {
color: var(--color-error);
}

</style>