2020-11-01 18:36:00 +01:00
|
|
|
<template>
|
|
|
|
<nav
|
|
|
|
:class="{'has-background': background}"
|
|
|
|
aria-label="main navigation"
|
|
|
|
class="navbar main-theme is-fixed-top"
|
|
|
|
role="navigation"
|
|
|
|
>
|
|
|
|
<div class="navbar-brand">
|
|
|
|
<router-link :to="{name: 'home'}" class="navbar-item logo">
|
|
|
|
<img alt="Vikunja" src="/images/logo-full-pride.svg" v-if="(new Date()).getMonth() === 5"/>
|
|
|
|
<img alt="Vikunja" src="/images/logo-full.svg" v-else/>
|
|
|
|
</router-link>
|
|
|
|
<a
|
|
|
|
@click="$store.commit('toggleMenu')"
|
|
|
|
class="menu-show-button"
|
|
|
|
@shortkey="() => $store.commit('toggleMenu')"
|
|
|
|
v-shortkey="['ctrl', 'e']"
|
|
|
|
>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<a
|
|
|
|
@click="$store.commit('toggleMenu')"
|
|
|
|
class="menu-show-button"
|
|
|
|
>
|
|
|
|
</a>
|
2021-06-24 01:24:57 +02:00
|
|
|
<div class="list-title" ref="listTitle" :style="{'display': currentList.id ? '': 'none'}">
|
|
|
|
<template v-if="currentList.id">
|
|
|
|
<h1
|
|
|
|
:style="{ 'opacity': currentList.title === '' ? '0': '1' }"
|
|
|
|
class="title">
|
2021-07-09 10:22:20 +02:00
|
|
|
{{ currentList.title === '' ? $t('misc.loading') : getListTitle(currentList) }}
|
2021-06-24 01:24:57 +02:00
|
|
|
</h1>
|
2021-01-30 17:17:04 +01:00
|
|
|
|
2021-06-24 01:24:57 +02:00
|
|
|
<list-settings-dropdown v-if="canWriteCurrentList && currentList.id !== -1" :list="currentList"/>
|
|
|
|
</template>
|
2020-11-01 18:36:00 +01:00
|
|
|
</div>
|
2021-01-30 17:17:04 +01:00
|
|
|
|
2020-11-01 18:36:00 +01:00
|
|
|
<div class="navbar-end">
|
|
|
|
<update/>
|
2021-05-30 20:30:08 +02:00
|
|
|
<a
|
|
|
|
@click="openQuickActions"
|
|
|
|
class="trigger-button pr-0"
|
|
|
|
@shortkey="openQuickActions"
|
|
|
|
v-shortkey="['ctrl', 'k']"
|
|
|
|
>
|
|
|
|
<icon icon="search"/>
|
|
|
|
</a>
|
2021-02-21 16:13:58 +01:00
|
|
|
<notifications/>
|
2020-11-01 18:36:00 +01:00
|
|
|
<div class="user">
|
|
|
|
<img :src="userAvatar" alt="" class="avatar"/>
|
2021-06-23 22:08:20 +02:00
|
|
|
<dropdown class="is-right" ref="usernameDropdown">
|
2021-01-30 17:17:04 +01:00
|
|
|
<template v-slot:trigger>
|
|
|
|
<x-button
|
|
|
|
type="secondary"
|
2021-01-17 18:57:57 +01:00
|
|
|
:shadow="false">
|
2020-11-21 22:25:00 +01:00
|
|
|
<span class="username">{{ userInfo.name !== '' ? userInfo.name : userInfo.username }}</span>
|
2020-11-01 18:36:00 +01:00
|
|
|
<span class="icon is-small">
|
2021-01-17 18:57:57 +01:00
|
|
|
<icon icon="chevron-down"/>
|
|
|
|
</span>
|
|
|
|
</x-button>
|
2021-01-30 17:17:04 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<router-link :to="{name: 'user.settings'}" class="dropdown-item">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.settings.title') }}
|
2021-01-30 17:17:04 +01:00
|
|
|
</router-link>
|
|
|
|
<a
|
|
|
|
:href="imprintUrl"
|
|
|
|
class="dropdown-item"
|
|
|
|
target="_blank"
|
|
|
|
v-if="imprintUrl">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('navigation.imprint') }}
|
2021-01-30 17:17:04 +01:00
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
:href="privacyPolicyUrl"
|
|
|
|
class="dropdown-item"
|
|
|
|
target="_blank"
|
|
|
|
v-if="privacyPolicyUrl">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('navigation.privacy') }}
|
2021-01-30 17:17:04 +01:00
|
|
|
</a>
|
2021-04-18 19:32:31 +02:00
|
|
|
<a @click="$store.commit('keyboardShortcutsActive', true)" class="dropdown-item">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('keyboardShortcuts.title') }}
|
2021-04-18 19:32:31 +02:00
|
|
|
</a>
|
2021-07-06 17:05:35 +02:00
|
|
|
<router-link :to="{name: 'about'}" class="dropdown-item">
|
|
|
|
{{ $t('about.title') }}
|
|
|
|
</router-link>
|
2021-01-30 17:17:04 +01:00
|
|
|
<a @click="logout()" class="dropdown-item">
|
2021-06-24 01:24:57 +02:00
|
|
|
{{ $t('user.auth.logout') }}
|
2021-01-30 17:17:04 +01:00
|
|
|
</a>
|
|
|
|
</dropdown>
|
2020-11-01 18:36:00 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {mapState} from 'vuex'
|
2021-05-30 20:30:08 +02:00
|
|
|
import {CURRENT_LIST, QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types'
|
2020-11-01 18:36:00 +01:00
|
|
|
import Rights from '@/models/rights.json'
|
|
|
|
import Update from '@/components/home/update'
|
2021-01-30 17:17:04 +01:00
|
|
|
import ListSettingsDropdown from '@/components/list/list-settings-dropdown'
|
|
|
|
import Dropdown from '@/components/misc/dropdown'
|
2021-02-21 16:13:58 +01:00
|
|
|
import Notifications from '@/components/notifications/notifications'
|
2020-11-01 18:36:00 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'topNavigation',
|
|
|
|
components: {
|
2021-02-21 16:13:58 +01:00
|
|
|
Notifications,
|
2021-01-30 17:17:04 +01:00
|
|
|
Dropdown,
|
|
|
|
ListSettingsDropdown,
|
2020-11-01 18:36:00 +01:00
|
|
|
Update,
|
|
|
|
},
|
|
|
|
computed: mapState({
|
|
|
|
userInfo: state => state.auth.info,
|
|
|
|
userAvatar: state => state.auth.avatarUrl,
|
|
|
|
userAuthenticated: state => state.auth.authenticated,
|
|
|
|
currentList: CURRENT_LIST,
|
|
|
|
background: 'background',
|
|
|
|
imprintUrl: state => state.config.legal.imprintUrl,
|
|
|
|
privacyPolicyUrl: state => state.config.legal.privacyPolicyUrl,
|
|
|
|
canWriteCurrentList: state => state.currentList.maxRight > Rights.READ,
|
|
|
|
}),
|
2021-06-23 22:08:20 +02:00
|
|
|
mounted() {
|
2021-06-24 01:24:57 +02:00
|
|
|
this.$nextTick(() => {
|
|
|
|
if (typeof this.$refs.usernameDropdown === 'undefined' || typeof this.$refs.listTitle === 'undefined') {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const usernameWidth = this.$refs.usernameDropdown.$el.clientWidth
|
|
|
|
this.$refs.listTitle.style.setProperty('--nav-username-width', `${usernameWidth}px`)
|
|
|
|
})
|
2021-06-23 22:08:20 +02:00
|
|
|
},
|
2020-11-01 18:36:00 +01:00
|
|
|
methods: {
|
|
|
|
logout() {
|
|
|
|
this.$store.dispatch('auth/logout')
|
|
|
|
this.$router.push({name: 'user.login'})
|
|
|
|
},
|
2021-05-30 20:30:08 +02:00
|
|
|
openQuickActions() {
|
|
|
|
this.$store.commit(QUICK_ACTIONS_ACTIVE, true)
|
|
|
|
},
|
2020-11-01 18:36:00 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|