Enable Create Path button on BrowserBreadcrumbs if User can create subPath (#3131)
This commit is contained in:
@@ -38,6 +38,7 @@ interface ICreatePath {
|
||||
folderName: string;
|
||||
onClose: () => any;
|
||||
simplePath: string | null;
|
||||
limitedSubPath?: boolean;
|
||||
}
|
||||
|
||||
const CreatePathModal = ({
|
||||
@@ -46,6 +47,7 @@ const CreatePathModal = ({
|
||||
bucketName,
|
||||
onClose,
|
||||
simplePath,
|
||||
limitedSubPath,
|
||||
}: ICreatePath) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
@@ -158,6 +160,11 @@ const CreatePathModal = ({
|
||||
onChange={inputChange}
|
||||
onKeyPress={keyPressed}
|
||||
required
|
||||
tooltip={
|
||||
(limitedSubPath &&
|
||||
"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.") ||
|
||||
""
|
||||
}
|
||||
/>
|
||||
<Grid item xs={12} sx={modalStyleUtils.modalButtonBar}>
|
||||
<Button
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Fragment, useState } from "react";
|
||||
import React, { Fragment, useEffect, useState } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import CopyToClipboard from "react-copy-to-clipboard";
|
||||
import styled from "styled-components";
|
||||
@@ -91,6 +91,7 @@ const BrowserBreadcrumbs = ({
|
||||
);
|
||||
|
||||
const [createFolderOpen, setCreateFolderOpen] = useState<boolean>(false);
|
||||
const [canCreateSubpath, setCanCreateSubpath] = useState<boolean>(false);
|
||||
|
||||
const putObjectPermScopes = [
|
||||
IAM_SCOPES.S3_PUT_OBJECT,
|
||||
@@ -117,11 +118,22 @@ const BrowserBreadcrumbs = ({
|
||||
putObjectPermScopes,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setCanCreateSubpath(false);
|
||||
Object.keys(sessionGrants).forEach((grant) => {
|
||||
grant.includes(pathToCheckPerms) &&
|
||||
grant.includes("/*") &&
|
||||
setCanCreateSubpath(true);
|
||||
});
|
||||
}, [pathToCheckPerms, internalPaths, sessionGrants]);
|
||||
|
||||
const canCreatePath =
|
||||
hasPermission(
|
||||
[pathToCheckPerms, ...sessionGrantWildCards],
|
||||
putObjectPermScopes,
|
||||
) || anonymousMode;
|
||||
) ||
|
||||
anonymousMode ||
|
||||
canCreateSubpath;
|
||||
|
||||
let breadcrumbsMap = splitPaths.map((objectItem: string, index: number) => {
|
||||
const subSplit = `${splitPaths.slice(0, index + 1).join("/")}/`;
|
||||
@@ -226,6 +238,15 @@ const BrowserBreadcrumbs = ({
|
||||
bucketName={bucketName}
|
||||
folderName={internalPaths}
|
||||
onClose={closeAddFolderModal}
|
||||
limitedSubPath={
|
||||
canCreateSubpath &&
|
||||
!(
|
||||
hasPermission(
|
||||
[pathToCheckPerms, ...sessionGrantWildCards],
|
||||
putObjectPermScopes,
|
||||
) || anonymousMode
|
||||
)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<Breadcrumbs
|
||||
|
||||
Reference in New Issue
Block a user