mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat: persist state at the org level when tab switching
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
useRevokeIdentityTokenAuthToken,
|
||||
useRevokeIdentityUniversalAuthClientSecret} from "@app/hooks/api";
|
||||
import { usePopUp } from "@app/hooks/usePopUp";
|
||||
import { TabSections } from "@app/types";
|
||||
|
||||
import { IdentityAuthMethodModal } from "../MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityAuthMethodModal";
|
||||
import { IdentityModal } from "../MembersPage/components/OrgIdentityTab/components/IdentitySection/IdentityModal";
|
||||
@@ -154,7 +155,7 @@ export const IdentityPage = withPermission(
|
||||
type="submit"
|
||||
leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
|
||||
onClick={() => {
|
||||
router.push(`/org/${orgId}/members`);
|
||||
router.push(`/org/${orgId}/members?selectedTab=${TabSections.Identities}`);
|
||||
}}
|
||||
className="mb-4"
|
||||
>
|
||||
|
||||
@@ -1,23 +1,38 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import { useRouter } from 'next/router';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
||||
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
|
||||
import { withPermission } from "@app/hoc";
|
||||
import { TabSections } from "@app/types";
|
||||
|
||||
import { OrgIdentityTab, OrgMembersTab, OrgRoleTabSection } from "./components";
|
||||
|
||||
enum TabSections {
|
||||
Member = "members",
|
||||
Roles = "roles",
|
||||
Identities = "identities"
|
||||
}
|
||||
|
||||
export const MembersPage = withPermission(
|
||||
() => {
|
||||
const router = useRouter();
|
||||
const { query } = router;
|
||||
const selectedTab = query.selectedTab as string;
|
||||
const [activeTab, setActiveTab] = useState<TabSections>(TabSections.Member);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedTab && Object.values(TabSections).includes(selectedTab as TabSections)) {
|
||||
setActiveTab(selectedTab as TabSections);
|
||||
}
|
||||
}, [selectedTab]);
|
||||
|
||||
const updateSelectedTab = (tab: TabSections) => {
|
||||
router.push({
|
||||
pathname: router.pathname,
|
||||
query: { ...router.query, selectedTab: tab },
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container mx-auto flex flex-col justify-between bg-bunker-800 text-white">
|
||||
<div className="mx-auto mb-6 w-full max-w-7xl py-6 px-6">
|
||||
<p className="mr-4 mb-4 text-3xl font-semibold text-white">Organization Access Control</p>
|
||||
<Tabs defaultValue={TabSections.Member}>
|
||||
<Tabs value={activeTab} onValueChange={updateSelectedTab}>
|
||||
<TabList>
|
||||
<Tab value={TabSections.Member}>Users</Tab>
|
||||
<Tab value={TabSections.Identities}>
|
||||
@@ -25,7 +40,7 @@ export const MembersPage = withPermission(
|
||||
<p>Machine Identities</p>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab value={TabSections.Roles}>Organization Roles</Tab>
|
||||
<Tab value={TabSections.Roles}>Organization Roles</Tab>
|
||||
</TabList>
|
||||
<TabPanel value={TabSections.Member}>
|
||||
<OrgMembersTab />
|
||||
|
||||
@@ -19,6 +19,7 @@ import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@a
|
||||
import { withPermission } from "@app/hoc";
|
||||
import { useDeleteOrgRole, useGetOrgRole } from "@app/hooks/api";
|
||||
import { usePopUp } from "@app/hooks/usePopUp";
|
||||
import { TabSections } from "@app/types";
|
||||
|
||||
import { RoleDetailsSection, RoleModal, RolePermissionsSection } from "./components";
|
||||
|
||||
@@ -51,7 +52,7 @@ export const RolePage = withPermission(
|
||||
});
|
||||
|
||||
handlePopUpClose("deleteOrgRole");
|
||||
router.push(`/org/${orgId}/members`);
|
||||
router.push(`/org/${orgId}/members?selectedTab=${TabSections.Roles}`);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
const error = err as any;
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
useUpdateOrgMembership
|
||||
} from "@app/hooks/api";
|
||||
import { usePopUp } from "@app/hooks/usePopUp";
|
||||
import { TabSections } from "@app/types";
|
||||
|
||||
import { UserDetailsSection, UserOrgMembershipModal, UserProjectsSection } from "./components";
|
||||
|
||||
@@ -111,7 +112,7 @@ export const UserPage = withPermission(
|
||||
type="submit"
|
||||
leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
|
||||
onClick={() => {
|
||||
router.push(`/org/${orgId}/members`);
|
||||
router.push(`/org/${orgId}/members?selectedTab=${TabSections.Member}`);
|
||||
}}
|
||||
className="mb-4"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user