From 98f897ed5bfe8977f71bb3cf1b9be0ffe3c2f7ba Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:46:07 -0500 Subject: [PATCH] Added object browser main paths (#302) Co-authored-by: Benjamin Perez --- pkg/acl/endpoints.go | 78 +++++++++++-------- pkg/acl/endpoints_test.go | 10 +-- portal-ui/src/screens/Console/Console.tsx | 11 ++- portal-ui/src/screens/Console/Menu/Menu.tsx | 21 +++-- .../Console/ObjectBrowser/ObjectBrowser.tsx | 9 +++ 5 files changed, 82 insertions(+), 47 deletions(-) create mode 100644 portal-ui/src/screens/Console/ObjectBrowser/ObjectBrowser.tsx diff --git a/pkg/acl/endpoints.go b/pkg/acl/endpoints.go index a3ef403ed..1fc15e2c9 100644 --- a/pkg/acl/endpoints.go +++ b/pkg/acl/endpoints.go @@ -22,24 +22,26 @@ import ( // endpoints definition var ( - configuration = "/configurations-list" - users = "/users" - groups = "/groups" - iamPolicies = "/policies" - dashboard = "/dashboard" - profiling = "/profiling" - trace = "/trace" - logs = "/logs" - watch = "/watch" - notifications = "/notification-endpoints" - buckets = "/buckets" - bucketsDetail = "/buckets/:bucketName" - serviceAccounts = "/service-accounts" - tenants = "/tenants" - tenantsDetail = "/namespaces/:tenantNamespace/tenants/:tenantName" - heal = "/heal" - remoteBuckets = "/remote-buckets" - replication = "/replication" + configuration = "/configurations-list" + users = "/users" + groups = "/groups" + iamPolicies = "/policies" + dashboard = "/dashboard" + profiling = "/profiling" + trace = "/trace" + logs = "/logs" + watch = "/watch" + notifications = "/notification-endpoints" + buckets = "/buckets" + bucketsDetail = "/buckets/:bucketName" + serviceAccounts = "/service-accounts" + tenants = "/tenants" + tenantsDetail = "/namespaces/:tenantNamespace/tenants/:tenantName" + heal = "/heal" + remoteBuckets = "/remote-buckets" + replication = "/replication" + objectBrowser = "/object-browser/:bucket?/*" + mainObjectBrowser = "/object-browser" ) type ConfigurationActionSet struct { @@ -228,24 +230,32 @@ var replicationActionSet = ConfigurationActionSet{ ), } +// objectBrowserActionSet no actions needed for this module to work +var objectBrowserActionSet = ConfigurationActionSet{ + actionTypes: iampolicy.NewActionSet(), + actions: iampolicy.NewActionSet(), +} + // endpointRules contains the mapping between endpoints and ActionSets, additional rules can be added here var endpointRules = map[string]ConfigurationActionSet{ - configuration: configurationActionSet, - users: usersActionSet, - groups: groupsActionSet, - iamPolicies: iamPoliciesActionSet, - dashboard: dashboardActionSet, - profiling: profilingActionSet, - trace: traceActionSet, - logs: logsActionSet, - watch: watchActionSet, - notifications: notificationsActionSet, - buckets: bucketsActionSet, - bucketsDetail: bucketsActionSet, - serviceAccounts: serviceAccountsActionSet, - heal: healActionSet, - remoteBuckets: remoteBucketsActionSet, - replication: replicationActionSet, + configuration: configurationActionSet, + users: usersActionSet, + groups: groupsActionSet, + iamPolicies: iamPoliciesActionSet, + dashboard: dashboardActionSet, + profiling: profilingActionSet, + trace: traceActionSet, + logs: logsActionSet, + watch: watchActionSet, + notifications: notificationsActionSet, + buckets: bucketsActionSet, + bucketsDetail: bucketsActionSet, + serviceAccounts: serviceAccountsActionSet, + heal: healActionSet, + remoteBuckets: remoteBucketsActionSet, + replication: replicationActionSet, + objectBrowser: objectBrowserActionSet, + mainObjectBrowser: objectBrowserActionSet, } // operatorRules contains the mapping between endpoints and ActionSets for operator only mode diff --git a/pkg/acl/endpoints_test.go b/pkg/acl/endpoints_test.go index caaef8455..7fb3a8af0 100644 --- a/pkg/acl/endpoints_test.go +++ b/pkg/acl/endpoints_test.go @@ -50,7 +50,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) { args: args{ []string{"admin:ServerInfo"}, }, - want: 2, + want: 4, }, { name: "policies endpoint", @@ -63,7 +63,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) { "admin:ListUserPolicies", }, }, - want: 2, + want: 4, }, { name: "all admin endpoints", @@ -72,7 +72,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) { "admin:*", }, }, - want: 13, + want: 15, }, { name: "all s3 endpoints", @@ -81,7 +81,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) { "s3:*", }, }, - want: 4, + want: 6, }, { name: "all admin and s3 endpoints", @@ -91,7 +91,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) { "s3:*", }, }, - want: 16, + want: 18, }, { name: "no endpoints", diff --git a/portal-ui/src/screens/Console/Console.tsx b/portal-ui/src/screens/Console/Console.tsx index e01050b6f..2d956c8dd 100644 --- a/portal-ui/src/screens/Console/Console.tsx +++ b/portal-ui/src/screens/Console/Console.tsx @@ -51,8 +51,6 @@ import Permissions from "./Permissions/Permissions"; import Dashboard from "./Dashboard/Dashboard"; import Menu from "./Menu/Menu"; import api from "../../common/api"; -import storage from "local-storage-fallback"; -import NotFoundPage from "../NotFoundPage"; import ServiceAccounts from "./ServiceAccounts/ServiceAccounts"; import Users from "./Users/Users"; import Groups from "./Groups/Groups"; @@ -70,6 +68,7 @@ import { saveSessionResponse } from "./actions"; import TenantDetails from "./Tenants/TenantDetails/TenantDetails"; import { clearSession } from "../../common/utils"; import RemoteBuckets from "./RemoteBuckets/RemoteBuckets"; +import ObjectBrowser from "./ObjectBrowser/ObjectBrowser"; function Copyright() { return ( @@ -254,6 +253,14 @@ const Console = ({ component: Buckets, path: "/buckets/:bucketName", }, + { + component: ObjectBrowser, + path: "/object-browser/:bucket?/*", + }, + { + component: ObjectBrowser, + path: "/object-browser", + }, { component: Watch, path: "/watch", diff --git a/portal-ui/src/screens/Console/Menu/Menu.tsx b/portal-ui/src/screens/Console/Menu/Menu.tsx index c9d28f373..d517a25a7 100644 --- a/portal-ui/src/screens/Console/Menu/Menu.tsx +++ b/portal-ui/src/screens/Console/Menu/Menu.tsx @@ -22,6 +22,7 @@ import ListItemIcon from "@material-ui/core/ListItemIcon"; import WebAssetIcon from "@material-ui/icons/WebAsset"; import HealingIcon from "@material-ui/icons/Healing"; import CloudUploadIcon from "@material-ui/icons/CloudUpload"; +import DescriptionIcon from "@material-ui/icons/Description"; import FileCopyIcon from "@material-ui/icons/FileCopy"; import Collapse from "@material-ui/core/Collapse"; import ListItemText from "@material-ui/core/ListItemText"; @@ -187,17 +188,17 @@ const Menu = ({ userLoggedIn, classes, pages }: IMenuProps) => { group: "User", type: "item", component: NavLink, - to: "/buckets", - name: "Buckets", - icon: , + to: "/service-accounts", + name: "Service Accounts", + icon: , }, { group: "User", type: "item", component: NavLink, - to: "/service-accounts", - name: "Service Accounts", - icon: , + to: "/object-browser", + name: "Object Browser", + icon: , }, { group: "Admin", @@ -215,6 +216,14 @@ const Menu = ({ userLoggedIn, classes, pages }: IMenuProps) => { name: "Groups", icon: , }, + { + group: "Admin", + type: "item", + component: NavLink, + to: "/buckets", + name: "Buckets", + icon: , + }, { group: "Admin", type: "item", diff --git a/portal-ui/src/screens/Console/ObjectBrowser/ObjectBrowser.tsx b/portal-ui/src/screens/Console/ObjectBrowser/ObjectBrowser.tsx new file mode 100644 index 000000000..a2716d720 --- /dev/null +++ b/portal-ui/src/screens/Console/ObjectBrowser/ObjectBrowser.tsx @@ -0,0 +1,9 @@ +import React from "react"; + +const ObjectBrowser = (props: any) => { + console.log(props); + + return Object Browser; +}; + +export default ObjectBrowser;