Skip to content

Commit

Permalink
Merge pull request #12543 from nextcloud/feat/noid/remove-confirmation
Browse files Browse the repository at this point in the history
feat(conversation): add confirmation dialog when removing participant
  • Loading branch information
Antreesy authored Jun 19, 2024
2 parents e5d6c47 + ecc2335 commit d87d7fb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
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>

0 comments on commit d87d7fb

Please sign in to comment.