Skip to content

Commit

Permalink
Merge pull request #4844 from FlowFuse/team-member-device-mode-toggle
Browse files Browse the repository at this point in the history
Team member device mode toggle
  • Loading branch information
knolleary authored Nov 29, 2024
2 parents 511acde + 6e1d7b8 commit 645a2c7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion forge/routes/api/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ module.exports = async function (app) {
* @memberof module:forge/routes/api/device
*/
app.put('/:deviceId/mode', {
preHandler: app.needsPermission('device:edit'),
preHandler: app.needsPermission('device:editor'),
schema: {
summary: 'Set device mode',
tags: ['Devices'],
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/pages/device/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ export default {
isVisitingAdmin: function () {
return this.teamMembership.role === Roles.Admin
},
isOwner: function () {
return this.teamMembership.role === Roles.Owner
isMember: function () {
return this.teamMembership.role === Roles.Member || this.teamMembership.role === Roles.Owner
},
isDevModeAvailable: function () {
return !!this.features.deviceEditor
Expand All @@ -201,7 +201,7 @@ export default {
return !this.isDevModeAvailable ||
!this.device ||
!this.agentSupportsDeviceAccess ||
!this.isOwner
!this.isMember
},
disableModeToggleReason: function () {
if (!this.device) {
Expand All @@ -210,8 +210,8 @@ export default {
if (!this.agentSupportsDeviceAccess) {
return 'Device Agent V0.8 or greater is required'
}
if (!this.isOwner) {
return 'Only an owner can change the Device Mode'
if (!this.isMember) {
return 'Only an Owner or Member can change the Device Mode'
}
return undefined
},
Expand Down
4 changes: 2 additions & 2 deletions test/unit/forge/routes/api/device_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ describe('Device API', async function () {
settings.should.have.property('mode', 'developer')
settings.should.have.property('editor')
})
it('team member can not set device to developer mode', async function () {
it('team member can set device to developer mode', async function () {
const device = await createDevice({ name: 'Ad1', type: '', team: TestObjects.ATeam.hashid, as: TestObjects.tokens.alice })
const response = await app.inject({
method: 'PUT',
Expand All @@ -1294,7 +1294,7 @@ describe('Device API', async function () {
},
cookies: { sid: TestObjects.tokens.chris }
})
response.statusCode.should.equal(403)
response.statusCode.should.equal(200)
})
})
})
Expand Down

0 comments on commit 645a2c7

Please sign in to comment.