From ae17b00b6f1b3355fbbd780e104354ec3d8b4141 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 22 Jun 2022 21:26:41 +0200 Subject: [PATCH] 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. --- packages/web_ui/src/components/InstanceList.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/web_ui/src/components/InstanceList.jsx b/packages/web_ui/src/components/InstanceList.jsx index 19f17b32..b37b4136 100644 --- a/packages/web_ui/src/components/InstanceList.jsx +++ b/packages/web_ui/src/components/InstanceList.jsx @@ -3,6 +3,7 @@ import { useHistory } from "react-router-dom"; import { message, Button, Space, Table } from "antd"; import CopyOutlined from "@ant-design/icons/CopyOutlined"; +import { useAccount } from "../model/account"; import { useSlaveList } from "../model/slave"; import InstanceStatusTag from "./InstanceStatusTag"; import StartStopInstanceButton from "./StartStopInstanceButton"; @@ -10,6 +11,7 @@ import StartStopInstanceButton from "./StartStopInstanceButton"; const strcmp = new Intl.Collator(undefined, { numerice: "true", sensitivity: "base" }).compare; export default function InstanceList(props) { + let account = useAccount(); let history = useHistory(); let [slaveList] = useSlaveList(); @@ -73,7 +75,7 @@ export default function InstanceList(props) { render: instance => , sorter: (a, b) => strcmp(a["status"], b["status"]), }, - { + ...(account.hasAnyPermission("core.instance.start", "core.instance.stop") ? [{ key: "action", render: instance =>