[TSK-223] UI: add routes metadata (#2175)

Signed-off-by: Anna <anna.no@xored.com>
This commit is contained in:
Anna No 2022-06-30 16:51:17 +07:00 committed by GitHub
parent 4e21858b1f
commit 55aa3a5292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 67 additions and 48 deletions

View File

@ -72,14 +72,13 @@ import { textEditorId } from '@anticrm/text-editor'
import { setMetadata } from '@anticrm/platform'
export async function configurePlatform() {
export async function configurePlatform() {
const config = await (await fetch('/config.json')).json()
console.log('loading configuration', config)
setMetadata(login.metadata.AccountsUrl, config.ACCOUNTS_URL)
setMetadata(login.metadata.UploadUrl, config.UPLOAD_URL)
if( config.MODEL_VERSION != null) {
setMetadata(login.metadata.UploadUrl, config.UPLOAD_URL)
if (config.MODEL_VERSION != null) {
console.log('Minimal Model version requirement', config.MODEL_VERSION)
setMetadata(presentation.metadata.RequiredVersion, config.MODEL_VERSION)
}
@ -87,10 +86,18 @@ export async function configurePlatform() {
setMetadata(login.metadata.GmailUrl, process.env.GMAIL_URL ?? 'http://localhost:8087')
setMetadata(login.metadata.OverrideEndpoint, process.env.LOGIN_ENDPOINT)
setMetadata(login.metadata.FrontUrl, process.env.FRONT_URL)
setMetadata(rekoni.metadata.RekoniUrl, process.env.REKONI_URL)
setMetadata(uiPlugin.metadata.DefaultApplication, workbench.component.WorkbenchApp )
setMetadata(uiPlugin.metadata.DefaultApplication, workbench.component.WorkbenchApp)
setMetadata(
uiPlugin.metadata.Routes,
new Map([
[workbenchId, workbench.component.WorkbenchApp],
[loginId, login.component.LoginApp]
])
)
addLocation(coreId, async () => ({ default: async () => ({}) }))
addLocation(presentationId, async () => ({ default: async () => ({}) }))

View File

@ -22,8 +22,13 @@
onDestroy(
location.subscribe((loc) => {
if (loc.path[0]) {
application = loc.path[0] as AnyComponent
const routes = getMetadata(uiPlugin.metadata.Routes) ?? new Map()
const component = loc.path[0]
application = routes.get(component)
if (application === undefined && Array.from(routes.values()).includes(component as AnyComponent)) {
// if component id is used
application = component as AnyComponent
}
if (application === undefined) {

View File

@ -67,7 +67,8 @@ export const uis = plugin(uiId, {
Back: '' as IntlString
},
metadata: {
DefaultApplication: '' as Metadata<AnyComponent>
DefaultApplication: '' as Metadata<AnyComponent>,
Routes: '' as Metadata<Map<string, AnyComponent>>
}
})

View File

@ -20,7 +20,7 @@
import { createWorkspace } from '../utils'
import { getCurrentLocation, navigate, setMetadataLocalStorage, showPopup } from '@anticrm/ui'
import login from '../plugin'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
import InviteLink from './InviteLink.svelte'
const fields = [{ name: 'workspace', i18n: login.string.Workspace, rule: /^[0-9a-z#%&^\-@!)(]{3,63}$/ }]
@ -45,7 +45,7 @@
setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, object.workspace)
showPopup(InviteLink, {}, undefined, () => {
navigate({ path: [workbench.component.WorkbenchApp] })
navigate({ path: [workbenchId] })
})
}
}

View File

@ -20,7 +20,7 @@
import { join, signUpJoin } from '../utils'
import login from '../plugin'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
const location = getCurrentLocation()
let page = 'login'
@ -76,7 +76,7 @@
setMetadataLocalStorage(login.metadata.LoginEndpoint, result.endpoint)
setMetadataLocalStorage(login.metadata.LoginEmail, result.email)
setMetadataLocalStorage(login.metadata.CurrentWorkspace, result.workspace)
navigate({ path: [workbench.component.WorkbenchApp] })
navigate({ path: [workbenchId] })
}
}
}

View File

@ -16,7 +16,7 @@
<script lang="ts">
import { OK, Severity, Status } from '@anticrm/platform'
import { Button, getCurrentLocation, Label, navigate, setMetadataLocalStorage } from '@anticrm/ui'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
import login from '../plugin'
import { getWorkspaces, selectWorkspace } from '../utils'
import StatusControl from './StatusControl.svelte'
@ -39,7 +39,7 @@
if (navigateUrl !== undefined) {
navigate(JSON.parse(decodeURIComponent(navigateUrl)))
} else {
navigate({ path: [workbench.component.WorkbenchApp] })
navigate({ path: [workbenchId] })
}
}
}

View File

@ -2,7 +2,7 @@ import { Doc, Ref, TxOperations } from '@anticrm/core'
import { getClient } from '@anticrm/presentation'
import { Issue, Team, trackerId } from '@anticrm/tracker'
import { getPanelURI, Location } from '@anticrm/ui'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
import tracker from './plugin'
export function getIssueId (team: Team, issue: Issue): string {
@ -48,7 +48,7 @@ export async function copyToClipboard (object: Issue, ev: Event, { type }: { typ
}
export function generateIssueShortLink (issueId: string): string {
return `${window.location.host}/${workbench.component.WorkbenchApp}/${trackerId}/${issueId}`
return `${window.location.host}/${workbenchId}/${trackerId}/${issueId}`
}
export async function generateIssueLocation (loc: Location, issueId: string): Promise<Location | undefined> {

View File

@ -33,7 +33,6 @@ import { templatesId } from '@anticrm/templates'
import { notificationId } from '@anticrm/notification'
import { calendarId } from '@anticrm/calendar'
import { trackerId } from '@anticrm/tracker'
import { preferenceId } from '@anticrm/preference'
import '@anticrm/login-assets'
import '@anticrm/task-assets'
@ -56,14 +55,13 @@ import { textEditorId } from '@anticrm/text-editor'
import { setMetadata } from '@anticrm/platform'
export async function configurePlatform() {
export async function configurePlatform() {
const config = await (await fetch('/config.json')).json()
console.log('loading configuration', config)
setMetadata(login.metadata.AccountsUrl, config.ACCOUNTS_URL)
setMetadata(login.metadata.UploadUrl, config.UPLOAD_URL)
setMetadata(login.metadata.UploadUrl, config.UPLOAD_URL)
if( config.MODEL_VERSION != null) {
if (config.MODEL_VERSION != null) {
console.log('Minimal Model version requirement', config.MODEL_VERSION)
setMetadata(presentation.metadata.RequiredVersion, config.MODEL_VERSION)
}
@ -71,9 +69,17 @@ export async function configurePlatform() {
setMetadata(login.metadata.GmailUrl, process.env.GMAIL_URL ?? 'http://localhost:8087')
setMetadata(login.metadata.OverrideEndpoint, process.env.LOGIN_ENDPOINT)
setMetadata(login.metadata.FrontUrl, process.env.FRONT_URL)
setMetadata(uiPlugin.metadata.DefaultApplication, workbench.component.WorkbenchApp )
setMetadata(workbench.metadata.ExcludedApplications, [contact.app.Contacts] )
setMetadata(uiPlugin.metadata.DefaultApplication, workbench.component.WorkbenchApp)
setMetadata(workbench.metadata.ExcludedApplications, [contact.app.Contacts])
setMetadata(
uiPlugin.metadata.Routes,
new Map([
[workbenchId, workbench.component.WorkbenchApp],
[loginId, login.component.LoginApp]
])
)
addLocation(coreId, async () => ({ default: async () => ({}) }))
addLocation(presentationId, async () => ({ default: async () => ({}) }))

View File

@ -13,7 +13,7 @@
// limitations under the License.
//
import chunter, { ChunterSpace, Comment, Message, ThreadMessage } from '@anticrm/chunter'
import chunter, { chunterId, ChunterSpace, Comment, Message, ThreadMessage } from '@anticrm/chunter'
import { EmployeeAccount } from '@anticrm/contact'
import core, {
Class,
@ -33,7 +33,7 @@ import core, {
import login from '@anticrm/login'
import { getMetadata } from '@anticrm/platform'
import { TriggerControl } from '@anticrm/server-core'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
/**
* @public
@ -41,7 +41,7 @@ import workbench from '@anticrm/workbench'
export function channelHTMLPresenter (doc: Doc): string {
const channel = doc as ChunterSpace
const front = getMetadata(login.metadata.FrontUrl) ?? ''
return `<a href="${front}/${workbench.component.WorkbenchApp}/${chunter.app.Chunter}/${channel._id}">${channel.name}</a>`
return `<a href="${front}/${workbenchId}/${chunterId}/${channel._id}">${channel.name}</a>`
}
/**

View File

@ -16,10 +16,10 @@
import core, { Doc, Tx, TxCreateDoc, TxRemoveDoc, TxUpdateDoc } from '@anticrm/core'
import type { TriggerControl } from '@anticrm/server-core'
import contact, { Contact, formatName, Organization, Person } from '@anticrm/contact'
import contact, { Contact, contactId, formatName, Organization, Person } from '@anticrm/contact'
import { getMetadata } from '@anticrm/platform'
import login from '@anticrm/login'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
import view from '@anticrm/view'
/**
@ -63,9 +63,9 @@ export async function OnContactDelete (tx: Tx, { findAll, hierarchy, storageFx }
export function personHTMLPresenter (doc: Doc): string {
const person = doc as Person
const front = getMetadata(login.metadata.FrontUrl) ?? ''
return `<a href="${front}/${workbench.component.WorkbenchApp}/${contact.app.Contacts}#${view.component.EditDoc}|${
person._id
}|${person._class}">${formatName(person.name)}</a>`
return `<a href="${front}/${workbenchId}/${contactId}#${view.component.EditDoc}|${person._id}|${
person._class
}">${formatName(person.name)}</a>`
}
/**
@ -82,7 +82,7 @@ export function personTextPresenter (doc: Doc): string {
export function organizationHTMLPresenter (doc: Doc): string {
const organization = doc as Organization
const front = getMetadata(login.metadata.FrontUrl) ?? ''
return `<a href="${front}/${workbench.component.WorkbenchApp}/${contact.app.Contacts}#${view.component.EditDoc}|${organization._id}|${organization._class}">${organization.name}</a>`
return `<a href="${front}/${workbenchId}/${contactId}#${view.component.EditDoc}|${organization._id}|${organization._class}">${organization.name}</a>`
}
/**

View File

@ -14,11 +14,11 @@
//
import { Doc } from '@anticrm/core'
import inventory, { Product } from '@anticrm/inventory'
import { inventoryId, Product } from '@anticrm/inventory'
import login from '@anticrm/login'
import { getMetadata } from '@anticrm/platform'
import view from '@anticrm/view'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
/**
* @public
@ -26,7 +26,7 @@ import workbench from '@anticrm/workbench'
export function productHTMLPresenter (doc: Doc): string {
const product = doc as Product
const front = getMetadata(login.metadata.FrontUrl) ?? ''
return `<a href="${front}/${workbench.component.WorkbenchApp}/${inventory.app.Inventory}/Products/#${view.component.EditDoc}|${product._id}|${product._class}">${product.name}</a>`
return `<a href="${front}/${workbenchId}/${inventoryId}/Products/#${view.component.EditDoc}|${product._id}|${product._class}">${product.name}</a>`
}
/**

View File

@ -14,11 +14,11 @@
//
import { Doc } from '@anticrm/core'
import leadP, { Lead } from '@anticrm/lead'
import { leadId, Lead } from '@anticrm/lead'
import login from '@anticrm/login'
import { getMetadata } from '@anticrm/platform'
import view from '@anticrm/view'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
/**
* @public
@ -26,7 +26,7 @@ import workbench from '@anticrm/workbench'
export function leadHTMLPresenter (doc: Doc): string {
const lead = doc as Lead
const front = getMetadata(login.metadata.FrontUrl) ?? ''
return `<a href="${front}/${workbench.component.WorkbenchApp}/${leadP.app.Lead}/${lead.space}/#${view.component.EditDoc}|${lead._id}|${lead._class}">${lead.title}</a>`
return `<a href="${front}/${workbenchId}/${leadId}/${lead.space}/#${view.component.EditDoc}|${lead._id}|${lead._class}">${lead.title}</a>`
}
/**

View File

@ -13,11 +13,11 @@
// limitations under the License.
//
import recruit, { Applicant, Vacancy } from '@anticrm/recruit'
import recruit, { Applicant, recruitId, Vacancy } from '@anticrm/recruit'
import { Doc } from '@anticrm/core'
import login from '@anticrm/login'
import { getMetadata } from '@anticrm/platform'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
import view from '@anticrm/view'
/**
@ -26,7 +26,7 @@ import view from '@anticrm/view'
export function vacancyHTMLPresenter (doc: Doc): string {
const vacancy = doc as Vacancy
const front = getMetadata(login.metadata.FrontUrl) ?? ''
return `<a href="${front}/${workbench.component.WorkbenchApp}/${recruit.app.Recruit}/${vacancy._id}/#${recruit.component.EditVacancy}|${vacancy._id}|${vacancy._class}">${vacancy.name}</a>`
return `<a href="${front}/${workbenchId}/${recruitId}/${vacancy._id}/#${recruit.component.EditVacancy}|${vacancy._id}|${vacancy._class}">${vacancy.name}</a>`
}
/**
@ -43,7 +43,7 @@ export function vacancyTextPresenter (doc: Doc): string {
export function applicationHTMLPresenter (doc: Doc): string {
const applicant = doc as Applicant
const front = getMetadata(login.metadata.FrontUrl) ?? ''
return `<a href="${front}/${workbench.component.WorkbenchApp}/${recruit.app.Recruit}/${applicant.space}/#${view.component.EditDoc}|${applicant._id}|${applicant._class}">APP-${applicant.number}</a>`
return `<a href="${front}/${workbenchId}/${recruitId}/${applicant.space}/#${view.component.EditDoc}|${applicant._id}|${applicant._class}">APP-${applicant.number}</a>`
}
/**

View File

@ -18,9 +18,9 @@ import login from '@anticrm/login'
import { getMetadata } from '@anticrm/platform'
import { extractTx, TriggerControl } from '@anticrm/server-core'
import { getUpdateLastViewTx } from '@anticrm/server-notification'
import task, { Issue, Task } from '@anticrm/task'
import task, { Issue, Task, taskId } from '@anticrm/task'
import view from '@anticrm/view'
import workbench from '@anticrm/workbench'
import { workbenchId } from '@anticrm/workbench'
/**
* @public
@ -28,7 +28,7 @@ import workbench from '@anticrm/workbench'
export function issueHTMLPresenter (doc: Doc): string {
const issue = doc as Issue
const front = getMetadata(login.metadata.FrontUrl) ?? ''
return `<a href="${front}/${workbench.component.WorkbenchApp}/${task.app.Tasks}/${issue.space}/#${view.component.EditDoc}|${issue._id}|${issue._class}">Task-${issue.number}</a>`
return `<a href="${front}/${workbenchId}/${taskId}/${issue.space}/#${view.component.EditDoc}|${issue._id}|${issue._class}">Task-${issue.number}</a>`
}
/**