Skip to content

Commit

Permalink
Provide route for Sudo rules
Browse files Browse the repository at this point in the history
As the Active users > Is a member of' > 'Sudo rules'
section is now implemented, it needs its own route
to navigate to it.

Signed-off-by: Carla Martinez <[email protected]>
  • Loading branch information
carma12 committed May 23, 2024
1 parent 8b5c53b commit 3d1e081
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/components/MemberOf/MemberOfSudoRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,29 @@ import {
import { API_VERSION_BACKUP, paginate } from "src/utils/utils";
import { apiToSudoRule } from "src/utils/sudoRulesUtils";
import { ErrorResult } from "src/services/rpc";
// Navigation
import { useNavigate, useParams } from "react-router-dom";
import { URL_PREFIX } from "src/navigation/NavRoutes";

interface MemberOfSudoRulesProps {
user: Partial<User>;
from: string;
isUserDataLoading: boolean;
onRefreshUserData: () => void;
}

const MemberOfSudoRules = (props: MemberOfSudoRulesProps) => {
const navigate = useNavigate();
const { uid } = useParams();

React.useEffect(() => {
if (props.user && props.user.uid) {
navigate(
URL_PREFIX + "/" + props.from + "/" + uid + "/memberof_sudorule"
);
}
}, [props.user]);

// Alerts to show in the UI
const alerts = useAlerts();

Expand Down
2 changes: 1 addition & 1 deletion src/navigation/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const AppRoutes = (): React.ReactElement => (
element={<ActiveUsersTabs memberof="hbacrule" />}
/>
<Route
path="memberof_rule"
path="memberof_sudorule"
element={<ActiveUsersTabs memberof="sudorule" />}
/>
</Route>
Expand Down
1 change: 1 addition & 0 deletions src/pages/ActiveUsers/UserMemberOf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ const UserMemberOf = (props: PropsToUserMemberOf) => {
>
<MemberOfSudoRules
user={user}
from={props.from}
isUserDataLoading={userQuery.isFetching}
onRefreshUserData={onRefreshUserData}
/>
Expand Down

0 comments on commit 3d1e081

Please sign in to comment.