Skip to content
Snippets Groups Projects
Commit 0bdbf143 authored by Imre Toth's avatar Imre Toth
Browse files

CE-2098: Convert useCurrentlyActiveIocs hook

parent 0d266eaf
No related branches found
No related tags found
2 merge requests!407CE-2141: 3.0.0,!373CE-2098: Convert useCurrentlyActiveIocs hook
...@@ -351,18 +351,27 @@ export function useNamingNames() { ...@@ -351,18 +351,27 @@ export function useNamingNames() {
return useAsync({ fcn: method, call: false, init: [] }); return useAsync({ fcn: method, call: false, init: [] });
} }
export function unpackCurrentlyActiveIOCS(statistics) { export function unpackGitReference(reference) {
return { ...statistics }; return { ...reference };
}
export function unpackTagAndCommitIdList(tagList) {
return tagList.map((t) => unpackGitReference(t));
} }
export function useCurrentlyActiveIOCs() { export function useTagsAndCommitIds(onError) {
const api = useContext(apiContext); const api = useContext(apiContext);
const method = useCallAndUnpack( const method = useCallAndUnpack(
api.apis.Statistics.currentlyActiveIocs, (gitProjectId, reference, includeAllReference, searchMethod) =>
unpackCurrentlyActiveIOCS api.apis.Git.listTagsAndCommitIds({
project_id: gitProjectId,
reference: reference,
include_all_reference: includeAllReference,
search_method: searchMethod
}),
unpackTagAndCommitIdList
); );
return useAsync({ fcn: method, call: false, onError: onError, init: [] });
return useAsync({ fcn: method, call: false });
} }
export function unpackActiveIOCHistory(statistics) { export function unpackActiveIOCHistory(statistics) {
......
import React from "react"; import React, { useContext } from "react";
import { useCurrentlyActiveIOCs } from "../../../api/SwaggerApi";
import { useEffect } from "react"; import { useEffect } from "react";
import { LinearProgress, useTheme, Typography } from "@mui/material"; import { LinearProgress, useTheme, Typography } from "@mui/material";
import { circularPalette } from "../../common/Helper"; import { circularPalette } from "../../common/Helper";
...@@ -14,11 +13,18 @@ import { ...@@ -14,11 +13,18 @@ import {
Cell, Cell,
LabelList LabelList
} from "recharts"; } from "recharts";
import { apiContext } from "../../../api/DeployApi";
import { useAPIMethod } from "@ess-ics/ce-ui-common";
export default function ActiveIOCChart({ title }) { export default function ActiveIOCChart({ title }) {
const [activeIocs, getActiveIocs] = useCurrentlyActiveIOCs();
const theme = useTheme(); const theme = useTheme();
const GRAPH_THRESHOLD = 0.2; const GRAPH_THRESHOLD = 0.2;
const client = useContext(apiContext);
const { value: activeIocs, wrapper: getActiveIocs } = useAPIMethod({
fcn: client.apis.Statistics.currentlyActiveIocs,
call: false
});
useEffect(() => { useEffect(() => {
getActiveIocs(); getActiveIocs();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment