mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-12 19:30:52 +00:00
Hide write email (#2826)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
b7e4b8b8dc
commit
67fa0c0858
@ -179,6 +179,7 @@ export function createModel (builder: Builder): void {
|
||||
},
|
||||
label: gmail.string.WriteEmail,
|
||||
icon: contact.icon.Email,
|
||||
visibilityTester: gmail.function.HasEmail,
|
||||
keyBinding: [],
|
||||
input: 'any',
|
||||
category: contact.category.Contact,
|
||||
|
@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Ref } from '@hcengineering/core'
|
||||
import { IntlString, mergeIds } from '@hcengineering/platform'
|
||||
import { Doc, Ref } from '@hcengineering/core'
|
||||
import { IntlString, mergeIds, Resource } from '@hcengineering/platform'
|
||||
import { gmailId } from '@hcengineering/gmail'
|
||||
import gmail from '@hcengineering/gmail-resources/src/plugin'
|
||||
import type { AnyComponent } from '@hcengineering/ui'
|
||||
@ -45,5 +45,8 @@ export default mergeIds(gmailId, gmail, {
|
||||
},
|
||||
activity: {
|
||||
TxSharedCreate: '' as AnyComponent
|
||||
},
|
||||
function: {
|
||||
HasEmail: '' as Resource<(doc?: Doc | Doc[] | undefined) => Promise<boolean>>
|
||||
}
|
||||
})
|
||||
|
@ -24,6 +24,7 @@ import IconGmail from './components/icons/GmailColor.svelte'
|
||||
import Main from './components/Main.svelte'
|
||||
import NewMessages from './components/NewMessages.svelte'
|
||||
import gmail from '@hcengineering/gmail'
|
||||
import { checkHasEmail } from './utils'
|
||||
|
||||
export default async (): Promise<Resources> => ({
|
||||
component: {
|
||||
@ -36,13 +37,18 @@ export default async (): Promise<Resources> => ({
|
||||
activity: {
|
||||
TxSharedCreate
|
||||
},
|
||||
function: {
|
||||
HasEmail: checkHasEmail
|
||||
},
|
||||
handler: {
|
||||
DisconnectHandler: async () => {
|
||||
const url = getMetadata(gmail.metadata.GmailURL) ?? ''
|
||||
const url = getMetadata(gmail.metadata.GmailURL)
|
||||
const token = getMetadata(presentation.metadata.Token)
|
||||
if (url === undefined || token === undefined) return
|
||||
await fetch(concatLink(url, '/signout'), {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + (getMetadata(presentation.metadata.Token) ?? ''),
|
||||
Authorization: 'Bearer ' + token,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
@ -1,3 +1,7 @@
|
||||
import contact from '@hcengineering/contact'
|
||||
import { Doc } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
|
||||
export function getTime (time: number): string {
|
||||
let options: Intl.DateTimeFormatOptions = { hour: 'numeric', minute: 'numeric' }
|
||||
if (!isCurrentYear(time)) {
|
||||
@ -33,3 +37,14 @@ export function isCurrentYear (time: number): boolean {
|
||||
const target = new Date(time)
|
||||
return current.getFullYear() === target.getFullYear()
|
||||
}
|
||||
|
||||
export async function checkHasEmail (doc: Doc | Doc[] | undefined): Promise<boolean> {
|
||||
if (doc === undefined) return false
|
||||
const client = getClient()
|
||||
const arr = Array.isArray(doc) ? doc.map((p) => p._id) : [doc._id]
|
||||
const res = await client.findAll(contact.class.Channel, {
|
||||
provider: contact.channelProvider.Email,
|
||||
attachedTo: { $in: arr }
|
||||
})
|
||||
return res.length === arr.length
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user