-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add default role to workspace #10444
base: main
Are you sure you want to change the base?
Conversation
@@ -190,6 +193,20 @@ export class WorkspaceResolver { | |||
} | |||
} | |||
|
|||
@ResolveField(() => RoleDTO, { nullable: true }) | |||
async defaultRole(@Parent() workspace: Workspace): Promise<RoleDTO | null> { | |||
if (!workspace.defaultRoleId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we throw if permissions are enabled and defaultRoleId is missing?
@@ -184,4 +185,9 @@ export class UpdateWorkspaceInput { | |||
@IsBoolean() | |||
@IsOptional() | |||
isPasswordAuthEnabled?: boolean; | |||
|
|||
@Field({ nullable: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we plan on updating this during the roll-out, through a command? as this field should not be null
If yes we can add it to our todo list not to forget
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
params.workspace.id, | ||
); | ||
|
||
if (isPermissionsEnabled && params.workspace.defaultRoleId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, we should always have a defaultRole, and since we have the isPermissionsEnabled gate here maybe we should throw if we have no defaultRoleId?
jest | ||
.spyOn(userWorkspaceService, 'addUserToWorkspace') | ||
.mockResolvedValue({} as User); | ||
jest.spyOn(userWorkspaceService, 'addUserToWorkspace').mockResolvedValue({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we somehow check that a new signed up user has the default role?
Context
Adding a defaultRole to each workspace, this role will be automatically added when a member joins a workspace via invite link or public link (seeds work differently though).
Took the occasion to refactor a bit the frontend components, splitting them in smaller components for more readability.
Test