Skip to content

Commit

Permalink
fixup! Add OCA.Files.Sidebar
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 12, 2019
1 parent 1b1080e commit 866e069
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
9 changes: 7 additions & 2 deletions apps/files_sharing/src/components/SharingInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ export default {
})
}

this.suggestions = exactSuggestions.concat(suggestions).concat(this.externalResults).concat(lookupEntry)
// if there is a condition specified, filter it
const externalResults = this.externalResults.filter(result => !result.condition || result.condition(this) )

this.suggestions = exactSuggestions.concat(suggestions).concat(externalResults).concat(lookupEntry)

this.loading = false
console.info('suggestions', this.suggestions)
Expand Down Expand Up @@ -368,7 +371,9 @@ export default {

// handle externalResults from OCA.Sharing.ShareSearch
if (value.handler) {
return value.handler(this)
const share = await value.handler(this)
this.$emit('add:share', new Share(share))
return true
}

this.loading = true
Expand Down
4 changes: 3 additions & 1 deletion apps/files_sharing/src/files_sharing_tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ if (window.OCA && window.OCA.Sharing) {
}

window.addEventListener('DOMContentLoaded', () => {
OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab('sharing', SharingTab))
if (OCA.Files && OCA.Files.Sidebar) {
OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab('sharing', SharingTab))
}
})
21 changes: 11 additions & 10 deletions apps/files_sharing/src/services/ShareSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,20 @@ export default class ShareSearch {
* Register a new result
*
* @param {Object} result
* @param {string} [result.user]
* @param {string} result.displayName
* @param {string} [result.desc]
* @param {string} [result.icon]
* @param {function} result.handler
* @param {string} [result.user] entry user
* @param {string} result.displayName entry first line
* @param {string} [result.desc] entry second line
* @param {string} [result.icon] entry icon
* @param {function} result.handler function to run on entry selection
* @param {function} [result.condition] condition to add entry or not
*/
addNewResult({ user, displayName, desc, icon, handler }) {
if (displayName.trim() !== ''
&& typeof handler === 'function') {
this.#state.results.push({ user, displayName, desc, icon, handler })
addNewResult(result) {
if (result.displayName.trim() !== ''
&& typeof result.handler === 'function') {
this.#state.results.push(result)
return true
}
console.error(`Invalid search result provided`, { user, displayName, desc, icon, handler });
console.error(`Invalid search result provided`, result);
return false
}
}

0 comments on commit 866e069

Please sign in to comment.