From 718a35737abb2628bcf97a014f6c99233e5be294 Mon Sep 17 00:00:00 2001 From: IMB11 Date: Thu, 31 Jul 2025 12:33:16 +0100 Subject: [PATCH] refactor: move org context to new DI setup --- .../composables/servers/modrinth-servers.ts | 10 +- apps/frontend/src/pages/organization/[id].vue | 185 +++++++----------- .../organization/[id]/settings/analytics.vue | 3 +- .../organization/[id]/settings/index.vue | 3 +- .../organization/[id]/settings/members.vue | 3 +- .../organization/[id]/settings/projects.vue | 3 +- .../src/providers/organization-context.ts | 108 ++++++++++ packages/utils/types.ts | 70 +++++++ 8 files changed, 260 insertions(+), 125 deletions(-) create mode 100644 apps/frontend/src/providers/organization-context.ts diff --git a/apps/frontend/src/composables/servers/modrinth-servers.ts b/apps/frontend/src/composables/servers/modrinth-servers.ts index d0e3cd921..22d1126fb 100644 --- a/apps/frontend/src/composables/servers/modrinth-servers.ts +++ b/apps/frontend/src/composables/servers/modrinth-servers.ts @@ -1,18 +1,20 @@ -import { ModrinthServerError } from "@modrinth/utils"; import type { JWTAuth, ModuleError, ModuleName } from "@modrinth/utils"; +import { ModrinthServerError } from "@modrinth/utils"; +import { injectNotificationManager } from "@modrinth/ui"; import { useServersFetch } from "./servers-fetch.ts"; import { - GeneralModule, - ContentModule, BackupsModule, + ContentModule, + FSModule, + GeneralModule, NetworkModule, StartupModule, WSModule, - FSModule, } from "./modules/index.ts"; export function handleError(err: any) { + const { addNotification } = injectNotificationManager(); if (err instanceof ModrinthServerError && err.v1Error) { addNotification({ title: err.v1Error?.context ?? `An error occurred`, diff --git a/apps/frontend/src/pages/organization/[id].vue b/apps/frontend/src/pages/organization/[id].vue index 901300161..1e629c5da 100644 --- a/apps/frontend/src/pages/organization/[id].vue +++ b/apps/frontend/src/pages/organization/[id].vue @@ -28,7 +28,7 @@ - {{ $formatNumber(acceptedMembers?.length || 0) }} + {{ formatNumber(acceptedMembers?.length || 0) }} member @@ -120,11 +120,11 @@ { id: 'manage-projects', action: () => - navigateTo('/organization/' + organization.slug + '/settings/projects'), - hoverOnly: true, - shown: auth.user && currentMember, + router.push('/organization/' + organization?.slug + '/settings/projects'), + hoverFilledOnly: true, + shown: !!(auth.user && currentMember), }, - { divider: true, shown: auth.user && currentMember }, + { divider: true, shown: !!(auth?.user && currentMember) }, { id: 'copy-id', action: () => copyId() }, { id: 'copy-permalink', action: () => copyPermalink() }, ]" @@ -157,20 +157,20 @@