TSK-887 InviteSettings should not depend on login-resources (#2799)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-22 11:01:28 +06:00 committed by GitHub
parent b0abf93487
commit d7265f033f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 114 additions and 64 deletions

View File

@ -45,7 +45,7 @@
"@hcengineering/panel": "^0.6.1", "@hcengineering/panel": "^0.6.1",
"@hcengineering/view-resources": "^0.6.0", "@hcengineering/view-resources": "^0.6.0",
"@hcengineering/attachment": "^0.6.1", "@hcengineering/attachment": "^0.6.1",
"@hcengineering/login-resources": "^0.6.2", "@hcengineering/login": "^0.6.1",
"@hcengineering/templates": "^0.6.0", "@hcengineering/templates": "^0.6.0",
"@hcengineering/image-cropper": "^0.6.0" "@hcengineering/image-cropper": "^0.6.0"
} }

View File

@ -16,7 +16,8 @@
<script lang="ts"> <script lang="ts">
import { Employee, EmployeeAccount, getFirstName, getLastName, Person } from '@hcengineering/contact' import { Employee, EmployeeAccount, getFirstName, getLastName, Person } from '@hcengineering/contact'
import { AccountRole, getCurrentAccount, Ref, Space } from '@hcengineering/core' import { AccountRole, getCurrentAccount, Ref, Space } from '@hcengineering/core'
import { changeName } from '@hcengineering/login-resources' import login from '@hcengineering/login'
import { getResource } from '@hcengineering/platform'
import { AttributeEditor, createQuery, getClient } from '@hcengineering/presentation' import { AttributeEditor, createQuery, getClient } from '@hcengineering/presentation'
import setting, { IntegrationType } from '@hcengineering/setting' import setting, { IntegrationType } from '@hcengineering/setting'
import { createFocusManager, EditBox, FocusHandler } from '@hcengineering/ui' import { createFocusManager, EditBox, FocusHandler } from '@hcengineering/ui'
@ -55,12 +56,14 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
function firstNameChange () { async function firstNameChange () {
changeName(firstName, getLastName(object.name)) const changeName = await getResource(login.function.ChangeName)
await changeName(firstName, getLastName(object.name))
} }
function lastNameChange () { async function lastNameChange () {
changeName(getFirstName(object.name), lastName) const changeName = await getResource(login.function.ChangeName)
await changeName(getFirstName(object.name), lastName)
} }
function changeDisplayName () { function changeDisplayName () {

View File

@ -15,7 +15,8 @@
<script lang="ts"> <script lang="ts">
import { Channel, ChannelProvider, Employee, getName } from '@hcengineering/contact' import { Channel, ChannelProvider, Employee, getName } from '@hcengineering/contact'
import core, { Doc, DocumentUpdate, Mixin, Ref, TxProcessor } from '@hcengineering/core' import core, { Doc, DocumentUpdate, Mixin, Ref, TxProcessor } from '@hcengineering/core'
import { leaveWorkspace } from '@hcengineering/login-resources' import login from '@hcengineering/login'
import { getResource } from '@hcengineering/platform'
import { Card, createQuery, getClient } from '@hcengineering/presentation' import { Card, createQuery, getClient } from '@hcengineering/presentation'
import { DatePresenter, Grid, Toggle } from '@hcengineering/ui' import { DatePresenter, Grid, Toggle } from '@hcengineering/ui'
import { isCollectionAttr, StringEditor } from '@hcengineering/view-resources' import { isCollectionAttr, StringEditor } from '@hcengineering/view-resources'
@ -113,7 +114,8 @@
} }
const account = await client.findOne(contact.class.EmployeeAccount, { employee: value._id }) const account = await client.findOne(contact.class.EmployeeAccount, { employee: value._id })
if (account !== undefined) { if (account !== undefined) {
leaveWorkspace(account.email) const leaveWorkspace = await getResource(login.function.LeaveWorkspace)
await leaveWorkspace(account.email)
} }
dispatch('close') dispatch('close')
} }

