mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
"Query in queue" should switch to "Executing query", but does not. Commands: git revert --no-commitbd17662005git revert --no-commit5ac5d86f5evim tests/handlers/test_query_results.py git add tests/handlers/test_query_results.py Co-authored-by: Justin Clift <justin@postgresql.org>
75 lines
2.1 KiB
JavaScript
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…</React.Fragment> : null;
|
|
|
|
switch (status) {
|
|
case "waiting":
|
|
if (!isCancelling) {
|
|
message = <React.Fragment>Query in queue…</React.Fragment>;
|
|
}
|
|
break;
|
|
case "processing":
|
|
if (!isCancelling) {
|
|
message = <React.Fragment>Executing query…</React.Fragment>;
|
|
}
|
|
break;
|
|
case "loading-result":
|
|
message = <React.Fragment>Loading results…</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: () => {},
|
|
};
|