funkwhale/front/src/components/common/UserModal.vue

268 wiersze
8.5 KiB
Vue
Czysty Zwykły widok Historia

2022-07-20 22:44:19 +00:00
<script setup lang="ts">
import SemanticModal from '~/components/semantic/Modal.vue'
import useThemeList from '~/composables/useThemeList'
import useTheme from '~/composables/useTheme'
2022-11-27 12:15:43 +00:00
2022-07-20 22:44:19 +00:00
import { useVModel } from '@vueuse/core'
import { computed } from 'vue'
2022-09-08 14:32:45 +00:00
import { useI18n } from 'vue-i18n'
2022-07-20 22:44:19 +00:00
2022-11-27 12:15:43 +00:00
import { SUPPORTED_LOCALES } from '~/init/locale'
2022-08-30 20:23:17 +00:00
interface Events {
(e: 'update:show', value: boolean): void
(e: 'showLanguageModalEvent'): void
(e: 'showThemeModalEvent'): void
}
2022-07-20 22:44:19 +00:00
interface Props {
show: boolean
}
2022-08-30 20:23:17 +00:00
const emit = defineEmits<Events>()
2022-07-20 22:44:19 +00:00
const props = defineProps<Props>()
const show = useVModel(props, 'show', emit)
2022-11-02 18:14:01 +00:00
const { theme } = useTheme()
2022-07-20 22:44:19 +00:00
const themes = useThemeList()
2022-09-08 14:32:45 +00:00
const { t } = useI18n()
2022-07-20 22:44:19 +00:00
const labels = computed(() => ({
2022-09-22 23:26:59 +00:00
header: t('components.common.UserModal.header.options'),
profile: t('components.common.UserModal.link.profile'),
settings: t('components.common.UserModal.link.settings'),
logout: t('components.common.UserModal.link.logout'),
about: t('components.common.UserModal.link.about'),
shortcuts: t('components.common.UserModal.label.shortcuts'),
support: t('components.common.UserModal.link.support'),
forum: t('components.common.UserModal.link.forum'),
docs: t('components.common.UserModal.link.docs'),
help: t('components.common.UserModal.link.support'),
language: t('components.common.UserModal.label.language'),
theme: t('components.common.UserModal.label.theme'),
chat: t('components.common.UserModal.link.chat'),
git: t('components.common.UserModal.link.git'),
login: t('components.common.UserModal.link.login'),
signup: t('components.common.UserModal.link.signup'),
notifications: t('components.common.UserModal.link.notifications'),
useOtherInstance: t('components.common.UserModal.button.switchInstance')
2022-07-20 22:44:19 +00:00
}))
</script>
2021-11-26 11:01:58 +00:00
<template>
<!-- TODO make generic and move to semantic/modal? -->
2022-07-20 22:44:19 +00:00
<semantic-modal
v-model:show="show"
2021-11-26 11:01:58 +00:00
:scrolling="true"
:fullscreen="false"
>
<div
v-if="$store.state.auth.authenticated"
class="header"
>
<img
2022-08-30 20:23:17 +00:00
v-if="$store.state.auth.profile?.avatar && $store.state.auth.profile?.avatar.urls.medium_square_crop"
v-lazy="$store.getters['instance/absoluteUrl']($store.state.auth.profile?.avatar.urls.medium_square_crop)"
2021-11-26 11:01:58 +00:00
alt=""
class="ui centered small circular image"
>
<actor-avatar
v-else
:actor="{preferred_username: $store.state.auth.username, full_username: $store.state.auth.username,}"
/>
<h3 class="user-modal title">
{{ labels.header }}
</h3>
</div>
<div
v-else
class="header"
>
<h3 class="ui center aligned icon header">
{{ labels.header }}
</h3>
</div>
<div class="content">
<div class="ui one column unstackable grid">
<div class="row">
<div
class="column"
role="button"
2022-08-30 20:23:17 +00:00
@click="[$emit('update:show', false), emit('showLanguageModalEvent')]"
2021-11-26 11:01:58 +00:00
>
<i class="language icon user-modal list-icon" />
2022-09-18 20:57:41 +00:00
<span class="user-modal list-item">
{{ labels.language }}
<span class="left colon symbol" />
</span>
2021-11-26 11:01:58 +00:00
<div class="right floated">
2022-11-27 12:15:43 +00:00
<span class="user-modal list-item">{{ SUPPORTED_LOCALES[$i18n.locale] }}</span>
2021-11-26 11:01:58 +00:00
<i class="action-hint chevron right icon" />
</div>
</div>
</div>
<div class="row">
<div
class="column"
role="button"
2022-08-30 20:23:17 +00:00
@click="[$emit('update:show', false), emit('showThemeModalEvent')]"
2021-11-26 11:01:58 +00:00
>
<i class="palette icon user-modal list-icon" />
2022-09-18 20:57:41 +00:00
<span class="user-modal list-item">
{{ labels.theme }}
<span class="left colon symbol" />
</span>
2021-11-26 11:01:58 +00:00
<div class="right floated">
2022-08-30 20:23:17 +00:00
<span class="user-modal list-item"> {{ themes.find(x => x.key === theme)?.name }}</span>
2021-11-26 11:01:58 +00:00
<i class="action-hint chevron right icon user-modal" />
</div>
</div>
</div>
<div class="ui divider" />
<template v-if="$store.state.auth.authenticated">
<div class="row">
<div
class="column"
role="button"
@click.prevent.exact="$router.push({name: 'profile.overview', params: { username: $store.state.auth.username }})"
>
<i class="user icon user-modal list-icon" />
<span class="user-modal list-item">{{ labels.profile }}</span>
</div>
</div>
<div class="row">
<router-link
v-if="$store.state.auth.authenticated"
2022-04-18 16:17:51 +00:00
v-slot="{ navigate }"
custom
:to="{ name: 'notifications' }"
2021-11-26 11:01:58 +00:00
>
2022-04-18 16:17:51 +00:00
<div
class="column"
role="button"
@click="navigate"
2022-07-20 22:44:19 +00:00
@keypress.enter="navigate()"
2022-04-18 16:17:51 +00:00
>
<i class="user-modal list-icon bell icon" />
<span class="user-modal list-item">{{ labels.notifications }}</span>
</div>
2021-11-26 11:01:58 +00:00
</router-link>
</div>
<div class="row">
<router-link
2022-04-18 16:17:51 +00:00
v-slot="{ navigate }"
custom
2021-11-26 11:01:58 +00:00
:to="{ path: '/settings' }"
>
2022-04-18 16:17:51 +00:00
<div
class="column"
role="button"
@click="navigate"
2022-07-20 22:44:19 +00:00
@keypress.enter="navigate()"
2022-04-18 16:17:51 +00:00
>
<i class="user-modal list-icon cog icon" />
<span class="user-modal list-item">{{ labels.settings }}</span>
</div>
2021-11-26 11:01:58 +00:00
</router-link>
</div>
<div class="ui divider" />
</template>
<div class="row">
<a
2021-12-06 10:35:20 +00:00
class="column"
href="https://funkwhale.audio/help"
target="_blank"
>
<i class="user-modal list-icon life ring outline icon" />
<span class="user-modal list-item">{{ labels.help }}</span>
</a>
</div>
2021-11-26 11:01:58 +00:00
<div class="row">
<a
class="column"
href="https://docs.funkwhale.audio"
target="_blank"
>
<i class="user-modal list-icon book open icon" />
<span class="user-modal list-item">{{ labels.docs }}</span>
</a>
</div>
<div class="row">
<router-link
2022-04-18 16:17:51 +00:00
v-slot="{ navigate }"
custom
2021-11-26 11:01:58 +00:00
:to="{ name: 'about' }"
>
2022-04-18 16:17:51 +00:00
<div
class="column"
role="button"
@click="navigate"
2022-07-20 22:44:19 +00:00
@keypress.enter="navigate()"
2022-04-18 16:17:51 +00:00
>
<i class="user-modal list-icon question circle outline icon" />
<span class="user-modal list-item">{{ labels.about }}</span>
</div>
2021-11-26 11:01:58 +00:00
</router-link>
</div>
<div class="ui divider" />
2022-04-18 16:17:51 +00:00
<router-link
v-if="$store.state.auth.authenticated"
v-slot="{ navigate }"
custom
:to="{ name: 'logout' }"
>
<div
2021-11-26 11:01:58 +00:00
class="column"
role="button"
2022-04-18 16:17:51 +00:00
@click="navigate"
2022-07-20 22:44:19 +00:00
@keypress.enter="navigate()"
2021-11-26 11:01:58 +00:00
>
<i class="user-modal list-icon sign out alternate icon" />
<span class="user-modal list-item">{{ labels.logout }}</span>
2022-04-18 16:17:51 +00:00
</div>
</router-link>
<router-link
v-else
v-slot="{ navigate }"
custom
:to="{ name: 'login' }"
>
<div
2021-11-26 11:01:58 +00:00
class="column"
role="button"
2022-04-18 16:17:51 +00:00
@click="navigate"
2022-07-20 22:44:19 +00:00
@keypress.enter="navigate()"
2021-11-26 11:01:58 +00:00
>
<i class="user-modal list-icon sign in alternate icon" />
<span class="user-modal list-item">{{ labels.login }}</span>
2022-04-18 16:17:51 +00:00
</div>
</router-link>
<router-link
v-if="!$store.state.auth.authenticated && $store.state.instance.settings.users.registration_enabled.value"
v-slot="{ navigate }"
custom
:to="{ name: 'signup' }"
2021-11-26 11:01:58 +00:00
>
2022-04-18 16:17:51 +00:00
<div
2021-11-26 11:01:58 +00:00
class="column"
role="button"
2022-04-18 16:17:51 +00:00
@click="navigate"
2022-07-20 22:44:19 +00:00
@keypress.enter="navigate()"
2021-11-26 11:01:58 +00:00
>
<i class="user-modal list-item user icon" />
<span class="user-modal list-item">{{ labels.signup }}</span>
2022-04-18 16:17:51 +00:00
</div>
</router-link>
2021-11-26 11:01:58 +00:00
</div>
</div>
2022-07-20 22:44:19 +00:00
</semantic-modal>
2021-11-26 11:01:58 +00:00
</template>
<style>
.action-hint {
margin-left: 1rem !important;
}
</style>