View File

@ -16,8 +16,8 @@
import { Channel, Contact, Employee, getGravatarUrl, getName } from '@hcengineering/contact' import { Channel, Contact, Employee, getGravatarUrl, getName } from '@hcengineering/contact'
import { Class, Client, DocumentQuery, Ref, RelatedDocument, WithLookup } from '@hcengineering/core' import { Class, Client, DocumentQuery, Ref, RelatedDocument, WithLookup } from '@hcengineering/core'
import { leaveWorkspace } from '@hcengineering/login-resources' import login from '@hcengineering/login'
import { IntlString, Resources } from '@hcengineering/platform' import { getResource, IntlString, Resources } from '@hcengineering/platform'
import { getClient, getFileUrl, MessageBox, ObjectSearchResult } from '@hcengineering/presentation' import { getClient, getFileUrl, MessageBox, ObjectSearchResult } from '@hcengineering/presentation'
import { AnyComponent, AnySvelteComponent, showPopup } from '@hcengineering/ui' import { AnyComponent, AnySvelteComponent, showPopup } from '@hcengineering/ui'
import AccountArrayEditor from './components/AccountArrayEditor.svelte' import AccountArrayEditor from './components/AccountArrayEditor.svelte'
@ -194,7 +194,9 @@ async function kickEmployee (doc: Employee): Promise<void> {
(res?: boolean) => { (res?: boolean) => {
if (res === true) { if (res === true) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises // eslint-disable-next-line @typescript-eslint/no-floating-promises
leaveWorkspace(email.email) getResource(login.function.LeaveWorkspace).then(async (f) => {
await f(email.email)
})
} }
} }
) )

View File

@ -27,8 +27,6 @@ export default mergeIds(contactId, contact, {
CreatePerson: '' as IntlString, CreatePerson: '' as IntlString,
OrganizationNamePlaceholder: '' as IntlString, OrganizationNamePlaceholder: '' as IntlString,
OrganizationsNamePlaceholder: '' as IntlString, OrganizationsNamePlaceholder: '' as IntlString,
PersonFirstNamePlaceholder: '' as IntlString,
PersonLastNamePlaceholder: '' as IntlString,
PersonLocationPlaceholder: '' as IntlString, PersonLocationPlaceholder: '' as IntlString,
PersonsNamePlaceholder: '' as IntlString, PersonsNamePlaceholder: '' as IntlString,
Organizations: '' as IntlString, Organizations: '' as IntlString,
@ -65,7 +63,6 @@ export default mergeIds(contactId, contact, {
Inactive: '' as IntlString, Inactive: '' as IntlString,
NotSpecified: '' as IntlString, NotSpecified: '' as IntlString,
MergeEmployee: '' as IntlString, MergeEmployee: '' as IntlString,
DisplayName: '' as IntlString,
SelectAvatar: '' as IntlString, SelectAvatar: '' as IntlString,
GravatarsManaged: '' as IntlString, GravatarsManaged: '' as IntlString,

View File

@ -241,7 +241,10 @@ export const contactPlugin = plugin(contactId, {
CreateOrganization: '' as IntlString, CreateOrganization: '' as IntlString,
UseImage: '' as IntlString, UseImage: '' as IntlString,
UseGravatar: '' as IntlString, UseGravatar: '' as IntlString,
UseColor: '' as IntlString UseColor: '' as IntlString,
PersonFirstNamePlaceholder: '' as IntlString,
PersonLastNamePlaceholder: '' as IntlString,
DisplayName: '' as IntlString
}, },
viewlet: { viewlet: {
TableMember: '' as Ref<Viewlet>, TableMember: '' as Ref<Viewlet>,

View File

@ -38,6 +38,7 @@
"EmailMask": "Email mask:", "EmailMask": "Email mask:",
"InviteLimit": "Invite limit:", "InviteLimit": "Invite limit:",
"GetLink": "Get invite link", "GetLink": "Get invite link",
"NoLimit": "No limit" "NoLimit": "No limit",
"AlreadyJoined": "Already joined?"
} }
} }

View File

@ -38,6 +38,7 @@
"EmailMask": "Маска для электронной почты:", "EmailMask": "Маска для электронной почты:",
"InviteLimit": "Предел использований:", "InviteLimit": "Предел использований:",
"GetLink": "Получить ссылку", "GetLink": "Получить ссылку",
"NoLimit": "Без предела использований" "NoLimit": "Без предела использований",
"AlreadyJoined": "Уже подключены?"
} }
} }

