diff --git a/packages/rocketchat-channel-settings/client/views/channelSettings.coffee b/packages/rocketchat-channel-settings/client/views/channelSettings.coffee index 103d0e085bb4..f2290223ef00 100644 --- a/packages/rocketchat-channel-settings/client/views/channelSettings.coffee +++ b/packages/rocketchat-channel-settings/client/views/channelSettings.coffee @@ -33,8 +33,37 @@ Template.channelSettings.helpers return t('Room_archivation_state_true') else return t('Room_archivation_state_false') + canDeleteRoom: -> + roomType = ChatRoom.findOne(@rid, { fields: { t: 1 }})?.t + return roomType? and RocketChat.authz.hasAtLeastOnePermission("delete-#{roomType}", @rid) Template.channelSettings.events + 'click .delete': -> + swal { + title: t('Are_you_sure') + text: t('Delete_Room_Warning') + type: 'warning' + showCancelButton: true + confirmButtonColor: '#DD6B55' + confirmButtonText: t('Yes_delete_it') + cancelButtonText: t('Cancel') + closeOnConfirm: false + html: false + }, => + swal.disableButtons() + + Meteor.call 'eraseRoom', @rid, (error, result) -> + if error + handleError(error) + swal.enableButtons() + else + swal + title: t('Deleted') + text: t('Room_has_been_deleted') + type: 'success' + timer: 2000 + showConfirmButton: false + 'keydown input[type=text]': (e, t) -> if e.keyCode is 13 e.preventDefault() diff --git a/packages/rocketchat-channel-settings/client/views/channelSettings.html b/packages/rocketchat-channel-settings/client/views/channelSettings.html index 4889ff035937..95433e8c9a32 100644 --- a/packages/rocketchat-channel-settings/client/views/channelSettings.html +++ b/packages/rocketchat-channel-settings/client/views/channelSettings.html @@ -75,6 +75,11 @@

{{_ "Room_Info"}}

{{/each}} + {{#if canDeleteRoom}} + + {{/if}}