Skip to content

Commit 10f8aed

Browse files
authored
Fix route navigation paths to match menus (#1978)
1 parent 5ee9213 commit 10f8aed

File tree

11 files changed

+84
-119
lines changed

11 files changed

+84
-119
lines changed

portal-ui/src/common/SecureComponent/permissions.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,21 @@ export const IAM_SCOPES = {
113113
export const IAM_PAGES = {
114114
/* Buckets */
115115
BUCKETS: "/buckets",
116-
ADD_BUCKETS: "/add-bucket",
116+
ADD_BUCKETS: "/buckets/add-bucket",
117117
BUCKETS_ADMIN_VIEW: "/buckets/:bucketName/admin*",
118118
BUCKETS_BROWSE_VIEW: "/buckets/:bucketName/browse*",
119119
/* Identity */
120120
IDENTITY: "/identity",
121121
USERS: "/identity/users",
122-
USERS_VIEW: "/identity/users/:userName+",
123-
USER_ADD: "/identity/add-user",
122+
USERS_VIEW: "/identity/users/:userName",
123+
USER_ADD: "/identity/users/add-user",
124124
GROUPS: "/identity/groups",
125-
GROUPS_ADD: "/identity/create-group",
125+
GROUPS_ADD: "/identity/groups/create-group",
126126
GROUPS_VIEW: "/identity/groups/:groupName+",
127127
ACCOUNT: "/identity/account",
128-
ACCOUNT_ADD: "/identity/new-account",
129-
USER_ACCOUNT: "/identity/new-user-sa",
130-
USER_ACCOUNT_ADD: "/identity/new-user-sa/:userName+",
128+
ACCOUNT_ADD: "/identity/account/new-account",
129+
USER_SA_ACCOUNT_ADD: "/identity/users/new-user-sa/:userName",
130+
131131
/* Access */
132132
POLICIES: "/access/policies",
133133
POLICY_ADD: "/access/add-policy",
@@ -316,7 +316,7 @@ export const IAM_PAGES_PERMISSIONS = {
316316
IAM_SCOPES.ADMIN_DISABLE_USER,
317317
IAM_SCOPES.ADMIN_DELETE_USER,
318318
],
319-
[IAM_PAGES.USER_ACCOUNT_ADD]: [
319+
[IAM_PAGES.USER_SA_ACCOUNT_ADD]: [
320320
IAM_SCOPES.ADMIN_CREATE_SERVICEACCOUNT,
321321
IAM_SCOPES.ADMIN_UPDATE_SERVICEACCOUNT,
322322
IAM_SCOPES.ADMIN_REMOVE_SERVICEACCOUNT,

portal-ui/src/screens/Console/Buckets/Buckets.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { AppState } from "../../../store";
2222
import { setMenuOpen } from "../../../actions";
2323
import NotFoundPage from "../../NotFoundPage";
2424
import LoadingComponent from "../../../common/LoadingComponent";
25+
import { IAM_PAGES } from "../../../common/SecureComponent/permissions";
2526

2627
const ListBuckets = React.lazy(() => import("./ListBuckets/ListBuckets"));
2728
const BucketDetails = React.lazy(() => import("./BucketDetails/BucketDetails"));
@@ -41,7 +42,7 @@ const Buckets = () => {
4142
<Router history={history}>
4243
<Switch>
4344
<Route
44-
path="/add-bucket"
45+
path={IAM_PAGES.ADD_BUCKETS}
4546
children={(routerProps) => (
4647
<Suspense fallback={<LoadingComponent />}>
4748
<AddBucket />

portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import SelectMultipleIcon from "../../../../icons/SelectMultipleIcon";
4646
import { SecureComponent } from "../../../../common/SecureComponent";
4747
import {
4848
CONSOLE_UI_RESOURCE,
49+
IAM_PAGES,
4950
IAM_SCOPES,
5051
} from "../../../../common/SecureComponent/permissions";
5152
import PageLayout from "../../Common/Layout/PageLayout";
@@ -293,7 +294,7 @@ const ListBuckets = ({
293294
<RBIconButton
294295
tooltip={"Create Bucket"}
295296
onClick={() => {
296-
history.push("/add-bucket");
297+
history.push(IAM_PAGES.ADD_BUCKETS);
297298
}}
298299
text={"Create Bucket"}
299300
icon={<AddIcon />}
@@ -358,7 +359,7 @@ const ListBuckets = ({
358359
To get started,&nbsp;
359360
<AButton
360361
onClick={() => {
361-
history.push("/add-bucket");
362+
history.push(IAM_PAGES.ADD_BUCKETS);
362363
}}
363364
>
364365
Create a Bucket.

portal-ui/src/screens/Console/Console.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ const Console = ({
424424
},
425425
{
426426
component: UserSACreate,
427-
path: IAM_PAGES.USER_ACCOUNT_ADD,
427+
path: IAM_PAGES.USER_SA_ACCOUNT_ADD,
428428
forceDisplay: true, // user has implicit access to service-accounts
429429
},
430430
{

portal-ui/src/screens/Console/Users/UserServiceAccountsPanel.tsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ import RBIconButton from "../Buckets/BucketDetails/SummaryItems/RBIconButton";
4141
import DeleteMultipleServiceAccounts from "./DeleteMultipleServiceAccounts";
4242
import { selectSAs } from "../../Console/Configurations/utils";
4343
import ServiceAccountPolicy from "../Account/ServiceAccountPolicy";
44-
import { IAM_PAGES,
45-
CONSOLE_UI_RESOURCE,
46-
IAM_SCOPES } from "../../../common/SecureComponent/permissions";
44+
import {
45+
IAM_PAGES,
46+
CONSOLE_UI_RESOURCE,
47+
IAM_SCOPES,
48+
} from "../../../common/SecureComponent/permissions";
4749
import { SecureComponent } from "../../../common/SecureComponent";
4850

4951
interface IUserServiceAccountsProps {
@@ -235,25 +237,30 @@ const UserServiceAccountsPanel = ({
235237
variant={"outlined"}
236238
/>
237239
<SecureComponent
238-
scopes={[IAM_SCOPES.ADMIN_CREATE_SERVICEACCOUNT,
240+
scopes={[
241+
IAM_SCOPES.ADMIN_CREATE_SERVICEACCOUNT,
239242
IAM_SCOPES.ADMIN_UPDATE_SERVICEACCOUNT,
240243
IAM_SCOPES.ADMIN_REMOVE_SERVICEACCOUNT,
241-
IAM_SCOPES.ADMIN_LIST_SERVICEACCOUNTS]}
244+
IAM_SCOPES.ADMIN_LIST_SERVICEACCOUNTS,
245+
]}
242246
resource={CONSOLE_UI_RESOURCE}
243247
matchAll
244248
errorProps={{ disabled: true }}
245249
>
246-
<RBIconButton
247-
tooltip={"Create service account"}
248-
text={"Create service account"}
249-
variant="contained"
250-
color="primary"
251-
icon={<AddIcon />}
252-
onClick={() => {
253-
history.push(`${IAM_PAGES.USER_ACCOUNT}/${user}`);
254-
}}
255-
disabled={!hasPolicy}
256-
/>
250+
<RBIconButton
251+
tooltip={"Create service account"}
252+
text={"Create service account"}
253+
variant="contained"
254+
color="primary"
255+
icon={<AddIcon />}
256+
onClick={() => {
257+
let newSAPath = `/identity/users/${user}/new-user-sa`;
258+
newSAPath = `${IAM_PAGES.USER_SA_ACCOUNT_ADD}/${user}`;
259+
newSAPath = `/identity/users/new-user-sa/${user}`;
260+
history.push(newSAPath);
261+
}}
262+
disabled={!hasPolicy}
263+
/>
257264
</SecureComponent>
258265
</Box>
259266
</div>

portal-ui/src/screens/Console/Users/Users.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ const Users = () => {
3737
return (
3838
<Router history={history}>
3939
<Switch>
40-
<Route path={IAM_PAGES.USERS_VIEW} component={UserDetails} />
41-
<Route path={IAM_PAGES.USERS} component={ListUsers} />
42-
<Route path={IAM_PAGES.USER_ADD} component={AddUserScreen} />
40+
<Route path={IAM_PAGES.USER_ADD} exact component={AddUserScreen} />
41+
<Route path={IAM_PAGES.USERS_VIEW} exact component={UserDetails} />
42+
<Route path={IAM_PAGES.USERS} exact component={ListUsers} />
4343
<Route component={NotFoundPage} />
4444
</Switch>
4545
</Router>

portal-ui/src/screens/Console/kbar-actions.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Action } from "kbar/lib/types";
1818
import history from "../../history";
1919
import { BucketsIcon } from "../../icons";
2020
import { validRoutes } from "./valid-routes";
21+
import { IAM_PAGES } from "../../common/SecureComponent/permissions";
2122
import { Bucket } from "./Buckets/types";
2223

2324
export const routesAsKbarActions = (
@@ -56,7 +57,7 @@ export const routesAsKbarActions = (
5657
id: `create-bucket`,
5758
name: "Create Bucket",
5859
section: "Buckets",
59-
perform: () => history.push(`/add-bucket`),
60+
perform: () => history.push(IAM_PAGES.ADD_BUCKETS),
6061
icon: <BucketsIcon />,
6162
};
6263
initialActions.push(a);

portal-ui/tests/permissions-1/groups.ts

Lines changed: 27 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ import * as constants from "../utils/constants";
2020
import * as functions from "../utils/functions";
2121
import { Selector } from "testcafe";
2222
import { groupsElement, identityElement } from "../utils/elements-menu";
23+
import { IAM_PAGES } from "../../src/common/SecureComponent/permissions";
2324

24-
const groupsListItemFor = (modifier) => {
25+
const groupsListItemFor = (modifier: string) => {
2526
return Selector(".ReactVirtualized__Table__rowColumn").withText(
2627
`${constants.TEST_GROUP_NAME}-${modifier}`
2728
);
2829
};
2930

30-
const createGroup = async (t, modifier) => {
31+
const appBaseUrl = "http://localhost:9090";
32+
let groupsPageUrl = `${appBaseUrl}${IAM_PAGES.GROUPS}`;
33+
let groupsAddPageUrl = `${appBaseUrl}${IAM_PAGES.GROUPS_ADD}`;
34+
const createGroup = async (t: TestController, modifier: string) => {
3135
await t
3236
.useRole(roles.groups)
33-
.navigateTo("http://localhost:9090/identity/groups")
34-
.click(elements.createGroupButton)
37+
.navigateTo(groupsAddPageUrl)
3538
.typeText(
3639
elements.groupNameInput,
3740
`${constants.TEST_GROUP_NAME}-${modifier}`
@@ -42,7 +45,7 @@ const createGroup = async (t, modifier) => {
4245
};
4346

4447
fixture("For user with Groups permissions")
45-
.page("http://localhost:9090")
48+
.page(appBaseUrl)
4649
.beforeEach(async (t) => {
4750
await t.useRole(roles.groups);
4851
});
@@ -58,30 +61,25 @@ test("Groups sidebar item exists", async (t) => {
5861

5962
test("Create Group button exists", async (t) => {
6063
const createGroupButtonExists = elements.createGroupButton.exists;
61-
await t
62-
.navigateTo("http://localhost:9090/identity/groups")
63-
.expect(createGroupButtonExists)
64-
.ok();
64+
await t.navigateTo(groupsPageUrl).expect(createGroupButtonExists).ok();
6565
});
6666

6767
test("Create Group button is clickable", async (t) => {
68-
await t
69-
.navigateTo("http://localhost:9090/identity/groups")
70-
.click(elements.createGroupButton);
68+
await t.navigateTo(groupsPageUrl).click(elements.createGroupButton);
7169
});
7270

73-
test("Group Name input exists in the Create Group modal", async (t) => {
71+
test("Group Name input exists in the Create Group page", async (t) => {
7472
await t
75-
.navigateTo("http://localhost:9090/identity/groups")
73+
.navigateTo(groupsPageUrl)
7674
.click(elements.createGroupButton)
7775
.expect(elements.groupNameInput.exists)
7876
.ok();
7977
});
8078

81-
test("Users table exists in the Create Group modal", async (t) => {
79+
test("Users table exists in the Create Groups page", async (t) => {
8280
const createGroupUserTableExists = elements.table.exists;
8381
await t
84-
.navigateTo("http://localhost:9090/identity/groups")
82+
.navigateTo(groupsPageUrl)
8583
.click(elements.createGroupButton)
8684
.expect(createGroupUserTableExists)
8785
.ok();
@@ -90,31 +88,24 @@ test("Users table exists in the Create Group modal", async (t) => {
9088
test.before(async (t) => {
9189
// A user must be created as we need to choose a user from the dropdown
9290
await functions.createUser(t);
93-
})(
94-
"Create Group modal can be submitted after inputs are entered",
95-
async (t) => {
96-
// We need to log back in after we use the admin account to create bucket,
97-
// using the specific role we use in this module
98-
await t
99-
.useRole(roles.groups)
100-
.navigateTo("http://localhost:9090/identity/groups")
101-
.click(elements.createGroupButton)
102-
.typeText(elements.groupNameInput, constants.TEST_GROUP_NAME)
103-
.typeText(elements.filterUserInput, constants.TEST_USER_NAME)
104-
.click(elements.groupUserCheckbox)
105-
.click(elements.saveButton);
106-
}
107-
);
91+
})("Create Group page can be submitted after inputs are entered", async (t) => {
92+
// We need to log back in after we use the admin account to create bucket,
93+
// using the specific role we use in this module
94+
await t
95+
.useRole(roles.groups)
96+
.navigateTo(groupsAddPageUrl)
97+
.typeText(elements.groupNameInput, constants.TEST_GROUP_NAME)
98+
.typeText(elements.filterUserInput, constants.TEST_USER_NAME)
99+
.click(elements.groupUserCheckbox)
100+
.click(elements.saveButton);
101+
});
108102

109103
test.before(async (t) => {
110104
// A user must be created as we need to choose a user from the dropdown
111105
await functions.createUser(t);
112106
await createGroup(t, "groups-table");
113107
})("Groups table exists", async (t) => {
114-
await t
115-
.navigateTo("http://localhost:9090/identity/groups")
116-
.expect(elements.table.exists)
117-
.ok();
108+
await t.navigateTo(groupsPageUrl).expect(elements.table.exists).ok();
118109
});
119110

120111
test.before(async (t) => {
@@ -123,7 +114,7 @@ test.before(async (t) => {
123114
await createGroup(t, "disable-enable");
124115
})("Created Group can be disabled and enabled back", async (t) => {
125116
await t
126-
.navigateTo("http://localhost:9090/identity/groups")
117+
.navigateTo(groupsPageUrl)
127118
.click(groupsListItemFor("disable-enable"))
128119
.click(elements.switchInput)
129120
.expect(elements.groupStatusText.innerText)
@@ -132,19 +123,3 @@ test.before(async (t) => {
132123
.expect(elements.groupStatusText.innerText)
133124
.eql("Enabled");
134125
});
135-
136-
test.before(async (t) => {
137-
// A user must be created as we need to choose a user from the dropdown
138-
await functions.createUser(t);
139-
await createGroup(t, "view-delete");
140-
})("Created Group can be viewed and deleted", async (t) => {
141-
await t
142-
.navigateTo("http://localhost:9090/identity/groups")
143-
.click(groupsListItemFor("view-delete"))
144-
.click(elements.editMembersButton)
145-
.typeText(elements.filterUserInput, constants.TEST_USER_NAME)
146-
.click(elements.groupUserCheckbox)
147-
.click(elements.saveButton)
148-
.click(elements.deleteGroupIconButton)
149-
.click(elements.deleteButton);
150-
});

0 commit comments

Comments
 (0)