Skip to content

Commit

Permalink
Add favorites capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasHirt committed Jul 9, 2020
1 parent 6eee41e commit 71efb51
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
6 changes: 5 additions & 1 deletion apps/files/src/components/FileDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
<div v-if="$route.name !== 'files-shared-with-others'">
<oc-star
v-if="!publicPage()"
v-if="!publicPage() && isFavoritesEnabled"
id="files-sidebar-star-icon"
class="uk-inline"
:shining="highlightedFile.starred"
Expand Down Expand Up @@ -94,6 +94,10 @@ export default {
activeTabComponent() {
return this.fileSideBarsEnabled.find(sidebar => sidebar.app === this.currentTab)
},
isFavoritesEnabled() {
return this.capabilities.files && this.capabilities.files.favorites
}
},
watch: {
Expand Down
3 changes: 3 additions & 0 deletions apps/files/src/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ const navItems = [
iconMaterial: 'star',
route: {
name: 'files-favorites'
},
enabled(capabilities) {
return capabilities.files && capabilities.files.favorites
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
return this.$gettext('Mark as favorite')
},
isEnabled: () => {
return this.isAuthenticated
return this.isAuthenticated && this.capabilities.files.favorites
}
},
{
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/favorites-capabilities
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add favorites capabilities

We've added a check of favorites capabilities to enable disabling of favorites list and favorite action.

https://github.com/owncloud/ocis/issues/354
https://github.com/owncloud/phoenix/pull/3754
11 changes: 9 additions & 2 deletions src/store/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@ const getters = {
* @param state
* @returns {function(*): *[]}
*/
getNavItems: state => extension => {
getNavItems: (state, rootState) => extension => {
const staticNavItems = state.staticNavItems[extension] || []
const dynamicNavItems = state.dynamicNavItems[extension] || []
return [...staticNavItems, ...dynamicNavItems]

return [...staticNavItems, ...dynamicNavItems].filter(navItem => {
if (!navItem.enabled) {
return true
}

return navItem.enabled(rootState.capabilities)
})
},
/**
* Get all extension ids that have at least one navigation item.
Expand Down

0 comments on commit 71efb51

Please sign in to comment.