Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Update API
  • Loading branch information
BrunoQuaresma committed May 6, 2022
commit cabe38559c2c8390fd8b7230f7e7a371e72ed0f7
4 changes: 2 additions & 2 deletions site/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const suspendUser = async (userId: TypesGen.User["id"]): Promise<TypesGen
export const updateUserPassword = async (password: string, userId: TypesGen.User["id"]): Promise<undefined> =>
axios.put(`/api/v2/users/${userId}/password`, { password })

export const getOrganizationRoles = async (organizationId: string): Promise<Array<string>> => {
const response = await axios.get<Array<string>>(`/api/v2/organizations/${organizationId}/members/roles`)
export const getOrganizationRoles = async (organizationId: string): Promise<Array<TypesGen.Role>> => {
const response = await axios.get<Array<TypesGen.Role>>(`/api/v2/organizations/${organizationId}/members/roles`)
return response.data
}
5 changes: 3 additions & 2 deletions site/src/components/UsersTable/UsersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import TableHead from "@material-ui/core/TableHead"
import TableRow from "@material-ui/core/TableRow"
import React from "react"
import { UserResponse } from "../../api/types"
import * as TypesGen from "../../api/typesGenerated"
import { EmptyState } from "../EmptyState/EmptyState"
import { TableHeaderRow } from "../TableHeaders/TableHeaders"
import { TableRowMenu } from "../TableRowMenu/TableRowMenu"
Expand All @@ -26,7 +27,7 @@ export interface UsersTableProps {
users: UserResponse[]
onSuspendUser: (user: UserResponse) => void
onResetUserPassword: (user: UserResponse) => void
roles: string[]
roles: TypesGen.Role[]
}

export const UsersTable: React.FC<UsersTableProps> = ({ users, roles, onSuspendUser, onResetUserPassword }) => {
Expand All @@ -47,7 +48,7 @@ export const UsersTable: React.FC<UsersTableProps> = ({ users, roles, onSuspendU
<TableCell>
<UserCell Avatar={{ username: u.username }} primaryText={u.username} caption={u.email} />{" "}
</TableCell>
<TableCell>{roles}</TableCell>
<TableCell>{roles.map((r) => r.display_name)}</TableCell>
<TableCell>
<TableRowMenu
data={u}
Expand Down
3 changes: 2 additions & 1 deletion site/src/pages/UsersPage/UsersPageView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import { UserResponse } from "../../api/types"
import * as TypesGen from "../../api/typesGenerated"
import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary"
import { Header } from "../../components/Header/Header"
import { Margins } from "../../components/Margins/Margins"
Expand All @@ -16,7 +17,7 @@ export interface UsersPageViewProps {
openUserCreationDialog: () => void
onSuspendUser: (user: UserResponse) => void
onResetUserPassword: (user: UserResponse) => void
roles: string[]
roles: TypesGen.Role[]
error?: unknown
}

Expand Down
5 changes: 3 additions & 2 deletions site/src/xServices/roles/rolesXService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { assign, createMachine } from "xstate"
import * as API from "../../api"
import * as TypesGen from "../../api/typesGenerated"
import { displayError } from "../../components/GlobalSnackbar/utils"

type RolesContext = {
roles?: string[]
roles?: TypesGen.Role[]
getRolesError: Error | unknown
organizationId?: string
}
Expand All @@ -22,7 +23,7 @@ export const rolesMachine = createMachine(
events: {} as RolesEvent,
services: {
getRoles: {
data: {} as string[],
data: {} as TypesGen.Role[],
},
},
},
Expand Down