Skip to content

Commit 4c03052

Browse files
committed
Fixing the shown errors
1 parent 657854b commit 4c03052

File tree

5 files changed

+97
-92
lines changed

5 files changed

+97
-92
lines changed

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

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ const AccessDetails = () => {
5555
]);
5656

5757
const displayUsersList = hasPermission(
58-
bucketName,
59-
[
60-
IAM_SCOPES.ADMIN_GET_POLICY,
61-
IAM_SCOPES.ADMIN_LIST_USERS,
62-
IAM_SCOPES.ADMIN_LIST_GROUPS,
63-
],
64-
true,
58+
bucketName,
59+
[
60+
IAM_SCOPES.ADMIN_GET_POLICY,
61+
IAM_SCOPES.ADMIN_LIST_USERS,
62+
IAM_SCOPES.ADMIN_LIST_GROUPS,
63+
],
64+
true,
6565
);
6666

6767
const viewUser = hasPermission(CONSOLE_UI_RESOURCE, [
@@ -104,15 +104,15 @@ const AccessDetails = () => {
104104
if (loadingUsers) {
105105
if (displayUsersList) {
106106
api.bucketUsers
107-
.listUsersWithAccessToBucket(bucketName)
108-
.then((res) => {
109-
setBucketUsers(res.data);
110-
setLoadingUsers(false);
111-
})
112-
.catch((err) => {
113-
dispatch(setErrorSnackMessage(errorToHandler(err)));
114-
setLoadingUsers(false);
115-
});
107+
.listUsersWithAccessToBucket(bucketName)
108+
.then((res) => {
109+
setBucketUsers(res.data);
110+
setLoadingUsers(false);
111+
})
112+
.catch((err) => {
113+
dispatch(setErrorSnackMessage(errorToHandler(err)));
114+
setLoadingUsers(false);
115+
});
116116
} else {
117117
setLoadingUsers(false);
118118
}
@@ -128,82 +128,82 @@ const AccessDetails = () => {
128128
if (loadingPolicies) {
129129
if (displayPoliciesList) {
130130
api.bucketPolicy
131-
.listPoliciesWithBucket(bucketName)
132-
.then((res) => {
133-
setBucketPolicy(res.data.policies);
134-
setLoadingPolicies(false);
135-
})
136-
.catch((err) => {
137-
dispatch(setErrorSnackMessage(errorToHandler(err)));
138-
setLoadingPolicies(false);
139-
});
131+
.listPoliciesWithBucket(bucketName)
132+
.then((res) => {
133+
setBucketPolicy(res.data.policies);
134+
setLoadingPolicies(false);
135+
})
136+
.catch((err) => {
137+
dispatch(setErrorSnackMessage(errorToHandler(err)));
138+
setLoadingPolicies(false);
139+
});
140140
} else {
141141
setLoadingPolicies(false);
142142
}
143143
}
144144
}, [loadingPolicies, dispatch, bucketName, displayPoliciesList]);
145145

146146
return (
147-
<Fragment>
148-
<SectionTitle separator>Access Audit</SectionTitle>
149-
<Tabs
150-
currentTabOrPath={curTab}
151-
onTabClick={(newValue: string) => {
152-
setCurTab(newValue);
153-
}}
154-
horizontal
155-
options={[
156-
{
157-
tabConfig: { label: "Policies", id: "simple-tab-0" },
158-
content: (
159-
<SecureComponent
160-
scopes={[IAM_SCOPES.ADMIN_LIST_USER_POLICIES]}
161-
resource={bucketName}
162-
errorProps={{ disabled: true }}
163-
>
164-
{bucketPolicy && (
165-
<DataTable
166-
noBackground={true}
167-
itemActions={PolicyActions}
168-
columns={[{ label: "Name", elementKey: "name" }]}
169-
isLoading={loadingPolicies}
170-
records={bucketPolicy}
171-
entityName="Policies"
172-
idField="name"
173-
/>
174-
)}
175-
</SecureComponent>
176-
),
177-
},
178-
{
179-
tabConfig: { label: "Users", id: "simple-tab-1" },
180-
content: (
181-
<SecureComponent
182-
scopes={[
183-
IAM_SCOPES.ADMIN_GET_POLICY,
184-
IAM_SCOPES.ADMIN_LIST_USERS,
185-
IAM_SCOPES.ADMIN_LIST_GROUPS,
186-
]}
187-
resource={bucketName}
188-
matchAll
189-
errorProps={{ disabled: true }}
190-
>
191-
<DataTable
192-
noBackground={true}
193-
itemActions={userTableActions}
194-
columns={[{ label: "User", elementKey: "accessKey" }]}
195-
isLoading={loadingUsers}
196-
records={bucketUsers}
197-
entityName="Users"
198-
idField="accessKey"
199-
/>
200-
</SecureComponent>
201-
),
202-
},
203-
]}
204-
/>
205-
</Fragment>
147+
<Fragment>
148+
<SectionTitle separator>Access Audit</SectionTitle>
149+
<Tabs
150+
currentTabOrPath={curTab}
151+
onTabClick={(newValue: string) => {
152+
setCurTab(newValue);
153+
}}
154+
horizontal
155+
options={[
156+
{
157+
tabConfig: { label: "Policies", id: "simple-tab-0" },
158+
content: (
159+
<SecureComponent
160+
scopes={[IAM_SCOPES.ADMIN_LIST_USER_POLICIES]}
161+
resource={bucketName}
162+
errorProps={{ disabled: true }}
163+
>
164+
{bucketPolicy && (
165+
<DataTable
166+
noBackground={true}
167+
itemActions={PolicyActions}
168+
columns={[{ label: "Name", elementKey: "name" }]}
169+
isLoading={loadingPolicies}
170+
records={bucketPolicy}
171+
entityName="Policies"
172+
idField="name"
173+
/>
174+
)}
175+
</SecureComponent>
176+
),
177+
},
178+
{
179+
tabConfig: { label: "Users", id: "simple-tab-1" },
180+
content: (
181+
<SecureComponent
182+
scopes={[
183+
IAM_SCOPES.ADMIN_GET_POLICY,
184+
IAM_SCOPES.ADMIN_LIST_USERS,
185+
IAM_SCOPES.ADMIN_LIST_GROUPS,
186+
]}
187+
resource={bucketName}
188+
matchAll
189+
errorProps={{ disabled: true }}
190+
>
191+
<DataTable
192+
noBackground={true}
193+
itemActions={userTableActions}
194+
columns={[{ label: "User", elementKey: "accessKey" }]}
195+
isLoading={loadingUsers}
196+
records={bucketUsers}
197+
entityName="Users"
198+
idField="accessKey"
199+
/>
200+
</SecureComponent>
201+
),
202+
},
203+
]}
204+
/>
205+
</Fragment>
206206
);
207207
};
208208

209-
export default AccessDetails;
209+
export default AccessDetails;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { AddIcon, Button, DataTable, SectionTitle } from "mds";
1919
import { useSelector } from "react-redux";
2020
import { useParams } from "react-router-dom";
2121
import { api } from "api";
22-
import { AccessRule as IAccessRule } from "api/consoleApi";
22+
import { AccessRule as IAccessRule, ApiError } from "api/consoleApi";
2323
import { errorToHandler } from "api/errors";
2424
import { IAM_SCOPES } from "../../../../common/SecureComponent/permissions";
2525
import {
@@ -114,7 +114,8 @@ const AccessRule = () => {
114114
setAccessRules(res.data.accessRules);
115115
setLoadingAccessRules(false);
116116
})
117-
.catch((err) => {
117+
.catch(async (res) => {
118+
const err = (await res.json()) as ApiError;
118119
dispatch(setErrorSnackMessage(errorToHandler(err)));
119120
setLoadingAccessRules(false);
120121
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
setSnackBarMessage,
3333
} from "../../../../systemSlice";
3434
import { useAppDispatch } from "../../../../store";
35+
import { ApiError } from "../../../../api/consoleApi";
3536

3637
interface IAddAccessRule {
3738
modalOpen: boolean;
@@ -78,8 +79,8 @@ const AddAccessRule = ({
7879
dispatch(setSnackBarMessage("Access Rule added successfully"));
7980
onClose();
8081
})
81-
.catch((err) => {
82-
dispatch(setErrorSnackMessage(errorToHandler(err)));
82+
.catch((res) => {
83+
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
8384
onClose();
8485
});
8586
};

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import { hasPermission } from "../../../../../common/SecureComponent";
7171
import BucketNamingRules from "./BucketNamingRules";
7272
import PageHeaderWrapper from "../../../Common/PageHeaderWrapper/PageHeaderWrapper";
7373
import { api } from "../../../../../api";
74-
import { ObjectRetentionMode } from "../../../../../api/consoleApi";
74+
import { ApiError, ObjectRetentionMode } from "../../../../../api/consoleApi";
7575
import { errorToHandler } from "../../../../../api/errors";
7676
import HelpMenu from "../../../HelpMenu";
7777
import CSVMultiSelector from "../../../Common/FormComponents/CSVMultiSelector/CSVMultiSelector";
@@ -191,7 +191,8 @@ const AddBucket = () => {
191191
dispatch(setErrorSnackMessage(errorToHandler(res.error)));
192192
}
193193
})
194-
.catch((err) => {
194+
.catch(async (res) => {
195+
const err = (await res.json()) as ApiError;
195196
dispatch(setErrorSnackMessage(errorToHandler(err)));
196197
});
197198
};

portal-ui/src/screens/Console/Configurations/ConfigurationPanels/ConfigurationOptions.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { useAppDispatch } from "../../../../store";
4646
import { api } from "../../../../api";
4747
import { IElement } from "../types";
4848
import { errorToHandler } from "../../../../api/errors";
49+
import { ApiError } from "../../../../api/consoleApi";
4950

5051
const getRoutePath = (path: string) => {
5152
return `${IAM_PAGES.SETTINGS}/${path}`;
@@ -79,7 +80,8 @@ const ConfigurationOptions = () => {
7980
setConfigSubSysList(confSubSysList);
8081
}
8182
})
82-
.catch((err) => {
83+
.catch(async (res) => {
84+
const err = (await res.json()) as ApiError;
8385
dispatch(setErrorSnackMessage(errorToHandler(err)));
8486
});
8587
}, [dispatch]);

0 commit comments

Comments
 (0)