From f08f2dc778d1c95d81bb2cc9406bd8b2161f9a98 Mon Sep 17 00:00:00 2001 From: Oliver Rose Date: Mon, 23 Feb 2026 14:14:36 -0500 Subject: [PATCH 1/4] add github connection --- app/components/Header/AccountMenu.client.vue | 96 +++++++++-- ...dal.client.vue => AtprotoModal.client.vue} | 2 +- app/components/Header/GitHubModal.client.vue | 40 +++++ app/composables/atproto/useAtproto.ts | 4 +- app/composables/github/useGitHub.ts | 37 +++++ app/composables/github/useGitHubStar.ts | 79 +++++++++ app/pages/package/[[org]]/[name].vue | 33 +++- i18n/locales/en.json | 19 ++- i18n/schema.json | 51 ++++++ lunaria/files/en-GB.json | 19 ++- lunaria/files/en-US.json | 19 ++- nuxt.config.ts | 3 + .../{atproto.get.ts => atproto/index.get.ts} | 7 +- .../api/auth/{ => atproto}/session.delete.ts | 7 +- server/api/auth/{ => atproto}/session.get.ts | 0 server/api/auth/github/index.get.ts | 153 ++++++++++++++++++ server/api/auth/github/session.delete.ts | 11 ++ server/api/auth/github/session.get.ts | 12 ++ server/api/github/star.delete.ts | 46 ++++++ server/api/github/star.put.ts | 47 ++++++ server/api/github/starred.get.ts | 45 ++++++ server/utils/auth.ts | 5 + shared/schemas/github.ts | 6 + shared/types/userSession.ts | 6 + 24 files changed, 716 insertions(+), 31 deletions(-) rename app/components/Header/{AuthModal.client.vue => AtprotoModal.client.vue} (99%) create mode 100644 app/components/Header/GitHubModal.client.vue create mode 100644 app/composables/github/useGitHub.ts create mode 100644 app/composables/github/useGitHubStar.ts rename server/api/auth/{atproto.get.ts => atproto/index.get.ts} (98%) rename server/api/auth/{ => atproto}/session.delete.ts (72%) rename server/api/auth/{ => atproto}/session.get.ts (100%) create mode 100644 server/api/auth/github/index.get.ts create mode 100644 server/api/auth/github/session.delete.ts create mode 100644 server/api/auth/github/session.get.ts create mode 100644 server/api/github/star.delete.ts create mode 100644 server/api/github/star.put.ts create mode 100644 server/api/github/starred.get.ts create mode 100644 server/utils/auth.ts create mode 100644 shared/schemas/github.ts diff --git a/app/components/Header/AccountMenu.client.vue b/app/components/Header/AccountMenu.client.vue index 00fa7a194..db28c29a2 100644 --- a/app/components/Header/AccountMenu.client.vue +++ b/app/components/Header/AccountMenu.client.vue @@ -12,14 +12,26 @@ const { } = useConnector() const { user: atprotoUser } = useAtproto() +const { isConnected: isGitHubConnected, user: githubUser } = useGitHub() const isOpen = shallowRef(false) /** Check if connected to at least one service */ -const hasAnyConnection = computed(() => isNpmConnected.value || !!atprotoUser.value) +const hasAnyConnection = computed( + () => isNpmConnected.value || !!atprotoUser.value || isGitHubConnected.value, +) -/** Check if connected to both services */ -const hasBothConnections = computed(() => isNpmConnected.value && !!atprotoUser.value) +/** Count of connected services for avatar stacking */ +const connectedCount = computed(() => { + let count = 0 + if (isNpmConnected.value) count++ + if (atprotoUser.value) count++ + if (isGitHubConnected.value) count++ + return count +}) + +/** Check if connected to more than one service */ +const hasMultipleConnections = computed(() => connectedCount.value > 1) /** Only show count of active (pending/approved/running) operations */ const operationCount = computed(() => activeOperations.value.length) @@ -45,12 +57,21 @@ function openConnectorModal() { } } -const authModal = useModal('auth-modal') +const atprotoModal = useModal('atproto-modal') -function openAuthModal() { - if (authModal) { +function openAtprotoModal() { + if (atprotoModal) { isOpen.value = false - authModal.open() + atprotoModal.open() + } +} + +const githubModal = useModal('github-modal') + +function openGitHubModal() { + if (githubModal) { + isOpen.value = false + githubModal.open() } } @@ -68,7 +89,7 @@ function openAuthModal() { + + + + @@ -189,7 +219,7 @@ function openAuthModal() { v-if="atprotoUser" role="menuitem" class="w-full text-start gap-x-3 border-none" - @click="openAuthModal" + @click="openAtprotoModal" > {{ $t('account_menu.atmosphere') }} + + + + + + + {{ + githubUser.username + }} + {{ $t('account_menu.github') }} + +
-
+
+ + + + + + + {{ $t('account_menu.connect_github') }} + + {{ $t('account_menu.github_desc') }} + +
- + + diff --git a/app/components/Header/AuthModal.client.vue b/app/components/Header/AtprotoModal.client.vue similarity index 99% rename from app/components/Header/AuthModal.client.vue rename to app/components/Header/AtprotoModal.client.vue index f0f2ea263..efa035d7a 100644 --- a/app/components/Header/AuthModal.client.vue +++ b/app/components/Header/AtprotoModal.client.vue @@ -54,7 +54,7 @@ watch(handleInput, newHandleInput => {