-
-
Notifications
You must be signed in to change notification settings - Fork 170
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 #100 from rclone/uploadfile
Add upload file feature in explorer.
- Loading branch information
Showing
28 changed files
with
944 additions
and
244 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,16 @@ | ||
import React from "react"; | ||
|
||
const DropOverlay = (props) => (<div data-test="dropOverlay" | ||
style={{ | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
height: '100%', | ||
width: '100%', | ||
zIndex: 1, | ||
opacity: 0.5, | ||
backgroundColor: 'gray', | ||
}} | ||
/>); | ||
|
||
export default DropOverlay; |
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,36 @@ | ||
import React from "react"; | ||
import {shallow} from "enzyme"; | ||
import toJson from "enzyme-to-json"; | ||
import DropOverlay from "./DropOverlay"; | ||
import {findByTestAttr, testStore} from "../../../../Utils"; | ||
|
||
|
||
const setUp = (intialState = {}, props = {}) => { | ||
const store = testStore(intialState); | ||
|
||
const component = shallow(<DropOverlay {...props} store={store}/>); | ||
return component; | ||
}; | ||
|
||
|
||
describe('Drop Overlay', function () { | ||
describe('renders', function () { | ||
let wrapper; | ||
beforeEach(() => { | ||
const initialState = {}; | ||
|
||
const props = {}; | ||
wrapper = setUp(initialState, props) | ||
}); | ||
|
||
it('should render without crashing', function () { | ||
const component = findByTestAttr(wrapper, "dropOverlay"); | ||
expect(component).toHaveLength(1); | ||
}); | ||
|
||
it('should match snapshot', function () { | ||
expect(toJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
|
||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
src/views/Base/DropOverlay/__snapshots__/DropOverlay.test.js.snap
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,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Drop Overlay renders should match snapshot 1`] = ` | ||
<div | ||
data-test="dropOverlay" | ||
style={ | ||
Object { | ||
"backgroundColor": "gray", | ||
"height": "100%", | ||
"left": 0, | ||
"opacity": 0.5, | ||
"position": "absolute", | ||
"top": 0, | ||
"width": "100%", | ||
"zIndex": 1, | ||
} | ||
} | ||
/> | ||
`; |
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,36 @@ | ||
import {NativeTypes} from 'react-dnd-html5-backend' | ||
import {useDrop} from 'react-dnd' | ||
import React from "react"; | ||
import DropOverlay from "../DropOverlay/DropOverlay"; | ||
import * as PropTypes from 'prop-types'; | ||
|
||
|
||
export const FileUploadBox = (props) => { | ||
const {onDrop} = props | ||
const [{canDrop, isOver}, drop] = useDrop({ | ||
accept: [NativeTypes.FILE], | ||
drop(item, monitor) { | ||
if (onDrop) { | ||
onDrop(props, monitor) | ||
} | ||
}, | ||
collect: (monitor) => ({ | ||
isOver: monitor.isOver(), | ||
canDrop: monitor.canDrop(), | ||
}), | ||
}) | ||
const isActive = canDrop && isOver | ||
return ( | ||
<div ref={drop}> | ||
{/*Display overlay if file is about to be dropped*/} | ||
{isActive && <DropOverlay/>} | ||
{props.children} | ||
</div> | ||
) | ||
} | ||
|
||
FileUploadBox.propTypes = { | ||
onDrop: PropTypes.func | ||
} | ||
|
||
export default FileUploadBox; |
Oops, something went wrong.