Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
"ViberPlaceholder": "Viber",
"UserProfile": "Uživatelský profil",
"DeactivatedAccount": "Deaktivovaný účet",
"LocalTime": "místní čas",
"LocalTimeNotSet": "Místní čas není nastaven"
"LocalTime": "místní čas"
}
}
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
"ViberPlaceholder": "Viber",
"UserProfile": "Benutzerprofil",
"DeactivatedAccount": "Deaktivierter Account",
"LocalTime": "Ortszeit",
"LocalTimeNotSet": "Ortszeit nicht festgelegt"
"LocalTime": "Ortszeit"
}
}
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"Confirmed": "Confirmed",
"UserProfile": "User profile",
"DeactivatedAccount": "Deactivated account",
"LocalTime": "local time",
"LocalTimeNotSet": "Local time not set"
"LocalTime": "local time"
}
}
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"Confirmed": "Confirmado",
"UserProfile": "Perfil de usuario",
"DeactivatedAccount": "Cuenta desactivada",
"LocalTime": "hora local",
"LocalTimeNotSet": "Hora local no establecida"
"LocalTime": "hora local"
}
}
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"Confirmed": "Confirmé",
"UserProfile": "Profil utilisateur",
"DeactivatedAccount": "Compte désactivé",
"LocalTime": "heure locale",
"LocalTimeNotSet": "Heure locale non définie"
"LocalTime": "heure locale"
}
}
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"Confirmed": "Confermato",
"UserProfile": "Profilo utente",
"DeactivatedAccount": "Account disattivato",
"LocalTime": "ora locale",
"LocalTimeNotSet": "Ora locale non impostata"
"LocalTime": "ora locale"
}
}
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"Confirmed": "Confirmado",
"UserProfile": "Perfil do usuário",
"DeactivatedAccount": "Conta desativada",
"LocalTime": "hora local",
"LocalTimeNotSet": "Hora local não definida"
"LocalTime": "hora local"
}
}
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"Confirmed": "Подтвержден",
"UserProfile": "Профиль пользователя",
"DeactivatedAccount": "Деактивированный аккаунт",
"LocalTime": "местного времени",
"LocalTimeNotSet": "Местное время не задано"
"LocalTime": "местного времени"
}
}
3 changes: 1 addition & 2 deletions plugins/contact-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
"Confirmed": "已确认",
"UserProfile": "用户资料",
"DeactivatedAccount": "已停用账户",
"LocalTime": "当地时间",
"LocalTimeNotSet": "未设置当地时间"
"LocalTime": "当地时间"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import ModernProfilePopup from './ModernProfilePopup.svelte'
import contact from '../../plugin'
import Avatar from '../Avatar.svelte'
import { employeeByIdStore, getAccountClient } from '../../utils'
import { employeeByIdStore } from '../../utils'
import { getPersonTimezone } from './utils'
import { EmployeePresenter } from '../../index'
import TimePresenter from './TimePresenter.svelte'
import DeactivatedHeader from './DeactivatedHeader.svelte'
Expand All @@ -36,7 +37,6 @@

let employee: Employee | undefined = undefined
let timezone: string | undefined = undefined
let isTimezoneLoading = true

$: employee = $employeeByIdStore.get(_id)
$: void loadPersonTimezone(employee?.personUuid)
Expand All @@ -50,15 +50,7 @@
}

async function loadPersonTimezone (personId: AccountUuid | undefined): Promise<void> {
if (personId === undefined) return
isTimezoneLoading = true
try {
const accountInfo = await getAccountClient().getAccountInfo(personId)
timezone = accountInfo.timezone
} catch (error) {
console.error(error)
}
isTimezoneLoading = false
timezone = await getPersonTimezone(personId)
}
</script>

