fix cut for copy bug

pull/4958/merge
Joseph Izang 3 months ago committed by Aniket
parent c889a9ae3d
commit e7ced5a566
  1. 10
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  2. 4
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  3. 2
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -37,7 +37,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
fileState,
canPaste,
feTarget,
setFeTarget
setFeTarget,
setHasCopied
} = props
const [state, setState] = useState<WorkSpaceState>(workspaceState)
// const [isPending, startTransition] = useTransition();
@ -208,8 +209,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
if (feTarget?.length > 0 && feTarget[0]?.key.length > 0) {
if (feTarget?.length > 1) {
handleMultiCopies(feTarget)
setHasCopied(false)
} else {
handleCopyClick(feTarget[0].key, feTarget[0].type)
setHasCopied(false)
}
}
}
@ -221,6 +224,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
setCutActivated(true)
} else {
handleCopyClick(feTarget[0].key, feTarget[0].type)
setCutActivated(true)
}
}
}
@ -232,8 +236,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
const promisesToKeep = state.copyElement.filter(x => x).map(async (item) => {
if (item.type === 'file') {
props.dispatchMoveFile(item.key, feTarget[0].key)
setCutActivated(false)
} else {
props.dispatchMoveFolder(item.key, feTarget[0].key)
setCutActivated(false)
}
})
await Promise.all(promisesToKeep)
@ -243,8 +249,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
setState((prev) => {
return { ...prev, copyElement: []}
})
setCutActivated(false)
} else {
props.dispatchMoveFolder(state.copyElement[0]?.key, feTarget[0].key)
setCutActivated(false)
}
}
} else {

@ -1110,6 +1110,8 @@ export function Workspace() {
importFromIpfs={importFromUrl}
importFromHttps={importFromUrl}
canPaste={canPaste}
hasCopied={hasCopied}
setHasCopied={setHasCopied}
/>
)}
@ -1183,6 +1185,8 @@ export function Workspace() {
dragStatus={dragStatus}
importFromIpfs={importFromUrl}
importFromHttps={importFromUrl}
hasCopied={hasCopied}
setHasCopied={setHasCopied}
/>
)}
</div>

@ -166,6 +166,8 @@ export interface FileExplorerProps {
type: "file" | "folder";
}[]>>
publishManyFilesToGist: () => Promise<void>
hasCopied: boolean
setHasCopied: Dispatch<React.SetStateAction<boolean>>
}
export interface FileExplorerMenuProps {

Loading…
Cancel
Save