mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
refactor: return value as Tabsection from isTabSection fn (avoids assertion at setState level)
This commit is contained in:
@@ -6,7 +6,7 @@ enum TabSections {
|
|||||||
ServiceTokens = "service-tokens"
|
ServiceTokens = "service-tokens"
|
||||||
}
|
}
|
||||||
|
|
||||||
const isTabSection = (value: any): boolean => {
|
const isTabSection = (value: any): value is TabSections => {
|
||||||
return Object.values(TabSections).includes(value);
|
return Object.values(TabSections).includes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useEffect, useState } from 'react';
|
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";
|
||||||
@@ -17,7 +18,7 @@ export const MembersPage = withPermission(
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedTab && isTabSection(selectedTab)) {
|
if (selectedTab && isTabSection(selectedTab)) {
|
||||||
setActiveTab(selectedTab as TabSections);
|
setActiveTab(selectedTab);
|
||||||
}
|
}
|
||||||
}, [isTabSection, selectedTab]);
|
}, [isTabSection, selectedTab]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
|
||||||
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
|
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
|
||||||
import { withProjectPermission } from "@app/hoc";
|
import { withProjectPermission } from "@app/hoc";
|
||||||
|
import { TabSections, isTabSection } from '@app/types';
|
||||||
|
|
||||||
import { IdentityTab, MembersTab,ProjectRoleListTab, ServiceTokenTab } from "./components";
|
import { IdentityTab, MembersTab,ProjectRoleListTab, ServiceTokenTab } from "./components";
|
||||||
|
|
||||||
import { TabSections, isTabSection } from '@app/types';
|
|
||||||
|
|
||||||
export const MembersPage = withProjectPermission(
|
export const MembersPage = withProjectPermission(
|
||||||
() => {
|
() => {
|
||||||
@@ -18,7 +19,7 @@ export const MembersPage = withProjectPermission(
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedTab && isTabSection(selectedTab)) {
|
if (selectedTab && isTabSection(selectedTab)) {
|
||||||
setActiveTab(selectedTab as TabSections);
|
setActiveTab(selectedTab);
|
||||||
}
|
}
|
||||||
}, [isTabSection, selectedTab]);
|
}, [isTabSection, selectedTab]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user