From dfa2bfc333d63697ba2b1315bd2f842318f725f4 Mon Sep 17 00:00:00 2001 From: rikimaru0345 Date: Sat, 14 Nov 2020 15:38:27 +0100 Subject: [PATCH] Don't try to fetch acls when the user doesn't have permissions; Show a "permission denied" screen when navigating to "/acls" directly. --- .../src/components/pages/acls/Acl.List.tsx | 71 +++++++++---------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/frontend/src/components/pages/acls/Acl.List.tsx b/frontend/src/components/pages/acls/Acl.List.tsx index 80436971c..dd8dc300a 100644 --- a/frontend/src/components/pages/acls/Acl.List.tsx +++ b/frontend/src/components/pages/acls/Acl.List.tsx @@ -1,27 +1,21 @@ -import React, { ReactNode, Component } from "react"; +import React, { } from "react"; import { observer } from "mobx-react"; -import { Empty, Table, Statistic, Row, Skeleton, Checkbox, Tooltip, Space, Descriptions, Select, Input } from "antd"; +import { Empty, Table, Select, Input, Button } from "antd"; import { ColumnProps } from "antd/lib/table"; import { PageComponent, PageInitHelper } from "../Page"; -import { aclRequestToQuery, api } from "../../../state/backendApi"; +import { api } from "../../../state/backendApi"; import { uiSettings } from "../../../state/ui"; import { makePaginationConfig, sortField } from "../../misc/common"; -import { AclOperation, AclPermissionType, AclRequestDefault, AclResource, AclResourcePatternTypeFilter, AclResourceType, AclRule, Broker, BrokerConfigEntry } from "../../../state/restInterfaces"; +import { AclRequestDefault, AclResource, AclRule, Broker } from "../../../state/restInterfaces"; import { motion } from "framer-motion"; import { animProps } from "../../../utils/animationProps"; -import { observable, computed, autorun, IReactionDisposer } from "mobx"; -import prettyBytes from "pretty-bytes"; -import { clone, containsIgnoreCase, prettyBytesOrNA } from "../../../utils/utils"; +import { observable } from "mobx"; +import { containsIgnoreCase } from "../../../utils/utils"; import { appGlobal } from "../../../state/appGlobal"; import Card from "../../misc/Card"; -import Icon, { CrownOutlined } from '@ant-design/icons'; -import { DefaultSkeleton, Label, ObjToKv, OptionGroup } from "../../../utils/tsxUtils"; -import { DataValue } from "../topics/Tab.Config"; -import { uiState } from "../../../state/uiState"; -import { ElementOf } from "antd/lib/_util/type"; -import SearchBar from "../../misc/SearchBar"; +import { DefaultSkeleton, Label } from "../../../utils/tsxUtils"; +import { LockIcon } from "@primer/octicons-v2-react"; -const InputGroup = Input.Group; type AclRuleFlat = AclResource & AclRule @@ -51,10 +45,12 @@ class AclList extends PageComponent { } refreshData(force: boolean) { + if (api.userData != null && !api.userData.canListAcls) return; api.refreshAcls(AclRequestDefault, force); } render() { + if (api.userData != null && !api.userData.canListAcls) return PermissionDenied; if (!api.ACLs) return DefaultSkeleton; // issue: we can't easily filter by 'resourceType' (because it is a string, and we have to use an enum for requests...) @@ -130,7 +126,7 @@ class AclList extends PageComponent {