Skip to content

Commit

Permalink
feat: Organization users management (TracecatHQ#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
daryllimyt authored Nov 30, 2024
1 parent ce5f227 commit 95c70da
Show file tree
Hide file tree
Showing 16 changed files with 957 additions and 13 deletions.
29 changes: 29 additions & 0 deletions frontend/src/app/organization/members/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use client"

import { OrgMembersTable } from "@/components/organization/org-members-table"

export default function MembersPage() {
return (
<div className="size-full overflow-auto">
<div className="container flex h-full max-w-[1000px] flex-col space-y-12">
<div className="flex w-full">
<div className="items-start space-y-3 text-left">
<h2 className="text-2xl font-semibold tracking-tight">
Organization Members
</h2>
<p className="text-md text-muted-foreground">
View all organization members here.
</p>
</div>
<div className="ml-auto flex items-center space-x-2"></div>
</div>
<div className="space-y-4">
<>
<h6 className="text-sm font-semibold">Manage Members</h6>
<OrgMembersTable />
</>
</div>
</div>
</div>
)
}
18 changes: 15 additions & 3 deletions frontend/src/app/organization/sidebar-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Link from "next/link"
import { usePathname } from "next/navigation"
import { KeyRoundIcon, LucideIcon } from "lucide-react"
import { KeyRoundIcon, LucideIcon, UsersIcon } from "lucide-react"

import { cn } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
Expand All @@ -13,7 +13,7 @@ type NavItem = {
href: string
}

const navItems: NavItem[] = [
const secretNavItems: NavItem[] = [
{
title: "Credentials",
href: "/organization/credentials",
Expand All @@ -24,6 +24,13 @@ const navItems: NavItem[] = [
},
]

const userNavItems: NavItem[] = [
{
title: "Members",
href: "/organization/members",
},
]

interface SidebarNavProps extends React.HTMLAttributes<HTMLElement> {
title: string
icon: LucideIcon
Expand All @@ -36,7 +43,12 @@ export function OrganizationSidebarNav() {
<div className="space-y-0.5">
<h2 className="text-xl font-bold tracking-tight">Organization</h2>
</div>
<SidebarNavBlock title="Secrets" icon={KeyRoundIcon} items={navItems} />
<SidebarNavBlock
title="Secrets"
icon={KeyRoundIcon}
items={secretNavItems}
/>
<SidebarNavBlock title="Users" icon={UsersIcon} items={userNavItems} />
</div>
)
}
Expand Down
55 changes: 55 additions & 0 deletions frontend/src/client/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,61 @@ export const $OAuth2AuthorizeResponse = {
title: 'OAuth2AuthorizeResponse'
} as const;

export const $OrgMemberRead = {
properties: {
user_id: {
type: 'string',
format: 'uuid4',
title: 'User Id'
},
first_name: {
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
],
title: 'First Name'
},
last_name: {
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
],
title: 'Last Name'
},
email: {
type: 'string',
format: 'email',
title: 'Email'
},
role: {
'$ref': '#/components/schemas/UserRole'
},
is_active: {
type: 'boolean',
title: 'Is Active'
},
is_superuser: {
type: 'boolean',
title: 'Is Superuser'
},
is_verified: {
type: 'boolean',
title: 'Is Verified'
}
},
type: 'object',
required: ['user_id', 'first_name', 'last_name', 'email', 'role', 'is_active', 'is_superuser', 'is_verified'],
title: 'OrgMemberRead'
} as const;

export const $RegistryActionCreate = {
properties: {
name: {
Expand Down
51 changes: 50 additions & 1 deletion frontend/src/client/services.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { CancelablePromise } from './core/CancelablePromise';
import { OpenAPI } from './core/OpenAPI';
import { request as __request } from './core/request';
import type { PublicIncomingWebhookData, PublicIncomingWebhookResponse, PublicIncomingWebhookWaitData, PublicIncomingWebhookWaitResponse, WorkspacesListWorkspacesResponse, WorkspacesCreateWorkspaceData, WorkspacesCreateWorkspaceResponse, WorkspacesSearchWorkspacesData, WorkspacesSearchWorkspacesResponse, WorkspacesGetWorkspaceData, WorkspacesGetWorkspaceResponse, WorkspacesUpdateWorkspaceData, WorkspacesUpdateWorkspaceResponse, WorkspacesDeleteWorkspaceData, WorkspacesDeleteWorkspaceResponse, WorkspacesListWorkspaceMembershipsData, WorkspacesListWorkspaceMembershipsResponse, WorkspacesCreateWorkspaceMembershipData, WorkspacesCreateWorkspaceMembershipResponse, WorkspacesGetWorkspaceMembershipData, WorkspacesGetWorkspaceMembershipResponse, WorkspacesDeleteWorkspaceMembershipData, WorkspacesDeleteWorkspaceMembershipResponse, WorkflowsListWorkflowsData, WorkflowsListWorkflowsResponse, WorkflowsCreateWorkflowData, WorkflowsCreateWorkflowResponse, WorkflowsGetWorkflowData, WorkflowsGetWorkflowResponse, WorkflowsUpdateWorkflowData, WorkflowsUpdateWorkflowResponse, WorkflowsDeleteWorkflowData, WorkflowsDeleteWorkflowResponse, WorkflowsCommitWorkflowData, WorkflowsCommitWorkflowResponse, WorkflowsExportWorkflowData, WorkflowsExportWorkflowResponse, WorkflowsGetWorkflowDefinitionData, WorkflowsGetWorkflowDefinitionResponse, WorkflowsCreateWorkflowDefinitionData, WorkflowsCreateWorkflowDefinitionResponse, TriggersCreateWebhookData, TriggersCreateWebhookResponse, TriggersGetWebhookData, TriggersGetWebhookResponse, TriggersUpdateWebhookData, TriggersUpdateWebhookResponse, WorkflowExecutionsListWorkflowExecutionsData, WorkflowExecutionsListWorkflowExecutionsResponse, WorkflowExecutionsCreateWorkflowExecutionData, WorkflowExecutionsCreateWorkflowExecutionResponse, WorkflowExecutionsGetWorkflowExecutionData, WorkflowExecutionsGetWorkflowExecutionResponse, WorkflowExecutionsListWorkflowExecutionEventHistoryData, WorkflowExecutionsListWorkflowExecutionEventHistoryResponse, WorkflowExecutionsCancelWorkflowExecutionData, WorkflowExecutionsCancelWorkflowExecutionResponse, WorkflowExecutionsTerminateWorkflowExecutionData, WorkflowExecutionsTerminateWorkflowExecutionResponse, ActionsListActionsData, ActionsListActionsResponse, ActionsCreateActionData, ActionsCreateActionResponse, ActionsGetActionData, ActionsGetActionResponse, ActionsUpdateActionData, ActionsUpdateActionResponse, ActionsDeleteActionData, ActionsDeleteActionResponse, SecretsSearchSecretsData, SecretsSearchSecretsResponse, SecretsListSecretsData, SecretsListSecretsResponse, SecretsCreateSecretData, SecretsCreateSecretResponse, SecretsGetSecretByNameData, SecretsGetSecretByNameResponse, SecretsUpdateSecretByIdData, SecretsUpdateSecretByIdResponse, SecretsDeleteSecretByIdData, SecretsDeleteSecretByIdResponse, SchedulesListSchedulesData, SchedulesListSchedulesResponse, SchedulesCreateScheduleData, SchedulesCreateScheduleResponse, SchedulesGetScheduleData, SchedulesGetScheduleResponse, SchedulesUpdateScheduleData, SchedulesUpdateScheduleResponse, SchedulesDeleteScheduleData, SchedulesDeleteScheduleResponse, SchedulesSearchSchedulesData, SchedulesSearchSchedulesResponse, UsersSearchUserData, UsersSearchUserResponse, RegistryRepositoriesSyncRegistryRepositoriesData, RegistryRepositoriesSyncRegistryRepositoriesResponse, RegistryRepositoriesListRegistryRepositoriesResponse, RegistryRepositoriesCreateRegistryRepositoryData, RegistryRepositoriesCreateRegistryRepositoryResponse, RegistryRepositoriesGetRegistryRepositoryData, RegistryRepositoriesGetRegistryRepositoryResponse, RegistryRepositoriesUpdateRegistryRepositoryData, RegistryRepositoriesUpdateRegistryRepositoryResponse, RegistryRepositoriesDeleteRegistryRepositoryData, RegistryRepositoriesDeleteRegistryRepositoryResponse, RegistryActionsListRegistryActionsResponse, RegistryActionsCreateRegistryActionData, RegistryActionsCreateRegistryActionResponse, RegistryActionsGetRegistryActionData, RegistryActionsGetRegistryActionResponse, RegistryActionsUpdateRegistryActionData, RegistryActionsUpdateRegistryActionResponse, RegistryActionsDeleteRegistryActionData, RegistryActionsDeleteRegistryActionResponse, RegistryActionsRunRegistryActionData, RegistryActionsRunRegistryActionResponse, RegistryActionsValidateRegistryActionData, RegistryActionsValidateRegistryActionResponse, UsersUsersCurrentUserResponse, UsersUsersPatchCurrentUserData, UsersUsersPatchCurrentUserResponse, UsersUsersUserData, UsersUsersUserResponse, UsersUsersPatchUserData, UsersUsersPatchUserResponse, UsersUsersDeleteUserData, UsersUsersDeleteUserResponse, AuthAuthDatabaseLoginData, AuthAuthDatabaseLoginResponse, AuthAuthDatabaseLogoutResponse, AuthRegisterRegisterData, AuthRegisterRegisterResponse, AuthResetForgotPasswordData, AuthResetForgotPasswordResponse, AuthResetResetPasswordData, AuthResetResetPasswordResponse, AuthVerifyRequestTokenData, AuthVerifyRequestTokenResponse, AuthVerifyVerifyData, AuthVerifyVerifyResponse, AuthOauthGoogleDatabaseAuthorizeData, AuthOauthGoogleDatabaseAuthorizeResponse, AuthOauthGoogleDatabaseCallbackData, AuthOauthGoogleDatabaseCallbackResponse, AuthSamlDatabaseLoginResponse, AuthSsoAcsData, AuthSsoAcsResponse, PublicCheckHealthResponse } from './types.gen';
import type { PublicIncomingWebhookData, PublicIncomingWebhookResponse, PublicIncomingWebhookWaitData, PublicIncomingWebhookWaitResponse, WorkspacesListWorkspacesResponse, WorkspacesCreateWorkspaceData, WorkspacesCreateWorkspaceResponse, WorkspacesSearchWorkspacesData, WorkspacesSearchWorkspacesResponse, WorkspacesGetWorkspaceData, WorkspacesGetWorkspaceResponse, WorkspacesUpdateWorkspaceData, WorkspacesUpdateWorkspaceResponse, WorkspacesDeleteWorkspaceData, WorkspacesDeleteWorkspaceResponse, WorkspacesListWorkspaceMembershipsData, WorkspacesListWorkspaceMembershipsResponse, WorkspacesCreateWorkspaceMembershipData, WorkspacesCreateWorkspaceMembershipResponse, WorkspacesGetWorkspaceMembershipData, WorkspacesGetWorkspaceMembershipResponse, WorkspacesDeleteWorkspaceMembershipData, WorkspacesDeleteWorkspaceMembershipResponse, WorkflowsListWorkflowsData, WorkflowsListWorkflowsResponse, WorkflowsCreateWorkflowData, WorkflowsCreateWorkflowResponse, WorkflowsGetWorkflowData, WorkflowsGetWorkflowResponse, WorkflowsUpdateWorkflowData, WorkflowsUpdateWorkflowResponse, WorkflowsDeleteWorkflowData, WorkflowsDeleteWorkflowResponse, WorkflowsCommitWorkflowData, WorkflowsCommitWorkflowResponse, WorkflowsExportWorkflowData, WorkflowsExportWorkflowResponse, WorkflowsGetWorkflowDefinitionData, WorkflowsGetWorkflowDefinitionResponse, WorkflowsCreateWorkflowDefinitionData, WorkflowsCreateWorkflowDefinitionResponse, TriggersCreateWebhookData, TriggersCreateWebhookResponse, TriggersGetWebhookData, TriggersGetWebhookResponse, TriggersUpdateWebhookData, TriggersUpdateWebhookResponse, WorkflowExecutionsListWorkflowExecutionsData, WorkflowExecutionsListWorkflowExecutionsResponse, WorkflowExecutionsCreateWorkflowExecutionData, WorkflowExecutionsCreateWorkflowExecutionResponse, WorkflowExecutionsGetWorkflowExecutionData, WorkflowExecutionsGetWorkflowExecutionResponse, WorkflowExecutionsListWorkflowExecutionEventHistoryData, WorkflowExecutionsListWorkflowExecutionEventHistoryResponse, WorkflowExecutionsCancelWorkflowExecutionData, WorkflowExecutionsCancelWorkflowExecutionResponse, WorkflowExecutionsTerminateWorkflowExecutionData, WorkflowExecutionsTerminateWorkflowExecutionResponse, ActionsListActionsData, ActionsListActionsResponse, ActionsCreateActionData, ActionsCreateActionResponse, ActionsGetActionData, ActionsGetActionResponse, ActionsUpdateActionData, ActionsUpdateActionResponse, ActionsDeleteActionData, ActionsDeleteActionResponse, SecretsSearchSecretsData, SecretsSearchSecretsResponse, SecretsListSecretsData, SecretsListSecretsResponse, SecretsCreateSecretData, SecretsCreateSecretResponse, SecretsGetSecretByNameData, SecretsGetSecretByNameResponse, SecretsUpdateSecretByIdData, SecretsUpdateSecretByIdResponse, SecretsDeleteSecretByIdData, SecretsDeleteSecretByIdResponse, SchedulesListSchedulesData, SchedulesListSchedulesResponse, SchedulesCreateScheduleData, SchedulesCreateScheduleResponse, SchedulesGetScheduleData, SchedulesGetScheduleResponse, SchedulesUpdateScheduleData, SchedulesUpdateScheduleResponse, SchedulesDeleteScheduleData, SchedulesDeleteScheduleResponse, SchedulesSearchSchedulesData, SchedulesSearchSchedulesResponse, UsersSearchUserData, UsersSearchUserResponse, RegistryRepositoriesSyncRegistryRepositoriesData, RegistryRepositoriesSyncRegistryRepositoriesResponse, RegistryRepositoriesListRegistryRepositoriesResponse, RegistryRepositoriesCreateRegistryRepositoryData, RegistryRepositoriesCreateRegistryRepositoryResponse, RegistryRepositoriesGetRegistryRepositoryData, RegistryRepositoriesGetRegistryRepositoryResponse, RegistryRepositoriesUpdateRegistryRepositoryData, RegistryRepositoriesUpdateRegistryRepositoryResponse, RegistryRepositoriesDeleteRegistryRepositoryData, RegistryRepositoriesDeleteRegistryRepositoryResponse, RegistryActionsListRegistryActionsResponse, RegistryActionsCreateRegistryActionData, RegistryActionsCreateRegistryActionResponse, RegistryActionsGetRegistryActionData, RegistryActionsGetRegistryActionResponse, RegistryActionsUpdateRegistryActionData, RegistryActionsUpdateRegistryActionResponse, RegistryActionsDeleteRegistryActionData, RegistryActionsDeleteRegistryActionResponse, RegistryActionsRunRegistryActionData, RegistryActionsRunRegistryActionResponse, RegistryActionsValidateRegistryActionData, RegistryActionsValidateRegistryActionResponse, OrganizationListOrgMembersResponse, OrganizationDeleteOrgMemberData, OrganizationDeleteOrgMemberResponse, OrganizationUpdateOrgMemberData, OrganizationUpdateOrgMemberResponse, UsersUsersCurrentUserResponse, UsersUsersPatchCurrentUserData, UsersUsersPatchCurrentUserResponse, UsersUsersUserData, UsersUsersUserResponse, UsersUsersPatchUserData, UsersUsersPatchUserResponse, UsersUsersDeleteUserData, UsersUsersDeleteUserResponse, AuthAuthDatabaseLoginData, AuthAuthDatabaseLoginResponse, AuthAuthDatabaseLogoutResponse, AuthRegisterRegisterData, AuthRegisterRegisterResponse, AuthResetForgotPasswordData, AuthResetForgotPasswordResponse, AuthResetResetPasswordData, AuthResetResetPasswordResponse, AuthVerifyRequestTokenData, AuthVerifyRequestTokenResponse, AuthVerifyVerifyData, AuthVerifyVerifyResponse, AuthOauthGoogleDatabaseAuthorizeData, AuthOauthGoogleDatabaseAuthorizeResponse, AuthOauthGoogleDatabaseCallbackData, AuthOauthGoogleDatabaseCallbackResponse, AuthSamlDatabaseLoginResponse, AuthSsoAcsData, AuthSsoAcsResponse, PublicCheckHealthResponse } from './types.gen';

/**
* Incoming Webhook
Expand Down Expand Up @@ -1351,6 +1351,55 @@ export const registryActionsValidateRegistryAction = (data: RegistryActionsValid
}
}); };

/**
* List Org Members
* @returns OrgMemberRead Successful Response
* @throws ApiError
*/
export const organizationListOrgMembers = (): CancelablePromise<OrganizationListOrgMembersResponse> => { return __request(OpenAPI, {
method: 'GET',
url: '/organization/members'
}); };

/**
* Delete Org Member
* @param data The data for the request.
* @param data.userId
* @returns void Successful Response
* @throws ApiError
*/
export const organizationDeleteOrgMember = (data: OrganizationDeleteOrgMemberData): CancelablePromise<OrganizationDeleteOrgMemberResponse> => { return __request(OpenAPI, {
method: 'DELETE',
url: '/organization/members/{user_id}',
path: {
user_id: data.userId
},
errors: {
422: 'Validation Error'
}
}); };

/**
* Update Org Member
* @param data The data for the request.
* @param data.userId
* @param data.requestBody
* @returns OrgMemberRead Successful Response
* @throws ApiError
*/
export const organizationUpdateOrgMember = (data: OrganizationUpdateOrgMemberData): CancelablePromise<OrganizationUpdateOrgMemberResponse> => { return __request(OpenAPI, {
method: 'PATCH',
url: '/organization/members/{user_id}',
path: {
user_id: data.userId
},
body: data.requestBody,
mediaType: 'application/json',
errors: {
422: 'Validation Error'
}
}); };

/**
* Users:Current User
* @returns UserRead Successful Response
Expand Down
64 changes: 64 additions & 0 deletions frontend/src/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,17 @@ export type OAuth2AuthorizeResponse = {
authorization_url: string;
};

export type OrgMemberRead = {
user_id: string;
first_name: string | null;
last_name: string | null;
email: string;
role: UserRole;
is_active: boolean;
is_superuser: boolean;
is_verified: boolean;
};

/**
* API create model for a registered action.
*/
Expand Down Expand Up @@ -1665,6 +1676,21 @@ export type RegistryActionsValidateRegistryActionData = {

export type RegistryActionsValidateRegistryActionResponse = RegistryActionValidateResponse;

export type OrganizationListOrgMembersResponse = Array<OrgMemberRead>;

export type OrganizationDeleteOrgMemberData = {
userId: string;
};

export type OrganizationDeleteOrgMemberResponse = void;

export type OrganizationUpdateOrgMemberData = {
requestBody: UserUpdate;
userId: string;
};

export type OrganizationUpdateOrgMemberResponse = OrgMemberRead;

export type UsersUsersCurrentUserResponse = UserRead;

export type UsersUsersPatchCurrentUserData = {
Expand Down Expand Up @@ -2608,6 +2634,44 @@ export type $OpenApiTs = {
};
};
};
'/organization/members': {
get: {
res: {
/**
* Successful Response
*/
200: Array<OrgMemberRead>;
};
};
};
'/organization/members/{user_id}': {
delete: {
req: OrganizationDeleteOrgMemberData;
res: {
/**
* Successful Response
*/
204: void;
/**
* Validation Error
*/
422: HTTPValidationError;
};
};
patch: {
req: OrganizationUpdateOrgMemberData;
res: {
/**
* Successful Response
*/
200: OrgMemberRead;
/**
* Validation Error
*/
422: HTTPValidationError;
};
};
};
'/users/me': {
get: {
res: {
Expand Down
Loading

0 comments on commit 95c70da

Please sign in to comment.