Skip to content

Commit

Permalink
Extension specific navigation and automatically inject extensions int…
Browse files Browse the repository at this point in the history
…o app switcher

Added translation
  • Loading branch information
LukasHirt committed Feb 12, 2020
1 parent b5d0dca commit 74d7cf4
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const navItems = [
iconMaterial: appInfo.icon,
route: {
name: 'files-list',
path: '/'
path: `/${appInfo.id}/list`
}
},
{
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/2746
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Change: Display only items for current extension in sidebar menu

We've filtered out nav items in the sidebar menu. Now only items for current extension will be displayed.
In case the extension has only one nav item, the sidebar menu is hidden and instead of menu button is displayed the name of extension.

https://github.com/owncloud/phoenix/issues/2746
https://github.com/owncloud/phoenix/pull/3013
44 changes: 38 additions & 6 deletions src/Phoenix.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@
</template>
<template v-else>
<message-bar :active-messages="activeMessages" @deleteMessage="$_deleteMessage" />
<top-bar :applicationsList="$_applicationsList" :activeNotifications="activeNotifications" :user-id="user.id" :user-display-name="user.displayname" :hasAppNavigation="!!appNavigationEntries.length" @toggleAppNavigation="$_toggleAppNavigation(!appNavigationVisible)"></top-bar>
<side-menu :visible="appNavigationVisible" :entries="appNavigationEntries" @closed="$_toggleAppNavigation(false)"></side-menu>
<top-bar
:applicationsList="$_applicationsList"
:activeNotifications="activeNotifications"
:user-id="user.id"
:user-display-name="user.displayname"
:hasAppNavigation="appNavigationEntries.length > 1"
@toggleAppNavigation="$_toggleAppNavigation(!appNavigationVisible)"
/>
<side-menu
v-if="appNavigationEntries.length > 1"
:visible="appNavigationVisible"
:entries="appNavigationEntries"
@closed="$_toggleAppNavigation(false)"
/>
<main id="main">
<router-view id="oc-app-container" name="app" class="uk-height-1-1"></router-view>
</main>
Expand Down Expand Up @@ -39,27 +51,47 @@ export default {
},
computed: {
...mapState(['route', 'user']),
...mapGetters(['configuration', 'activeNotifications', 'activeMessages', 'capabilities']),
...mapGetters(['configuration', 'activeNotifications', 'activeMessages', 'capabilities', 'apps']),
$_applicationsList () {
return this.configuration.applications
const list = []
// Get extensions manually added into config
list.push(this.configuration.applications)
// Get extensions which have at least one nav item
const navItems = this.$root.navItems
for (const extensionId in navItems) {
list.push(this.apps[extensionId])
}
return list.flat()
},
appNavigationEntries () {
if (this.publicPage()) {
return []
}
// FIXME: use store or other ways, not $root
return this.$root.navItems.filter(item => {
// FIXME: filter to only show current app
const items = this.$root.navItems[this.currentExtension]
if (!items) {
return []
}
return items.filter(item => {
if (item.enabled === undefined) {
return true
}
if (this.capabilities === undefined) {
return false
}
return item.enabled(this.capabilities)
})
},
showHeader () {
return this.$route.meta.hideHeadbar !== true
},
Expand Down
22 changes: 15 additions & 7 deletions src/components/ApplicationsMenu.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<template>
<div v-if="!!applicationsList.length">
<oc-button id="_appSwitcherButton" icon="apps" variation="primary" class="oc-topbar-menu-burger uk-height-1-1" aria-label="$gettext('Application Switcher')" ref="menubutton" />
<oc-drop toggle="#_appSwitcherButton" mode="click" :options="{pos:'bottom-right'}" class="uk-width-large" ref="menu">
<oc-drop
dropId="app-switcher-dropdown"
toggle="#_appSwitcherButton"
mode="click"
:options="{pos:'bottom-right', delayHide: 0}"
class="uk-width-large"
ref="menu"
closeOnClick
>
<div class="uk-grid-small uk-text-center" uk-grid>
<div class="uk-width-1-3" v-for="(n, nid) in $_applicationsList" :key="nid">
<a v-if="n.url" key="external-link" target="_blank" :href="n.url">
Expand Down Expand Up @@ -36,14 +44,14 @@ export default {
},
computed: {
$_applicationsList () {
return this.applicationsList.map((item) => {
return this.applicationsList.map(item => {
const lang = this.$language.current
// TODO: move language resolution to a common function
// FIXME: need to handle logic for variants like en_US vs en_GB
let title = item.title.en
let title = item.title ? item.title.en : item.name
let iconMaterial
let iconUrl
if (item.title[lang]) {
if (item.title && item.title[lang]) {
title = item.title[lang]
}
Expand All @@ -64,10 +72,10 @@ export default {
if (item.url) {
app.url = item.url
}
if (item.path) {
} else if (item.path) {
app.path = item.path
} else {
app.path = `/${item.id}`
}
return app
Expand Down
26 changes: 25 additions & 1 deletion src/components/Top-Bar.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<template>
<oc-navbar id="oc-topbar" tag="header" class="oc-topbar uk-position-relative uk-navbar">
<oc-navbar-item position="left">
<oc-button v-if="hasAppNavigation" icon="menu" variation="primary" class="oc-topbar-menu-burger uk-height-1-1" aria-label="Menu" @click="$_onOpenAppNavigation" ref="menubutton">
<oc-button
v-if="hasAppNavigation"
key="extension-navigation-button"
icon="menu"
variation="primary"
class="oc-topbar-menu-burger uk-height-1-1"
:aria-label="$gettext('Menu')"
@click="$_onOpenAppNavigation"
ref="menubutton"
>
<span class="oc-topbar-menu-burger-label" v-translate>Menu</span>
</oc-button>
<span v-else key="extension-title" class="topbar-current-extension-title uk-margin-left" v-text="currentExtensionName" />
</oc-navbar-item>
<oc-navbar-item position="center">
<router-link to="/" class="oc-topbar-icon">ownCloud X</router-link>
Expand All @@ -17,6 +27,7 @@
</template>

<script>
import { mapGetters } from 'vuex'
import pluginHelper from '../mixins/pluginHelper.js'
import ApplicationsMenu from './ApplicationsMenu.vue'
import UserMenu from './UserMenu.vue'
Expand Down Expand Up @@ -59,8 +70,14 @@ export default {
}
},
computed: {
...mapGetters(['apps']),
isPublicPage () {
return !this.userId
},
currentExtensionName () {
return this.$gettext(this.apps[this.currentExtension].name)
}
},
methods: {
Expand All @@ -70,3 +87,10 @@ export default {
}
}
</script>

TODO: Move to ODS and enable theming
<style scoped>
.topbar-current-extension-title {
color: white
}
</style>
5 changes: 2 additions & 3 deletions src/phoenix.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const supportedLanguages = {

function loadApps () {
let plugins = []
let navItems = []
let navItems = {}
let translations = coreTranslations

let routes = [{
Expand Down Expand Up @@ -122,7 +122,7 @@ function loadApps () {
plugins.push(app.plugins)
}
if (app.navItems) {
navItems.push(app.navItems)
navItems[app.appInfo.id] = app.navItems
}
if (app.translations) {
Object.keys(supportedLanguages).forEach((lang) => {
Expand Down Expand Up @@ -157,7 +157,6 @@ function loadApps () {
silent: true
})

navItems = navItems.flat()
const OC = new Vue({
el: '#owncloud',
data: {
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/phoenix.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export default {
Vue.mixin({
computed: {
...mapGetters(['getToken', 'isAuthenticated']),
...mapGetters('Files', ['publicLinkPassword'])
...mapGetters('Files', ['publicLinkPassword']),

currentExtension () {
return this.$route.path.split('/')[1]
}
},
methods: {
...mapActions('Files', ['addActionToProgress', 'removeActionFromProgress']),
Expand Down

0 comments on commit 74d7cf4

Please sign in to comment.