mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 00:23:12 +09:00
Hide start button based on permissions
Hide the start/stop buttin in instance view if the current used does not have permission to use it.
This commit is contained in:
1 parent
36808b34de
commit
ae17b00b6f
1 file changed
+4
-2
@@ -3,6 +3,7 @@ import { useHistory } from "react-router-dom";
|
|||||||
import { message, Button, Space, Table } from "antd";
|
import { message, Button, Space, Table } from "antd";
|
||||||
import CopyOutlined from "@ant-design/icons/CopyOutlined";
|
import CopyOutlined from "@ant-design/icons/CopyOutlined";
|
||||||
|
|
||||||
|
import { useAccount } from "../model/account";
|
||||||
import { useSlaveList } from "../model/slave";
|
import { useSlaveList } from "../model/slave";
|
||||||
import InstanceStatusTag from "./InstanceStatusTag";
|
import InstanceStatusTag from "./InstanceStatusTag";
|
||||||
import StartStopInstanceButton from "./StartStopInstanceButton";
|
import StartStopInstanceButton from "./StartStopInstanceButton";
|
||||||
@@ -10,6 +11,7 @@ import StartStopInstanceButton from "./StartStopInstanceButton";
|
|||||||
const strcmp = new Intl.Collator(undefined, { numerice: "true", sensitivity: "base" }).compare;
|
const strcmp = new Intl.Collator(undefined, { numerice: "true", sensitivity: "base" }).compare;
|
||||||
|
|
||||||
export default function InstanceList(props) {
|
export default function InstanceList(props) {
|
||||||
|
let account = useAccount();
|
||||||
let history = useHistory();
|
let history = useHistory();
|
||||||
let [slaveList] = useSlaveList();
|
let [slaveList] = useSlaveList();
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@ export default function InstanceList(props) {
|
|||||||
render: instance => <InstanceStatusTag status={instance["status"]} />,
|
render: instance => <InstanceStatusTag status={instance["status"]} />,
|
||||||
sorter: (a, b) => strcmp(a["status"], b["status"]),
|
sorter: (a, b) => strcmp(a["status"], b["status"]),
|
||||||
},
|
},
|
||||||
{
|
...(account.hasAnyPermission("core.instance.start", "core.instance.stop") ? [{
|
||||||
key: "action",
|
key: "action",
|
||||||
render: instance => <StartStopInstanceButton
|
render: instance => <StartStopInstanceButton
|
||||||
buttonProps={{ size: "small" }}
|
buttonProps={{ size: "small" }}
|
||||||
@@ -82,7 +84,7 @@ export default function InstanceList(props) {
|
|||||||
responsive: ["sm"],
|
responsive: ["sm"],
|
||||||
align: "right",
|
align: "right",
|
||||||
width: 100,
|
width: 100,
|
||||||
},
|
}] : []),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (props.hideAssignedSlave) {
|
if (props.hideAssignedSlave) {
|
||||||
|
|||||||
Reference in new issue
Block a user