2023-05-19 18:37:06 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import {
|
|
|
|
|
ACTION_EXECUTION_CANCEL,
|
|
|
|
|
ACTION_EXECUTION_MESSAGE,
|
|
|
|
|
createMessage,
|
2024-08-06 14:52:22 +00:00
|
|
|
} from "ee/constants/messages";
|
2023-05-19 18:37:06 +00:00
|
|
|
import ActionAPI from "api/ActionAPI";
|
2023-06-06 15:45:00 +00:00
|
|
|
import { Button, Spinner, Text } from "design-system";
|
2023-05-19 18:37:06 +00:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
import type { EditorTheme } from "./CodeEditor/EditorConfig";
|
|
|
|
|
import LoadingOverlayScreen from "./LoadingOverlayScreen";
|
|
|
|
|
|
2024-02-08 07:55:23 +00:00
|
|
|
const Wrapper = styled.div`
|
|
|
|
|
position: relative;
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
`;
|
|
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const LoadingOverlayContainer = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: var(--ads-v2-spaces-3);
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
position: relative;
|
|
|
|
|
z-index: 20;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const LoadingProgressWrapper = styled.div`
|
|
|
|
|
height: 100%;
|
|
|
|
|
`;
|
|
|
|
|
|
2023-06-06 15:45:00 +00:00
|
|
|
const InProgressText = styled(Text)`
|
|
|
|
|
text-align: center;
|
|
|
|
|
`;
|
|
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const handleCancelActionExecution = () => {
|
|
|
|
|
ActionAPI.abortActionExecutionTokenSource.cancel();
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-11 07:35:24 +00:00
|
|
|
interface ActionExecutionInProgressViewProps {
|
2023-05-19 18:37:06 +00:00
|
|
|
actionType: string;
|
|
|
|
|
theme?: EditorTheme;
|
2023-10-11 07:35:24 +00:00
|
|
|
}
|
2023-05-19 18:37:06 +00:00
|
|
|
|
|
|
|
|
const ActionExecutionInProgressView = ({
|
|
|
|
|
actionType,
|
|
|
|
|
theme,
|
|
|
|
|
}: ActionExecutionInProgressViewProps) => {
|
|
|
|
|
return (
|
2024-02-08 07:55:23 +00:00
|
|
|
<Wrapper>
|
|
|
|
|
<LoadingProgressWrapper>
|
|
|
|
|
<LoadingOverlayScreen theme={theme} />
|
|
|
|
|
<LoadingOverlayContainer>
|
|
|
|
|
<Spinner size="md" />
|
|
|
|
|
<InProgressText kind="body-m" renderAs="p">
|
|
|
|
|
{createMessage(ACTION_EXECUTION_MESSAGE, actionType)}
|
|
|
|
|
</InProgressText>
|
|
|
|
|
<Button
|
|
|
|
|
className={`t--cancel-action-button`}
|
|
|
|
|
kind="secondary"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
handleCancelActionExecution();
|
|
|
|
|
}}
|
|
|
|
|
size="md"
|
|
|
|
|
>
|
|
|
|
|
{createMessage(ACTION_EXECUTION_CANCEL)}
|
|
|
|
|
</Button>
|
|
|
|
|
</LoadingOverlayContainer>
|
|
|
|
|
</LoadingProgressWrapper>
|
|
|
|
|
</Wrapper>
|
2023-05-19 18:37:06 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ActionExecutionInProgressView;
|