Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add favorites capabilities #3754

Merged
merged 1 commit into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion apps/files/src/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default {
return this.$gettext('Mark as favorite')
},
isEnabled: () => {
return this.isAuthenticated
return (
this.isAuthenticated && this.capabilities.files && 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