Skip to content

Commit

Permalink
feat: add file type filter in drop zone
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp committed Apr 21, 2022
1 parent 25fb509 commit 23a8b03
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/xo-web/src/common/dropzone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ export default class Dropzone extends Component {
onDrop: PropTypes.func,
message: PropTypes.node,
multiple: PropTypes.bool,
accept: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
}

render() {
const { onDrop, message, multiple } = this.props
const { onDrop, message, multiple, accept } = this.props

return (
<ReactDropzone
activeClassName={styles.activeDropzone}
className={styles.dropzone}
multiple={multiple}
onDrop={onDrop}
accept={accept}
>
<div className={styles.dropzoneText}>{message}</div>
</ReactDropzone>
Expand Down
6 changes: 5 additions & 1 deletion packages/xo-web/src/xo-app/disk-import/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ const DiskImport = decorate([
</Row>
{sr !== undefined && (
<div>
<Dropzone onDrop={effects.handleDrop} message={_('dropDisksFiles')} />
<Dropzone
onDrop={effects.handleDrop}
message={_('dropDisksFiles')}
accept={sr.content_type === 'iso' ? '.iso' : '.vhd,.vmdk'}
/>
{loadingDisks && <Icon icon='loading' />}
{disks.length > 0 && (
<div>
Expand Down

0 comments on commit 23a8b03

Please sign in to comment.