MCPcopy Create free account
hub / github.com/FeatureProbe/FeatureProbe / Toggle

Function Toggle

ui/src/pages/toggle/index.tsx:61–670  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59}
60
61const Toggle = () => {
62 const location = useLocation();
63 const search = new URLSearchParams(location.search);
64 const { projectKey, environmentKey } = useParams<IParams>();
65 const [ toggleList, setToggleList ] = useState<IToggle[]>([]);
66 const [ pagination, setPagination ] = useState({
67 pageIndex: 1,
68 totalPages: 1,
69 });
70 const [ visible, setDrawerVisible ] = useState<boolean>(false);
71 const [ isAdd, setIsAdd ] = useState<boolean>(false);
72 const [ total, setTotal ] = useState<number>(0);
73 const [ tagOptions, setTagsOptions ] = useState<ITagOption[]>([]);
74 const [ searchParams, setSearchParams ] = useState<ISearchParams>({
75 pageIndex: Number(search.get('pageIndex')) ?? 0,
76 pageSize: 10,
77 environmentKey,
78 visitFilter: search.get('visitFilter') ?? '',
79 archived: search.get('archived') === 'true',
80 disabled: search.get('disabled') ? search.get('disabled') === 'true' : undefined,
81 permanent: search.get('permanent') ? search.get('permanent') === 'true' : undefined,
82 keyword: search.get('keyword') ?? '',
83 related: search.get('related') ? search.get('related') === 'true' : undefined,
84 tags: search.get('tags') ? search.get('tags')?.split(',') : undefined,
85 });
86
87 const [ archiveOpen, setArchiveOpen ] = useState<boolean>(false);
88 const [ isArchived, setArchived ] = useState<boolean>(search.get('archived') === 'true');
89 const [ isLoading, saveIsLoading ] = useState<boolean>(true);
90 const [ popupOpen, savePopupOpen ] = useState<boolean>(false);
91 const [ releaseStatusList, saveReleaseStatusList ] = useState<string[]>([]);
92 const [ enableApproval, saveEnableApproval ] = useState<boolean>(false);
93 const history = useHistory();
94 const intl = useIntl();
95 const { i18n } = I18NContainer.useContainer();
96
97 useEffect(() => {
98 const handler = () => {
99 if (archiveOpen) {
100 setArchiveOpen(false);
101 }
102 if (popupOpen) {
103 savePopupOpen(false);
104 }
105 };
106 window.addEventListener('click', handler);
107
108 return () => window.removeEventListener('click', handler);
109 }, [archiveOpen, popupOpen]);
110
111 const getToggleLists = useCallback(() => {
112 searchParams.environmentKey = environmentKey;
113 saveIsLoading(true);
114 getToggleList<IToggleList>(projectKey, searchParams)
115 .then(async (res) => {
116 const { success, data, code } = res;
117 saveIsLoading(false);
118 if (success && data) {

Callers

nothing calls this directly

Calls 10

getToggleListFunction · 0.90
saveDictionaryFunction · 0.90
evaluationOptionsFunction · 0.90
statusOptionsFunction · 0.90
permanentOptionsFunction · 0.90
toStringMethod · 0.80
handleChangeFunction · 0.70
getMethod · 0.65
pushMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected