Added user links to sidebar.

This commit is contained in:
DebaucheryLibrarian 2021-03-19 21:57:04 +01:00
parent c8ac8d6564
commit 3b3f4a1f2d
5 changed files with 77 additions and 27 deletions

View File

@ -21,7 +21,7 @@
class="menu-item"
@click.stop="$store.dispatch('logout')"
>
<Icon icon="enter2" />Log out
<Icon icon="exit2" />Log out
</li>
<li

View File

@ -129,35 +129,63 @@
</nav>
</div>
<div class="sidebar-section toggles noselect">
<div class="sidebar-section controls noselect">
<label
v-show="sfw"
class="toggle"
@click="setSfw(false)"
><Icon icon="fire" />Disable safe mode</label>
v-if="auth && me"
@click="$emit('toggleSidebar', false)"
>
<router-link
:to="{ name: 'user', params: { username: me.username } }"
class="toggle username nolink"
>{{ me.username }}</router-link>
</label>
<label
v-show="!sfw"
class="toggle"
@click="setSfw(true)"
><Icon icon="flower" />Enable safe mode</label>
<div class="toggles noselect">
<label
v-if="auth && !me"
@click="$emit('toggleSidebar', false)"
>
<router-link
:to="{ name: 'login', query: { ref: $route.path } }"
class="toggle nolink"
><Icon icon="enter2" />Log in</router-link>
</label>
<label
v-show="theme === 'dark'"
class="toggle"
@click="setTheme('light')"
><Icon icon="sun" />Use light theme</label>
<label
v-if="auth && me"
class="toggle"
@click.stop="$store.dispatch('logout')"
><Icon icon="exit2" />Log out</label>
<label
v-show="theme === 'light'"
class="toggle"
@click="setTheme('dark')"
><Icon icon="moon" />Use dark theme</label>
<label
v-show="sfw"
class="toggle"
@click="setSfw(false)"
><Icon icon="fire" />Disable safe mode</label>
<label
class="toggle"
@click="$emit('showFilters', true)"
><Icon icon="filter" />Filters</label>
<label
v-show="!sfw"
class="toggle"
@click="setSfw(true)"
><Icon icon="flower" />Enable safe mode</label>
<label
v-show="theme === 'dark'"
class="toggle"
@click="setTheme('light')"
><Icon icon="sun" />Use light theme</label>
<label
v-show="theme === 'light'"
class="toggle"
@click="setTheme('dark')"
><Icon icon="moon" />Use dark theme</label>
<label
class="toggle"
@click="$emit('showFilters', true)"
><Icon icon="filter" />Filters</label>
</div>
</div>
</div>
</div>
@ -178,6 +206,14 @@ function theme(state) {
return state.ui.theme;
}
function auth(state) {
return state.auth.enabled;
}
function me(state) {
return state.auth.user;
}
function setTheme(newTheme) {
this.$store.dispatch('setTheme', newTheme);
}
@ -198,6 +234,8 @@ export default {
},
computed: {
...mapState({
auth,
me,
sfw,
theme,
}),
@ -312,10 +350,13 @@ export default {
}
}
.controls {
margin: .5rem 0 0 0;
}
.toggles {
flex-shrink: 0;
border-top: solid 1px var(--shadow-hint);
margin: .5rem 0 0 0;
}
.toggle {
@ -324,6 +365,10 @@ export default {
color: var(--shadow);
font-weight: bold;
&.username {
justify-content: center;
}
.icon {
fill: var(--shadow);
margin: 0 1rem 0 0;

View File

@ -82,6 +82,7 @@ export default {
align-items: center;
height: 100%;
padding: 0 .5rem;
font-size: .8rem;
font-weight: bold;
}
</style>

View File

@ -148,6 +148,10 @@ function curateStash(stash) {
}
function curateUser(user) {
if (!user) {
return null;
}
const curatedUser = user;
if (user.stashes) {

View File

@ -55,7 +55,7 @@ function initUsersActions(store, _router) {
}
`, {
hasAuth: !!store.state.auth.user,
userId: store.state.auth.user?.id,
userId: store.state.auth.user?.id || null,
username,
});