/* * 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 } from "react"; import { Button, Modal, Spinner, useCloseModal, sendAlertEvent, useQueryParams, } from "@drill4j/ui-kit"; import { useHistory, Link } from "react-router-dom"; import "twin.macro"; import { ActiveScope } from "types/active-scope"; import { useAgentRouteParams, useFilteredData, useNavigation, useTestToCodeRouteParams, } from "hooks"; import { ActiveSessions } from "types/active-sessions"; import { getModalPath } from "common"; import { deleteScope } from "../../api"; export const DeleteScopeModal = () => { const { agentId = "", pluginId = "" } = useAgentRouteParams(); const { buildVersion } = useTestToCodeRouteParams(); const { getPagePath } = useNavigation(); const { scopeId } = useQueryParams<{scopeId?: string;}>(); const scope = useFilteredData(`/build/scopes/${scopeId}`); const { push, location: { pathname = "" } } = useHistory(); const [loading, setLoading] = useState(false); const { testTypes = [] } = useFilteredData("/active-scope/summary/active-sessions") || {}; const closeModal = useCloseModal(["scopeId"]); return (
{`Delete Scope ${scope?.name}`}
{scope && scope.active && !testTypes.length && ( You are about to delete an active scope. Are you sure you
want to proceed? All scope data will be lost.
)} {scope && scope.active && Boolean(testTypes.length) && ( You are about to delete an active scope, but at least one active
session has been detected. First, you need to finish it in
{}} > Sessions Management
)} { scope && !scope.active && ( You are about to delete a non-empty scope. Are you sure you want to proceed? All scope data will be lost. )}
{scope && scope.active && Boolean(testTypes.length) ? ( ) : ( <> )}
); };