Skip to content

Commit cabe385

Browse files
committed
Update API
1 parent b167995 commit cabe385

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

site/src/api/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export const suspendUser = async (userId: TypesGen.User["id"]): Promise<TypesGen
159159
export const updateUserPassword = async (password: string, userId: TypesGen.User["id"]): Promise<undefined> =>
160160
axios.put(`/api/v2/users/${userId}/password`, { password })
161161

162-
export const getOrganizationRoles = async (organizationId: string): Promise<Array<string>> => {
163-
const response = await axios.get<Array<string>>(`/api/v2/organizations/${organizationId}/members/roles`)
162+
export const getOrganizationRoles = async (organizationId: string): Promise<Array<TypesGen.Role>> => {
163+
const response = await axios.get<Array<TypesGen.Role>>(`/api/v2/organizations/${organizationId}/members/roles`)
164164
return response.data
165165
}

site/src/components/UsersTable/UsersTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import TableHead from "@material-ui/core/TableHead"
66
import TableRow from "@material-ui/core/TableRow"
77
import React from "react"
88
import { UserResponse } from "../../api/types"
9+
import * as TypesGen from "../../api/typesGenerated"
910
import { EmptyState } from "../EmptyState/EmptyState"
1011
import { TableHeaderRow } from "../TableHeaders/TableHeaders"
1112
import { TableRowMenu } from "../TableRowMenu/TableRowMenu"
@@ -26,7 +27,7 @@ export interface UsersTableProps {
2627
users: UserResponse[]
2728
onSuspendUser: (user: UserResponse) => void
2829
onResetUserPassword: (user: UserResponse) => void
29-
roles: string[]
30+
roles: TypesGen.Role[]
3031
}
3132

3233
export const UsersTable: React.FC<UsersTableProps> = ({ users, roles, onSuspendUser, onResetUserPassword }) => {
@@ -47,7 +48,7 @@ export const UsersTable: React.FC<UsersTableProps> = ({ users, roles, onSuspendU
4748
<TableCell>
4849
<UserCell Avatar={{ username: u.username }} primaryText={u.username} caption={u.email} />{" "}
4950
</TableCell>
50-
<TableCell>{roles}</TableCell>
51+
<TableCell>{roles.map((r) => r.display_name)}</TableCell>
5152
<TableCell>
5253
<TableRowMenu
5354
data={u}

site/src/pages/UsersPage/UsersPageView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react"
22
import { UserResponse } from "../../api/types"
3+
import * as TypesGen from "../../api/typesGenerated"
34
import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary"
45
import { Header } from "../../components/Header/Header"
56
import { Margins } from "../../components/Margins/Margins"
@@ -16,7 +17,7 @@ export interface UsersPageViewProps {
1617
openUserCreationDialog: () => void
1718
onSuspendUser: (user: UserResponse) => void
1819
onResetUserPassword: (user: UserResponse) => void
19-
roles: string[]
20+
roles: TypesGen.Role[]
2021
error?: unknown
2122
}
2223

site/src/xServices/roles/rolesXService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { assign, createMachine } from "xstate"
22
import * as API from "../../api"
3+
import * as TypesGen from "../../api/typesGenerated"
34
import { displayError } from "../../components/GlobalSnackbar/utils"
45

56
type RolesContext = {
6-
roles?: string[]
7+
roles?: TypesGen.Role[]
78
getRolesError: Error | unknown
89
organizationId?: string
910
}
@@ -22,7 +23,7 @@ export const rolesMachine = createMachine(
2223
events: {} as RolesEvent,
2324
services: {
2425
getRoles: {
25-
data: {} as string[],
26+
data: {} as TypesGen.Role[],
2627
},
2728
},
2829
},

0 commit comments

Comments
 (0)