diff --git a/.gitignore b/.gitignore index 4afc76b9..4c2ac708 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ babel_cache/ dist/ .DS_Store +package-lock.json \#*\# .\#* *.log diff --git a/client/model/files.js b/client/model/files.js index f20451bc..420050fa 100644 --- a/client/model/files.js +++ b/client/model/files.js @@ -53,6 +53,7 @@ class FileSystem{ path: path, results: null, access_count: 0, + metadata: null }, _files); store.access_count += 1; store.results = response.results || []; @@ -60,6 +61,7 @@ class FileSystem{ f.path = pathBuilder(path, f.name); return f; }); + store.metadata = response.metadata; if(_files && _files.results){ // find out which entry we want to keep from the cache @@ -82,7 +84,11 @@ class FileSystem{ } if(this.current_path === path){ - this.obs && this.obs.next({status: 'ok', results: store.results}); + this.obs && this.obs.next({ + status: 'ok', + results: store.results, + metadata: store.metadata + }); } store.last_update = new Date(); store.last_access = new Date(); @@ -99,7 +105,11 @@ class FileSystem{ return cache.get(cache.FILE_PATH, path).then((response) => { if(!response || !response.results) return null; if(this.current_path === path){ - this.obs && this.obs.next({status: 'ok', results: response.results}); + this.obs && this.obs.next({ + status: 'ok', + results: response.results, + metadata: response.metadata + }); } return response; }); @@ -107,7 +117,11 @@ class FileSystem{ return cache.upsert(cache.FILE_PATH, path, (response) => { if(!response || !response.results) return null; if(this.current_path === path){ - this.obs && this.obs.next({status: 'ok', results: response.results}); + this.obs && this.obs.next({ + status: 'ok', + results: response.results, + metadata: response.metadata + }); } response.last_access = new Date(); response.access_count += 1; diff --git a/client/pages/filespage.js b/client/pages/filespage.js index 4dc7a274..c7e0313f 100644 --- a/client/pages/filespage.js +++ b/client/pages/filespage.js @@ -25,6 +25,7 @@ export class FilesPage extends React.Component { show_hidden: settings_get('filespage_show_hidden') || CONFIG["display_hidden"], view: settings_get('filespage_view') || 'grid', files: [], + metadata: null, frequents: [], page_number: PAGE_NUMBER_INIT, loading: true, @@ -101,7 +102,12 @@ export class FilesPage extends React.Component { if(this.state.show_hidden === false){ files = files.filter((file) => file.name[0] === "." ? false : true); } - this.setState({files: sort(files, this.state.sort), loading: false, page_number: PAGE_NUMBER_INIT}); + this.setState({ + metadata: res.metadata, + files: sort(files, this.state.sort), + loading: false, + page_number: PAGE_NUMBER_INIT + }); }else{ notify.send(res, 'error'); } @@ -172,7 +178,7 @@ export class FilesPage extends React.Component { - + diff --git a/client/pages/filespage/filesystem.js b/client/pages/filespage/filesystem.js index 7d0f0a63..8b0afabb 100644 --- a/client/pages/filespage/filesystem.js +++ b/client/pages/filespage/filesystem.js @@ -18,31 +18,15 @@ import { FileZone } from './filezone'; export class FileSystem extends React.Component { constructor(props){ super(props); - this.state = { - creating: null, - access_right: this._findAccessRight(props.files) - }; - } - - _findAccessRight(files){ - for(let i=0, l=files.length; i< l; i++){ - let file = files[i]; - if(file.name === './' && file.type === 'metadata'){ - return file; - } - } - return {can_create_file: true, can_create_directory: true}; - } - - onComponentPropsUpdate(props){ - this.setState({access_right: this._findAccessRight(props.files)}); } render() { + const metadata = this.props.metadata || {}; + return this.props.connectDropFile(
- this.props.onView(value)} onSortUpdate={(value) => {this.props.onSort(value);}} accessRight={this.state.access_right}> + this.props.onView(value)} onSortUpdate={(value) => {this.props.onSort(value);}} accessRight={metadata}> @@ -51,13 +35,13 @@ export class FileSystem extends React.Component { { this.props.files.map((file, index) => { if(file.type === 'directory' || file.type === 'file' || file.type === 'link' || file.type === 'bucket'){ - return ( ); + return ( ); } }) } - + There is nothing here @@ -68,5 +52,6 @@ export class FileSystem extends React.Component { FileSystem.PropTypes = { path: PropTypes.string.isRequired, - files: PropTypes.array.isRequired + files: PropTypes.array.isRequired, + metadata: PropTypes.object.isRequired } diff --git a/client/pages/filespage/thing-existing.js b/client/pages/filespage/thing-existing.js index e79b2e82..584fff8e 100644 --- a/client/pages/filespage/thing-existing.js +++ b/client/pages/filespage/thing-existing.js @@ -19,6 +19,9 @@ const fileSource = { }; }, canDrag(props, monitor){ + if (props.metadata.can_move === false){ + return false; + } return props.file.icon === 'loading'? false : true; }, endDrag(props, monitor, component){ @@ -211,7 +214,7 @@ export class ExistingThing extends React.Component { - +
@@ -291,10 +294,10 @@ const ActionButton = (props) => { return (
- + - +
diff --git a/client/pages/filespage/thing-new.js b/client/pages/filespage/thing-new.js index 3c380450..9e54050e 100644 --- a/client/pages/filespage/thing-new.js +++ b/client/pages/filespage/thing-new.js @@ -57,20 +57,12 @@ export class NewThing extends React.Component { this.props.onSortUpdate(e); } - // SEARCH BAR: WIP - //
- // - //
- render(){ return (
- New File - New Directory + New File + New Directory diff --git a/client/pages/viewerpage/filedownloader.js b/client/pages/viewerpage/filedownloader.js index c91aa5d2..8147e133 100644 --- a/client/pages/viewerpage/filedownloader.js +++ b/client/pages/viewerpage/filedownloader.js @@ -10,10 +10,11 @@ export class FileDownloader extends React.Component{ } onClick(){ + document.cookie = "download=yes; path=/; max-age=120;"; this.setState({ loading: true, id: window.setInterval(function(){ - if(document.cookie){ + if(/download=yes/.test(document.cookie) === false){ this.setState({loading: false}) window.clearInterval(this.state.id); } diff --git a/client/pages/viewerpage/menubar.js b/client/pages/viewerpage/menubar.js index d07c1689..9936d397 100644 --- a/client/pages/viewerpage/menubar.js +++ b/client/pages/viewerpage/menubar.js @@ -38,10 +38,6 @@ class DownloadButton extends React.Component { loading: true }); - // This my friend is a dirty hack aiming to detect when we the download effectively start - // so that we can display a spinner instead of having a user clicking the download button - // 10 times. It works by sniffing a cookie in our session that will get destroy when - // the server actually send a response document.cookie = "download=yes; path=/; max-age=120;"; this.state.id = window.setInterval(() => { if(/download=yes/.test(document.cookie) === false){