-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from guardian/pm-drag-drop-copy
Support copying files between workspaces
- Loading branch information
Showing
12 changed files
with
200 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { copyItem as copyItemApi } from '../../services/WorkspaceApi'; | ||
import {ThunkAction} from "redux-thunk"; | ||
import {GiantState} from "../../types/redux/GiantState"; | ||
import {AppAction, AppActionType, WorkspacesAction} from "../../types/redux/GiantActions"; | ||
import {getWorkspace} from "./getWorkspace"; | ||
|
||
export function copyItems( | ||
workspaceId: string, | ||
itemIds: string[], | ||
newWorkspaceId?: string, | ||
newParentId?: string // Note: not currently used but could be useful for future 'copy to folder' functionality | ||
): ThunkAction<void, GiantState, null, WorkspacesAction | AppAction> { | ||
return dispatch => { | ||
for (const itemId of itemIds) { | ||
if (itemId !== newParentId) { | ||
dispatch(copyItem(workspaceId, itemId, newWorkspaceId, newParentId)); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
export function copyItem( | ||
workspaceId: string, | ||
itemId: string, | ||
newWorkspaceId?: string, | ||
newParentId?: string // Note: not currently used but could be useful for future 'copy to folder' functionality | ||
): ThunkAction<void, GiantState, null, WorkspacesAction | AppAction> { | ||
return dispatch => { | ||
return copyItemApi(workspaceId, itemId, newWorkspaceId, newParentId) | ||
.then(() => { | ||
dispatch(getWorkspace(workspaceId)); | ||
}) | ||
.catch(error => dispatch(() => errorCopyingItem(error))); | ||
}; | ||
} | ||
|
||
function errorCopyingItem(error: Error): AppAction { | ||
return { | ||
type: AppActionType.APP_SHOW_ERROR, | ||
message: 'Failed to copy item', | ||
error: error, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
|
||
type Props = { | ||
destinationWorkspaceName: string | ||
onSubmit: (action: "copy" | "move") => void | ||
} | ||
export const CopyOrMoveModal = ({destinationWorkspaceName, onSubmit}: Props) => { | ||
|
||
return ( | ||
<form className='form' > | ||
<h2>Copy or move items</h2> | ||
Do you want to copy or move the selected items to the workspace '{destinationWorkspaceName}'? | ||
|
||
<div className='modal-action__buttons'> | ||
<button | ||
className='btn' | ||
onClick={() => onSubmit("move")} | ||
type='button'>Move</button> | ||
|
||
|
||
<button | ||
className='btn' | ||
onClick={() => onSubmit("copy")} | ||
type='button'>Copy</button> | ||
</div> | ||
</form> | ||
); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters