Skip to content

Commit aca0029

Browse files
committed
Nabber fully implemented with Element UI
Also the spinner was changed to work in the new structure.
1 parent 5ef5dc4 commit aca0029

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// http://vuex.vuejs.org/en/getters.html
22
import { isEmpty } from 'lodash'
33

4-
// if has token, we assumed that user is logged in our system
4+
// if has token, we assume that user is logged in our system
55
export const isLogged = ({ token }) => !isEmpty(token)
66
// get current user data
77
export const currentUser = ({ user }) => user

client/src/components/general/spinner.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@
1919
.container {
2020
display: inline-block;
2121
width: 40px;
22+
color: #fff;
23+
position: absolute;
24+
z-index: 1;
25+
right: 18px;
26+
top: 18px;
2227
}
2328
</style>

client/src/components/root/navbar.vue

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<script>
3-
import { mapActions, mapState } from 'vuex'
3+
import { mapActions, mapGetters } from 'vuex'
44
import CcSpinner from '../general/spinner'
55
import { version } from '../../config'
66
@@ -9,20 +9,27 @@
99
CcSpinner,
1010
},
1111
computed: {
12-
...mapState({
13-
user: state => state.Auth.user,
14-
}),
12+
/**
13+
* See src/app/auth/vuex/getters.js
14+
*/
15+
...mapGetters(['currentUser', 'isLogged']),
1516
version() {
1617
return version
1718
},
1819
},
19-
methods: {
20-
...mapActions(['setToken', 'setUser']),
21-
logout() {
22-
this.setToken('')
23-
this.setUser({})
24-
this.$router.push({ name: 'login.index' })
20+
watch: {
21+
isLogged(value) { // isLogged changes when the token changes
22+
if (value === false) {
23+
this.$router.push({ name: 'auth.singin' })
24+
}
2525
},
26+
},
27+
methods: {
28+
/**
29+
* Makes logout() action available withint this component
30+
* See /src/app/auth/vuex/actions.js
31+
*/
32+
...mapActions(['logout']),
2633
/* eslint-disable no-undef */
2734
navigate(name) {
2835
switch (name) {
@@ -43,6 +50,7 @@
4350

4451
<template>
4552
<div>
53+
<cc-spinner></cc-spinner>
4654
<el-menu theme="dark" default-active="1" class="cc-navigation"
4755
mode="horizontal" @select="navigate">
4856
<el-menu-item index="codecasts" class="brand">Codecasts.com.br</el-menu-item>
@@ -53,7 +61,7 @@
5361
<el-menu-item index="products.index">Products</el-menu-item>
5462
</el-submenu>
5563
<el-submenu index="menu-user" class="logout-button">
56-
<template slot="title">{{ user.name }}</template>
64+
<template slot="title">{{ currentUser.name }}</template>
5765
<el-menu-item index="logout">Logout</el-menu-item>
5866
</el-submenu>
5967
</el-menu>
@@ -64,6 +72,7 @@
6472
<style scoped>
6573
.cc-navigation {
6674
padding-left: 115px;
75+
padding-right: 30px;
6776
}
6877
.brand {
6978
font-size: 1.2em;

0 commit comments

Comments
 (0)