mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-08 00:52:30 +00:00
Merge remote-tracking branch 'origin/develop' into staging
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
commit
25698f5205
@ -145,6 +145,7 @@
|
|||||||
value={selected}
|
value={selected}
|
||||||
{avatarSize}
|
{avatarSize}
|
||||||
tooltipLabels={showTooltip}
|
tooltipLabels={showTooltip}
|
||||||
|
showPopup={false}
|
||||||
shouldShowName={false}
|
shouldShowName={false}
|
||||||
shouldShowPlaceholder
|
shouldShowPlaceholder
|
||||||
onEmployeeEdit={_click}
|
onEmployeeEdit={_click}
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
export let icon: Asset | AnySvelteComponent | undefined = undefined
|
export let icon: Asset | AnySvelteComponent | undefined = undefined
|
||||||
export let variant: 'circle' | 'roundedRect' | 'none' = 'roundedRect'
|
export let variant: 'circle' | 'roundedRect' | 'none' = 'roundedRect'
|
||||||
export let borderColor: number | undefined = undefined
|
export let borderColor: number | undefined = undefined
|
||||||
export let showStatus: boolean = true
|
export let showStatus: boolean = false
|
||||||
|
|
||||||
export function pulse (): void {
|
export function pulse (): void {
|
||||||
avatarInst.pulse()
|
avatarInst.pulse()
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
export let icon: Asset | AnySvelteComponent | undefined = undefined
|
export let icon: Asset | AnySvelteComponent | undefined = undefined
|
||||||
export let variant: 'circle' | 'roundedRect' | 'none' = 'roundedRect'
|
export let variant: 'circle' | 'roundedRect' | 'none' = 'roundedRect'
|
||||||
export let borderColor: number | undefined = undefined
|
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)
|
$: empValue = $employeeByIdStore.get(_id as Ref<Employee>) ?? $personByIdStore.get(_id)
|
||||||
|
|
||||||
|
@ -860,7 +860,7 @@
|
|||||||
>
|
>
|
||||||
<Component
|
<Component
|
||||||
is={contact.component.Avatar}
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
import { Analytics } from '@hcengineering/analytics'
|
import { Analytics } from '@hcengineering/analytics'
|
||||||
import { WithLookup, getCurrentAccount } from '@hcengineering/core'
|
import { WithLookup, getCurrentAccount } from '@hcengineering/core'
|
||||||
|
import { GithubAuthentication, GithubIntegration } from '@hcengineering/github'
|
||||||
import { getEmbeddedLabel, getMetadata, translate } from '@hcengineering/platform'
|
import { getEmbeddedLabel, getMetadata, translate } from '@hcengineering/platform'
|
||||||
import presentation, { Card, HTMLViewer, NavLink, createQuery } from '@hcengineering/presentation'
|
import presentation, { Card, HTMLViewer, NavLink, createQuery } from '@hcengineering/presentation'
|
||||||
import { Integration } from '@hcengineering/setting'
|
import { Integration } from '@hcengineering/setting'
|
||||||
import tracker, { Project } from '@hcengineering/tracker'
|
import tracker, { Project } from '@hcengineering/tracker'
|
||||||
import ui, { Button, Label, Loading, TabItem, TabList, location, ticker } from '@hcengineering/ui'
|
import ui, { Button, Label, Loading, TabItem, TabList, location, ticker } from '@hcengineering/ui'
|
||||||
import { GithubAuthentication, GithubIntegration } from '@hcengineering/github'
|
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import github from '../plugin'
|
import github from '../plugin'
|
||||||
import { onAuthorize } from './utils'
|
import { onAuthorize } from './utils'
|
||||||
@ -50,7 +50,7 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
authQuery.query(github.class.GithubAuthentication, {}, (res) => {
|
authQuery.query(github.class.GithubAuthentication, {}, (res) => {
|
||||||
;[auth] = res
|
auth = res.find((it) => it.login !== '')
|
||||||
})
|
})
|
||||||
|
|
||||||
projectsQuery.query(tracker.class.Project, {}, (res) => {
|
projectsQuery.query(tracker.class.Project, {}, (res) => {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { Analytics } from '@hcengineering/analytics'
|
import { Analytics } from '@hcengineering/analytics'
|
||||||
import core, { concatLink, getCurrentAccount, toIdMap, type IdMap } from '@hcengineering/core'
|
import { 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 {
|
import {
|
||||||
makeQuery,
|
makeQuery,
|
||||||
type GithubAuthentication,
|
type GithubAuthentication,
|
||||||
type GithubIntegrationRepository,
|
type GithubIntegrationRepository,
|
||||||
type GithubProject
|
type GithubProject
|
||||||
} from '@hcengineering/github'
|
} 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 { get, writable } from 'svelte/store'
|
||||||
import github from '../plugin'
|
import github from '../plugin'
|
||||||
|
|
||||||
@ -29,28 +29,6 @@ export async function onAuthorize (login?: string): Promise<void> {
|
|||||||
for (const c of config) {
|
for (const c of config) {
|
||||||
await client.remove(c)
|
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')
|
Analytics.handleEvent('Authorize github clicked')
|
||||||
|
|
||||||
const url =
|
const url =
|
||||||
@ -89,7 +67,7 @@ projectQuery.query(github.mixin.GithubProject, {}, (res) => {
|
|||||||
const authQuery = createQuery(true)
|
const authQuery = createQuery(true)
|
||||||
export const githubAuth = writable<GithubAuthentication | undefined>(undefined)
|
export const githubAuth = writable<GithubAuthentication | undefined>(undefined)
|
||||||
authQuery.query(github.class.GithubAuthentication, {}, (res) => {
|
authQuery.query(github.class.GithubAuthentication, {}, (res) => {
|
||||||
githubAuth.set(res.shift())
|
githubAuth.set(res.find((it) => it.login !== ''))
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -390,14 +390,57 @@ export class PlatformWorker {
|
|||||||
}
|
}
|
||||||
const client = new TxOperations(platformClient, payload.accountId)
|
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
|
attachedTo: payload.accountId
|
||||||
})
|
})
|
||||||
if (personAuth !== undefined) {
|
if (personAuths.length > 1) {
|
||||||
if (revoke) {
|
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)
|
await client.remove(personAuth, Date.now(), payload.accountId)
|
||||||
} else {
|
}
|
||||||
await client.update<GithubAuthentication>(personAuth, update, false, Date.now(), payload.accountId)
|
} else {
|
||||||
|
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 {
|
try {
|
||||||
await syncUser(this.ctx, dta, personAuth, client, payload.accountId)
|
await syncUser(this.ctx, dta, personAuths[0], client, payload.accountId)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err.response?.data?.message === 'Bad credentials') {
|
if (err.response?.data?.message === 'Bad credentials') {
|
||||||
await this.revokeUserAuth(dta)
|
await this.revokeUserAuth(dta)
|
||||||
|
Loading…
Reference in New Issue
Block a user