Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add default role to workspace #10444

wants to merge 6 commits into from

Conversation

Weiko
Copy link
Member

@Weiko Weiko commented Feb 24, 2025

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

Screenshot 2025-02-24 at 14 54 02

@@ -190,6 +193,20 @@ export class WorkspaceResolver {
}
}

@ResolveField(() => RoleDTO, { nullable: true })
async defaultRole(@Parent() workspace: Workspace): Promise<RoleDTO | null> {
if (!workspace.defaultRoleId) {
Copy link
Collaborator

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 })
Copy link
Collaborator

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

Copy link
Member Author

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) {
Copy link
Collaborator

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({
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants