Workspace in url (#2214)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-07-06 13:02:01 +06:00 committed by GitHub
parent 8df9011bb0
commit 67d1d92e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 261 additions and 202 deletions

View File

@ -2,21 +2,25 @@ import client from '@anticrm/client'
import contact from '@anticrm/contact' import contact from '@anticrm/contact'
import core, { Client, setCurrentAccount, Version } from '@anticrm/core' import core, { Client, setCurrentAccount, Version } from '@anticrm/core'
import login from '@anticrm/login' import login from '@anticrm/login'
import { getMetadata, getResource } from '@anticrm/platform' import { getMetadata, getResource, setMetadata } from '@anticrm/platform'
import { fetchMetadataLocalStorage, getCurrentLocation, navigate, setMetadataLocalStorage } from '@anticrm/ui' import { fetchMetadataLocalStorage, getCurrentLocation, navigate, setMetadataLocalStorage } from '@anticrm/ui'
import presentation from './plugin' import presentation from './plugin'
export let versionError: string | undefined = '' export let versionError: string | undefined = ''
export async function connect (title: string): Promise<Client | undefined> { export async function connect (title: string): Promise<Client | undefined> {
const token = fetchMetadataLocalStorage(login.metadata.LoginToken) const loc = getCurrentLocation()
const ws = loc.path[1]
const tokens: Record<string, string> = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {}
const token = tokens[ws]
setMetadata(login.metadata.LoginToken, token)
const endpoint = fetchMetadataLocalStorage(login.metadata.LoginEndpoint) const endpoint = fetchMetadataLocalStorage(login.metadata.LoginEndpoint)
const email = fetchMetadataLocalStorage(login.metadata.LoginEmail) const email = fetchMetadataLocalStorage(login.metadata.LoginEmail)
if (token === null || endpoint === null || email === null) { if (token === undefined || endpoint === null || email === null) {
navigate({ navigate({
path: [login.component.LoginApp], path: [login.component.LoginApp],
query: { navigateUrl: encodeURIComponent(JSON.stringify(getCurrentLocation())) } query: { navigateUrl: encodeURIComponent(JSON.stringify(loc)) }
}) })
return return
} }
@ -29,7 +33,7 @@ export async function connect (title: string): Promise<Client | undefined> {
location.reload() location.reload()
}, },
() => { () => {
clearMetadata() clearMetadata(ws)
navigate({ navigate({
path: [login.component.LoginApp], path: [login.component.LoginApp],
query: {} query: {}
@ -44,7 +48,7 @@ export async function connect (title: string): Promise<Client | undefined> {
setCurrentAccount(me) setCurrentAccount(me)
} else { } else {
console.error('WARNING: no employee account found.') console.error('WARNING: no employee account found.')
clearMetadata() clearMetadata(ws)
navigate({ navigate({
path: [login.component.LoginApp], path: [login.component.LoginApp],
query: { navigateUrl: encodeURIComponent(JSON.stringify(getCurrentLocation())) } query: { navigateUrl: encodeURIComponent(JSON.stringify(getCurrentLocation())) }
@ -77,13 +81,19 @@ export async function connect (title: string): Promise<Client | undefined> {
} }
// Update window title // Update window title
document.title = [fetchMetadataLocalStorage(login.metadata.CurrentWorkspace), title].filter((it) => it).join(' - ') document.title = [ws, title].filter((it) => it).join(' - ')
return instance return instance
} }
function clearMetadata (): void { function clearMetadata (ws: string): void {
setMetadataLocalStorage(login.metadata.LoginToken, null) const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokens)
if (tokens !== null) {
const loc = getCurrentLocation()
// eslint-disable-next-line
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}
setMetadata(login.metadata.LoginToken, null)
setMetadataLocalStorage(login.metadata.LoginEndpoint, null) setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
setMetadataLocalStorage(login.metadata.LoginEmail, null) setMetadataLocalStorage(login.metadata.LoginEmail, null)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, null)
} }

View File

@ -16,19 +16,26 @@
import type { Metadata } from '@anticrm/platform' import type { Metadata } from '@anticrm/platform'
import { setMetadata } from '@anticrm/platform' import { setMetadata } from '@anticrm/platform'
export function setMetadataLocalStorage (id: Metadata<string>, value: string | null): void { export function setMetadataLocalStorage<T> (id: Metadata<T>, value: T | null): void {
if (value != null) { if (value != null) {
localStorage.setItem(id, value) localStorage.setItem(id, typeof value === 'string' ? value : JSON.stringify(value))
} else { } else {
localStorage.removeItem(id) localStorage.removeItem(id)
} }
setMetadata(id, value) setMetadata(id, value)
} }
export function fetchMetadataLocalStorage (id: Metadata<string>): string | null { export function fetchMetadataLocalStorage<T> (id: Metadata<T>): T | null {
const value = localStorage.getItem(id) const data = localStorage.getItem(id)
if (value !== null) { if (data === null) {
setMetadata(id, value) return null
}
try {
const value = JSON.parse(data)
setMetadata(id, value)
return value
} catch {
setMetadata(id, data as unknown as T)
return data as unknown as T
} }
return value
} }

View File

@ -20,10 +20,10 @@
function showMenu () { function showMenu () {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[3] = space._id loc.path[4] = space._id
navigate(loc) navigate(loc)
} }
$: showMenuButton = $location.path[3] === undefined $: showMenuButton = $location.path[4] === undefined
$: viewslist = viewlets.map((views) => { $: viewslist = viewlets.map((views) => {
return { return {

View File

@ -79,7 +79,7 @@
function openThread (_id: Ref<Message>) { function openThread (_id: Ref<Message>) {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[3] = _id loc.path[4] = _id
navigate(loc) navigate(loc)
} }

View File

@ -96,7 +96,7 @@
class="showMoreAttachmentsButton" class="showMoreAttachmentsButton"
on:click={() => { on:click={() => {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = 'fileBrowser' loc.path[3] = 'fileBrowser'
loc.query = channel ? { spaceId: channel._id } : {} loc.query = channel ? { spaceId: channel._id } : {}
navigate(loc) navigate(loc)
}} }}

View File

@ -113,13 +113,13 @@
const location = getCurrentLocation() const location = getCurrentLocation()
location.fragment = message._id location.fragment = message._id
location.path[2] = message.space location.path[3] = message.space
if (message.attachedToClass === chunter.class.Message) { if (message.attachedToClass === chunter.class.Message) {
location.path.length = 4 location.path.length = 5
location.path[3] = message.attachedTo location.path[4] = message.attachedTo
} else { } else {
location.path.length = 3 location.path.length = 4
} }
await navigator.clipboard.writeText(`${window.location.origin}${locationToUrl(location)}`) await navigator.clipboard.writeText(`${window.location.origin}${locationToUrl(location)}`)
} }

View File

@ -82,7 +82,7 @@
if (!message) { if (!message) {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path.length = 3 loc.path.length = 4
navigate(loc) navigate(loc)
} }
}, },

View File

@ -123,8 +123,8 @@ export async function ArchiveChannel (channel: Channel, evt: any, afterArchive?:
if (afterArchive != null) afterArchive() if (afterArchive != null) afterArchive()
const loc = getCurrentLocation() const loc = getCurrentLocation()
if (loc.path[2] === channel._id) { if (loc.path[3] === channel._id) {
loc.path.length = 2 loc.path.length = 3
navigate(loc) navigate(loc)
} }
} }

View File

@ -58,9 +58,9 @@ export async function getDmName (client: Client, dm: Space): Promise<string> {
export function getSpaceLink (id: Ref<Space>): string { export function getSpaceLink (id: Ref<Space>): string {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = chunterId loc.path[2] = chunterId
loc.path[2] = id loc.path[3] = id
loc.path.length = 3 loc.path.length = 4
loc.fragment = undefined loc.fragment = undefined
return locationToUrl(loc) return locationToUrl(loc)
@ -76,19 +76,19 @@ export function openMessageFromSpecial (message: ChunterMessage): void {
const loc = getCurrentLocation() const loc = getCurrentLocation()
if (message.attachedToClass === chunter.class.ChunterSpace) { if (message.attachedToClass === chunter.class.ChunterSpace) {
loc.path.length = 3
loc.path[2] = message.attachedTo
} else if (message.attachedToClass === chunter.class.Message) {
loc.path.length = 4 loc.path.length = 4
loc.path[2] = message.space
loc.path[3] = message.attachedTo loc.path[3] = message.attachedTo
} else if (message.attachedToClass === chunter.class.Message) {
loc.path.length = 5
loc.path[3] = message.space
loc.path[4] = message.attachedTo
} }
navigate(loc) navigate(loc)
} }
export function navigateToSpecial (specialId: string): void { export function navigateToSpecial (specialId: string): void {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = specialId loc.path[3] = specialId
navigate(loc) navigate(loc)
} }

View File

@ -37,8 +37,8 @@
closePopup() closePopup()
closePanel() closePanel()
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = organization._id loc.path[3] = organization._id
loc.path.length = 3 loc.path.length = 4
navigate(loc) navigate(loc)
} }
}} }}

View File

@ -14,11 +14,17 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { Status, Severity, OK } from '@anticrm/platform' import { Status, Severity, OK, setMetadata } from '@anticrm/platform'
import Form from './Form.svelte' import Form from './Form.svelte'
import { createWorkspace } from '../utils' import { createWorkspace } from '../utils'
import { getCurrentLocation, navigate, setMetadataLocalStorage, showPopup } from '@anticrm/ui' import {
fetchMetadataLocalStorage,
getCurrentLocation,
navigate,
setMetadataLocalStorage,
showPopup
} from '@anticrm/ui'
import login from '../plugin' import login from '../plugin'
import { workbenchId } from '@anticrm/workbench' import { workbenchId } from '@anticrm/workbench'
import InviteLink from './InviteLink.svelte' import InviteLink from './InviteLink.svelte'
@ -40,12 +46,14 @@
status = loginStatus status = loginStatus
if (result !== undefined) { if (result !== undefined) {
setMetadataLocalStorage(login.metadata.LoginToken, result.token) setMetadata(login.metadata.LoginToken, result.token)
const tokens: Record<string, string> = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {}
tokens[object.workspace] = result.token
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint) setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
setMetadataLocalStorage(login.metadata.LoginEmail, result.email) setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, object.workspace)
showPopup(InviteLink, {}, undefined, () => { showPopup(InviteLink, {}, undefined, () => {
navigate({ path: [workbenchId] }) navigate({ path: [workbenchId, object.workspace] })
}) })
} }
} }

View File

@ -13,8 +13,8 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { OK, Status, Severity } from '@anticrm/platform' import { OK, Status, Severity, setMetadata } from '@anticrm/platform'
import { getCurrentLocation, navigate, setMetadataLocalStorage } from '@anticrm/ui' import { fetchMetadataLocalStorage, getCurrentLocation, navigate, setMetadataLocalStorage } from '@anticrm/ui'
import Form from './Form.svelte' import Form from './Form.svelte'
import { join, signUpJoin } from '../utils' import { join, signUpJoin } from '../utils'
@ -72,11 +72,13 @@
status = loginStatus status = loginStatus
if (result !== undefined) { if (result !== undefined) {
setMetadata(login.metadata.LoginToken, result.token)
const tokens: Record<string, string> = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {}
tokens[result.workspace] = result.token
setMetadataLocalStorage(login.metadata.LoginToken, result.token) setMetadataLocalStorage(login.metadata.LoginToken, result.token)
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint) setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
setMetadataLocalStorage(login.metadata.LoginEmail, result.email) setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, result.workspace) navigate({ path: [workbenchId, result.workspace] })
navigate({ path: [workbenchId] })
} }
} }
} }

View File

@ -14,7 +14,7 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { fetchMetadataLocalStorage, location, Popup, ticker } from '@anticrm/ui' import { location, Popup, ticker } from '@anticrm/ui'
import LoginForm from './LoginForm.svelte' import LoginForm from './LoginForm.svelte'
import SignupForm from './SignupForm.svelte' import SignupForm from './SignupForm.svelte'
@ -23,13 +23,14 @@
import Join from './Join.svelte' import Join from './Join.svelte'
import { onDestroy } from 'svelte' import { onDestroy } from 'svelte'
import login from '../plugin' import login from '../plugin'
import { getMetadata } from '@anticrm/platform'
export let page: string = 'login' export let page: string = 'login'
let navigateUrl: string | undefined let navigateUrl: string | undefined
function getToken (timer: number): string | null { function getToken (timer: number): string | undefined {
return fetchMetadataLocalStorage(login.metadata.LoginToken) return getMetadata(login.metadata.LoginToken)
} }
$: token = getToken($ticker) $: token = getToken($ticker)

View File

@ -14,7 +14,7 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { OK, Status, Severity } from '@anticrm/platform' import { OK, Status, Severity, setMetadata } from '@anticrm/platform'
import { getCurrentLocation, navigate, setMetadataLocalStorage } from '@anticrm/ui' import { getCurrentLocation, navigate, setMetadataLocalStorage } from '@anticrm/ui'
import Form from './Form.svelte' import Form from './Form.svelte'
@ -50,7 +50,7 @@
status = loginStatus status = loginStatus
if (result !== undefined) { if (result !== undefined) {
setMetadataLocalStorage(login.metadata.LoginToken, result.token) setMetadata(login.metadata.LoginToken, result.token)
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint) setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
setMetadataLocalStorage(login.metadata.LoginEmail, result.email) setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
const loc = getCurrentLocation() const loc = getCurrentLocation()

View File

@ -14,8 +14,16 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { OK, Severity, Status } from '@anticrm/platform' import { OK, setMetadata, Severity, Status } from '@anticrm/platform'
import { Button, getCurrentLocation, Label, navigate, setMetadataLocalStorage } from '@anticrm/ui' import {
Button,
fetchMetadataLocalStorage,
getCurrentLocation,
Label,
Location,
navigate,
setMetadataLocalStorage
} from '@anticrm/ui'
import { workbenchId } from '@anticrm/workbench' import { workbenchId } from '@anticrm/workbench'
import login from '../plugin' import login from '../plugin'
import { getWorkspaces, selectWorkspace, Workspace } from '../utils' import { getWorkspaces, selectWorkspace, Workspace } from '../utils'
@ -32,15 +40,20 @@
status = loginStatus status = loginStatus
if (result !== undefined) { if (result !== undefined) {
setMetadataLocalStorage(login.metadata.LoginToken, result.token) setMetadata(login.metadata.LoginToken, result.token)
const tokens: Record<string, string> = fetchMetadataLocalStorage(login.metadata.LoginTokens) ?? {}
tokens[result.workspace] = result.token
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint) setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
setMetadataLocalStorage(login.metadata.LoginEmail, result.email) setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, workspace)
if (navigateUrl !== undefined) { if (navigateUrl !== undefined) {
navigate(JSON.parse(decodeURIComponent(navigateUrl))) const url = JSON.parse(decodeURIComponent(navigateUrl)) as Location
} else { if (url.path[1] === workspace) {
navigate({ path: [workbenchId] }) navigate(url)
return
}
} }
navigate({ path: [workbenchId, workspace] })
} }
} }
@ -51,7 +64,6 @@
setMetadataLocalStorage(login.metadata.LoginToken, null) setMetadataLocalStorage(login.metadata.LoginToken, null)
setMetadataLocalStorage(login.metadata.LoginEndpoint, null) setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
setMetadataLocalStorage(login.metadata.LoginEmail, null) setMetadataLocalStorage(login.metadata.LoginEmail, null)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, null)
changeAccount() changeAccount()
throw err throw err
} }

View File

@ -14,7 +14,7 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { Status, Severity, OK } from '@anticrm/platform' import { Status, Severity, OK, setMetadata } from '@anticrm/platform'
import Form from './Form.svelte' import Form from './Form.svelte'
import { signUp } from '../utils' import { signUp } from '../utils'
@ -49,7 +49,7 @@
status = loginStatus status = loginStatus
if (result !== undefined) { if (result !== undefined) {
setMetadataLocalStorage(login.metadata.LoginToken, result.token) setMetadata(login.metadata.LoginToken, result.token)
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint) setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
setMetadataLocalStorage(login.metadata.LoginEmail, result.email) setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
const loc = getCurrentLocation() const loc = getCurrentLocation()

View File

@ -139,8 +139,8 @@ export async function createWorkspace (workspace: string): Promise<[Status, Logi
} }
} }
const token = fetchMetadataLocalStorage(login.metadata.LoginToken) const token = getMetadata(login.metadata.LoginToken)
if (token === null) { if (token === undefined) {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = 'login' loc.path[1] = 'login'
loc.path.length = 2 loc.path.length = 2
@ -188,8 +188,8 @@ export async function getWorkspaces (): Promise<Workspace[]> {
} }
} }
const token = fetchMetadataLocalStorage(login.metadata.LoginToken) const token = getMetadata(login.metadata.LoginToken)
if (token === null) { if (token === undefined) {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = 'login' loc.path[1] = 'login'
loc.path.length = 2 loc.path.length = 2
@ -238,8 +238,8 @@ export async function selectWorkspace (workspace: string): Promise<[Status, Work
} }
} }
const token = fetchMetadataLocalStorage(login.metadata.LoginToken) const token = getMetadata(login.metadata.LoginToken)
if (token === null) { if (token === undefined) {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = 'login' loc.path[1] = 'login'
loc.path.length = 2 loc.path.length = 2
@ -279,8 +279,8 @@ export async function getInviteLink (): Promise<string> {
throw new Error('accounts url not specified') throw new Error('accounts url not specified')
} }
const token = fetchMetadataLocalStorage(login.metadata.LoginToken) const token = getMetadata(login.metadata.LoginToken)
if (token === null) { if (token === undefined) {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = 'login' loc.path[1] = 'login'
loc.path.length = 2 loc.path.length = 2
@ -399,7 +399,7 @@ export async function changeName (first: string, last: string): Promise<void> {
return return
} }
} }
const token = fetchMetadataLocalStorage(login.metadata.LoginToken) as string const token = getMetadata(login.metadata.LoginToken) as string
const request: Request<[string, string]> = { const request: Request<[string, string]> = {
method: 'changeName', method: 'changeName',
@ -430,7 +430,7 @@ export async function changePassword (oldPassword: string, password: string): Pr
return return
} }
} }
const token = fetchMetadataLocalStorage(login.metadata.LoginToken) as string const token = getMetadata(login.metadata.LoginToken) as string
const request: Request<[string, string]> = { const request: Request<[string, string]> = {
method: 'changePassword', method: 'changePassword',
@ -461,7 +461,7 @@ export async function leaveWorkspace (email: string): Promise<void> {
return return
} }
} }
const token = fetchMetadataLocalStorage(login.metadata.LoginToken) as string const token = getMetadata(login.metadata.LoginToken) as string
const request: Request<[string]> = { const request: Request<[string]> = {
method: 'leaveWorkspace', method: 'leaveWorkspace',

View File

@ -30,9 +30,9 @@ export default plugin(loginId, {
TelegramUrl: '' as Asset, TelegramUrl: '' as Asset,
GmailUrl: '' as Asset, GmailUrl: '' as Asset,
LoginToken: '' as Metadata<string>, LoginToken: '' as Metadata<string>,
LoginTokens: '' as Metadata<Record<string, string>>,
LoginEndpoint: '' as Metadata<string>, LoginEndpoint: '' as Metadata<string>,
LoginEmail: '' as Metadata<string>, LoginEmail: '' as Metadata<string>,
CurrentWorkspace: '' as Metadata<string>,
OverrideLoginToken: '' as Metadata<string>, // debug purposes OverrideLoginToken: '' as Metadata<string>, // debug purposes
OverrideEndpoint: '' as Metadata<string> OverrideEndpoint: '' as Metadata<string>
}, },

View File

@ -6,8 +6,8 @@
function onTag (tag: TagElement): void { function onTag (tag: TagElement): void {
selectedTagElements.set([tag._id]) selectedTagElements.set([tag._id])
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = 'candidates' loc.path[3] = 'candidates'
loc.path.length = 3 loc.path.length = 4
navigate(loc) navigate(loc)
} }
</script> </script>

View File

@ -52,8 +52,8 @@
closePopup() closePopup()
closePanel() closePanel()
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = vacancy._id loc.path[3] = vacancy._id
loc.path.length = 3 loc.path.length = 4
navigate(loc) navigate(loc)
} }
}} }}

