mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-22 16:24:05 +01:00
feature (search): dynamically create link for search
This commit is contained in:
parent
bf2e44baab
commit
d4b0496b19
2 changed files with 10 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue