@finos/legend-data-cube
Version:
40 lines • 3.96 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* 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 { DataCubeIcon } from '@finos/legend-art';
import { CODE_EDITOR_LANGUAGE } from '@finos/legend-code-editor';
import { DATE_TIME_FORMAT } from '@finos/legend-graph';
import { ContentType, downloadFileUsingDataURI, formatDate, } from '@finos/legend-shared';
import { FormButton, FormCheckbox, FormCodeEditor, } from './DataCubeFormUtils.js';
import { useState } from 'react';
export function DataCubeExecutionErrorAlert(props) {
const { error, message, text, onClose } = props;
const [showDebugInfo, setShowDebugInfo] = useState(false);
const queryCode = error.queryCode;
const executeInput = error.executeInput;
let prompt = undefined;
if (executeInput !== undefined && queryCode !== undefined) {
prompt = `Check the execute input and the query code below to debug or report issue`;
}
else if (queryCode !== undefined) {
prompt = `Check the query code below to debug or report issue`;
}
else if (executeInput !== undefined) {
prompt = `Check the execute input below to debug or report issue`;
}
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "h-[calc(100%_-_40px)] w-full pt-2", children: _jsxs("div", { className: "h-full w-full overflow-auto", children: [_jsxs("div", { className: "flex w-full p-6 pb-4", children: [_jsx("div", { className: "mr-3", children: _jsx(DataCubeIcon.AlertError, { className: "flex-shrink-0 stroke-[0.5px] text-[40px] text-red-500" }) }), _jsxs("div", { children: [_jsx("div", { className: "whitespace-break-spaces text-lg", children: message }), _jsx("div", { className: "mt-1 whitespace-break-spaces text-neutral-500", children: text })] })] }), showDebugInfo && (_jsxs(_Fragment, { children: [_jsx("div", { className: "h-[1px] w-full bg-neutral-300" }), prompt !== undefined && (_jsx("div", { className: "pl-5 pt-1", children: prompt })), queryCode !== undefined && (_jsx("div", { className: "h-40 justify-center px-4 pt-1", children: _jsx("div", { className: "h-full w-full", children: _jsx(FormCodeEditor, { value: queryCode, isReadOnly: true, title: "Query Code", language: CODE_EDITOR_LANGUAGE.PURE, hidePadding: true }) }) })), executeInput !== undefined && (_jsx("div", { className: "h-40 justify-center px-4 pt-1", children: _jsx("div", { className: "h-full w-full", children: _jsx(FormCodeEditor, { value: JSON.stringify(executeInput, null, 2), isReadOnly: true, title: "Execute Input", language: CODE_EDITOR_LANGUAGE.JSON, hidePadding: true }) }) }))] }))] }) }), _jsxs("div", { className: "flex h-10 items-center justify-between border border-t-neutral-300 px-2", children: [_jsx("div", { className: "flex h-full items-center pl-1", children: _jsx(FormCheckbox, { label: "Show debug info?", checked: showDebugInfo, onChange: () => setShowDebugInfo(!showDebugInfo) }) }), _jsxs("div", { className: "flex", children: [_jsx(FormButton, { onClick: onClose, children: "OK" }), showDebugInfo && (_jsx(FormButton, { className: "ml-2", onClick: () => downloadFileUsingDataURI(`DEBUG__ExecuteInput__${formatDate(new Date(Date.now()), DATE_TIME_FORMAT)}.json`, JSON.stringify(executeInput, null, 2), ContentType.APPLICATION_JSON), children: "Download Execute Input" }))] })] })] }));
}
//# sourceMappingURL=DataCubeExecutionErrorAlert.js.map