View File

@ -36,8 +36,8 @@
function getLoc (): Location { function getLoc (): Location {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = value._id loc.path[3] = value._id
loc.path.length = 3 loc.path.length = 4
return loc return loc
} }

View File

@ -17,6 +17,7 @@
import setting, { SettingsCategory } from '@anticrm/setting' import setting, { SettingsCategory } from '@anticrm/setting'
import { import {
Component, Component,
fetchMetadataLocalStorage,
getCurrentLocation, getCurrentLocation,
Label, Label,
location, location,
@ -29,6 +30,7 @@
import login from '@anticrm/login' import login from '@anticrm/login'
import { AccountRole, getCurrentAccount } from '@anticrm/core' import { AccountRole, getCurrentAccount } from '@anticrm/core'
import { EmployeeAccount } from '@anticrm/contact' import { EmployeeAccount } from '@anticrm/contact'
import { setMetadata } from '@anticrm/platform'
let category: SettingsCategory | undefined let category: SettingsCategory | undefined
let categoryId: string = '' let categoryId: string = ''
@ -49,7 +51,7 @@
onDestroy( onDestroy(
location.subscribe(async (loc) => { location.subscribe(async (loc) => {
categoryId = loc.path[2] categoryId = loc.path[3]
category = findCategory(categoryId) category = findCategory(categoryId)
}) })
) )
@ -59,15 +61,20 @@
} }
function selectCategory (id: string): void { function selectCategory (id: string): void {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = id loc.path[3] = id
loc.path.length = 3 loc.path.length = 4
navigate(loc) navigate(loc)
} }
function signOut (): void { function signOut (): void {
setMetadataLocalStorage(login.metadata.LoginToken, null) const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokens)
if (tokens !== null) {
const loc = getCurrentLocation()
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}
setMetadata(login.metadata.LoginToken, null)
setMetadataLocalStorage(login.metadata.LoginEndpoint, null) setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
setMetadataLocalStorage(login.metadata.LoginEmail, null) setMetadataLocalStorage(login.metadata.LoginEmail, null)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, null)
navigate({ path: [login.component.LoginApp] }) navigate({ path: [login.component.LoginApp] })
} }
function selectWorkspace (): void { function selectWorkspace (): void {

View File

@ -44,15 +44,15 @@
onDestroy( onDestroy(
location.subscribe(async (loc) => { location.subscribe(async (loc) => {
categoryId = loc.path[3] categoryId = loc.path[4]
category = findCategory(categoryId) category = findCategory(categoryId)
}) })
) )
function selectCategory (id: string): void { function selectCategory (id: string): void {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[3] = id loc.path[4] = id
loc.path.length = 4 loc.path.length = 5
navigate(loc) navigate(loc)
} }
</script> </script>

View File

@ -16,9 +16,18 @@
import contact, { Employee, EmployeeAccount, formatName } from '@anticrm/contact' import contact, { Employee, EmployeeAccount, formatName } from '@anticrm/contact'
import { getCurrentAccount } from '@anticrm/core' import { getCurrentAccount } from '@anticrm/core'
import login from '@anticrm/login' import login from '@anticrm/login'
import { setMetadata } from '@anticrm/platform'
import { Avatar, createQuery } from '@anticrm/presentation' import { Avatar, createQuery } from '@anticrm/presentation'
import setting, { SettingsCategory, settingId } from '@anticrm/setting' import setting, { SettingsCategory, settingId } from '@anticrm/setting'
import { closePopup, getCurrentLocation, Icon, Label, navigate, setMetadataLocalStorage } from '@anticrm/ui' import {
closePopup,
fetchMetadataLocalStorage,
getCurrentLocation,
Icon,
Label,
navigate,
setMetadataLocalStorage
} from '@anticrm/ui'
// const client = getClient() // const client = getClient()
async function getItems (): Promise<SettingsCategory[]> { async function getItems (): Promise<SettingsCategory[]> {
@ -43,17 +52,22 @@
function selectCategory (sp: SettingsCategory): void { function selectCategory (sp: SettingsCategory): void {
closePopup() closePopup()
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = settingId loc.path[2] = settingId
loc.path[2] = sp.name loc.path[3] = sp.name
loc.path.length = 3 loc.path.length = 4
navigate(loc) navigate(loc)
} }
function signOut (): void { function signOut (): void {
setMetadataLocalStorage(login.metadata.LoginToken, null) const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokens)
if (tokens !== null) {
const loc = getCurrentLocation()
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}
setMetadata(login.metadata.LoginToken, null)
setMetadataLocalStorage(login.metadata.LoginEndpoint, null) setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
setMetadataLocalStorage(login.metadata.LoginEmail, null) setMetadataLocalStorage(login.metadata.LoginEmail, null)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, null)
navigate({ path: [login.component.LoginApp] }) navigate({ path: [login.component.LoginApp] })
} }

View File

@ -20,8 +20,8 @@
export let value: WithLookup<Project> export let value: WithLookup<Project>
function navigateToProject () { function navigateToProject () {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[4] = value._id loc.path[5] = value._id
loc.path.length = 5 loc.path.length = 6
navigate(loc) navigate(loc)
} }
</script> </script>

View File

@ -37,8 +37,7 @@
closeTooltip() closeTooltip()
closePopup() closePopup()
projectId = loc.path[4] as Ref<Project> projectId = loc.path[5] as Ref<Project>
console.log('PROJECT SELECTED', projectId)
}) })
) )

View File

