Files
redash/client/app/pages/queries/components/QueryExecutionStatus.jsx
Eric Radman c874eb6b11 Revert changes to job status (#6969)
"Query in queue" should switch to "Executing query", but does not.

Commands:

git revert --no-commit bd17662005
git revert --no-commit 5ac5d86f5e
vim tests/handlers/test_query_results.py
git add tests/handlers/test_query_results.py

Co-authored-by: Justin Clift <justin@postgresql.org>
2024-05-14 22:06:45 -04:00

75 lines
2.1 KiB
JavaScript

import { includes } from "lodash";
import React from "react";
import PropTypes from "prop-types";
import Alert from "antd/lib/alert";
import Button from "antd/lib/button";
import Timer from "@/components/Timer";
export default function QueryExecutionStatus({ status, updatedAt, error, isCancelling, onCancel }) {
const alertType = status === "failed" ? "error" : "info";
const showTimer = status !== "failed" && updatedAt;
const isCancelButtonAvailable = includes(["waiting", "processing"], status);
let message = isCancelling ? <React.Fragment>Cancelling&hellip;</React.Fragment> : null;
switch (status) {
case "waiting":
if (!isCancelling) {
message = <React.Fragment>Query in queue&hellip;</React.Fragment>;
}
break;
case "processing":
if (!isCancelling) {
message = <React.Fragment>Executing query&hellip;</React.Fragment>;
}
break;
case "loading-result":
message = <React.Fragment>Loading results&hellip;</React.Fragment>;
break;
case "failed":
message = (
<React.Fragment>
Error running query: <strong>{error}</strong>
</React.Fragment>
);
break;
// no default
}
return (
<Alert
data-test="QueryExecutionStatus"
type={alertType}
message={
<div className="d-flex align-items-center">
<div className="flex-fill p-t-5 p-b-5">
{message} {showTimer && <Timer from={updatedAt} />}
</div>
<div>
{isCancelButtonAvailable && (
<Button className="m-l-10" type="primary" size="small" disabled={isCancelling} onClick={onCancel}>
Cancel
</Button>
)}
</div>
</div>
}
/>
);
}
QueryExecutionStatus.propTypes = {
status: PropTypes.string,
updatedAt: PropTypes.any,
error: PropTypes.string,
isCancelling: PropTypes.bool,
onCancel: PropTypes.func,
};
QueryExecutionStatus.defaultProps = {
status: "waiting",
updatedAt: null,
error: null,
isCancelling: true,
onCancel: () => {},
};