/* * 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, { useState, useMemo } from "react"; import { Icons, Dropdown, Panel, useCloseModal, capitalize, useCopy, } from "@drill4j/ui-kit"; import { copyToClipboard } from "@drill4j/common-utils"; import tw from "twin.macro"; import { useGroupData, useGroupRouteParams } from "hooks"; import { PLUGIN_ID } from "common"; import { TestDetails } from "types"; import { concatTestName } from "utils/transform-tests"; import { getTestsToRunURL, TestsToRunUrl } from "../tests-to-run-url"; interface TestToRun { id?: string; details?: TestDetails; } interface GroupedTestToRun { byType?: Record; totalCount?: number; } export const TestsToRunPanel = () => { const { copied, setCopied } = useCopy({ delay: 5000 }); const { groupId = "" } = useGroupRouteParams(); const { byType: testsToRun = {} } = useGroupData("/group/data/tests-to-run", groupId) || {}; const allTests = useMemo(() => Object.values(testsToRun).reduce((acc, value) => [...acc, ...value], []), [testsToRun]); const [selectedTestsType, setSelectedTestsType] = useState("all"); const getSelectedTests = () => { switch (selectedTestsType) { case "all": return allTests; default: return testsToRun[selectedTestsType]; } }; const closePanel = useCloseModal(); const dropdownItems = Object.entries(testsToRun).map(([key, value]) => ({ value: key, label: `${capitalize(key)} (${value.length})`, })); return ( Tests to run

{allTests.length}

These are recommendations for this build updates only. Use this Curl in your command line to get JSON:
{copied ? (
Copied to clipboard.
) : ( { copyToClipboard(getTestsToRunURL(groupId, PLUGIN_ID, "ServiceGroup")); setCopied(true); }} /> )}
setSelectedTestsType(String(value))} value={selectedTestsType} />
{getSelectedTests().map(({ id = "", details }) => (
{concatTestName(details?.testName, details?.params?.methodParams)}
))}
); };