Skip to content

Commit

Permalink
Merge pull request #1003 from chaos-genius/redundant-api-in-kpi-explorer
Browse files Browse the repository at this point in the history
added condition for comparing KPI search texts
  • Loading branch information
manassolanki committed Jun 22, 2022
2 parents 06ac831 + 223c72b commit 9c1efb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions frontend/src/components/KPITable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const KPITable = ({
changeData,
pagination,
pgInfo,
setKpiSearch,
setPgInfo
}) => {
const connectionType = useContext(connectionContext);
Expand Down Expand Up @@ -67,7 +66,7 @@ const KPITable = ({
header: 'KPI deleted successfully',
description: kpiDisableData.message
});
setKpiSearch('');
changeData((prev) => !prev);
} else if (kpiDisableData && kpiDisableData.status === 'failed') {
customToast({
type: 'error',
Expand Down
15 changes: 9 additions & 6 deletions frontend/src/containers/KpiExplorer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const KpiExplorer = () => {
const query = new URLSearchParams(location.search);

const [kpiSearch, setKpiSearch] = useState('');
const [data, setData] = useState(false);
const [data, setData] = useState(null);
const [dashboard, setDashboard] = useState([]);
const [datasourceType, setDatasourceType] = useState([]);
const [dashboardTypeList, setDashboardTypeList] = useState([]);
Expand Down Expand Up @@ -68,9 +68,11 @@ const KpiExplorer = () => {
}, []);

useEffect(() => {
store.dispatch(KPI_RESET);
store.dispatch(SETTING_RESET);
dispatchGetAllKpiExplorer();
if (data !== null) {
store.dispatch(KPI_RESET);
store.dispatch(SETTING_RESET);
dispatchGetAllKpiExplorer();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data]);

Expand Down Expand Up @@ -115,7 +117,9 @@ const KpiExplorer = () => {
}, [kpiExplorerList]);

useEffect(() => {
setPgInfo({ ...pgInfo, page: 1, search: kpiSearch });
if (kpiSearch !== pgInfo.search) {
setPgInfo({ ...pgInfo, page: 1, search: kpiSearch });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [kpiSearch]);

Expand Down Expand Up @@ -174,7 +178,6 @@ const KpiExplorer = () => {
<div className="table-section">
<KPITable
kpiData={kpiExplorerData}
setKpiSearch={setKpiSearch}
kpiSearch={kpiSearch}
changeData={setData}
kpiLoading={isLoading}
Expand Down

0 comments on commit 9c1efb5

Please sign in to comment.