@ -1,7 +1,7 @@
import { Doc, Ref, TxOperations } from '@anticrm/core' import { Doc, Ref, TxOperations } from '@anticrm/core'
import { getClient } from '@anticrm/presentation' import { getClient } from '@anticrm/presentation'
import { Issue, Team, trackerId } from '@anticrm/tracker' import { Issue, Team, trackerId } from '@anticrm/tracker'
import { getPanelURI, Location } from '@anticrm/ui' import { getCurrentLocation, getPanelURI, Location } from '@anticrm/ui'
import { workbenchId } from '@anticrm/workbench' import { workbenchId } from '@anticrm/workbench'
import tracker from './plugin' import tracker from './plugin'
@ -47,7 +47,8 @@ export async function copyToClipboard (object: Issue, ev: Event, { type }: { typ
} }
export function generateIssueShortLink (issueId: string): string { export function generateIssueShortLink (issueId: string): string {
return `${window.location.host}/${workbenchId}/${trackerId}/${issueId}` const location = getCurrentLocation()
return `${window.location.host}/${workbenchId}/${location.path[1]}/${trackerId}/${issueId}`
} }
export async function generateIssueLocation (loc: Location, issueId: string): Promise<Location | undefined> { export async function generateIssueLocation (loc: Location, issueId: string): Promise<Location | undefined> {
@ -71,19 +72,20 @@ export async function generateIssueLocation (loc: Location, issueId: string): Pr
return undefined return undefined
} }
const appComponent = loc.path[0] ?? '' const appComponent = loc.path[0] ?? ''
const workspace = loc.path[1] ?? ''
return { return {
path: [appComponent, trackerId, team._id, 'issues'], path: [appComponent, workspace, trackerId, team._id, 'issues'],
fragment: generateIssuePanelUri(issue) fragment: generateIssuePanelUri(issue)
} }
} }
export async function resolveLocation (loc: Location): Promise<Location | undefined> { export async function resolveLocation (loc: Location): Promise<Location | undefined> {
const app = loc.path.length > 1 ? loc.path[1] : undefined const app = loc.path.length > 2 ? loc.path[2] : undefined
if (app !== trackerId) { if (app !== trackerId) {
return undefined return undefined
} }
const shortLink = loc.path.length > 2 ? loc.path[2] : undefined const shortLink = loc.path.length > 3 ? loc.path[3] : undefined
if (shortLink === undefined || shortLink === null) { if (shortLink === undefined || shortLink === null) {
return undefined return undefined
} }

View File

@ -65,10 +65,10 @@
on:click={(ev) => { on:click={(ev) => {
ev.stopPropagation() ev.stopPropagation()
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = settingId loc.path[2] = settingId
loc.path[2] = 'setting' loc.path[3] = 'setting'
loc.path[3] = 'classes' loc.path[4] = 'classes'
loc.path.length = 4 loc.path.length = 5
loc.query = { _class } loc.query = { _class }
loc.fragment = undefined loc.fragment = undefined
navigate(loc) navigate(loc)

View File

@ -16,9 +16,10 @@
import contact, { Employee, EmployeeAccount, formatName } from '@anticrm/contact' import contact, { Employee, EmployeeAccount, formatName } from '@anticrm/contact'
import { AccountRole, getCurrentAccount } from '@anticrm/core' import { AccountRole, getCurrentAccount } from '@anticrm/core'
import login from '@anticrm/login' import login from '@anticrm/login'
import { setMetadata } from '@anticrm/platform'
import { Avatar, createQuery } from '@anticrm/presentation' import { Avatar, createQuery } from '@anticrm/presentation'
import setting, { settingId, SettingsCategory } from '@anticrm/setting' import setting, { settingId, SettingsCategory } from '@anticrm/setting'
import type { Action } from '@anticrm/ui' import { Action, fetchMetadataLocalStorage } from '@anticrm/ui'
import { import {
closePanel, closePanel,
closePopup, closePopup,
@ -62,17 +63,22 @@
closePopup() closePopup()
closePanel() closePanel()
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = settingId loc.path[2] = settingId
loc.path[2] = sp.name loc.path[3] = sp.name
loc.path.length = 3 loc.path.length = 4
navigate(loc) navigate(loc)
} }
function signOut (): void { function signOut (): void {
setMetadataLocalStorage(login.metadata.LoginToken, null) const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokens)
if (tokens !== null) {
const loc = getCurrentLocation()
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}
setMetadata(login.metadata.LoginToken, null)
setMetadataLocalStorage(login.metadata.LoginEndpoint, null) setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
setMetadataLocalStorage(login.metadata.LoginEmail, null) setMetadataLocalStorage(login.metadata.LoginEmail, null)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, null)
navigate({ path: [login.component.LoginApp] }) navigate({ path: [login.component.LoginApp] })
} }
@ -98,9 +104,9 @@
function getURLCategory (sp: SettingsCategory): string { function getURLCategory (sp: SettingsCategory): string {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[1] = settingId loc.path[2] = settingId
loc.path[2] = sp.name loc.path[3] = sp.name
loc.path.length = 3 loc.path.length = 4
return locationToUrl(loc) return locationToUrl(loc)
} }

View File

@ -14,18 +14,19 @@
--> -->
<script lang="ts"> <script lang="ts">
import type { IntlString } from '@anticrm/platform' import type { IntlString } from '@anticrm/platform'
import { fetchMetadataLocalStorage, Label } from '@anticrm/ui' import { getCurrentLocation, Label } from '@anticrm/ui'
import login from '@anticrm/login'
export let label: IntlString export let label: IntlString
// export let action: () => Promise<void> | void // export let action: () => Promise<void> | void
const loc = getCurrentLocation()
</script> </script>
<div class="antiNav-header"> <div class="antiNav-header">
<div class="flex-row"> <div class="flex-row">
<span class="fs-title overflow-label"><Label {label} /></span> <span class="fs-title overflow-label"><Label {label} /></span>
<div> <div>
{fetchMetadataLocalStorage(login.metadata.CurrentWorkspace)} {loc.path[1]}
</div> </div>
</div> </div>
<!-- <ActionIcon label={workbench.string.More} icon={IconMoreH} size={'small'} {action}/> --> <!-- <ActionIcon label={workbench.string.More} icon={IconMoreH} size={'small'} {action}/> -->

View File

@ -107,7 +107,7 @@
async function view (space: Space): Promise<void> { async function view (space: Space): Promise<void> {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = space._id loc.path[3] = space._id
navigate(loc) navigate(loc)
} }
</script> </script>

View File

@ -26,7 +26,6 @@
closeTooltip, closeTooltip,
Component, Component,
DatePickerPopup, DatePickerPopup,
fetchMetadataLocalStorage,
getCurrentLocation, getCurrentLocation,
Label, Label,
location, location,
@ -39,7 +38,6 @@
showPopup, showPopup,
TooltipInstance TooltipInstance
} from '@anticrm/ui' } from '@anticrm/ui'
import login from '@anticrm/login'
import view from '@anticrm/view' import view from '@anticrm/view'
import { ActionContext, ActionHandler } from '@anticrm/view-resources' import { ActionContext, ActionHandler } from '@anticrm/view-resources'
import type { Application, NavigatorModel, SpecialNavModel, ViewConfiguration } from '@anticrm/workbench' import type { Application, NavigatorModel, SpecialNavModel, ViewConfiguration } from '@anticrm/workbench'
@ -147,7 +145,7 @@
async function updateWindowTitle (loc: Location) { async function updateWindowTitle (loc: Location) {
const title = (await getWindowTitle(loc)) ?? getMetadata(workbench.metadata.PlatformTitle) ?? 'Platform' const title = (await getWindowTitle(loc)) ?? getMetadata(workbench.metadata.PlatformTitle) ?? 'Platform'
const ws = fetchMetadataLocalStorage(login.metadata.CurrentWorkspace) const ws = loc.path[1]
document.title = ws == null ? title : `${ws} - ${title}` document.title = ws == null ? title : `${ws} - ${title}`
} }
async function getWindowTitle (loc: Location) { async function getWindowTitle (loc: Location) {
@ -169,9 +167,9 @@
} }
async function syncLoc (loc: Location): Promise<void> { async function syncLoc (loc: Location): Promise<void> {
const app = loc.path.length > 1 ? loc.path[1] : undefined const app = loc.path.length > 2 ? loc.path[2] : undefined
const space = loc.path.length > 2 ? (loc.path[2] as Ref<Space>) : undefined const space = loc.path.length > 3 ? (loc.path[3] as Ref<Space>) : undefined
const special = loc.path.length > 3 ? loc.path[3] : undefined const special = loc.path.length > 4 ? loc.path[4] : undefined
if (currentAppAlias !== app) { if (currentAppAlias !== app) {
clear(1) clear(1)
@ -195,13 +193,13 @@
const last = localStorage.getItem(`platform_last_loc_${app}`) const last = localStorage.getItem(`platform_last_loc_${app}`)
if (last !== null) { if (last !== null) {
const newLocation: Location = JSON.parse(last) const newLocation: Location = JSON.parse(last)
if (newLocation.path[2] != null) { if (newLocation.path[3] != null) {
loc.path[2] = newLocation.path[2] as Ref<Space> loc.path[3] = newLocation.path[3] as Ref<Space>
loc.path[3] = newLocation.path[3] loc.path[4] = newLocation.path[4]
if (loc.path[3] == null) { if (loc.path[4] == null) {
loc.path.length = 3
} else {
loc.path.length = 4 loc.path.length = 4
} else {
loc.path.length = 5
} }
navigate(loc) navigate(loc)
return return
@ -282,7 +280,7 @@
function closeAside (): void { function closeAside (): void {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path.length = 3 loc.path.length = 4
checkOnHide() checkOnHide()
navigate(loc) navigate(loc)
} }

View File

@ -63,7 +63,7 @@
icon: IconSearch, icon: IconSearch,
action: async (_id: Ref<Doc>): Promise<void> => { action: async (_id: Ref<Doc>): Promise<void> => {
const loc = getCurrentLocation() const loc = getCurrentLocation()
loc.path[2] = 'spaceBrowser' loc.path[3] = 'spaceBrowser'
dispatch('open') dispatch('open')
navigate(loc) navigate(loc)
} }

View File

@ -72,44 +72,44 @@ export async function doNavigate (
const client = getClient() const client = getClient()
switch (props.mode) { switch (props.mode) {
case 'app': case 'app':
loc.path[1] = props.application ?? '' loc.path[2] = props.application ?? ''
if (props.special !== undefined) { if (props.special !== undefined) {
loc.path[2] = props.special loc.path[3] = props.special
loc.path.length = 3 loc.path.length = 4
} else { } else {
loc.path.length = 2 loc.path.length = 3
} }
navigate(loc) navigate(loc)
break break
case 'special': case 'special':
if (props.application !== undefined && loc.path[1] !== props.application) { if (props.application !== undefined && loc.path[2] !== props.application) {
loc.path[1] = props.application loc.path[2] = props.application
} }
loc.path[2] = props.special ?? '' loc.path[3] = props.special ?? ''
loc.path.length = 3 loc.path.length = 4
navigate(loc) navigate(loc)
break break
case 'space': { case 'space': {
if (props.space !== undefined) { if (props.space !== undefined) {
loc.path[2] = props.space loc.path[3] = props.space
} else { } else {
if (doc !== undefined && !Array.isArray(doc) && client.getHierarchy().isDerived(doc._class, core.class.Space)) { if (doc !== undefined && !Array.isArray(doc) && client.getHierarchy().isDerived(doc._class, core.class.Space)) {
loc.path[2] = doc._id loc.path[3] = doc._id
} }
} }
if (props.spaceSpecial !== undefined) { if (props.spaceSpecial !== undefined) {
loc.path[3] = props.spaceSpecial loc.path[4] = props.spaceSpecial
} }
if (props.spaceClass !== undefined) { if (props.spaceClass !== undefined) {
const ex = await client.findOne(props.spaceClass, { _id: loc.path[2] as Ref<Space> }) const ex = await client.findOne(props.spaceClass, { _id: loc.path[3] as Ref<Space> })
if (ex === undefined) { if (ex === undefined) {
const r = await client.findOne(props.spaceClass, {}) const r = await client.findOne(props.spaceClass, {})
if (r !== undefined) { if (r !== undefined) {
loc.path[2] = r._id loc.path[3] = r._id
} }
} }
} }
loc.path.length = 4 loc.path.length = 5
navigate(loc) navigate(loc)
break break

View File

@ -9,12 +9,8 @@
"value": "user1" "value": "user1"
}, },
{ {
"name": "login:metadata:LoginToken", "name": "login:metadata:LoginTokens",
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InVzZXIxIiwid29ya3NwYWNlIjoic2FuaXR5LXdzIn0.hfUCqePHO-WNps2by4B-CYGKIpDpLG0WVCUUtU-SVI4" "value": "{\"sanity-ws\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InVzZXIxIiwid29ya3NwYWNlIjoic2FuaXR5LXdzIn0.hfUCqePHO-WNps2by4B-CYGKIpDpLG0WVCUUtU-SVI4\"}"
},
{
"name": "login:metadata:CurrentWorkspace",
"value": "sanity-ws"
}, },
{ {
"name": "login:metadata:LoginEndpoint", "name": "login:metadata:LoginEndpoint",

View File

@ -9,12 +9,8 @@
"value": "user1" "value": "user1"
}, },
{ {
"name": "login:metadata:LoginToken", "name": "login:metadata:LoginTokens",
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InVzZXIxIiwid29ya3NwYWNlIjoic2FuaXR5LXdzIn0.hfUCqePHO-WNps2by4B-CYGKIpDpLG0WVCUUtU-SVI4" "value": "{\"sanity-ws\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InVzZXIxIiwid29ya3NwYWNlIjoic2FuaXR5LXdzIn0.hfUCqePHO-WNps2by4B-CYGKIpDpLG0WVCUUtU-SVI4\"}"
},
{
"name": "login:metadata:CurrentWorkspace",
"value": "sanity-ws"
}, },
{ {
"name": "login:metadata:LoginEndpoint", "name": "login:metadata:LoginEndpoint",

View File

@ -8,13 +8,13 @@ test.use({
test.describe('actions tests', () => { test.describe('actions tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/sanity-ws`)
}) })
test('action-new-candidate', async ({ page }) => { test('action-new-candidate', async ({ page }) => {
await page.click('[id="app-recruit\\:string\\:RecruitApplication"]') await page.click('[id="app-recruit\\:string\\:RecruitApplication"]')
await page.click('text=Talents') await page.click('text=Talents')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/talents`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/talents`)
await page.click('td:has-text("Frontend Engineer")') await page.click('td:has-text("Frontend Engineer")')
@ -29,26 +29,26 @@ test.describe('actions tests', () => {
await page.click('[id="app-recruit\\:string\\:RecruitApplication"]') await page.click('[id="app-recruit\\:string\\:RecruitApplication"]')
await page.click('text=Talents') await page.click('text=Talents')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/talents`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/talents`)
await page.press('body', 'Meta+k') await page.press('body', 'Meta+k')
await page.fill('[placeholder="type\\ to\\ filter\\.\\.\\."]', 'go to') await page.fill('[placeholder="type\\ to\\ filter\\.\\.\\."]', 'go to')
expect(await page.locator('div.selectPopup :text("Go To Vacancies")').count()).toBe(1) expect(await page.locator('div.selectPopup :text("Go To Vacancies")').count()).toBe(1)
await page.click('div.selectPopup :text("Go To Vacancies")') await page.click('div.selectPopup :text("Go To Vacancies")')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/vacancies`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/vacancies`)
}) })
test('action-switch-applications', async ({ page }) => { test('action-switch-applications', async ({ page }) => {
await page.click('[id="app-recruit\\:string\\:RecruitApplication"]') await page.click('[id="app-recruit\\:string\\:RecruitApplication"]')
await page.click('text=Talents') await page.click('text=Talents')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/talents`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/talents`)
await page.press('body', 'Meta+k') await page.press('body', 'Meta+k')
await page.fill('[placeholder="type\\ to\\ filter\\.\\.\\."]', 'go to') await page.fill('[placeholder="type\\ to\\ filter\\.\\.\\."]', 'go to')
expect(await page.locator('div.selectPopup :text("Go To Applications")').count()).toBe(1) expect(await page.locator('div.selectPopup :text("Go To Applications")').count()).toBe(1)
await page.click('div.selectPopup :text("Go To Applications")') await page.click('div.selectPopup :text("Go To Applications")')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/candidates`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/candidates`)
}) })
}) })

View File

@ -8,7 +8,7 @@ test.use({
test.describe('duplicate-org-test', () => { test.describe('duplicate-org-test', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('test', async ({ page }) => { test('test', async ({ page }) => {
await page.click('[id="app-lead\\:string\\:LeadApplication"]') await page.click('[id="app-lead\\:string\\:LeadApplication"]')

View File

@ -8,7 +8,7 @@ test.use({
test.describe('contact tests', () => { test.describe('contact tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('create-contact', async ({ page }) => { test('create-contact', async ({ page }) => {
// Create a new context with the saved storage state. // Create a new context with the saved storage state.

View File

@ -8,7 +8,7 @@ test.use({
test.describe('recruit tests', () => { test.describe('recruit tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('org-add-member', async ({ page }) => { test('org-add-member', async ({ page }) => {

View File

@ -8,7 +8,7 @@ test.use({
test.describe('recruit review tests', () => { test.describe('recruit review tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('create-review', async ({ page, context }) => { test('create-review', async ({ page, context }) => {
await page.click('[id="app-recruit\\:string\\:RecruitApplication"]') await page.click('[id="app-recruit\\:string\\:RecruitApplication"]')

View File

@ -8,7 +8,7 @@ test.use({
test.describe('recruit tests', () => { test.describe('recruit tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('create-candidate', async ({ page, context }) => { test('create-candidate', async ({ page, context }) => {
await page.locator('[id="app-recruit\\:string\\:RecruitApplication"]').click() await page.locator('[id="app-recruit\\:string\\:RecruitApplication"]').click()

View File

@ -7,18 +7,18 @@ test.use({
test.describe('contact tests', () => { test.describe('contact tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('update-profile', async ({ page, context }) => { test('update-profile', async ({ page, context }) => {
// Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp // Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/sanity-ws
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
// Click #profile-button // Click #profile-button
await page.click('#profile-button') await page.click('#profile-button')
await page.click('text=John Appleseed') await page.click('text=John Appleseed')
// await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/setting/setting`) // await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/setting/setting`)
// Click text=Edit profile // Click text=Edit profile
// await page.click('text=Edit profile') // await page.click('text=Edit profile')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/setting/profile`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/setting/profile`)
// Click [placeholder="Location"] // Click [placeholder="Location"]
await page.click('[placeholder="Location"]') await page.click('[placeholder="Location"]')
// Fill [placeholder="Location"] // Fill [placeholder="Location"]
@ -37,8 +37,8 @@ test.describe('contact tests', () => {
await page.click('.editor-container button:nth-child(3)') await page.click('.editor-container button:nth-child(3)')
}) })
test('create-template', async ({ page }) => { test('create-template', async ({ page }) => {
// Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp // Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/sanity-ws
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
// Click #profile-button // Click #profile-button
await page.click('#profile-button') await page.click('#profile-button')
// Click button:has-text("Settings") // Click button:has-text("Settings")
@ -70,8 +70,8 @@ test.describe('contact tests', () => {
}) })
test('manage-status-templates', async ({ page }) => { test('manage-status-templates', async ({ page }) => {
// Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp // Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/sanity-ws
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
// Click #profile-button // Click #profile-button
await page.click('#profile-button') await page.click('#profile-button')
// await page.click('text=Workspace') // await page.click('text=Workspace')

View File

@ -8,17 +8,17 @@ test.use({
test.describe('recruit tests', () => { test.describe('recruit tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('create-candidate-with-skill', async ({ page }) => { test('create-candidate-with-skill', async ({ page }) => {
// Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp // Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/sanity-ws
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
// Click [id="app-recruit\:string\:RecruitApplication"] // Click [id="app-recruit\:string\:RecruitApplication"]
await page.click('[id="app-recruit\\:string\\:RecruitApplication"]') await page.click('[id="app-recruit\\:string\\:RecruitApplication"]')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit`)
// Click text=Talents // Click text=Talents
await page.click('text=Talents') await page.click('text=Talents')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/talents`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/talents`)
// Click button:has-text("Talent") // Click button:has-text("Talent")
await page.click('button:has-text("Talent")') await page.click('button:has-text("Talent")')
// Fill [placeholder="John"] // Fill [placeholder="John"]
@ -48,14 +48,14 @@ test.describe('recruit tests', () => {
}) })
test('create-tag-candidate', async ({ page }) => { test('create-tag-candidate', async ({ page }) => {
// Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp // Go to http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/sanity-ws
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
// Click [id="app-recruit\:string\:RecruitApplication"] // Click [id="app-recruit\:string\:RecruitApplication"]
await page.click('[id="app-recruit\\:string\\:RecruitApplication"]') await page.click('[id="app-recruit\\:string\\:RecruitApplication"]')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit`)
// Click text=Skills // Click text=Skills
await page.click('text=Skills') await page.click('text=Skills')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/skills`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/skills`)
// Click button:has-text("Skill") // Click button:has-text("Skill")
await page.click('button:has-text("Skill")') await page.click('button:has-text("Skill")')
// Click [placeholder="Please\ type\ skill\ title"] // Click [placeholder="Please\ type\ skill\ title"]
@ -78,7 +78,7 @@ test.describe('recruit tests', () => {
await page.click('button:has-text("Create")') await page.click('button:has-text("Create")')
// Click text=Talents // Click text=Talents
await page.click('text=Talents') await page.click('text=Talents')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/talents`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/talents`)
// Click button:has-text("Talent") // Click button:has-text("Talent")
await page.click('button:has-text("Talent")') await page.click('button:has-text("Talent")')
// Click #add-tag div div // Click #add-tag div div

View File

@ -8,7 +8,7 @@ test.use({
test.describe('project tests', () => { test.describe('project tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('create-project-issue', async ({ page }) => { test('create-project-issue', async ({ page }) => {
await page.click('[id="app-tracker\\:string\\:TrackerApplication"]') await page.click('[id="app-tracker\\:string\\:TrackerApplication"]')
@ -16,7 +16,7 @@ test.describe('project tests', () => {
// Click text=Projects // Click text=Projects
await page.click('text=Projects') await page.click('text=Projects')
await expect(page).toHaveURL( await expect(page).toHaveURL(
`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/tracker/tracker%3Ateam%3ADefaultTeam/projects` `${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/tracker/tracker%3Ateam%3ADefaultTeam/projects`
) )
await page.click('button:has-text("Project")') await page.click('button:has-text("Project")')
await page.click('[placeholder="Project\\ name"]') await page.click('[placeholder="Project\\ name"]')
@ -39,7 +39,7 @@ test.describe('project tests', () => {
await page.click('[id="app-tracker\\:string\\:TrackerApplication"]') await page.click('[id="app-tracker\\:string\\:TrackerApplication"]')
await page.click('text=Projects') await page.click('text=Projects')
await expect(page).toHaveURL( await expect(page).toHaveURL(
`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/tracker/tracker%3Ateam%3ADefaultTeam/projects` `${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/tracker/tracker%3Ateam%3ADefaultTeam/projects`
) )
await page.click('button:has-text("Project")') await page.click('button:has-text("Project")')
const prjId = 'project-' + generateId() const prjId = 'project-' + generateId()

View File

@ -5,9 +5,9 @@ test.use({
}) })
async function navigate (page: Page): Promise<void> { async function navigate (page: Page): Promise<void> {
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
await page.click('[id="app-tracker\\:string\\:TrackerApplication"]') await page.click('[id="app-tracker\\:string\\:TrackerApplication"]')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/tracker`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/tracker`)
} }
interface IssueProps { interface IssueProps {

View File

@ -7,28 +7,28 @@ test.use({
test.describe('workbench tests', () => { test.describe('workbench tests', () => {
test.beforeEach(async ({ page }) => { test.beforeEach(async ({ page }) => {
// Create user and workspace // Create user and workspace
await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp`) await page.goto(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws`)
}) })
test('navigator', async ({ page }) => { test('navigator', async ({ page }) => {
// Click [id="app-recruit\:string\:RecruitApplication"] // Click [id="app-recruit\:string\:RecruitApplication"]
await page.click('[id="app-recruit\\:string\\:RecruitApplication"]') await page.click('[id="app-recruit\\:string\\:RecruitApplication"]')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit`)
// Click text=Applications // Click text=Applications
await page.click('text=Applications') await page.click('text=Applications')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/candidates`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/candidates`)
// Click text=Applications Application >> span // Click text=Applications Application >> span
await expect(page.locator('text=Applications Filter')).toBeVisible() await expect(page.locator('text=Applications Filter')).toBeVisible()
await expect(page.locator('text="APP-1')).toBeDefined() await expect(page.locator('text="APP-1')).toBeDefined()
// Click text=Talents // Click text=Talents
await page.click('text=Talents') await page.click('text=Talents')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/talents`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/talents`)
await expect(page.locator('text=Andrey P.')).toBeVisible() await expect(page.locator('text=Andrey P.')).toBeVisible()
// Click text=Vacancies // Click text=Vacancies
await page.click('text=Vacancies') await page.click('text=Vacancies')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/recruit/vacancies`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/recruit/vacancies`)
// Click text=Software Engineer // Click text=Software Engineer
await page.click('text=Software Engineer') await page.click('text=Software Engineer')
await expect(page.locator('text=Software Engineer')).toBeVisible() await expect(page.locator('text=Software Engineer')).toBeVisible()
@ -38,7 +38,7 @@ test.describe('workbench tests', () => {
// Click [id="app-chunter\:string\:ApplicationLabelChunter"] // Click [id="app-chunter\:string\:ApplicationLabelChunter"]
await page.click('[id="app-chunter\\:string\\:ApplicationLabelChunter"]') await page.click('[id="app-chunter\\:string\\:ApplicationLabelChunter"]')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/chunter`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/chunter`)
await page.click('text=general') await page.click('text=general')
@ -46,7 +46,7 @@ test.describe('workbench tests', () => {
await expect(page.locator('.textInput')).toBeVisible() await expect(page.locator('.textInput')).toBeVisible()
await page.click('[id="app-contact\\:string\\:Contacts"]') await page.click('[id="app-contact\\:string\\:Contacts"]')
await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/contact`) await expect(page).toHaveURL(`${PlatformURI}/workbench%3Acomponent%3AWorkbenchApp/sanity-ws/contact`)
// Click text=John Appleseed // Click text=John Appleseed
await expect(page.locator('text=John Appleseed')).toBeVisible() await expect(page.locator('text=John Appleseed')).toBeVisible()
}) })