UBERF-8488: Fix github re-auth (#7041)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2024-10-26 23:27:24 +07:00
committed by GitHub
parent e11a0a87cb
commit 88dd3ddd04
3 changed files with 57 additions and 36 deletions
@@ -10,12 +10,12 @@
import { Analytics } from '@hcengineering/analytics'
import { WithLookup, getCurrentAccount } from '@hcengineering/core'
import { GithubAuthentication, GithubIntegration } from '@hcengineering/github'
import { getEmbeddedLabel, getMetadata, translate } from '@hcengineering/platform'
import presentation, { Card, HTMLViewer, NavLink, createQuery } from '@hcengineering/presentation'
import { Integration } from '@hcengineering/setting'
import tracker, { Project } from '@hcengineering/tracker'
import ui, { Button, Label, Loading, TabItem, TabList, location, ticker } from '@hcengineering/ui'
import { GithubAuthentication, GithubIntegration } from '@hcengineering/github'
import { createEventDispatcher } from 'svelte'
import github from '../plugin'
import { onAuthorize } from './utils'
@@ -50,7 +50,7 @@
)
authQuery.query(github.class.GithubAuthentication, {}, (res) => {
;[auth] = res
auth = res.find((it) => it.login !== '')
})
projectsQuery.query(tracker.class.Project, {}, (res) => {
@@ -1,14 +1,14 @@
import { Analytics } from '@hcengineering/analytics'
import core, { concatLink, getCurrentAccount, toIdMap, type IdMap } from '@hcengineering/core'
import { PlatformError, getMetadata, unknownError } from '@hcengineering/platform'
import presentation, { createQuery, getClient } from '@hcengineering/presentation'
import { location } from '@hcengineering/ui'
import { concatLink, getCurrentAccount, toIdMap, type IdMap } from '@hcengineering/core'
import {
makeQuery,
type GithubAuthentication,
type GithubIntegrationRepository,
type GithubProject
} from '@hcengineering/github'
import { PlatformError, getMetadata, unknownError } from '@hcengineering/platform'
import presentation, { createQuery, getClient } from '@hcengineering/presentation'
import { location } from '@hcengineering/ui'
import { get, writable } from 'svelte/store'
import github from '../plugin'
@@ -29,28 +29,6 @@ export async function onAuthorize (login?: string): Promise<void> {
for (const c of config) {
await client.remove(c)
}
await client.createDoc<GithubAuthentication>(github.class.GithubAuthentication, core.space.Workspace, {
attachedTo: meId,
login: '',
error: null,
authRequestTime: Date.now(),
createdAt: new Date(),
followers: 0,
following: 0,
nodeId: '',
updatedAt: new Date(),
url: '',
repositories: 0,
organizations: { totalCount: 0, nodes: [] },
closedIssues: 0,
openIssues: 0,
mergedPRs: 0,
openPRs: 0,
closedPRs: 0,
repositoryDiscussions: 0,
starredRepositories: 0
})
Analytics.handleEvent('Authorize github clicked')
const url =
@@ -89,7 +67,7 @@ projectQuery.query(github.mixin.GithubProject, {}, (res) => {
const authQuery = createQuery(true)
export const githubAuth = writable<GithubAuthentication | undefined>(undefined)
authQuery.query(github.class.GithubAuthentication, {}, (res) => {
githubAuth.set(res.shift())
githubAuth.set(res.find((it) => it.login !== ''))
})
/**