diff --git a/apps/meteor/app/api/server/v1/teams.ts b/apps/meteor/app/api/server/v1/teams.ts index 4ea8f2a48f38..47d64917395b 100644 --- a/apps/meteor/app/api/server/v1/teams.ts +++ b/apps/meteor/app/api/server/v1/teams.ts @@ -175,7 +175,7 @@ API.v1.addRoute( return API.v1.failure('team-does-not-exist'); } - if (!(await hasPermissionAsync(this.userId, 'add-team-channel', team.roomId))) { + if (!(await hasPermissionAsync(this.userId, 'move-room-to-team', team.roomId))) { return API.v1.unauthorized('error-no-permission-team-channel'); } diff --git a/apps/meteor/app/authorization/server/constant/permissions.ts b/apps/meteor/app/authorization/server/constant/permissions.ts index 9d799cc3c6f9..7128d9b916c6 100644 --- a/apps/meteor/app/authorization/server/constant/permissions.ts +++ b/apps/meteor/app/authorization/server/constant/permissions.ts @@ -178,7 +178,7 @@ export const permissions = [ { _id: 'edit-team', roles: ['admin', 'owner'] }, { _id: 'add-team-member', roles: ['admin', 'owner', 'moderator'] }, { _id: 'edit-team-member', roles: ['admin', 'owner', 'moderator'] }, - { _id: 'add-team-channel', roles: ['admin', 'owner', 'moderator'] }, + { _id: 'move-room-to-team', roles: ['admin', 'owner', 'moderator'] }, { _id: 'create-team-channel', roles: ['admin', 'owner', 'moderator'] }, { _id: 'create-team-group', roles: ['admin', 'owner', 'moderator'] }, { _id: 'delete-team-channel', roles: ['admin', 'owner', 'moderator'] }, diff --git a/apps/meteor/client/views/teams/contextualBar/channels/TeamsChannels.tsx b/apps/meteor/client/views/teams/contextualBar/channels/TeamsChannels.tsx index 7b3916b396b7..71a7c4433348 100644 --- a/apps/meteor/client/views/teams/contextualBar/channels/TeamsChannels.tsx +++ b/apps/meteor/client/views/teams/contextualBar/channels/TeamsChannels.tsx @@ -56,7 +56,7 @@ const TeamsChannels = () => { setText(event.currentTarget.value); }, []); - const canAddExistingRoomToTeam = usePermission('add-team-channel', room._id); + const canAddExistingRoomToTeam = usePermission('move-room-to-team', room._id); const canCreateRoomInTeam = useAtLeastOnePermission(['create-team-channel', 'create-team-group'], room._id); const addExisting = useReactModal(AddExistingModal, teamId, reload); const createNew = useReactModal(CreateChannelWithData, teamId, reload); diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json index a6ee7609cda9..725f82a29927 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json @@ -327,8 +327,6 @@ "add-oauth-service_description": "Permission to add a new OAuth service", "bypass-time-limit-edit-and-delete": "Bypass time limit", "bypass-time-limit-edit-and-delete_description": "Permission to Bypass time limit for editing and deleting messages", - "add-team-channel": "Move room within team", - "add-team-channel_description": "Permission to add an existing room to a team", "create-team-channel": "Create channel within team", "create-team-channel_description": "Permission to create a channel in a team (Overrides global permission)", "create-team-group": "Create group within team", @@ -3642,6 +3640,8 @@ "Move_beginning_message": "`%s` - Move to the beginning of the message", "Move_end_message": "`%s` - Move to the end of the message", "Move_queue": "Move to the queue", + "move-room-to-team": "Move room within team", + "move-room-to-team_description": "Permission to add an existing room to a team", "Msgs": "Msgs", "multi": "multi", "Multi_line": "Multi line", diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index df8fa3ae1505..0dd935d92a13 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -297,8 +297,6 @@ "add-livechat-department-agents_description": "Permissão para incluir agentes omnichannel aos departamentos", "add-oauth-service": "Adicionar Serviço OAuth", "add-oauth-service_description": "Permissão para adicionar um novo serviço OAuth", - "add-team-channel": "Mover sala a um time", - "add-team-channel_description": "Permissão para adicionar uma sala existente a um time", "create-team-channel": "Criar canal em um time", "create-team-channel_description": "Permissão para criar um canal em um time (sobrepõe a permissão global)", "create-team-group": "Criar grupo em um time", @@ -3040,6 +3038,8 @@ "Move_beginning_message": "`%s` - Mover para o início da mensagem", "Move_end_message": "`%s` - Mover para o final da mensagem", "Move_queue": "Mover para a fila", + "move-room-to-team": "Mover sala a um time", + "move-room-to-team_description": "Permissão para adicionar uma sala existente a um time", "Msgs": "Msgs", "multi": "multi", "Mute": "Silenciar", diff --git a/apps/meteor/server/startup/migrations/v305.ts b/apps/meteor/server/startup/migrations/v305.ts index ef93423d15e0..84b40f663b91 100644 --- a/apps/meteor/server/startup/migrations/v305.ts +++ b/apps/meteor/server/startup/migrations/v305.ts @@ -6,7 +6,7 @@ import { addMigration } from '../../lib/migrations'; addMigration({ version: 305, - name: 'Copy roles from add-team-channel permission to new create-team-channel and create-team-group permissions', + name: 'Copy roles from add-team-channel permission to new create-team-channel, create-team-group and move-room-to-team permissions', async up() { // Calling upsertPermissions on purpose so that the new permissions are added before the migration runs await upsertPermissions(); @@ -17,9 +17,11 @@ addMigration({ if (addTeamChannelPermission) { await Permissions.updateMany( - { _id: { $in: ['create-team-channel', 'create-team-group'] } }, + { _id: { $in: ['create-team-channel', 'create-team-group', 'move-room-to-team'] } }, { $set: { roles: addTeamChannelPermission.roles } }, ); + + await Permissions.deleteOne({ _id: 'add-team-channel' }); } }, }); diff --git a/apps/meteor/tests/end-to-end/api/25-teams.js b/apps/meteor/tests/end-to-end/api/25-teams.js index a44fd2a0f6dc..957e3c80bf7f 100644 --- a/apps/meteor/tests/end-to-end/api/25-teams.js +++ b/apps/meteor/tests/end-to-end/api/25-teams.js @@ -1221,7 +1221,7 @@ describe('[Teams]', () => { }); it('should throw an error if no permission', (done) => { - updatePermission('add-team-channel', []).then(() => { + updatePermission('move-room-to-team', []).then(() => { request .post(api('teams.addRooms')) .set(credentials) @@ -1241,7 +1241,7 @@ describe('[Teams]', () => { }); it('should add public and private rooms to team', (done) => { - updatePermission('add-team-channel', ['admin']).then(() => { + updatePermission('move-room-to-team', ['admin']).then(() => { request .post(api('teams.addRooms')) .set(credentials) @@ -1270,7 +1270,7 @@ describe('[Teams]', () => { }); it('should add public room to private team', (done) => { - updatePermission('add-team-channel', ['admin']).then(() => { + updatePermission('move-room-to-team', ['admin']).then(() => { request .post(api('teams.addRooms')) .set(credentials) @@ -1291,7 +1291,7 @@ describe('[Teams]', () => { }); it('should add private room to team', (done) => { - updatePermission('add-team-channel', ['admin']).then(() => { + updatePermission('move-room-to-team', ['admin']).then(() => { request .post(api('teams.addRooms')) .set(credentials) @@ -1312,7 +1312,7 @@ describe('[Teams]', () => { }); it('should fail if the user cannot access the channel', (done) => { - updatePermission('add-team-channel', ['admin', 'user']) + updatePermission('move-room-to-team', ['admin', 'user']) .then(() => { request .post(api('teams.addRooms'))