Skip to content

feat: add custom roles #14069

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

Merged
merged 28 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1b450da
feat: initial commit custom roles
jaaydenh Jul 31, 2024
e3647cb
feat: add page to create and edit custom roles
jaaydenh Jul 31, 2024
14f7bfc
feat: add assign org role permission
jaaydenh Aug 1, 2024
928de7e
feat: wip
jaaydenh Aug 2, 2024
8ebfee7
feat: cleanup
jaaydenh Aug 2, 2024
cb870e1
fix: role name is disabled when editing the role
jaaydenh Aug 2, 2024
6dff9ed
fix: assign role context menu falls back to name when no display_name
jaaydenh Aug 2, 2024
688ab79
feat: add helper text to let users know that role name is immutable
jaaydenh Aug 2, 2024
68eae17
fix: format
jaaydenh Aug 2, 2024
fbea545
feat: - hide custom roles tab if experiment is not enabled
jaaydenh Aug 2, 2024
b4a460f
fix: use custom TableLoader
jaaydenh Aug 2, 2024
832573f
fix: fix custom roles text
jaaydenh Aug 2, 2024
a5415c5
fix: use PatchRoleRequest
jaaydenh Aug 2, 2024
8db1da0
fix: use addIcon to create roles
jaaydenh Aug 2, 2024
4e05a33
feat: add cancel and save buttons to top of page
jaaydenh Aug 2, 2024
a17f579
fix: use nameValidator for name
jaaydenh Aug 4, 2024
e9af2f9
chore: cleanup
jaaydenh Aug 5, 2024
e40f0bf
feat: add show all permissions checkbox
jaaydenh Aug 6, 2024
add45fb
fix: update sidebar for roles
jaaydenh Aug 6, 2024
dfe82b1
fix: fix format
jaaydenh Aug 6, 2024
f623356
fix: custom roles is not needed outside orgs
jaaydenh Aug 6, 2024
f7860aa
fix: fix sidebar stories
jaaydenh Aug 6, 2024
764b15f
feat: add custom roles page stories
jaaydenh Aug 6, 2024
124090b
fix: use organization permissions
jaaydenh Aug 7, 2024
11db948
feat: add stories for CreateEditRolePageView
jaaydenh Aug 8, 2024
e18bf46
fix: design improvements for the create edit role form
jaaydenh Aug 8, 2024
d455c4e
feat: add show all resources checkbox to bottom of table
jaaydenh Aug 9, 2024
72f1bab
feat: improve spacing
jaaydenh Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add assign org role permission
  • Loading branch information
jaaydenh committed Aug 6, 2024
commit 14f7bfc3b7ed552460e70722623fcd0eb4b93715
7 changes: 7 additions & 0 deletions site/src/contexts/auth/permissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const checks = {
viewAnyGroup: "viewAnyGroup",
createGroup: "createGroup",
viewAllLicenses: "viewAllLicenses",
assignOrgRole: "assignOrgRole",
} as const;

export const permissionsToCheck = {
Expand Down Expand Up @@ -131,6 +132,12 @@ export const permissionsToCheck = {
},
action: "read",
},
[checks.assignOrgRole]: {
object: {
resource_type: "assign_org_role",
},
action: "create",
},
} as const;

export type Permissions = Record<keyof typeof permissionsToCheck, boolean>;
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import CustomRolesPageView from "./CustomRolesPageView";

export const CustomRolesPage: FC = () => {
const { permissions } = useAuthenticated();
const { createGroup: canCreateGroup } = permissions;
const { assignOrgRole: canAssignOrgRole } = permissions;
const {
multiple_organizations: organizationsEnabled,
template_rbac: isTemplateRBACEnabled,
custom_roles: isCustomRolesEnabled,
} = useFeatureVisibility();
const { experiments } = useDashboard();
const location = useLocation();
Expand Down Expand Up @@ -62,7 +62,7 @@ export const CustomRolesPage: FC = () => {
<PageHeader
actions={
<>
{canCreateGroup && isTemplateRBACEnabled && (
{canAssignOrgRole && isCustomRolesEnabled && (
<Button
component={RouterLink}
startIcon={<GroupAdd />}
Expand All @@ -79,8 +79,8 @@ export const CustomRolesPage: FC = () => {

<CustomRolesPageView
roles={organizationRolesQuery.data}
canCreateGroup={canCreateGroup}
isTemplateRBACEnabled={isTemplateRBACEnabled}
canAssignOrgRole={canAssignOrgRole}
isCustomRolesEnabled={isCustomRolesEnabled}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ import { docs } from "utils/docs";

export type CustomRolesPageViewProps = {
roles: Role[] | undefined;
canCreateGroup: boolean;
isTemplateRBACEnabled: boolean;
canAssignOrgRole: boolean;
isCustomRolesEnabled: boolean;
};

// const filter = createFilterOptions<Role>();

export const CustomRolesPageView: FC<CustomRolesPageViewProps> = ({
roles,
canCreateGroup,
isTemplateRBACEnabled,
canAssignOrgRole,
isCustomRolesEnabled,
}) => {
const isLoading = Boolean(roles === undefined);
const isEmpty = Boolean(roles && roles.length === 0);
// const [selectedRole, setSelectedRole] = useState<Role | null>(null);

console.log({ roles });
return (
<>
<ChooseOne>
<Cond condition={!isTemplateRBACEnabled}>
<Cond condition={!isCustomRolesEnabled}>
<Paywall
message="Custom Roles"
description="Organize users into groups with restricted access to templates. You need an Enterprise license to use this feature."
Expand Down Expand Up @@ -77,19 +77,19 @@ export const CustomRolesPageView: FC<CustomRolesPageViewProps> = ({
<EmptyState
message="No groups yet"
description={
canCreateGroup
? "Create your first group"
: "You don't have permission to create a group"
canAssignOrgRole
? "Create your first custom role"
: "You don't have permission to create a custom role"
}
cta={
canCreateGroup && (
canAssignOrgRole && (
<Button
component={RouterLink}
to="create"
startIcon={<AddOutlined />}
variant="contained"
>
Create group
Create custom role
</Button>
)
}
Expand Down
Loading