mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 12:27:28 +00:00
refactor: create helper fn to check if string is in TabSections
This commit is contained in:
@@ -6,4 +6,8 @@ enum TabSections {
|
|||||||
ServiceTokens = "service-tokens"
|
ServiceTokens = "service-tokens"
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TabSections
|
const isTabSection = (value: any): boolean => {
|
||||||
|
return Object.values(TabSections).includes(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { TabSections, isTabSection }
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
import TabSections from "./TabSections";
|
import { TabSections, isTabSection } from "./TabSections";
|
||||||
export { TabSections };
|
|
||||||
|
export { TabSections, isTabSection };
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
||||||
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
|
import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
|
||||||
import { withPermission } from "@app/hoc";
|
import { withPermission } from "@app/hoc";
|
||||||
import { TabSections } from "@app/types";
|
import { isTabSection, TabSections } from "@app/types";
|
||||||
|
|
||||||
import { OrgIdentityTab, OrgMembersTab, OrgRoleTabSection } from "./components";
|
import { OrgIdentityTab, OrgMembersTab, OrgRoleTabSection } from "./components";
|
||||||
|
|
||||||
@@ -16,10 +16,10 @@ export const MembersPage = withPermission(
|
|||||||
const [activeTab, setActiveTab] = useState<TabSections>(TabSections.Member);
|
const [activeTab, setActiveTab] = useState<TabSections>(TabSections.Member);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedTab && Object.values(TabSections).includes(selectedTab as TabSections)) {
|
if (selectedTab && isTabSection(selectedTab)) {
|
||||||
setActiveTab(selectedTab as TabSections);
|
setActiveTab(selectedTab as TabSections);
|
||||||
}
|
}
|
||||||
}, [selectedTab]);
|
}, [isTabSection, selectedTab]);
|
||||||
|
|
||||||
const updateSelectedTab = (tab: string) => {
|
const updateSelectedTab = (tab: string) => {
|
||||||
router.push({
|
router.push({
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { withProjectPermission } from "@app/hoc";
|
|||||||
|
|
||||||
import { IdentityTab, MembersTab,ProjectRoleListTab, ServiceTokenTab } from "./components";
|
import { IdentityTab, MembersTab,ProjectRoleListTab, ServiceTokenTab } from "./components";
|
||||||
|
|
||||||
import { TabSections } from '@app/types';
|
import { TabSections, isTabSection } from '@app/types';
|
||||||
|
|
||||||
export const MembersPage = withProjectPermission(
|
export const MembersPage = withProjectPermission(
|
||||||
() => {
|
() => {
|
||||||
@@ -17,10 +17,10 @@ export const MembersPage = withProjectPermission(
|
|||||||
const [activeTab, setActiveTab] = useState<TabSections>(TabSections.Member);
|
const [activeTab, setActiveTab] = useState<TabSections>(TabSections.Member);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedTab && Object.values(TabSections).includes(selectedTab as TabSections)) {
|
if (selectedTab && isTabSection(selectedTab)) {
|
||||||
setActiveTab(selectedTab as TabSections);
|
setActiveTab(selectedTab as TabSections);
|
||||||
}
|
}
|
||||||
}, [selectedTab]);
|
}, [isTabSection, selectedTab]);
|
||||||
|
|
||||||
const updateSelectedTab = (tab: string) => {
|
const updateSelectedTab = (tab: string) => {
|
||||||
router.push({
|
router.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user