Skip to content

Commit

Permalink
fix(editor): Add back credential use permission (#8023)
Browse files Browse the repository at this point in the history
## Summary
A shared credential is not selectable in NDV

Aim

If a credential is shared with a user they should be able to select it
in node details view
  • Loading branch information
cstuncsik committed Dec 14, 2023
1 parent fcb8b91 commit 329e5bf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
20 changes: 20 additions & 0 deletions cypress/e2e/17-sharing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ describe('Sharing', { disableAutoLogin: true }, () => {
ndv.actions.close();
});

it('should open W1, add node using C2 as U2', () => {
cy.signin(INSTANCE_MEMBERS[0]);

cy.visit(workflowsPage.url);
workflowsPage.getters.workflowCards().should('have.length', 2);
workflowsPage.getters.workflowCard('Workflow W1').click();
workflowPage.actions.addNodeToCanvas('Airtable', true, true);
ndv.getters.credentialInput().find('input').should('have.value', 'Credential C2');
ndv.actions.close();
workflowPage.actions.saveWorkflowOnButtonClick();

workflowPage.actions.openNode('Notion');
ndv.getters
.credentialInput()
.find('input')
.should('have.value', 'Credential C1')
.should('be.enabled');
ndv.actions.close();
});

it('should not have access to W2, as U3', () => {
cy.signin(INSTANCE_MEMBERS[1]);

Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/composables/useNodeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export function useNodeHelpers() {
.getCredentialsByType(credentialTypeDescription.name)
.filter((credential: ICredentialsResponse) => {
const permissions = getCredentialPermissions(currentUser, credential);
return permissions.read;
return permissions.use;
});

if (userCredentials === null) {
Expand Down
4 changes: 4 additions & 0 deletions packages/editor-ui/src/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export const getCredentialPermissions = (user: IUser | null, credential: ICreden
test: (permissions) =>
hasPermission(['rbac'], { rbac: { scope: 'credential:delete' } }) || !!permissions.isOwner,
},
{
name: 'use',
test: (permissions) => !!permissions.isOwner || !!permissions.isSharee,
},
];

return parsePermissionsTable(user, table);
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/stores/users.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
return (resource: ICredentialsResponse): boolean => {
const permissions = getCredentialPermissions(this.currentUser, resource);

return permissions.read;
return permissions.use;
};
},
},
Expand Down

0 comments on commit 329e5bf

Please sign in to comment.