View File

@ -13,15 +13,16 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { OK, Status, Severity, setMetadata } from '@hcengineering/platform' import { OK, setMetadata, Severity, Status } from '@hcengineering/platform'
import { fetchMetadataLocalStorage, getCurrentLocation, navigate, setMetadataLocalStorage } from '@hcengineering/ui' import { fetchMetadataLocalStorage, getCurrentLocation, navigate, setMetadataLocalStorage } from '@hcengineering/ui'
import Form from './Form.svelte'
import { checkJoined, join, signUpJoin } from '../utils' import { checkJoined, join, signUpJoin } from '../utils'
import Form from './Form.svelte'
import presentation from '@hcengineering/presentation' import presentation from '@hcengineering/presentation'
import login from '../plugin'
import { workbenchId } from '@hcengineering/workbench' import { workbenchId } from '@hcengineering/workbench'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import login from '../plugin'
const location = getCurrentLocation() const location = getCurrentLocation()
let page = 'login' let page = 'login'
@ -103,7 +104,7 @@
} }
const loginAction = { const loginAction = {
caption: login.string.HaveAccount, caption: login.string.AlreadyJoined,
i18n: login.string.LogIn, i18n: login.string.LogIn,
func: () => { func: () => {
const loc = getCurrentLocation() const loc = getCurrentLocation()

View File

@ -14,8 +14,9 @@
// limitations under the License. // limitations under the License.
// //
import LoginApp from './components/LoginApp.svelte'
import InviteLink from './components/InviteLink.svelte' import InviteLink from './components/InviteLink.svelte'
import LoginApp from './components/LoginApp.svelte'
import { changeName, changePassword, getWorkspaces, leaveWorkspace, selectWorkspace } from './utils'
/*! /*!
* Anticrm Platform Login Plugin * Anticrm Platform Login Plugin
* © 2020, 2021 Anticrm Platform Contributors. * © 2020, 2021 Anticrm Platform Contributors.
@ -27,6 +28,13 @@ export default async () => ({
component: { component: {
LoginApp, LoginApp,
InviteLink InviteLink
},
function: {
ChangeName: changeName,
LeaveWorkspace: leaveWorkspace,
ChangePassword: changePassword,
SelectWorkspace: selectWorkspace,
GetWorkspaces: getWorkspaces
} }
}) })

View File

@ -14,7 +14,7 @@
// limitations under the License. // limitations under the License.
*/ */
import type { StatusCode, IntlString } from '@hcengineering/platform' import type { IntlString, StatusCode } from '@hcengineering/platform'
import { mergeIds } from '@hcengineering/platform' import { mergeIds } from '@hcengineering/platform'
import login, { loginId } from '@hcengineering/login' import login, { loginId } from '@hcengineering/login'
@ -55,10 +55,7 @@ export default mergeIds(loginId, login, {
PasswordRecovery: '' as IntlString, PasswordRecovery: '' as IntlString,
RecoveryLinkSent: '' as IntlString, RecoveryLinkSent: '' as IntlString,
UseWorkspaceInviteSettings: '' as IntlString, UseWorkspaceInviteSettings: '' as IntlString,
LinkValidHours: '' as IntlString,
EmailMask: '' as IntlString,
InviteLimit: '' as IntlString,
GetLink: '' as IntlString, GetLink: '' as IntlString,
NoLimit: '' as IntlString AlreadyJoined: '' as IntlString
} }
}) })

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
// //
import login from '@hcengineering/login' import login, { LoginInfo, Workspace, WorkspaceLoginInfo } from '@hcengineering/login'
import { import {
getMetadata, getMetadata,
OK, OK,
@ -36,20 +36,6 @@ import {
import { workbenchId } from '@hcengineering/workbench' import { workbenchId } from '@hcengineering/workbench'
import presentation from '@hcengineering/presentation' import presentation from '@hcengineering/presentation'
export interface WorkspaceLoginInfo extends LoginInfo {
workspace: string
}
export interface LoginInfo {
token: string
endpoint: string
email: string
}
export interface Workspace {
workspace: string
}
const DEV_WORKSPACE = 'DEV WORKSPACE' const DEV_WORKSPACE = 'DEV WORKSPACE'
/** /**

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
// //
import type { Plugin, Asset, Metadata } from '@hcengineering/platform' import type { Asset, IntlString, Metadata, Plugin, Resource, Status } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform'
import type { AnyComponent } from '@hcengineering/ui' import type { AnyComponent } from '@hcengineering/ui'
@ -22,6 +22,29 @@ import type { AnyComponent } from '@hcengineering/ui'
*/ */
export const loginId = 'login' as Plugin export const loginId = 'login' as Plugin
/**
* @public
*/
export interface Workspace {
workspace: string
}
/**
* @public
*/
export interface WorkspaceLoginInfo extends LoginInfo {
workspace: string
}
/**
* @public
*/
export interface LoginInfo {
token: string
endpoint: string
email: string
}
export default plugin(loginId, { export default plugin(loginId, {
metadata: { metadata: {
AccountsUrl: '' as Asset, AccountsUrl: '' as Asset,
@ -37,5 +60,18 @@ export default plugin(loginId, {
}, },
icon: { icon: {
InviteWorkspace: '' as Asset InviteWorkspace: '' as Asset
},
string: {
LinkValidHours: '' as IntlString,
EmailMask: '' as IntlString,
NoLimit: '' as IntlString,
InviteLimit: '' as IntlString
},
function: {
ChangeName: '' as Resource<(first: string, last: string) => Promise<void>>,
LeaveWorkspace: '' as Resource<(email: string) => Promise<void>>,
ChangePassword: '' as Resource<(oldPassword: string, password: string) => Promise<void>>,
SelectWorkspace: '' as Resource<(workspace: string) => Promise<[Status, WorkspaceLoginInfo | undefined]>>,
GetWorkspaces: '' as Resource<() => Promise<Workspace[]>>
} }
}) })

View File

@ -42,7 +42,6 @@
"@hcengineering/presentation": "^0.6.2", "@hcengineering/presentation": "^0.6.2",
"@hcengineering/view": "^0.6.2", "@hcengineering/view": "^0.6.2",
"@hcengineering/view-resources": "^0.6.0", "@hcengineering/view-resources": "^0.6.0",
"@hcengineering/login-resources": "^0.6.2",
"@hcengineering/task": "^0.6.2", "@hcengineering/task": "^0.6.2",
"@hcengineering/contact-resources": "^0.6.0", "@hcengineering/contact-resources": "^0.6.0",
"@hcengineering/login": "^0.6.1", "@hcengineering/login": "^0.6.1",

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import login from '@hcengineering/login-resources/src/plugin' import login from '@hcengineering/login'
import presentation, { createQuery, getClient } from '@hcengineering/presentation' import presentation, { createQuery, getClient } from '@hcengineering/presentation'
import setting, { InviteSettings } from '@hcengineering/setting' import setting, { InviteSettings } from '@hcengineering/setting'
import { Button, EditBox, MiniToggle } from '@hcengineering/ui' import { Button, EditBox, MiniToggle } from '@hcengineering/ui'

View File

@ -16,9 +16,10 @@
import setting from '@hcengineering/setting' import setting from '@hcengineering/setting'
import presentation from '@hcengineering/presentation' import presentation from '@hcengineering/presentation'
import { Button, EditBox, Icon, Label } from '@hcengineering/ui' import { Button, EditBox, Icon, Label } from '@hcengineering/ui'
import { changePassword } from '@hcengineering/login-resources' import login from '@hcengineering/login'
import Error from './icons/Error.svelte' import Error from './icons/Error.svelte'
import plugin from '../plugin' import plugin from '../plugin'
import { getResource } from '@hcengineering/platform'
let oldPassword: string = '' let oldPassword: string = ''
let password: string = '' let password: string = ''
@ -34,6 +35,7 @@
label = setting.string.Saving label = setting.string.Saving
saved = true saved = true
try { try {
const changePassword = await getResource(login.function.ChangePassword)
await changePassword(oldPassword, password) await changePassword(oldPassword, password)
label = setting.string.Saved label = setting.string.Saved
} catch (e) { } catch (e) {

View File

@ -13,14 +13,13 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { AttributeEditor, getClient } from '@hcengineering/presentation'
import contact, { EmployeeAccount, getFirstName, getLastName } from '@hcengineering/contact' import contact, { EmployeeAccount, getFirstName, getLastName } from '@hcengineering/contact'
import { ChannelsEditor, EditableAvatar, employeeByIdStore } from '@hcengineering/contact-resources' import { ChannelsEditor, employeeByIdStore } from '@hcengineering/contact-resources'
import contactRes from '@hcengineering/contact-resources/src/plugin'
import { getCurrentAccount } from '@hcengineering/core' import { getCurrentAccount } from '@hcengineering/core'
import { changeName, leaveWorkspace } from '@hcengineering/login-resources' import login from '@hcengineering/login'
import { MessageBox } from '@hcengineering/presentation' import { getResource } from '@hcengineering/platform'
import { AttributeEditor, getClient, MessageBox } from '@hcengineering/presentation'
import { EditableAvatar } from '@hcengineering/contact-resources'
import { Button, createFocusManager, EditBox, FocusHandler, Icon, Label, showPopup } from '@hcengineering/ui' import { Button, createFocusManager, EditBox, FocusHandler, Icon, Label, showPopup } from '@hcengineering/ui'
import setting from '../plugin' import setting from '../plugin'
const client = getClient() const client = getClient()
@ -57,6 +56,7 @@
undefined, undefined,
async (res?: boolean) => { async (res?: boolean) => {
if (res === true) { if (res === true) {
const leaveWorkspace = await getResource(login.function.LeaveWorkspace)
await leaveWorkspace(getCurrentAccount().email) await leaveWorkspace(getCurrentAccount().email)
} }
} }
@ -94,26 +94,28 @@
</div> </div>
<div class="flex-grow flex-col"> <div class="flex-grow flex-col">
<EditBox <EditBox
placeholder={contactRes.string.PersonFirstNamePlaceholder} placeholder={contact.string.PersonFirstNamePlaceholder}
bind:value={firstName} bind:value={firstName}
kind={'large-style'} kind={'large-style'}
focus focus
focusIndex={1} focusIndex={1}
on:change={() => { on:change={async () => {
const changeName = await getResource(login.function.ChangeName)
changeName(firstName, lastName) changeName(firstName, lastName)
}} }}
/> />
<EditBox <EditBox
placeholder={contactRes.string.PersonLastNamePlaceholder} placeholder={contact.string.PersonLastNamePlaceholder}
bind:value={lastName} bind:value={lastName}
kind={'large-style'} kind={'large-style'}
focusIndex={2} focusIndex={2}
on:change={() => { on:change={async () => {
const changeName = await getResource(login.function.ChangeName)
changeName(firstName, lastName) changeName(firstName, lastName)
}} }}
/> />
<EditBox <EditBox
placeholder={contactRes.string.DisplayName} placeholder={contact.string.DisplayName}
bind:value={displayName} bind:value={displayName}
kind={'large-style'} kind={'large-style'}
focusIndex={2} focusIndex={2}

View File

@ -47,7 +47,6 @@
"@hcengineering/notification-resources": "^0.6.0", "@hcengineering/notification-resources": "^0.6.0",
"@hcengineering/preference": "^0.6.2", "@hcengineering/preference": "^0.6.2",
"@hcengineering/contact": "^0.6.11", "@hcengineering/contact": "^0.6.11",
"@hcengineering/view-resources": "^0.6.0", "@hcengineering/view-resources": "^0.6.0"
"@hcengineering/login-resources": "^0.6.2"
} }
} }

View File

@ -13,8 +13,8 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import login, { loginId } from '@hcengineering/login' import login, { loginId, Workspace } from '@hcengineering/login'
import { getWorkspaces, selectWorkspace, Workspace } from '@hcengineering/login-resources' import { getResource } from '@hcengineering/platform'
import { import {
closePopup, closePopup,
fetchMetadataLocalStorage, fetchMetadataLocalStorage,
@ -30,8 +30,9 @@
import { workspacesStore } from '../utils' import { workspacesStore } from '../utils'
onMount(() => { onMount(() => {
getWorkspaces().then((ws: Workspace[]) => { getResource(login.function.GetWorkspaces).then(async (f) => {
$workspacesStore = ws const workspaces = await f()
$workspacesStore = workspaces
}) })
}) })
@ -44,6 +45,7 @@
const ws = p.workspace const ws = p.workspace
const token = tokens[ws] const token = tokens[ws]
if (!token) { if (!token) {
const selectWorkspace = await getResource(login.function.SelectWorkspace)
const loginInfo = (await selectWorkspace(ws))[1] const loginInfo = (await selectWorkspace(ws))[1]
if (loginInfo !== undefined) { if (loginInfo !== undefined) {
tokens[ws] = loginInfo?.token tokens[ws] = loginInfo?.token

View File

@ -59,6 +59,8 @@
import NavHeader from './NavHeader.svelte' import NavHeader from './NavHeader.svelte'
import Navigator from './Navigator.svelte' import Navigator from './Navigator.svelte'
import SpaceView from './SpaceView.svelte' import SpaceView from './SpaceView.svelte'
import login from '@hcengineering/login'
import { workspacesStore } from '../utils'
let contentPanel: HTMLElement let contentPanel: HTMLElement
let shownMenu: boolean = false let shownMenu: boolean = false
@ -101,6 +103,13 @@
} }
} }
onMount(() => {
getResource(login.function.GetWorkspaces).then(async (f) => {
const workspaces = await f()
$workspacesStore = workspaces
})
})
let account = getCurrentAccount() as EmployeeAccount let account = getCurrentAccount() as EmployeeAccount
const accountQ = createQuery() const accountQ = createQuery()
accountQ.query( accountQ.query(

View File

@ -25,7 +25,7 @@ import { getClient } from '@hcengineering/presentation'
import type { Application } from '@hcengineering/workbench' import type { Application } from '@hcengineering/workbench'
import preference from '@hcengineering/preference' import preference from '@hcengineering/preference'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
import { Workspace } from '@hcengineering/login-resources' import type { Workspace } from '@hcengineering/login'
export function classIcon (client: Client, _class: Ref<Class<Obj>>): Asset | undefined { export function classIcon (client: Client, _class: Ref<Class<Obj>>): Asset | undefined {
return client.getHierarchy().getClass(_class).icon return client.getHierarchy().getClass(_class).icon