Skip to content

Commit

Permalink
WIP: Add modal to prompt user whether they want to copy or move
Browse files Browse the repository at this point in the history
  • Loading branch information
philmcmahon committed Dec 22, 2023
1 parent c8f0779 commit 112b563
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions frontend/src/js/components/workspace/CopyOrMoveModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import {ThunkAction} from "redux-thunk";
import {GiantState} from "../../types/redux/GiantState";
import {AppAction, WorkspacesAction} from "../../types/redux/GiantActions";
import {copyItems} from "../../actions/workspaces/copyItem";
import {moveItems} from "../../actions/workspaces/moveItem";

type Props = {
selectedWorkspaceId: string;
entryIds: string[];
linkedToWorkspaceId: string;
copyItems: (workspaceId: string, itemIds: string[], newWorkspaceId?: (string | undefined), newParentId?: (string | undefined)) => ThunkAction<void, GiantState, null, WorkspacesAction | AppAction>;
moveItems: (workspaceId: string, itemIds: string[], newWorkspaceId?: (string | undefined), newParentId?: (string | undefined)) => ThunkAction<void, GiantState, null, WorkspacesAction | AppAction>;
onComplete: () => void

}

export default class CopyOrMoveModal extends React.Component<Props> {

actionAndClose = (action: "copy" | "move") => {
const actionFn = action === "copy" ? copyItems: moveItems
actionFn(this.props.selectedWorkspaceId, this.props.entryIds, this.props.linkedToWorkspaceId)
this.props.onComplete()
}

render() {

return (
<form className='form' >
<h2>Copy or move items</h2>
Do you want to copy or move the selected items to the destination workspace?

<button
className='btn'
onClick={() => this.actionAndClose("copy")}
type='button'>Copy</button>
<button
className='btn'
onClick={() => this.actionAndClose("move")}
type='button'>Copy</button>
</form>
);
}
}

0 comments on commit 112b563

Please sign in to comment.