diff --git a/client/pages/filespage.helper.js b/client/pages/filespage.helper.js index 953d04d2..dcfc93cf 100644 --- a/client/pages/filespage.helper.js +++ b/client/pages/filespage.helper.js @@ -411,3 +411,7 @@ export const onSearch = (keyword, path = "/") => { Files.search(keyword, path).then((f) => obs.next(f)) }); }; + +export const createLink = (type, path) => { + return type === "file" ? "/view" + path : "/files" + path; +} diff --git a/client/pages/filespage.js b/client/pages/filespage.js index 99ec09b0..eeb69559 100644 --- a/client/pages/filespage.js +++ b/client/pages/filespage.js @@ -5,7 +5,7 @@ import HTML5Backend from 'react-dnd-html5-backend-filedrop'; import './filespage.scss'; import './error.scss'; import { Files } from '../model/'; -import { sort, onCreate, onRename, onDelete, onUpload, onSearch } from './filespage.helper'; +import { sort, onCreate, onRename, onDelete, onUpload, onSearch, createLink } from './filespage.helper'; import { NgIf, Loader, EventReceiver, LoggedInOnly, ErrorPage } from '../components/'; import { notify, debounce, goToFiles, goToViewer, event, settings_get, settings_put } from '../helpers/'; import { BreadCrumb, FileSystem, FrequentlyAccess, Submenu } from './filespage/'; @@ -122,7 +122,7 @@ export class FilesPage extends React.Component { continue; } files[i] = res.results[i]; - files[i].link = res.results[i].type === "file" ? "/view"+path : "/files"+path+"/"; + files[i].link = createLink(res.results[i].type, res.results[i].path) } this.setState({ metadata: res.metadata, @@ -205,7 +205,10 @@ export class FilesPage extends React.Component { } this._search = onSearch(search, this.state.path).subscribe((f) => { this.setState({ - files: f || [], + files: f.map((f) => { + f.link = createLink(f.type, f.path); + return f; + }) || [], metadata: { can_rename: false, can_delete: false,