Skip to content

Commit

Permalink
feat: disable user ui
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Feb 4, 2023
1 parent e21657b commit 7a810e4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lang/en/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"base_path": "Base path",
"role": "Role",
"permission": "Permission",
"disabled": "Disabled",
"available": "Available",
"update_profile": "Update Profile",
"update_profile_success": "Update profile successfully, please re-login.",
"change_username": "Change Username",
Expand Down
14 changes: 14 additions & 0 deletions src/pages/manage/users/AddOrEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const AddOrEdit = () => {
base_path: "",
role: 0,
permission: 0,
disabled: false,
github_id: 0,
})
const [userLoading, loadUser] = useFetch(
(): PResp<User> => r.get(`/admin/user/get?id=${id}`)
Expand Down Expand Up @@ -126,6 +128,18 @@ const AddOrEdit = () => {
</For>
</Flex>
</FormControl>
<FormControl w="fit-content" display="flex">
<Checkbox
css={{ whiteSpace: "nowrap" }}
id="disabled"
onChange={(e: any) => setUser("disabled", e.currentTarget.checked)}
color="$neutral10"
fontSize="$sm"
checked={user.disabled}
>
{t(`users.disabled`)}
</Checkbox>
</FormControl>
<Button
loading={okLoading()}
onClick={async () => {
Expand Down
14 changes: 13 additions & 1 deletion src/pages/manage/users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
PEmptyResp,
} from "~/types"
import { DeletePopover } from "../common/DeletePopover"
import { Wether } from "~/components"

const Role = (props: { role: number }) => {
const roles = [
Expand Down Expand Up @@ -102,7 +103,15 @@ const Users = () => {
<Table highlightOnHover dense>
<Thead>
<Tr>
<For each={["username", "base_path", "role", "permission"]}>
<For
each={[
"username",
"base_path",
"role",
"permission",
"available",
]}
>
{(title) => <Th>{t(`users.${title}`)}</Th>}
</For>
<Th>{t("global.operations")}</Th>
Expand All @@ -120,6 +129,9 @@ const Users = () => {
<Td>
<Permissions user={user} />
</Td>
<Td>
<Wether yes={!user.disabled} />
</Td>
<Td>
<HStack spacing="$2">
<Button
Expand Down
1 change: 1 addition & 0 deletions src/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface User {
role: UserRole
permission: number
github_id: number
disabled: boolean
// otp: boolean;
}

Expand Down

0 comments on commit 7a810e4

Please sign in to comment.