eecc7aaed3
Introduce a read-only view of permissions similar to agent roles tab. The role selector in the following image feels as if it would lead to a new page, which is not what we want. <img width="1281" height="813" alt="Permissions (If easier V1)" src="https://github.com/user-attachments/assets/7b272f5a-40ef-43ad-83d8-f9e588b1cd6e" /> Therefore, I added a Select component for now and would love some clarity on what's ideal. <img width="554" height="651" alt="image" src="https://github.com/user-attachments/assets/91575208-66b1-4ed1-86cd-f3aa528ad0dc" /> Also, the "Add Rule" button changes to enabled when we switch the role from `Admin` to `Member` and clicking it redirects to `/settings/roles/:role-id/add-object-permission`. Do we want to disable the button completely? One final thing: SettingsAgentRoleTab already re-uses SettingsRolePermissions. I created MemberPermissionsTab to do the same. I don't think we need an abstracted shared component here since both tabs rely on the same shared child anyway. However, if we need a refactor, I can use some direction on how the code should look. Creating this PR as draft since I think there might be a couple suggested changes on this.
21 lines
727 B
TypeScript
21 lines
727 B
TypeScript
import { settingsAllRolesSelector } from '@/settings/roles/states/settingsAllRolesSelector';
|
|
import { settingsRolesIsLoadingState } from '@/settings/roles/states/settingsRolesIsLoadingState';
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
export const useWorkspaceMemberRoles = (workspaceMemberId: string) => {
|
|
const settingsAllRoles = useRecoilValue(settingsAllRolesSelector);
|
|
const settingsRolesIsLoading = useRecoilValue(settingsRolesIsLoadingState);
|
|
|
|
const roles = workspaceMemberId
|
|
? settingsAllRoles.filter((role) =>
|
|
role.workspaceMembers.some((member) => member.id === workspaceMemberId),
|
|
)
|
|
: [];
|
|
|
|
return {
|
|
roles,
|
|
allRoles: settingsAllRoles,
|
|
loading: settingsRolesIsLoading,
|
|
};
|
|
};
|