Merge remote-tracking branch 'origin/develop' into staging

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-10-27 00:21:34 +07:00
commit 25698f5205
No known key found for this signature in database
GPG Key ID: BD80F68D68D8F7F2
7 changed files with 61 additions and 39 deletions

View File

@ -145,6 +145,7 @@
value={selected}
{avatarSize}
tooltipLabels={showTooltip}
showPopup={false}
shouldShowName={false}
shouldShowPlaceholder
onEmployeeEdit={_click}

View File

@ -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()

View File

@ -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<Employee>) ?? $personByIdStore.get(_id)

View File

@ -860,7 +860,7 @@
>
<Component
is={contact.component.Avatar}
props={{ person, name: person?.name, size: 'small', account: account._id }}
props={{ person, name: person?.name, size: 'small', account: account._id, showStatus: true }}
/>
</div>
</div>

View File

@ -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) => {

View File

@ -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 !== ''))
})
/**

View File

@ -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 (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<GithubAuthentication>(personAuth, update, false, Date.now(), payload.accountId)
if (personAuths.length > 0) {
await client.update<GithubAuthentication>(personAuths[0], update, false, Date.now(), payload.accountId)
} else if (dta !== undefined) {
const authId = await client.createDoc<GithubAuthentication>(
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)