Skip to content

Commit 04e9cb0

Browse files
authored
Enable Create Path button on BrowserBreadcrumbs if User can create subPath (#3131)
1 parent da53daf commit 04e9cb0

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ListObjects/CreatePathModal.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface ICreatePath {
3838
folderName: string;
3939
onClose: () => any;
4040
simplePath: string | null;
41+
limitedSubPath?: boolean;
4142
}
4243

4344
const CreatePathModal = ({
@@ -46,6 +47,7 @@ const CreatePathModal = ({
4647
bucketName,
4748
onClose,
4849
simplePath,
50+
limitedSubPath,
4951
}: ICreatePath) => {
5052
const dispatch = useAppDispatch();
5153
const navigate = useNavigate();
@@ -158,6 +160,11 @@ const CreatePathModal = ({
158160
onChange={inputChange}
159161
onKeyPress={keyPressed}
160162
required
163+
tooltip={
164+
(limitedSubPath &&
165+
"You may only have write access on a limited set of subpaths within this path. Please carefully review your User permissions to understand the paths to which you may write.") ||
166+
""
167+
}
161168
/>
162169
<Grid item xs={12} sx={modalStyleUtils.modalButtonBar}>
163170
<Button

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React, { Fragment, useState } from "react";
17+
import React, { Fragment, useEffect, useState } from "react";
1818
import { useSelector } from "react-redux";
1919
import CopyToClipboard from "react-copy-to-clipboard";
2020
import styled from "styled-components";
@@ -91,6 +91,7 @@ const BrowserBreadcrumbs = ({
9191
);
9292

9393
const [createFolderOpen, setCreateFolderOpen] = useState<boolean>(false);
94+
const [canCreateSubpath, setCanCreateSubpath] = useState<boolean>(false);
9495

9596
const putObjectPermScopes = [
9697
IAM_SCOPES.S3_PUT_OBJECT,
@@ -117,11 +118,22 @@ const BrowserBreadcrumbs = ({
117118
putObjectPermScopes,
118119
);
119120

121+
useEffect(() => {
122+
setCanCreateSubpath(false);
123+
Object.keys(sessionGrants).forEach((grant) => {
124+
grant.includes(pathToCheckPerms) &&
125+
grant.includes("/*") &&
126+
setCanCreateSubpath(true);
127+
});
128+
}, [pathToCheckPerms, internalPaths, sessionGrants]);
129+
120130
const canCreatePath =
121131
hasPermission(
122132
[pathToCheckPerms, ...sessionGrantWildCards],
123133
putObjectPermScopes,
124-
) || anonymousMode;
134+
) ||
135+
anonymousMode ||
136+
canCreateSubpath;
125137

126138
let breadcrumbsMap = splitPaths.map((objectItem: string, index: number) => {
127139
const subSplit = `${splitPaths.slice(0, index + 1).join("/")}/`;
@@ -226,6 +238,15 @@ const BrowserBreadcrumbs = ({
226238
bucketName={bucketName}
227239
folderName={internalPaths}
228240
onClose={closeAddFolderModal}
241+
limitedSubPath={
242+
canCreateSubpath &&
243+
!(
244+
hasPermission(
245+
[pathToCheckPerms, ...sessionGrantWildCards],
246+
putObjectPermScopes,
247+
) || anonymousMode
248+
)
249+
}
229250
/>
230251
)}
231252
<Breadcrumbs

0 commit comments

Comments
 (0)