Fix permissions on project page

This commit is contained in:
Ramon Wenger 2021-10-26 10:33:09 +02:00
parent ac6c60f8c3
commit 08c4a6f7e1
3 changed files with 24 additions and 4 deletions

View File

@ -144,6 +144,24 @@ describe('Project Page', () => {
cy.getByDataCy('project-share-link').should('contain', unsharedText);
});
it('cannot edit or delete the project as a teacher', () => {
cy.mockGraphqlOps({
operations: {
...operations,
MeQuery: {
me: {
id: 'not-the-same',
isTeacher: true
},
},
},
});
cy.visit('/portfolio/groot');
cy.getByDataCy('project-actions').should('not.exist');
cy.getByDataCy('project-entry').should('have.length', 1);
cy.getByDataCy('project-entry-more').should('not.exist');
});
describe('Project Entry', () => {
it('should create a new project entry', () => {
cy.visit('/portfolio');

View File

@ -107,7 +107,6 @@ export default function (uri, networkErrorCallback) {
objectiveGroup: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveGroupNode', id: args.id}),
projectEntry: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ProjectEntryNode', id: args.id}),
project: (_, args, {getCacheKey}) => {
console.log(args);
if (args.slug) {
return getCacheKey({__typename: 'ProjectNode', id: args.slug});
} else {

View File

@ -13,13 +13,13 @@
:final="project.final"
data-cy="project-share-link"
class="project__share"
@click.native="updateProjectShareState(project.id, !project.final)" />
@click.native="updateProjectShareState(project.id, !project.final)"/>
<project-actions
:id="project.id"
:share-buttons="false"
class="project__more"
v-if="!me.readOnly && !me.selectedClass.readOnly"/>
v-if="canEdit"/>
</div>
@ -45,7 +45,7 @@
<project-entry
v-bind="entry"
:key="index"
:read-only="me.readOnly || me.selectedClass.readOnly"
:read-only="!canEdit"
v-for="(entry, index) in project.entries"/>
</div>
</div>
@ -109,6 +109,9 @@
projectEntryCount() {
return this.project.entries ? this.project.entries.length : 0;
},
canEdit() {
return !this.me.readOnly && !this.me.selectedClass.readOnly && this.isOwner;
},
},
apollo: {