Skip to content

Commit

Permalink
feat: open files in the viewer from the search results
Browse files Browse the repository at this point in the history
  • Loading branch information
y-lohse committed Apr 13, 2018
1 parent a8c6dde commit 739decb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/drive/ducks/services/components/SuggestionProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,23 @@ class SuggestionProvider extends React.Component {
.map(file => {
const isDir = file.type === TYPE_DIRECTORY
const dirId = isDir ? file._id : file.dir_id
let path
const urlToFolder = `${window.location.origin}/#/folder/${dirId}`

let path, url
if (isDir) {
path = file.path
url = urlToFolder
} else {
const parentDir = folders.find(folder => folder._id === file.dir_id)
path = parentDir && parentDir.path ? parentDir.path : ''
url = `${urlToFolder}/file/${file._id}`
}

return {
id: file._id,
name: file.name,
path,
url: window.location.origin + '/#/folder/' + dirId,
url,
icon: getIconUrl(file)
}
})
Expand Down

0 comments on commit 739decb

Please sign in to comment.