From a676da3a6b3fb0d8644dfcd714005a138c4c7ade Mon Sep 17 00:00:00 2001 From: Chanwit Kaewkasi Date: Mon, 1 Jun 2020 19:50:03 +0700 Subject: [PATCH] cleanup debugging logs and optimize uses of local storage --- .../ClusterTemplateCardList.tsx | 9 +-------- .../ProfileCardList/ProfileCardList.tsx | 15 ++++----------- .../components/ProfileCatalog/ProfileCatalog.tsx | 3 --- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/plugins/gitops-profiles/src/components/ClusterTemplateCardList/ClusterTemplateCardList.tsx b/plugins/gitops-profiles/src/components/ClusterTemplateCardList/ClusterTemplateCardList.tsx index f681d20a47..20beb6d00a 100644 --- a/plugins/gitops-profiles/src/components/ClusterTemplateCardList/ClusterTemplateCardList.tsx +++ b/plugins/gitops-profiles/src/components/ClusterTemplateCardList/ClusterTemplateCardList.tsx @@ -17,7 +17,6 @@ import React, { FC } from 'react'; import { Grid } from '@material-ui/core'; import ClusterTemplateCard from '../ClusterTemplateCard'; -import { useLocalStorage } from 'react-use'; interface Props { template: { @@ -30,16 +29,10 @@ interface Props { const ClusterTemplateCardList: FC = props => { const [activeIndex, setActiveIndex] = React.useState(-1); - const [templateRepo, setTemplateRepo] = useLocalStorage( - 'gitops-template-repo', - ); const handleClicked = (index: number, repository: string) => { - // eslint-disable-next-line no-console - console.log(templateRepo); - setActiveIndex(index); - setTemplateRepo(repository); + window.localStorage.setItem('gitops-template-repo', repository); }; return ( diff --git a/plugins/gitops-profiles/src/components/ProfileCardList/ProfileCardList.tsx b/plugins/gitops-profiles/src/components/ProfileCardList/ProfileCardList.tsx index 30fc73cac3..5aea5e56e4 100644 --- a/plugins/gitops-profiles/src/components/ProfileCardList/ProfileCardList.tsx +++ b/plugins/gitops-profiles/src/components/ProfileCardList/ProfileCardList.tsx @@ -16,7 +16,6 @@ import React, { FC, useState } from 'react'; import { Grid } from '@material-ui/core'; import ProfileCard from '../ProfileCard'; -import { useLocalStorage } from 'react-use'; interface Props { profileTemplates: { @@ -30,9 +29,6 @@ interface Props { const ProfileCardList: FC = props => { const [selections, setSelections] = useState>(new Set()); const [profiles, setProfiles] = useState>(new Set()); - const [gitopsProfiles, setGitopsProfiles] = useLocalStorage( - 'gitops-profiles', - ); const handleClicked = (index: number, repository: string) => { if (selections.has(index)) { @@ -46,13 +42,10 @@ const ProfileCardList: FC = props => { setSelections(selections); setProfiles(profiles); - setGitopsProfiles(Array.from(profiles)); - // eslint-disable-next-line no-console - console.log(profiles); - // eslint-disable-next-line no-console - console.log(gitopsProfiles); - // eslint-disable-next-line no-console - console.log(gitopsProfiles); + window.localStorage.setItem( + 'gitops-profiles', + JSON.stringify(Array.from(profiles)), + ); }; return ( diff --git a/plugins/gitops-profiles/src/components/ProfileCatalog/ProfileCatalog.tsx b/plugins/gitops-profiles/src/components/ProfileCatalog/ProfileCatalog.tsx index f54fe6f1fc..1994539950 100644 --- a/plugins/gitops-profiles/src/components/ProfileCatalog/ProfileCatalog.tsx +++ b/plugins/gitops-profiles/src/components/ProfileCatalog/ProfileCatalog.tsx @@ -177,9 +177,6 @@ const ProfileCatalog: FC<{}> = () => { }; const doCreateCluster = async () => { - // eslint-disable-next-line no-console - console.log(gitopsProfiles); - setShowProgress(true); setRunStatus([]);