diff --git a/front/src/components/audio/SearchBar.vue b/front/src/components/audio/SearchBar.vue index b13a6eba0..c7dab2d31 100644 --- a/front/src/components/audio/SearchBar.vue +++ b/front/src/components/audio/SearchBar.vue @@ -1,14 +1,257 @@ + + - - + + + @@ -16,252 +259,3 @@ - - diff --git a/front/src/components/audio/album/Widget.vue b/front/src/components/audio/album/Widget.vue index 5e61c2631..d2b0d42da 100644 --- a/front/src/components/audio/album/Widget.vue +++ b/front/src/components/audio/album/Widget.vue @@ -1,3 +1,66 @@ + + - - diff --git a/front/src/components/audio/artist/Widget.vue b/front/src/components/audio/artist/Widget.vue index 13128e9d9..e752f26a5 100644 --- a/front/src/components/audio/artist/Widget.vue +++ b/front/src/components/audio/artist/Widget.vue @@ -1,3 +1,66 @@ + + - - diff --git a/front/src/components/audio/track/Widget.vue b/front/src/components/audio/track/Widget.vue index 0397debe3..75842616f 100644 --- a/front/src/components/audio/track/Widget.vue +++ b/front/src/components/audio/track/Widget.vue @@ -1,13 +1,19 @@ + - - diff --git a/front/src/components/auth/ApplicationForm.vue b/front/src/components/auth/ApplicationForm.vue index 303d1599f..8cd8d48dd 100644 --- a/front/src/components/auth/ApplicationForm.vue +++ b/front/src/components/auth/ApplicationForm.vue @@ -1,3 +1,95 @@ + + {{ child.id }} - - {{ child.description }} - @@ -101,7 +190,7 @@ type="submit" > Update application @@ -115,111 +204,3 @@ - - diff --git a/front/src/components/auth/Authorize.vue b/front/src/components/auth/Authorize.vue index 36379bade..ac15c4bbd 100644 --- a/front/src/components/auth/Authorize.vue +++ b/front/src/components/auth/Authorize.vue @@ -1,3 +1,116 @@ + + - - diff --git a/front/src/components/favorites/List.vue b/front/src/components/favorites/List.vue index c7be9fb2d..efd7004ee 100644 --- a/front/src/components/favorites/List.vue +++ b/front/src/components/favorites/List.vue @@ -7,7 +7,6 @@ import axios from 'axios' import $ from 'jquery' import RadioButton from '~/components/radios/Button.vue' import Pagination from '~/components/vui/Pagination.vue' -import { checkRedirectToLogin } from '~/utils' import TrackTable from '~/components/audio/track/Table.vue' import useLogger from '~/composables/useLogger' import useSharedLabels from '~/composables/locale/useSharedLabels' @@ -29,7 +28,6 @@ const props = withDefaults(defineProps(), { }) const store = useStore() -await checkRedirectToLogin(store, useRouter()) // TODO (wvffle): Make sure everything is it's own type const page = ref(+props.defaultPage) diff --git a/front/src/composables/auth/useScopes.ts b/front/src/composables/auth/useScopes.ts new file mode 100644 index 000000000..704011b4f --- /dev/null +++ b/front/src/composables/auth/useScopes.ts @@ -0,0 +1,17 @@ +export type ScopeId = 'profile' | 'libraries' | 'favorites' | 'listenings' | 'follows' + | 'playlists' | 'radios' | 'filters' | 'notifications' | 'edits' | 'security' | 'reports' + +export default () => [ + { id: 'profile', icon: 'user' }, + { id: 'libraries', icon: 'book' }, + { id: 'favorites', icon: 'heart' }, + { id: 'listenings', icon: 'music' }, + { id: 'follows', icon: 'users' }, + { id: 'playlists', icon: 'list' }, + { id: 'radios', icon: 'rss' }, + { id: 'filters', icon: 'eye slash' }, + { id: 'notifications', icon: 'bell' }, + { id: 'edits', icon: 'pencil alternate' }, + { id: 'security', icon: 'lock' }, + { id: 'reports', icon: 'warning sign' } +] as { id: ScopeId, icon: string }[] diff --git a/front/src/composables/locale/useSharedLabels.ts b/front/src/composables/locale/useSharedLabels.ts index 17710fd70..284626615 100644 --- a/front/src/composables/locale/useSharedLabels.ts +++ b/front/src/composables/locale/useSharedLabels.ts @@ -1,4 +1,5 @@ import type { PrivacyLevel, ImportStatus } from '~/types' +import type { ScopeId } from '~/composables/auth/useScopes' import { gettext } from '~/init/locale' @@ -144,5 +145,5 @@ export default () => ({ label: $pgettext('*/Moderation/*/Noun', 'Reports'), description: $pgettext('Content/OAuth Scopes/Paragraph', 'Access to moderation reports') } - } + } as Record }) diff --git a/front/src/router/guards.ts b/front/src/router/guards.ts index a0be2c291..cdad7b525 100644 --- a/front/src/router/guards.ts +++ b/front/src/router/guards.ts @@ -2,6 +2,7 @@ import type { NavigationGuardNext, RouteLocationNamedRaw, RouteLocationNormalized } from 'vue-router' import type { Permission } from '~/store/auth' +import router from '~/router' import store from '~/store' export const hasPermissions = (permission: Permission) => (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => { @@ -13,9 +14,9 @@ export const hasPermissions = (permission: Permission) => (to: RouteLocationNorm next({ name: 'library.index' }) } -export const requireLoggedIn = (fallbackLocation: RouteLocationNamedRaw) => (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => { +export const requireLoggedIn = (fallbackLocation?: RouteLocationNamedRaw) => (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => { if (store.state.auth.authenticated) return next() - return next(fallbackLocation) + return next(fallbackLocation ?? { name: 'login', query: { next: router.currentRoute.value.fullPath } }) } export const requireLoggedOut = (fallbackLocation: RouteLocationNamedRaw) => (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => { diff --git a/front/src/router/routes/auth.ts b/front/src/router/routes/auth.ts index 7ad640388..e3c4e1718 100644 --- a/front/src/router/routes/auth.ts +++ b/front/src/router/routes/auth.ts @@ -1,6 +1,6 @@ import type { RouteRecordRaw } from 'vue-router' -import { requireLoggedOut } from '../guards' +import { requireLoggedOut, requireLoggedIn } from '../guards' export default [ { @@ -52,7 +52,8 @@ export default [ responseType: route.query.response_type, nonce: route.query.nonce, state: route.query.state - }) + }), + beforeEnter: requireLoggedIn() }, { path: '/signup', diff --git a/front/src/router/routes/index.ts b/front/src/router/routes/index.ts index d275225f6..c4b8cd6fa 100644 --- a/front/src/router/routes/index.ts +++ b/front/src/router/routes/index.ts @@ -7,6 +7,7 @@ import manage from './manage' import store from '~/store' import auth from './auth' import user from './user' +import { requireLoggedIn } from '../guards' export default [ { @@ -71,7 +72,8 @@ export default [ props: route => ({ defaultOrdering: route.query.ordering, defaultPage: route.query.page ? +route.query.page : undefined - }) + }), + beforeEnter: requireLoggedIn() }, ...content, ...manage, diff --git a/front/src/store/moderation.ts b/front/src/store/moderation.ts index af63cbf46..69c6e2087 100644 --- a/front/src/store/moderation.ts +++ b/front/src/store/moderation.ts @@ -111,12 +111,9 @@ const store: Module = { }, getters: { artistFilters: (state) => () => { - const f = state.filters.filter((f) => { - return f.target.type === 'artist' - }) - const p = sortBy(f, [(e) => { return e.creation_date }]) - p.reverse() - return p + const filters = state.filters.filter((filter) => filter.target.type === 'artist') + const sorted = sortBy(filters, [(e) => { return e.creation_date }]) + return sorted.reverse() } }, actions: { diff --git a/front/src/style/globals/_app.scss b/front/src/style/globals/_app.scss index 63cea66af..7c1199f6b 100644 --- a/front/src/style/globals/_app.scss +++ b/front/src/style/globals/_app.scss @@ -7,3 +7,7 @@ html { scroll-behavior: auto; } } + +input[type=search]::-webkit-search-cancel-button { + appearance: none; +} \ No newline at end of file diff --git a/front/src/types.ts b/front/src/types.ts index 7017a3625..330f4343e 100644 --- a/front/src/types.ts +++ b/front/src/types.ts @@ -472,3 +472,16 @@ export interface Notification { id: number is_read: boolean } + +// Tags stuff +export interface Tag { + name: string +} + +// Application stuff +export interface Application { + client_id: string + name: string + redirect_uris: string + scopes: string +} diff --git a/front/src/utils/index.ts b/front/src/utils/index.ts index c559b1d25..38fdce8a6 100644 --- a/front/src/utils/index.ts +++ b/front/src/utils/index.ts @@ -1,8 +1,6 @@ -import { startCase } from 'lodash-es' -import type { Store } from 'vuex' -import type { Router } from 'vue-router' import type { APIErrorResponse } from '~/types' -import type { RootState } from '~/store' + +import { startCase } from 'lodash-es' export function parseAPIErrors (responseData: APIErrorResponse, parentField?: string): string[] { const errors = [] @@ -40,13 +38,6 @@ export function getCookie (name: string) { ?.split('=')[1] } -// TODO (wvffle): Use navigation guards -export async function checkRedirectToLogin (store: Store, router: Router) { - if (!store.state.auth.authenticated) { - return router.push({ name: 'login', query: { next: router.currentRoute.value.fullPath } }) - } -} - export function getDomain (url: string) { const parser = document.createElement('a') parser.href = url
- {{ child.description }} -