Update master with new auth (#1236)

* Begin UI for threads and moderation overhaul

* Hide close button on non-report threads

* Fix review age coloring

* Add project count

* Remove action buttons from queue page and add queued date to project page

* Hook up to actual data

* Remove unused icon

* Get up to 1000 projects in queue

* prettier

* more prettier

* Changed all the things

* lint

* rebuild

* Add omorphia

* Workaround formatjs bug in ThreadSummary.vue

* Fix notifications page on prod

* Fix a few notifications and threads bugs

* lockfile

* Fix duplicate button styles

* more fixes and polishing

* More fixes

* Remove legacy pages

* More bugfixes

* Add some error catching for reports and notifications

* More error handling

* fix lint

* Add inbox links

* Remove loading component and rename member header

* Rely on threads always existing

* Handle if project update notifs are not grouped

* oops

* Fix chips on notifications page

* Import ModalModeration

* finish threads

* New authentication (#1234)

* Initial new auth work

* more auth pages

* Finish most

* more

* fix on landing page

* Finish everything but PATs + Sessions

* fix threads merge bugs

* fix cf pages ssr

* fix most issues

* Finish authentication

* Fix merge

---------

Co-authored-by: triphora <emma@modrinth.com>
Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Prospector
2023-07-20 11:19:42 -07:00
committed by GitHub
parent a5613ebb10
commit 34d63f3557
72 changed files with 2373 additions and 711 deletions

View File

@@ -1,4 +1,6 @@
export default defineNuxtPlugin((nuxtApp) => {
export default defineNuxtPlugin(async (nuxtApp) => {
await useAuth()
await useUser()
const themeStore = useTheme()
nuxtApp.hook('app:mounted', () => {

View File

@@ -1,11 +0,0 @@
export default defineNuxtPlugin(async (nuxtApp) => {
const authStore = await useAuth()
await useUser()
const cosmeticsStore = useCosmetics()
const tagsStore = useTags()
nuxtApp.provide('auth', authStore.value)
nuxtApp.provide('cosmetics', cosmeticsStore.value)
nuxtApp.provide('tag', tagsStore.value)
nuxtApp.provide('notify', (notif) => addNotification(notif))
})

View File

@@ -1,29 +1,10 @@
import { getProjectTypeForUrlShorthand } from '~/helpers/projects.js'
export default defineNuxtPlugin((nuxtApp) => {
const tagStore = nuxtApp.$tag
const authStore = nuxtApp.$auth
nuxtApp.provide('defaultHeaders', () => {
const obj = { headers: {} }
if (process.server) {
const config = useRuntimeConfig()
if (config.rateLimitKey) {
obj.headers['x-ratelimit-key'] = config.rateLimitKey || ''
}
}
if (authStore.user) {
obj.headers.Authorization = authStore.token
}
return obj
})
nuxtApp.provide('formatNumber', formatNumber)
nuxtApp.provide('capitalizeString', capitalizeString)
nuxtApp.provide('formatMoney', formatMoney)
nuxtApp.provide('formatVersion', (versionsArray) => formatVersions(versionsArray, tagStore))
nuxtApp.provide('formatVersion', (versionsArray) => formatVersions(versionsArray))
nuxtApp.provide('orElse', (first, otherwise) => first ?? otherwise)
nuxtApp.provide('external', () => {
const cosmeticsStore = useCosmetics().value
@@ -95,15 +76,17 @@ export default defineNuxtPlugin((nuxtApp) => {
.sort((a, b) => nuxtApp.$dayjs(b.date_published) - nuxtApp.$dayjs(a.date_published))
})
nuxtApp.provide('getProjectTypeForDisplay', (type, categories) => {
const tagStore = useTags()
if (type === 'mod') {
const isPlugin = categories.some((category) => {
return tagStore.loaderData.allPluginLoaders.includes(category)
return tagStore.value.loaderData.allPluginLoaders.includes(category)
})
const isMod = categories.some((category) => {
return tagStore.loaderData.modLoaders.includes(category)
return tagStore.value.loaderData.modLoaders.includes(category)
})
const isDataPack = categories.some((category) => {
return tagStore.loaderData.dataPackLoaders.includes(category)
return tagStore.value.loaderData.dataPackLoaders.includes(category)
})
if (isMod && isPlugin && isDataPack) {
@@ -123,25 +106,29 @@ export default defineNuxtPlugin((nuxtApp) => {
return type
})
nuxtApp.provide('getProjectTypeForUrl', (type, loaders) =>
getProjectTypeForUrlShorthand(nuxtApp, type, loaders)
nuxtApp.provide('getProjectTypeForUrl', (type, loaders, tags) =>
getProjectTypeForUrlShorthand(type, loaders, tags)
)
nuxtApp.provide('cycleValue', cycleValue)
const sortedCategories = tagStore.categories.slice().sort((a, b) => {
const headerCompare = a.header.localeCompare(b.header)
if (headerCompare !== 0) {
return headerCompare
}
if (a.header === 'resolutions' && b.header === 'resolutions') {
return a.name.replace(/\D/g, '') - b.name.replace(/\D/g, '')
} else if (a.header === 'performance impact' && b.header === 'performance impact') {
const x = ['potato', 'low', 'medium', 'high', 'screenshot']
nuxtApp.provide('sortedCategories', () => {
const tagStore = useTags()
return x.indexOf(a.name) - x.indexOf(b.name)
}
return 0
return tagStore.value.categories.slice().sort((a, b) => {
const headerCompare = a.header.localeCompare(b.header)
if (headerCompare !== 0) {
return headerCompare
}
if (a.header === 'resolutions' && b.header === 'resolutions') {
return a.name.replace(/\D/g, '') - b.name.replace(/\D/g, '')
} else if (a.header === 'performance impact' && b.header === 'performance impact') {
const x = ['potato', 'low', 'medium', 'high', 'screenshot']
return x.indexOf(a.name) - x.indexOf(b.name)
}
return 0
})
})
nuxtApp.provide('sortedCategories', sortedCategories)
nuxtApp.provide('notify', (notif) => addNotification(notif))
})
export const formatNumber = (number, abbreviate = true) => {
const x = +number
@@ -257,8 +244,9 @@ export const formatProjectStatus = (name) => {
return capitalizeString(name)
}
export const formatVersions = (versionArray, tag) => {
const allVersions = tag.gameVersions.slice().reverse()
export const formatVersions = (versionArray) => {
const tag = useTags()
const allVersions = tag.value.gameVersions.slice().reverse()
const allReleases = allVersions.filter((x) => x.version_type === 'release')
const intervals = []