New organizations (#1488)

* [WIP] Transfer organizations to own branch

* push progress

* Setup organizations page

* Add organizations grid to user profile

* Remove debug

* Add error handling for failed organization fetch

* Refactor organization page and settings

* Restructure to composition setup api

* checklist completion

* Apply suggestions from code review

Co-authored-by: Emma Alexia <emma@modrinth.com>

* Update pages/[type]/[id]/settings/index.vue

Co-authored-by: Emma Alexia <emma@modrinth.com>

* Update pages/[type]/[id]/settings/index.vue

Co-authored-by: Emma Alexia <emma@modrinth.com>

* Update pages/[type]/[id]/settings/index.vue

Co-authored-by: Emma Alexia <emma@modrinth.com>

* Update pages/[type]/[id]/settings/index.vue

Co-authored-by: Emma Alexia <emma@modrinth.com>

* Clean up org state management

* Refactor useClientTry to simplify code

* Remove unused code and update dependencies

* Refactor bulkEditLinks event handler

* Refactor organization management functions

* Update heading from "Creators" to "Members"

* Refactor team member invitation

* Refactor member management functions

* Implement validation on clientside for org names

* Name sanitization for fun characters

* Update onInviteTeamMember function parameters

* Remove name

* sidebar

* random rendering issue

* Conform to org removal

* Org no projects conditional

* Update organization links in dashboard

* Update Cards to universal-cards

* Refactor gallery upload permissions

* Refactor to sidebar pattern

* Update button classes in gallery and versions components

* Finish (most)

* almost finish

* Finish orgs :D

* Fix lint

* orgs fixes

* fix most things

* project settings

* convert grid to cards

* clean up unused test class

* Settings -> Manage

* add org view to org management

* Fix prop mounting issue

* fix analytics grid layout overflow

* fix multiselect breaking layout

* Refactor chart selection logic in ChartDisplay.vue

* Add transfer modal

---------

Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Emma Alexia <emma@modrinth.com>
This commit is contained in:
Carter
2024-01-06 15:09:26 -08:00
committed by GitHub
parent 1108b0264e
commit d893765b24
44 changed files with 4092 additions and 1037 deletions

View File

@@ -1,12 +1,12 @@
import { useNuxtApp } from '#app'
async function getBulk(type, ids) {
async function getBulk(type, ids, apiVersion = 2) {
if (ids.length === 0) {
return []
}
const url = `${type}?ids=${encodeURIComponent(JSON.stringify([...new Set(ids)]))}`
const { data: bulkFetch } = await useAsyncData(url, () => useBaseFetch(url))
const { data: bulkFetch } = await useAsyncData(url, () => useBaseFetch(url, { apiVersion }))
return bulkFetch.value
}
@@ -22,6 +22,7 @@ export async function fetchNotifications() {
const threadIds = []
const userIds = []
const versionIds = []
const organizationIds = []
for (const notification of notifications.value) {
if (notification.body) {
@@ -40,6 +41,9 @@ export async function fetchNotifications() {
if (notification.body.invited_by) {
userIds.push(notification.body.invited_by)
}
if (notification.body.organization_id) {
organizationIds.push(notification.body.organization_id)
}
}
}
@@ -61,9 +65,12 @@ export async function fetchNotifications() {
projectIds.push(version.project_id)
}
const projects = await getBulk('projects', projectIds)
const threads = await getBulk('threads', threadIds)
const users = await getBulk('users', userIds)
const [projects, threads, users, organizations] = await Promise.all([
getBulk('projects', projectIds),
getBulk('threads', threadIds),
getBulk('users', userIds),
getBulk('organizations', organizationIds, 3),
])
for (const notification of notifications.value) {
notification.extra_data = {}
@@ -73,6 +80,11 @@ export async function fetchNotifications() {
(x) => x.id === notification.body.project_id
)
}
if (notification.body.organization_id) {
notification.extra_data.organization = organizations.find(
(x) => x.id === notification.body.organization_id
)
}
if (notification.body.report_id) {
notification.extra_data.report = reports.find((x) => x.id === notification.body.report_id)

View File

@@ -1,5 +1,6 @@
export const acceptTeamInvite = async (teamId) => {
await useBaseFetch(`team/${teamId}/join`, {
apiVersion: 3,
method: 'POST',
})
}
@@ -9,6 +10,7 @@ export const removeSelfFromTeam = async (teamId) => {
}
export const removeTeamMember = async (teamId, userId) => {
await useBaseFetch(`team/${teamId}/members/${userId}`, {
apiVersion: 3,
method: 'DELETE',
})
}