Skip to content

Commit df2e92e

Browse files
authored
Use swagger api for Site Replication Status (#3208)
1 parent 8836fe0 commit df2e92e

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

web-app/src/screens/Console/Configurations/SiteReplication/SiteReplicationStatus.tsx

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@ import {
3333
import { useNavigate } from "react-router-dom";
3434
import { IAM_PAGES } from "../../../../common/SecureComponent/permissions";
3535
import { useAppDispatch } from "../../../../store";
36-
import { setHelpName } from "../../../../systemSlice";
37-
import useApi from "../../Common/Hooks/useApi";
36+
import { setErrorSnackMessage, setHelpName } from "../../../../systemSlice";
3837
import StatusCountCard from "../../Dashboard/BasicDashboard/StatusCountCard";
3938
import EntityReplicationLookup from "./EntityReplicationLookup";
4039
import TooltipWrapper from "../../Common/TooltipWrapper/TooltipWrapper";
4140
import PageHeaderWrapper from "../../Common/PageHeaderWrapper/PageHeaderWrapper";
4241
import HelpMenu from "../../HelpMenu";
42+
import { api } from "api";
43+
import { errorToHandler } from "api/errors";
44+
import {
45+
ApiError,
46+
HttpResponse,
47+
SiteReplicationStatusResponse,
48+
} from "api/consoleApi";
4349

4450
export type StatsResponseType = {
4551
maxBuckets?: number;
@@ -91,15 +97,7 @@ const SiteReplicationStatus = () => {
9197
const navigate = useNavigate();
9298

9399
const [stats, setStats] = useState<StatsResponseType>({});
94-
95-
const [isStatsLoading, invokeSiteStatsApi] = useApi(
96-
(res: any) => {
97-
setStats(res);
98-
},
99-
(err: any) => {
100-
setStats({});
101-
},
102-
);
100+
const [loading, setLoading] = useState<boolean>(false);
103101

104102
const {
105103
maxBuckets = 0,
@@ -113,8 +111,22 @@ const SiteReplicationStatus = () => {
113111
} = stats || {};
114112

115113
const getStats = () => {
116-
let url = `api/v1/admin/site-replication/status?buckets=true&groups=true&policies=true&users=true`;
117-
invokeSiteStatsApi("GET", url);
114+
setLoading(true);
115+
api.admin
116+
.getSiteReplicationStatus({
117+
buckets: true,
118+
groups: true,
119+
policies: true,
120+
users: true,
121+
})
122+
.then((res: HttpResponse<SiteReplicationStatusResponse, ApiError>) => {
123+
setStats(res.data);
124+
})
125+
.catch((res: HttpResponse<SiteReplicationStatusResponse, ApiError>) => {
126+
setStats({});
127+
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
128+
})
129+
.finally(() => setLoading(false));
118130
};
119131

120132
useEffect(() => {
@@ -163,7 +175,7 @@ const SiteReplicationStatus = () => {
163175
Replication status from all Sites
164176
</SectionTitle>
165177

166-
{!isStatsLoading ? (
178+
{!loading ? (
167179
<Box
168180
sx={{
169181
display: "grid",

web-app/src/screens/Console/IDP/AddIDPConfiguration.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const AddIDPConfiguration = ({
114114
navigate(backLink);
115115
dispatch(setServerNeedsRestart(res.data.restart === true));
116116
})
117-
.catch(async (res: HttpResponse<SetIDPResponse, ApiError>) => {
117+
.catch((res: HttpResponse<SetIDPResponse, ApiError>) => {
118118
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
119119
})
120120
.finally(() => setLoadingCreate(false));

web-app/src/screens/Console/Support/GetApiKeyModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const GetApiKeyModal = ({ open, closeModal, onSet }: IGetApiKeyModalProps) => {
7272
getApiKey(res.data.access_token);
7373
}
7474
})
75-
.catch(async (res: HttpResponse<SubnetLoginResponse, ApiError>) => {
75+
.catch((res: HttpResponse<SubnetLoginResponse, ApiError>) => {
7676
onError(res.error);
7777
})
7878
.finally(() => setLoadingSave(false));
@@ -90,7 +90,7 @@ const GetApiKeyModal = ({ open, closeModal, onSet }: IGetApiKeyModalProps) => {
9090
closeModal();
9191
}
9292
})
93-
.catch(async (res: HttpResponse<SubnetLoginResponse, ApiError>) => {
93+
.catch((res: HttpResponse<SubnetLoginResponse, ApiError>) => {
9494
onError(res.error);
9595
})
9696
.finally(() => setLoadingSave(false));
@@ -105,7 +105,7 @@ const GetApiKeyModal = ({ open, closeModal, onSet }: IGetApiKeyModalProps) => {
105105
setMfaToken(res.data.mfa_token);
106106
}
107107
})
108-
.catch(async (res: HttpResponse<SubnetLoginResponse, ApiError>) => {
108+
.catch((res: HttpResponse<SubnetLoginResponse, ApiError>) => {
109109
onError(res.error);
110110
})
111111
.finally(() => setLoadingSave(false));

web-app/src/screens/Console/Support/OfflineRegistration.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const OfflineRegistration = () => {
6666
dispatch(fetchLicenseInfo());
6767
dispatch(setServerNeedsRestart(true));
6868
})
69-
.catch(async (res: HttpResponse<SetConfigResponse, ApiError>) => {
69+
.catch((res: HttpResponse<SetConfigResponse, ApiError>) => {
7070
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
7171
})
7272
.finally(() => setLoadingSave(false));

0 commit comments

Comments
 (0)