Add initial support for the v2 of the API (Still WIP) (#250)

* Functionally implement modpacks

* Add LogoAnimated to logo license

* Fix eslint errors

* Add `z-index: 20` to user dropdown (#287)

* Fix pages not working, add changelog page, redesign versions page

* Update theme colors, add OLED theme, update some project creation text. (#292)

* Update theme colors, add OLED theme, update some project creation text.

* Make summary normal text color

* Update favicons, update logos to use dynamic colors, updated filters panel a bit

* Update wording from #250

* Version page rework

* Manually apply some commits from master, other minor v2 fixes (#296)

* Homepage styling improvements (#285)

* Add border radius to video + example code colors

* Change color + allow overflow scroll

* Minor v2 fixes

- Makes multiple loaders display correctly (used to be `Fabric,Forge` is now `Fabric, Forge`
- Fix oopses in #292
- Allow .jar and .zip in file prompt
- Apply 30cbd3a6c372940d1e86cc8134d0dfc7e8e5ee9c to pages/create/project.vue
- Display `fabric, forge` instead of broken icons on pages/create/project.vue

* Markdown styling fixes (#268)

* Add table color variables (+ prettier fixes)

* Add details and table styling to .markdown-body

* Add indexing meta value depending on the status of the mod. (#261)

* General UI Improvement (again) (#255)

* Add and fix some stuff

* Add warning when leaving to `mod/create`

* Fix mods/create not working

* Fix a bug & add improvements to a couple moderation aspects (#278)

This PR fixes reports on the moderation dashboard going to `/dashboard/mod/_id` instead of to `/mod/_id`.
It also allows the ability for moderators to unlist mods in the queue from the frontend instead of having to do it via the backend.
![image](https://i.imgur.com/x8shSVn.png)
Unlisted mods should have the ability to resubmit for approval, so I've also changed "Submit for Review" to "Submit for approval", allowing unlisted mods to do that as well.
![image](https://i.imgur.com/OC8Vyfo.png)

* Add project guidelines to Terms page (#275)

* Add project guidelines to Terms page

This adds the project guidelines as outlined [here](https://discord.com/channels/734077874708938864/734077874708938867/806556531491471368).
NOTE: I've made a few tweaks in wording to accommodate this format, so this is not an exact copy.

* Move rules to its own page

* Allow users to login from search page when it is rendered serverside (#272)

* Change `this.$route.fullPath` → `this.$route.path`

* Closes modrinth/knossos#256

* Wrap mod icon and title in link (#273)

* Wrap mod icon and title in link

* Fixes #218

* Editor's note

    Skipped #249 (search was rewritten), #266 (couldn't figure out how to apply it), #270 (didn't seem to apply properly), #252 (manually merged in with #292), #262 (superceded by #270), #282, #271, #277, #283, and #281 (those five didn't get wiped)

Co-authored-by: venashial <venashial.levo@aleeas.com>
Co-authored-by: Redblueflame <contact@redblueflame.com>
Co-authored-by: Johan Novak <wickedtree@wickedtree.codes>

* SSR descriptions, version edit page

* Working version editing + dependency management (besides files)

* Version create page, file functionality

* Fix some issues with the version page

* More versions page fixes

* Project gallery

* Box shadows, user profile page, WIP header

* Finish user dashboard

* Finish search and fix minor issues

* Moderator page + messages, notifications page

* Fix dropdown menu, fix XSS, fix team members page

* Change doc url on main page (#309)

* Re-Fix docs url (#313)

* Clean up. Part 1: Fix immediate problems (#316)

* Clean up tabs and cards CSS a little

* Fix project page; Remove bad styles from search

* Yeet and flatten lots of styles; fix font sizes

* Restyle search; fix moderation

* Fix profile page

* Remove injected SCSS entirely

* Fix a mobile layout overflowing

* Apiv2-support fixes (#320)

* Fix member user_id -> user.id

* Fix incorrect report redirect

* Change theme switcher from button to multiselect

* Fix remaining items

Co-authored-by: Jai A <jaiagr+gpg@pm.me>

* Fix bugs

* Full mobile support, update create project page, fix various bugs

* New Dark Mode brand colors (#325)

* Use "color-brand-hover" for auth-prompt when hover over

* New dark mode brand colors

* Fix new version featured bug

* Remove old home page, other fixes

* Fix error when merging

* Fix prettier error :(

Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: venashial <venashial.levo@aleeas.com>
Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
Co-authored-by: Emma <emmaffle@modrinth.com>
Co-authored-by: Johan Novak <wickedtree@wickedtree.codes>
Co-authored-by: Jai A <jaiagr@pm.me>
Co-authored-by: Mysterious_Dev <40738104+Mysterious-Dev@users.noreply.github.com>
Co-authored-by: Mikhail Oleynikov <contact@falseresync.ru>
Co-authored-by: Christian Popov <30723811+Xrey274@users.noreply.github.com>
This commit is contained in:
Redblueflame
2022-01-09 23:19:27 +01:00
committed by GitHub
parent c518f373df
commit a2266adb3f
167 changed files with 18841 additions and 18188 deletions

View File

@@ -0,0 +1,58 @@
<template>
<div v-if="$user.follows.length > 0">
<ProjectCard
v-for="project in $user.follows"
:id="project.id"
:key="project.id"
:type="project.project_type"
:categories="project.categories"
:created-at="project.published"
:updated-at="project.updated"
:description="project.description"
:downloads="project.downloads.toString()"
:icon-url="project.icon_url"
:name="project.title"
:client-side="project.client_side"
:server-side="project.server_side"
>
<button
class="iconified-button"
@click="$store.dispatch('user/unfollowProject', project)"
>
<HeartIcon />
Unfollow
</button>
</ProjectCard>
</div>
<div v-else class="error">
<FollowIllustration class="icon" />
<br />
<span class="text"
>You don't have any followed mods. <br />
Why don't you <nuxt-link class="link" to="/mods">search</nuxt-link> for
new ones?</span
>
</div>
</template>
<script>
import ProjectCard from '~/components/ui/ProjectCard'
import HeartIcon from '~/assets/images/utils/heart.svg?inline'
import FollowIllustration from '~/assets/images/illustrations/follow_illustration.svg?inline'
export default {
components: {
ProjectCard,
HeartIcon,
FollowIllustration,
},
async fetch() {
await this.$store.dispatch('user/fetchFollows')
},
head: {
title: 'Followed Projects - Modrinth',
},
}
</script>
<style lang="scss" scoped></style>

323
pages/settings/index.vue Normal file
View File

@@ -0,0 +1,323 @@
<template>
<div class="edit-page">
<div class="left-side">
<div class="profile-picture card">
<h3>Profile picture</h3>
<div class="uploader">
<img :src="previewImage ? previewImage : $auth.user.avatar_url" />
<file-input
accept="image/png,image/jpeg,image/gif,image/webp"
class="choose-image"
prompt="Choose image or drag it here"
@change="showPreviewImage"
/>
</div>
<button
class="iconified-button"
@click="
icon = null
previewImage = null
"
>
<TrashIcon />
Reset icon
</button>
</div>
<div class="recap">
<section>
<h2>Quick recap of you</h2>
<div>
<Badge
v-if="$auth.user.role === 'admin'"
type="You are an admin"
color="red"
/>
<Badge
v-else-if="$auth.user.role === 'moderator'"
type="You are a moderator"
color="yellow"
/>
<Badge v-else type="You are a developer" color="green" />
<div class="stat">
<SunriseIcon />
<span>You joined {{ $dayjs($auth.user.created).fromNow() }}</span>
</div>
</div>
</section>
<section>
<h2>You have</h2>
<div class="stat">
<DownloadIcon />
<span>
<strong>{{ sumDownloads() }}</strong> downloads
</span>
</div>
<div class="stat">
<HeartIcon />
<span>
<strong>{{ sumFollows() }}</strong> followers of projects
</span>
</div>
</section>
</div>
</div>
<div class="right-side">
<section class="card">
<h3>Username</h3>
<label>
<span>
The username used on Modrinth to identify yourself. This must be
unique.
</span>
<input
v-model="username"
type="text"
placeholder="Enter your username"
/>
</label>
<h3>Email</h3>
<label>
<span>
The email for your account. This is private information which is not
exposed in any API routes or on your profile. It is also optional.
</span>
<input v-model="email" type="email" placeholder="Enter your email" />
</label>
<h3>Bio</h3>
<label>
<span>
A description of yourself which other users can see on your profile.
</span>
<input v-model="bio" type="text" placeholder="Enter your bio" />
</label>
<h3>Theme</h3>
<label>
<span
>Change the global site theme of Modrinth. You can switch it here or
anywhere by accessing the theme switcher in the navigation bar
dropdown.</span
>
<Multiselect
v-model="$colorMode.preference"
:options="['light', 'dark', 'oled']"
:searchable="false"
:close-on-select="true"
:show-labels="false"
:allow-empty="false"
/>
</label>
</section>
</div>
</div>
</template>
<script>
import Multiselect from 'vue-multiselect'
import FileInput from '~/components/ui/FileInput'
import Badge from '~/components/ui/Badge'
import HeartIcon from '~/assets/images/utils/heart.svg?inline'
import TrashIcon from '~/assets/images/utils/trash.svg?inline'
import SunriseIcon from '~/assets/images/utils/sunrise.svg?inline'
import DownloadIcon from '~/assets/images/utils/download-alt.svg?inline'
export default {
components: {
TrashIcon,
SunriseIcon,
DownloadIcon,
HeartIcon,
Badge,
FileInput,
Multiselect,
},
asyncData(ctx) {
return {
username: ctx.$auth.user.username,
email: ctx.$auth.user.email,
bio: ctx.$auth.user.bio,
}
},
data() {
return {
icon: null,
previewImage: null,
}
},
fetch() {
this.$emit('update:action-button', 'Save profile settings')
this.$emit('update:action-button-callback', this.saveChanges)
},
head: {
title: 'Settings - Modrinth',
},
created() {
this.$emit('update:action-button', 'Save profile settings')
this.$emit('update:action-button-callback', this.saveChanges)
},
methods: {
changeTheme() {
const shift = event.shiftKey
switch (this.$colorMode.preference) {
case 'dark':
this.$colorMode.preference = shift ? 'light' : 'oled'
break
case 'oled':
this.$colorMode.preference = shift ? 'dark' : 'light'
break
default:
this.$colorMode.preference = shift ? 'oled' : 'dark'
}
},
showPreviewImage(files) {
const reader = new FileReader()
this.icon = files[0]
reader.readAsDataURL(this.icon)
reader.onload = (event) => {
this.previewImage = event.target.result
}
},
formatNumber(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
},
sumDownloads() {
let sum = 0
for (const projects of this.$user.projects) {
sum += projects.downloads
}
return this.formatNumber(sum)
},
sumFollows() {
let sum = 0
for (const projects of this.$user.projects) {
sum += projects.followers
}
return this.formatNumber(sum)
},
async saveChanges() {
this.$nuxt.$loading.start()
try {
if (this.icon) {
await this.$axios.patch(
`user/${this.$auth.user.id}/icon?ext=${
this.icon.type.split('/')[this.icon.type.split('/').length - 1]
}`,
this.icon,
this.$auth.headers
)
}
const data = {
email: this.email,
bio: this.bio,
}
if (this.username !== this.$auth.user.username) {
data.username = this.username
}
await this.$axios.patch(
`user/${this.$auth.user.id}`,
data,
this.$auth.headers
)
await this.$store.dispatch('auth/fetchUser', {
token: this.$auth.token,
})
} catch (err) {
this.$notify({
group: 'main',
title: 'An error occurred',
text: err.response.data.description,
type: 'error',
})
}
this.$nuxt.$loading.finish()
},
},
}
</script>
<style lang="scss" scoped>
.edit-page {
display: flex;
flex-direction: column;
@media screen and (min-width: 1024px) {
flex-direction: row;
}
}
.left-side {
min-width: 20rem;
.profile-picture {
margin-right: var(--spacing-card-bg);
h3 {
font-size: var(--font-size-lg);
}
.uploader {
margin: 1rem 0;
text-align: center;
img {
box-shadow: var(--shadow-card);
border-radius: var(--size-rounded-md);
width: 8rem;
margin-bottom: 0.5rem;
}
}
}
.recap {
section {
padding: var(--spacing-card-md) var(--spacing-card-lg);
margin-bottom: 1rem;
@media screen and (min-width: 1024px) {
padding: 0;
}
h2 {
font-size: var(--font-size-lg);
margin: 0 0 0.5rem 0;
}
.version-badge {
text-transform: none;
margin-bottom: 0.25rem;
&::first-letter {
text-transform: uppercase;
}
}
}
}
}
.stat {
display: flex;
align-items: center;
svg {
width: auto;
height: 1.25rem;
margin-right: 0.25rem;
}
span {
strong {
font-weight: bolder;
font-size: var(--font-size-xl);
}
}
}
</style>

176
pages/settings/privacy.vue Normal file
View File

@@ -0,0 +1,176 @@
<template>
<div class="rows card">
<div class="consent-container">
<div>
Modrinth relies on different providers and in-house tools to allow us to
provide custom-tailored experiences and personalized advertising. You
can change your privacy settings at any time by going to this settings
page or via the footer of any page.
</div>
<br class="divider" />
<div class="toggles">
<div v-for="(scope, id) in scopes" :key="id" class="toggle">
<div class="toggle-text">
<div class="title">{{ scope.title }}</div>
<div class="contents">
{{ scope.description }}
</div>
</div>
<div class="spacer"></div>
<div class="toggle-action">
<label :for="id"></label>
<input
:id="id"
ref="toggles"
v-model="scopes[id].value"
type="checkbox"
class="switch stylized-toggle"
/>
</div>
</div>
</div>
</div>
<div class="actions">
<button class="iconified-button" @click="toggleAll(false)">
Refuse All
</button>
<button class="iconified-button" @click="toggleAll(true)">
Accept All
</button>
</div>
</div>
</template>
<script>
import toggles from '@/privacy-toggles'
export default {
auth: false,
name: 'Privacy',
data: () => {
const settings = toggles.settings
return {
scopes: settings,
}
},
fetch() {
this.$emit('update:action-button', 'Confirm my choices')
this.$emit('update:action-button-callback', this.confirm)
this.$store.dispatch('consent/loadFromCookies', this.$cookies)
if (this.$store.state.consent.is_consent_given) {
Object.keys(toggles.settings).forEach((key) => {
toggles.settings[key].value = false
})
// Load the allowed scopes from the store
this.$store.state.consent.scopes_allowed.forEach((scope) => {
if (this.scopes[scope] != null)
this.$set(this.scopes[scope], 'value', true)
})
} else {
Object.keys(toggles.settings).forEach((key) => {
toggles.settings[key].value = toggles.settings[key].default
})
}
},
head: {
title: 'Privacy Settings - Modrinth',
},
created() {
this.$emit('update:action-button', 'Confirm my choices')
this.$emit('update:action-button-callback', this.confirm)
},
options: {
auth: false,
},
methods: {
toggleAll(value) {
for (const elem in this.scopes) {
this.scopes[elem].value = value
this.$set(this.scopes[elem], 'value', value)
}
this.$forceUpdate()
},
confirm() {
this.$store.commit('consent/set_consent', true)
for (const elem in this.scopes) {
if (this.scopes[elem].value === true) {
this.$store.commit('consent/add_scope', elem)
} else {
this.$store.commit('consent/remove_scope', elem)
}
}
this.$store.dispatch('consent/save', this.$cookies)
this.$notify({
group: 'main',
title: 'Saved',
text: 'Your preferences have been saved successfully.',
type: 'success',
})
},
},
}
</script>
<style lang="scss" scoped>
.spacer {
margin-top: 1rem;
}
.actions {
margin-top: 1rem;
margin-right: -0.5rem;
display: flex;
flex-direction: row;
justify-content: flex-end;
flex-wrap: wrap;
button {
padding: 0.5rem 0.75rem;
margin-top: 0.5rem;
margin-right: 0.5rem;
}
}
.consent-container {
.divider {
margin-top: 1rem;
}
.toggles {
display: flex;
flex-direction: column;
width: 100%;
.toggle {
display: flex;
flex-direction: row;
margin-bottom: 1rem;
.toggle-text {
.title {
color: var(--color-text-dark);
font-weight: bold;
margin-bottom: 0.5rem;
}
.contents {
color: var(--color-text);
}
}
.spacer {
flex-grow: 1;
}
.toggle-action {
margin-left: 1rem;
display: flex;
flex-direction: column;
justify-content: center;
margin-right: 1rem;
}
}
}
}
</style>

View File

@@ -0,0 +1,86 @@
<template>
<div>
<section class="card essentials pad-maker">
<h3>Revoke your Modrinth token</h3>
<p>
Revoking your Modrinth token can have unintended consequences. Please be
aware that the following could break:
</p>
<ul>
<li>Any application that uses your token to access the API.</li>
<li>
Gradle - if Minotaur is given a incorrect token, your Gradle builds
could fail.
</li>
<li>
GitHub - if you use a GitHub action that uses the Modrinth API, it
will cause errors.
</li>
</ul>
<p>If you are willing to continue, complete the following steps:</p>
<ol>
<li>
<a
href="https://github.com/settings/connections/applications/3acffb2e808d16d4b226"
target="_blank"
>
Head to the Modrinth Application page on GitHub.
</a>
Make sure to be logged into the GitHub account you used for Modrinth!
</li>
<li>
Press the big red "Revoke Access" button next to the "Permissions"
header.
</li>
</ol>
<p>
Once you have completed those steps, press the continue button below.
</p>
<p>
<strong>
This will log you out of Modrinth, however, when you log back in, your
token will be regenerated.
</strong>
</p>
<button class="iconified-button brand-button-colors" @click="logout">
<CheckIcon />
Continue
</button>
</section>
</div>
</template>
<script>
import CheckIcon from '~/assets/images/utils/right-arrow.svg?inline'
export default {
components: {
CheckIcon,
},
head: {
title: 'Revoke Token - Modrinth',
},
methods: {
async logout() {
this.$cookies.set('auth-token-reset', true)
await this.$router.replace(
`auth/init?url=${process.env.domain}${this.$route.fullPath}`
)
},
},
}
</script>
<style lang="scss" scoped>
section {
a {
color: var(--color-link);
text-decoration: underline;
}
button {
padding: 0.5rem 0.75rem;
margin-left: auto;
}
}
</style>

View File

@@ -0,0 +1,98 @@
<template>
<div>
<ConfirmPopup
ref="delete_popup"
title="Are you sure you want to delete your account?"
description="If you proceed, your user and all attached data will be removed from our
servers. This cannot be reversed, so be careful!"
proceed-label="Delete account"
:confirmation-text="$auth.user.username"
:has-to-type="true"
@proceed="deleteAccount"
/>
<section class="card">
<h3>Authorization token</h3>
<label>
<span>
Your authorization token can be used with the Modrinth API, the
Minotaur Gradle plugin, and other applications that interact with
Modrinth's API. Be sure to keep this secret!
</span>
<input
type="button"
class="iconified-button"
value="Copy to clipboard"
@click="copyToken"
/>
</label>
<h3>Revoke your token</h3>
<label>
<span
>This will log you out of Modrinth, and you will have to log in again
to access Modrinth with a new token.</span
>
<input
type="button"
class="iconified-button"
value="Revoke token"
@click="$router.replace('/settings/revoke-token')"
/>
</label>
<h3>Delete your account</h3>
<label>
<span
>Clicking on this WILL delete your account. Do not click on this
unless you want your account deleted. If you delete your account, all
attached data, including projects, will be removed from our servers.
This cannot be reversed, so be careful!</span
>
<input
value="Delete Account"
type="button"
class="iconified-button"
@click="$refs.delete_popup.show()"
/>
</label>
</section>
</div>
</template>
<script>
import ConfirmPopup from '~/components/ui/ConfirmPopup'
export default {
components: { ConfirmPopup },
head: {
title: 'Security - Modrinth',
},
methods: {
async copyToken() {
await navigator.clipboard.writeText(this.$auth.token)
this.$notify({
group: 'main',
title: 'Copied to clipboard.',
text: 'Copied your Modrinth token to the clipboard.',
type: 'success',
})
},
async deleteAccount() {
this.$nuxt.$loading.start()
try {
await this.$axios.delete(
`user/${this.$auth.user.id}`,
this.$auth.headers
)
} catch (err) {
this.$notify({
group: 'main',
title: 'An error occurred',
text: err.response.data.description,
type: 'error',
})
}
this.$nuxt.$loading.finish()
},
},
}
</script>