diff --git a/plugins/contact-resources/src/components/AssigneeBox.svelte b/plugins/contact-resources/src/components/AssigneeBox.svelte index 88efc44e60..a3a0b4aaea 100644 --- a/plugins/contact-resources/src/components/AssigneeBox.svelte +++ b/plugins/contact-resources/src/components/AssigneeBox.svelte @@ -145,6 +145,7 @@ value={selected} {avatarSize} tooltipLabels={showTooltip} + showPopup={false} shouldShowName={false} shouldShowPlaceholder onEmployeeEdit={_click} diff --git a/plugins/contact-resources/src/components/Avatar.svelte b/plugins/contact-resources/src/components/Avatar.svelte index 6160eccf3e..29146aa886 100644 --- a/plugins/contact-resources/src/components/Avatar.svelte +++ b/plugins/contact-resources/src/components/Avatar.svelte @@ -55,7 +55,7 @@ export let icon: Asset | AnySvelteComponent | undefined = undefined export let variant: 'circle' | 'roundedRect' | 'none' = 'roundedRect' export let borderColor: number | undefined = undefined - export let showStatus: boolean = true + export let showStatus: boolean = false export function pulse (): void { avatarInst.pulse() diff --git a/plugins/contact-resources/src/components/AvatarRef.svelte b/plugins/contact-resources/src/components/AvatarRef.svelte index 91c5336201..9d1fceab8d 100644 --- a/plugins/contact-resources/src/components/AvatarRef.svelte +++ b/plugins/contact-resources/src/components/AvatarRef.svelte @@ -30,7 +30,7 @@ export let icon: Asset | AnySvelteComponent | undefined = undefined export let variant: 'circle' | 'roundedRect' | 'none' = 'roundedRect' export let borderColor: number | undefined = undefined - export let showStatus: boolean = true + export let showStatus: boolean = false $: empValue = $employeeByIdStore.get(_id as Ref) ?? $personByIdStore.get(_id) diff --git a/plugins/workbench-resources/src/components/Workbench.svelte b/plugins/workbench-resources/src/components/Workbench.svelte index cefc3c3078..a1ca9db53a 100644 --- a/plugins/workbench-resources/src/components/Workbench.svelte +++ b/plugins/workbench-resources/src/components/Workbench.svelte @@ -860,7 +860,7 @@ > diff --git a/services/github/github-resources/src/components/Connect.svelte b/services/github/github-resources/src/components/Connect.svelte index 7eb6e3cdae..92aa9c093a 100644 --- a/services/github/github-resources/src/components/Connect.svelte +++ b/services/github/github-resources/src/components/Connect.svelte @@ -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) => { diff --git a/services/github/github-resources/src/components/utils.ts b/services/github/github-resources/src/components/utils.ts index 5600ca53c7..88ac84d0d6 100644 --- a/services/github/github-resources/src/components/utils.ts +++ b/services/github/github-resources/src/components/utils.ts @@ -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 { for (const c of config) { await client.remove(c) } - await client.createDoc(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(undefined) authQuery.query(github.class.GithubAuthentication, {}, (res) => { - githubAuth.set(res.shift()) + githubAuth.set(res.find((it) => it.login !== '')) }) /** diff --git a/services/github/pod-github/src/platform.ts b/services/github/pod-github/src/platform.ts index 6f1347a8c5..2479d6aeee 100644 --- a/services/github/pod-github/src/platform.ts +++ b/services/github/pod-github/src/platform.ts @@ -390,14 +390,57 @@ export class PlatformWorker { } const client = new TxOperations(platformClient, payload.accountId) - const personAuth = await client.findOne(github.class.GithubAuthentication, { + let personAuths = await client.findAll(github.class.GithubAuthentication, { attachedTo: payload.accountId }) - if (personAuth !== undefined) { - if (revoke) { + if (personAuths.length > 1) { + for (const auth of personAuths.slice(1)) { + await client.remove(auth) + } + personAuths.length = 1 + } + + if (revoke) { + for (const personAuth of personAuths) { await client.remove(personAuth, Date.now(), payload.accountId) - } else { - await client.update(personAuth, update, false, Date.now(), payload.accountId) + } + } else { + if (personAuths.length > 0) { + await client.update(personAuths[0], update, false, Date.now(), payload.accountId) + } else if (dta !== undefined) { + const authId = await client.createDoc( + github.class.GithubAuthentication, + core.space.Workspace, + { + 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, + ...update, + attachedTo: payload.accountId, + login: dta._id + }, + undefined, + undefined, + payload.accountId + ) + + personAuths = await client.findAll(github.class.GithubAuthentication, { + _id: authId + }) } } @@ -454,9 +497,9 @@ export class PlatformWorker { } } - if (dta !== undefined && personAuth !== undefined) { + if (dta !== undefined && personAuths.length === 1) { try { - await syncUser(this.ctx, dta, personAuth, client, payload.accountId) + await syncUser(this.ctx, dta, personAuths[0], client, payload.accountId) } catch (err: any) { if (err.response?.data?.message === 'Bad credentials') { await this.revokeUserAuth(dta)