/* * Copyright 2020 EPAM Systems * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import React, { useRef } from "react"; import { MainProgressBar, AdditionalProgressBar, StripedProgressBar, Tooltip, useElementSize, } from "@drill4j/ui-kit"; import { percentFormatter } from "@drill4j/common-utils"; import tw, { styled } from "twin.macro"; import { useActiveBuild, useActiveScope, useActiveSessions, useAgentRouteParams, useFilteredData, useTestToCodeRouteParams, } from "hooks"; import { BUILD_STATUS } from "common"; import { BuildCoverage } from "types/build-coverage"; const Message = styled.div` ${tw`text-center`} `; export const MultiProgressBar = () => { const { agentId } = useAgentRouteParams(); const { buildVersion } = useTestToCodeRouteParams(); const node = useRef(null); const { width } = useElementSize(node); const { buildStatus } = useActiveBuild(agentId) || {}; const activeSessions = useActiveSessions("Agent", agentId, buildVersion); const active = Boolean(activeSessions?.length) && buildStatus === BUILD_STATUS.ONLINE; const scope = useActiveScope(); const buildCoverage = useFilteredData("/build/coverage"); const { coverage: { percentage: coveragePercentage = 0, overlap: { percentage: overlappingCode = 0 } = {}, } = {}, } = scope || {}; const uniqueCodeCoverage = percentFormatter(coveragePercentage) - percentFormatter(Number(overlappingCode)); return (
{buildCoverage && scope && ( <> {percentFormatter(Number(buildCoverage?.percentage))}% of current build has
already been covered by tests )} >
{percentFormatter(overlappingCode)}% of current build coverage
has been overlapped in active scope )} >
{active ? : }
Active scope additionally covered +{percentFormatter(uniqueCodeCoverage)}%.
Finish your scope to add it to your total build coverage. )} > {active ? : ( )}
)}
); };