Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-2987]: fix/rename item issues in Shared Section #1296

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/share/views/SharedLinksView/SharedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ function SharedView({
)
}
<SharedItemListContainer
isRootFolder={isRootFolder}
disableKeyboardShortcuts={disableKeyboardShortcuts || showStopSharingConfirmation}
onItemDoubleClicked={handleOnItemDoubleClick}
onUploadFileButtonClicked={onUploadFileButtonClicked}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { isItemsOwnedByCurrentUser, sortSharedItems } from '../sharedViewUtils';
type ShareItemListContainerProps = {
disableKeyboardShortcuts: boolean;
sharedNamePath: SharedNamePath[];
isRootFolder: boolean;
onItemDoubleClicked: (shareItem: AdvancedSharedItem) => void;
onUploadFileButtonClicked: () => void;
isCurrentUserViewer: () => boolean;
Expand All @@ -33,6 +34,7 @@ type ShareItemListContainerProps = {

const SharedItemListContainer = ({
disableKeyboardShortcuts,
isRootFolder,
onItemDoubleClicked,
onUploadFileButtonClicked,
isCurrentUserViewer,
Expand Down Expand Up @@ -241,6 +243,7 @@ const SharedItemListContainer = ({
isItemsOwnedByCurrentUser: checkIfIsItemsOwnedByCurrentUser(),
isCurrentUserViewer: isCurrentUserViewer(),
isItemOwnedByCurrentUser,
isRootFolder,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface SharedContextMenuProps {
selectedItems: AdvancedSharedItem[];
sharedContextMenuActions: SharedContextMenuActions;
isItemsOwnedByCurrentUser: boolean;
isRootFolder?: boolean;
isItemOwnedByCurrentUser: (userUUID: string | undefined) => boolean;
isCurrentUserViewer: boolean;
}
Expand All @@ -39,6 +40,7 @@ const useSharedContextMenu = ({
},
isItemsOwnedByCurrentUser,
isItemOwnedByCurrentUser,
isRootFolder,
isCurrentUserViewer,
}: SharedContextMenuProps) => {
const menu = useMemo(() => {
Expand Down Expand Up @@ -71,6 +73,8 @@ const useSharedContextMenu = ({

const getItemContextMenu = (item: AdvancedSharedItem) => {
const userUUID = item?.user?.uuid;
const isSubFolderAndEditorUser = !isCurrentUserViewer && !isRootFolder;
const isRootFolderAndIsOwner = isRootFolder && isItemOwnedByCurrentUser(userUUID);

const ownerCurrentUserOptions = isItemOwnedByCurrentUser(userUUID)
? {
Expand All @@ -89,7 +93,7 @@ const useSharedContextMenu = ({
showDetails,
copyLink,
downloadItem: handleDownload,
renameItem: !isCurrentUserViewer ? renameItem : undefined,
renameItem: isSubFolderAndEditorUser || isRootFolderAndIsOwner ? renameItem : undefined,
...ownerCurrentUserOptions,
});
};
Expand Down Expand Up @@ -122,6 +126,7 @@ const useSharedContextMenu = ({
isItemsOwnedByCurrentUser,
isItemOwnedByCurrentUser,
isCurrentUserViewer,
isRootFolder,
]);

return menu;
Expand Down
Loading