Skip to content

Commit 0c07d96

Browse files
authored
Merge pull request #4417 from FlowFuse/4415_hide-the-application-kebab-menu-for-users-without-permissions
hide the application page instance kebab menu for non admin/owner users
2 parents 648d717 + a09f3f4 commit 0c07d96

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

frontend/src/pages/team/Applications/components/compact/InstanceTile.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
:show-text="showButtonLabels"
5353
/>
5454

55-
<ff-kebab-menu @click.stop>
55+
<ff-kebab-menu v-if="shouldDisplayKebabMenu" @click.stop>
5656
<ff-list-item
5757
:disabled="localInstance.pendingStateChange || instanceRunning "
5858
label="Start"
@@ -82,6 +82,8 @@
8282
</template>
8383

8484
<script>
85+
import { mapGetters } from 'vuex'
86+
8587
import InstanceStatusPolling from '../../../../../components/InstanceStatusPolling.vue'
8688
import AuditMixin from '../../../../../mixins/Audit.js'
8789
import instanceActionsMixin from '../../../../../mixins/InstanceActions.js'
@@ -121,6 +123,7 @@ export default {
121123
}
122124
},
123125
computed: {
126+
...mapGetters('account', ['isAdminUser']),
124127
isInstanceRunning () {
125128
return this.localInstance.meta?.state === 'running'
126129
},
@@ -135,6 +138,9 @@ export default {
135138
},
136139
instanceSuspended () {
137140
return this.localInstance.meta?.state === 'suspended'
141+
},
142+
shouldDisplayKebabMenu () {
143+
return this.isAdminUser || this.hasPermission('project:change-status')
138144
}
139145
},
140146
watch: {

test/e2e/frontend/cypress/tests/applications/overview.spec.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,65 @@ describe('FlowForge - Applications', () => {
375375
})
376376
})
377377

378+
it('doesn\'t display the instance kebab menu for non-owner users', () => {
379+
cy.intercept(
380+
'GET',
381+
'/api/*/teams/*/user',
382+
{ role: 30 }
383+
).as('getTeamRole')
384+
cy.intercept(
385+
'GET',
386+
'/api/*/teams/*/applications/status*',
387+
{ count: 1, applications: [{ id: 'some-id', instances: [], devices: [] }] }
388+
).as('getAppStatuses')
389+
cy.intercept('get', '/api/*/applications/*/devices*', {
390+
meta: {},
391+
count: 0,
392+
devices: []
393+
}).as('getDevices')
394+
cy.intercept(
395+
'GET',
396+
'/api/*/teams/*/applications*',
397+
req => req.reply(res => {
398+
res.send({
399+
count: 1,
400+
applications: [
401+
{
402+
id: 'some-id',
403+
name: 'My app',
404+
description: 'My empty app description',
405+
instancesSummary: {
406+
instances: [
407+
{
408+
id: 1,
409+
name: 'instance-1',
410+
meta: {
411+
versions: {
412+
launcher: '2.3.1'
413+
},
414+
state: 'running'
415+
},
416+
url: 'https://www.google.com:123/search?q=rick+astley'
417+
}
418+
]
419+
},
420+
devicesSummary: {
421+
devices: [
422+
]
423+
}
424+
}
425+
]
426+
})
427+
})
428+
).as('getApplication')
429+
430+
cy.visit('/')
431+
cy.wait('@getTeamRole')
432+
cy.wait('@getDevices')
433+
434+
cy.get('[data-el="kebab-menu"]').should('not.exist')
435+
})
436+
378437
describe('can search through', () => {
379438
it('applications', () => {
380439
cy.intercept(

0 commit comments

Comments
 (0)