Expand Down Expand Up @@ -95,9 +87,10 @@
on:click={viewProfile}
/>
<div class="flex-col flex-gap-0-5">
<div class="status-container" />
<EmployeePresenter value={employee} shouldShowAvatar={false} showPopup={false} compact accent />
<span class="flex-presenter cursor-default">
<TimePresenter {timezone} {isTimezoneLoading} />
<TimePresenter {timezone} />
</span>
</div>
</div>
Expand Down Expand Up @@ -151,4 +144,8 @@
display: flex;
background-color: var(--theme-button-container-color);
}
.status-container {
display: flex;
min-height: 1rem;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
// limitations under the License.
-->
<script lang="ts">
import { Icon, Label } from '@hcengineering/ui'
import { Label } from '@hcengineering/ui'

import contact from '@hcengineering/contact'
import view from '@hcengineering/view'

export let timezone: string | undefined
export let isTimezoneLoading: boolean

function displayTimeInTimezone (timezone: string): string {
const options: Intl.DateTimeFormatOptions = {
Expand All @@ -35,30 +33,19 @@
</script>

<div class="time-container">
<div class="clock-icon">
<Icon icon={contact.icon.Clock} size={'smaller'} />
</div>
<div class="text-normal font-normal content-color select-text">
{#if isTimezoneLoading}
<span class="time-text-span"><Label label={view.string.Loading} /></span>
{:else if timezone != null}
<div class="text-normal font-normal content-color">
{#if timezone != null}
<span class="time-text-span">{displayTimeInTimezone(timezone)} <Label label={contact.string.LocalTime} /></span>
{:else}
<span class="time-text-span"><Label label={contact.string.LocalTimeNotSet} /></span>
{/if}
</div>
</div>

<style>
.clock-icon {
position: relative;
color: var(--theme-content-color);
}

.time-container {
justify-content: flex-start;
align-items: center;
gap: 0.25rem;
display: inline-flex;
min-height: 1.25rem;
}
</style>
31 changes: 30 additions & 1 deletion plugins/contact-resources/src/components/person/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
//
// See the License for the specific language governing permissions and
// limitations under the License.
import { get, writable } from 'svelte/store'

import type { AccountUuid, Class, Ref } from '@hcengineering/core'
import type { Person } from '@hcengineering/contact'
import { getClient } from '@hcengineering/presentation'
import type { LabelAndProps } from '@hcengineering/ui'

import contact from '../../plugin'
import EmployeePreviewPopup from './EmployeePreviewPopup.svelte'
import type { Class, Ref } from '@hcengineering/core'
import { getAccountClient } from '../../utils'

const client = getClient()
const h = client.getHierarchy()
Expand All @@ -35,3 +39,28 @@ export function getPreviewPopup (
noArrow: true
}
}

export const timezoneByAccountStore = writable<Map<AccountUuid, string>>(new Map())

export async function getPersonTimezone (personId: AccountUuid | undefined): Promise<string | undefined> {
if (personId === undefined) return undefined

const storedTimezone = get(timezoneByAccountStore).get(personId)
if (storedTimezone !== undefined) return storedTimezone

try {
const accountInfo = await getAccountClient().getAccountInfo(personId)
if (accountInfo.timezone !== undefined) {
timezoneByAccountStore.update((store: Map<AccountUuid, string>) => {
if (accountInfo.timezone !== undefined) {
store.set(personId, accountInfo.timezone)
}
return store
})
}
return accountInfo.timezone
} catch (error) {
console.error(error)
return undefined
}
}
3 changes: 1 addition & 2 deletions plugins/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ export const contactPlugin = plugin(contactId, {
Confirmed: '' as IntlString,
UserProfile: '' as IntlString,
DeactivatedAccount: '' as IntlString,
LocalTime: '' as IntlString,
LocalTimeNotSet: '' as IntlString
LocalTime: '' as IntlString
},
viewlet: {
TableMember: '' as Ref<Viewlet>,
Expand Down
7 changes: 6 additions & 1 deletion server/account/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ export async function selectWorkspace (
workspaceUrl: string
kind: 'external' | 'internal' | 'byregion'
externalRegions?: string[]
}
},
meta?: Meta
): Promise<WorkspaceLoginInfo> {
const { workspaceUrl, kind, externalRegions = [] } = params
const { account: accountUuid, workspace: tokenWorkspaceUuid, extra } = decodeTokenVerbose(ctx, token ?? '')
Expand Down Expand Up @@ -581,6 +582,10 @@ export async function selectWorkspace (
throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUrl }))
}

if (accountUuid !== systemAccountUuid) {
void setTimezoneIfNotDefined(ctx, db, accountUuid, account, meta)
}

if (accountUuid === systemAccountUuid || extra?.admin === 'true') {
return {
account: accountUuid,
Expand Down
Loading