Skip to content

fix: always show add user button #9229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
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
24 changes: 10 additions & 14 deletions site/src/components/UsersLayout/UsersLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Link from "@mui/material/Link"
import { makeStyles } from "@mui/styles"
import GroupAdd from "@mui/icons-material/GroupAddOutlined"
import PersonAdd from "@mui/icons-material/PersonAddOutlined"
import { useMachine } from "@xstate/react"
import { USERS_LINK } from "components/Navbar/NavbarView"
import { PageHeader, PageHeaderTitle } from "components/PageHeader/PageHeader"
import { useFeatureVisibility } from "hooks/useFeatureVisibility"
Expand All @@ -16,15 +15,13 @@ import {
useNavigate,
} from "react-router-dom"
import { combineClasses } from "utils/combineClasses"
import { authMethodsXService } from "xServices/auth/authMethodsXService"
import { Margins } from "../../components/Margins/Margins"
import { Stack } from "../../components/Stack/Stack"

export const UsersLayout: FC = () => {
const styles = useStyles()
const { createUser: canCreateUser, createGroup: canCreateGroup } =
usePermissions()
const [authMethods] = useMachine(authMethodsXService)
const navigate = useNavigate()
const { template_rbac: isTemplateRBACEnabled } = useFeatureVisibility()

Expand All @@ -34,17 +31,16 @@ export const UsersLayout: FC = () => {
<PageHeader
actions={
<>
{canCreateUser &&
authMethods.context.authMethods?.password.enabled && (
<Button
onClick={() => {
navigate("/users/create")
}}
startIcon={<PersonAdd />}
>
Create user
</Button>
)}
{canCreateUser && (
<Button
onClick={() => {
navigate("/users/create")
}}
startIcon={<PersonAdd />}
>
Create user
</Button>
)}
{canCreateGroup && isTemplateRBACEnabled && (
<Link component={RouterLink} to="/groups/create">
<Button startIcon={<GroupAdd />}>Create group</Button>
Expand Down