Skip to content

Commit 55c5fe6

Browse files
committed
Currently "activate" on ui does nothing
1 parent 15a9b36 commit 55c5fe6

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

site/src/api/api.ts

+5
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ export const updateProfile = async (
218218
return response.data
219219
}
220220

221+
export const activateUser = async (userId: TypesGen.User["id"]): Promise<TypesGen.User> => {
222+
const response = await axios.put<TypesGen.User>(`/api/v2/users/${userId}/status/active`)
223+
return response.data
224+
}
225+
221226
export const suspendUser = async (userId: TypesGen.User["id"]): Promise<TypesGen.User> => {
222227
const response = await axios.put<TypesGen.User>(`/api/v2/users/${userId}/status/suspend`)
223228
return response.data

site/src/components/UsersTable/UsersTable.tsx

+18-11
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ export const UsersTable: React.FC<UsersTableProps> = ({
6565
<TableCell>
6666
<AvatarData title={u.username} subtitle={u.email} />
6767
</TableCell>
68-
<TableCell>
69-
{u.status}
70-
</TableCell>
68+
<TableCell>{u.status}</TableCell>
7169
<TableCell>
7270
{canEditUsers ? (
7371
<RoleSelect
@@ -86,16 +84,25 @@ export const UsersTable: React.FC<UsersTableProps> = ({
8684
data={u}
8785
menuItems={
8886
// Return either suspend or activate depending on status
89-
(u.status == "active" ? [{
90-
label: Language.suspendMenuItem,
91-
onClick: onSuspendUser,
92-
}] : [{
93-
label: Language.activateMenuItem,
94-
onClick: onSuspendUser,
95-
}]).concat({
87+
(u.status == "active"
88+
? [
89+
{
90+
label: Language.suspendMenuItem,
91+
onClick: onSuspendUser,
92+
},
93+
]
94+
: [
95+
{
96+
label: Language.activateMenuItem,
97+
// TODO: Activate user
98+
onClick: function () {},
99+
},
100+
]
101+
).concat({
96102
label: Language.resetPasswordMenuItem,
97103
onClick: onResetUserPassword,
98-
})}
104+
})
105+
}
99106
/>
100107
</TableCell>
101108
)}

site/src/pages/LoginPage/LoginPage.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { makeStyles } from "@material-ui/core/styles"
22
import { useActor } from "@xstate/react"
33
import React, { useContext } from "react"
44
import { Navigate, useLocation } from "react-router-dom"
5+
import { isApiError } from "../../api/errors"
56
import { Footer } from "../../components/Footer/Footer"
67
import { SignInForm } from "../../components/SignInForm/SignInForm"
78
import { retrieveRedirect } from "../../util/redirect"
89
import { XServiceContext } from "../../xServices/StateContext"
9-
import { AxiosError } from "axios"
10-
import {isApiError} from "../../api/errors";
1110

1211
export const useStyles = makeStyles((theme) => ({
1312
root: {
@@ -35,7 +34,9 @@ export const LoginPage: React.FC = () => {
3534
const [authState, authSend] = useActor(xServices.authXService)
3635
const isLoading = authState.hasTag("loading")
3736
const redirectTo = retrieveRedirect(location.search)
38-
const authErrorMessage = isApiError(authState.context.authError) ? authState.context.authError.response.data.message : undefined
37+
const authErrorMessage = isApiError(authState.context.authError)
38+
? authState.context.authError.response.data.message
39+
: undefined
3940
const getMethodsError = authState.context.getMethodsError
4041
? (authState.context.getMethodsError as Error).message
4142
: undefined

site/src/xServices/auth/authXService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { AxiosError } from "axios"
12
import { assign, createMachine } from "xstate"
23
import * as API from "../../api/api"
34
import * as TypesGen from "../../api/typesGenerated"
45
import { displayError, displaySuccess } from "../../components/GlobalSnackbar/utils"
5-
import { AxiosError } from "axios"
66

77
export const Language = {
88
successProfileUpdate: "Updated settings.",

0 commit comments

Comments
 (0)