add object settings permission tab (#10159)

## Context
Introducing the "Permissions" tab in the role page

Next: Need to address some css improvements, some components might be
reusable and it still does not fully match the figma (icon missing for
permission types for example). We decided to merge like this for now so
we have something functional and I will update the code in an upcoming
PR

<img width="633" alt="Screenshot 2025-02-12 at 13 54 16"
src="https://github.com/user-attachments/assets/762db5d7-e0a6-4ee1-b299-24de6645bad1"
/>
This commit is contained in:
Weiko
2025-02-12 18:49:50 +01:00
committed by GitHub
parent 61881d6d0f
commit 193ef432a0
18 changed files with 479 additions and 160 deletions

View File

@ -108,6 +108,31 @@ export class WorkspaceManagerService {
await this.prefillWorkspaceWithDemoObjects(dataSourceMetadata, workspaceId);
}
public async initDev(workspaceId: string): Promise<void> {
const schemaName =
await this.workspaceDataSourceService.createWorkspaceDBSchema(
workspaceId,
);
const dataSourceMetadata =
await this.dataSourceService.createDataSourceMetadata(
workspaceId,
schemaName,
);
await this.workspaceSyncMetadataService.synchronize({
workspaceId: workspaceId,
dataSourceId: dataSourceMetadata.id,
});
const permissionsEnabled =
await this.permissionsService.isPermissionsEnabled();
if (permissionsEnabled === true) {
await this.initPermissions(workspaceId);
}
}
/**
*
* We are prefilling a few standard objects with data to make it easier for the user to get started.
@ -209,30 +234,25 @@ export class WorkspaceManagerService {
workspaceId,
});
const userWorkspace = await this.userWorkspaceRepository.find({
const userWorkspaces = await this.userWorkspaceRepository.find({
where: {
workspaceId,
},
});
if (isEmpty(userWorkspace)) {
if (isEmpty(userWorkspaces)) {
throw new PermissionsException(
'User workspace not found',
PermissionsExceptionCode.USER_WORKSPACE_NOT_FOUND,
);
}
if (userWorkspace.length > 1) {
throw new PermissionsException(
'Multiple user workspaces found, cannot tell which one should be admin',
PermissionsExceptionCode.TOO_MANY_ADMIN_CANDIDATES,
);
for (const userWorkspace of userWorkspaces) {
await this.userRoleService.assignRoleToUserWorkspace({
workspaceId,
userWorkspaceId: userWorkspace.id,
roleId: adminRole.id,
});
}
await this.userRoleService.assignRoleToUserWorkspace({
workspaceId,
userWorkspaceId: userWorkspace[0].id,
roleId: adminRole.id,
});
}
}