UBERF-4815 (#4299)

* UBERF-4815

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>

* Fix

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>

* Fix formatting

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>

* Fix

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>

---------

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-01-04 16:37:11 +06:00 committed by GitHub
parent b43231b78e
commit e43783da94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 17 deletions

View File

@ -32,11 +32,13 @@ export class ConfigurationManager {
return this.configuration.get(plugin)?.enabled !== false
}
hasResource<T>(resource?: Resource<T> | null): boolean {
hasResource<T>(resource?: Resource<T> | null): boolean | undefined {
if (resource == null) {
return false
}
return this.has(getResourcePlugin(resource))
try {
return this.has(getResourcePlugin(resource))
} catch {}
}
}
// Issue status live query
@ -51,7 +53,7 @@ let workspaceId: string = ''
/**
* @public
*/
export function hasResource<T> (resource?: Resource<T>): boolean {
export function hasResource<T> (resource?: Resource<T>): boolean | undefined {
return configuration.hasResource(resource)
}

View File

@ -15,11 +15,12 @@
<script lang="ts">
import { Ref, generateId } from '@hcengineering/core'
import { Card, getClient } from '@hcengineering/presentation'
import { Card, getClient, hasResource } from '@hcengineering/presentation'
import { ProjectTypeDescriptor, createProjectType } from '@hcengineering/task'
import { DropdownLabelsIntl, EditBox, ToggleWithLabel } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import task from '../../plugin'
import { Resource } from '@hcengineering/platform'
const client = getClient()
@ -49,7 +50,10 @@
dispatch('close')
}
const descriptors = client.getModel().findAllSync(task.class.ProjectTypeDescriptor, {})
const descriptors = client
.getModel()
.findAllSync(task.class.ProjectTypeDescriptor, {})
.filter((p) => hasResource(p._id as any as Resource<any>))
const items = descriptors.map((it) => ({
label: it.name,
id: it._id

View File

@ -18,9 +18,10 @@
import task, { ProjectType } from '@hcengineering/task'
import { Location, getCurrentResolvedLocation, navigate, resolvedLocationStore } from '@hcengineering/ui'
import { createQuery } from '@hcengineering/presentation'
import { createQuery, hasResource } from '@hcengineering/presentation'
import { onDestroy } from 'svelte'
import Types from './Types.svelte'
import { Resource } from '@hcengineering/platform'
export let kind: 'navigation' | 'tools' | undefined
export let categoryName: string
@ -50,7 +51,7 @@
task.class.ProjectType,
{ archived: false },
(result) => {
types = result
types = result.filter((p) => hasResource(p.descriptor as any as Resource<any>))
},
{
lookup: {

View File

@ -14,8 +14,8 @@
-->
<script lang="ts">
import core, { Class, ClassifierKind, Data, Ref, RefTo, Status, generateId, toIdMap } from '@hcengineering/core'
import { getEmbeddedLabel } from '@hcengineering/platform'
import presentation, { Card, getClient } from '@hcengineering/presentation'
import { Resource, getEmbeddedLabel } from '@hcengineering/platform'
import presentation, { Card, getClient, hasResource } from '@hcengineering/presentation'
import {
ProjectType,
ProjectTypeDescriptor,
@ -57,7 +57,10 @@
}
}
const taskTypeDescriptors = client.getModel().findAllSync(task.class.TaskTypeDescriptor, { allowCreate: true })
const taskTypeDescriptors = client
.getModel()
.findAllSync(task.class.TaskTypeDescriptor, { allowCreate: true })
.filter((p) => hasResource(p._id as any as Resource<any>))
let { kind, name, targetClass, statusCategories, statuses, allowedAsChildOf } =
taskType !== undefined ? { ...taskType } : { ...defaultTaskType(type) }

View File

@ -219,8 +219,10 @@
}
async function getHeaderEditor (_class: Ref<Class<Doc>>): Promise<AnyComponent | undefined> {
const editorMixin = hierarchy.classHierarchyMixin(_class, view.mixin.ObjectEditorHeader, (m) =>
hasResource(m.editor)
const editorMixin = hierarchy.classHierarchyMixin(
_class,
view.mixin.ObjectEditorHeader,
(m) => hasResource(m.editor) ?? false
)
return editorMixin?.editor
}

View File

@ -176,7 +176,11 @@
: category === 'collection'
? view.mixin.CollectionPresenter
: view.mixin.AttributePresenter
const presenter = hierarchy.classHierarchyMixin(attrClass, mixin, (m) => hasResource(m.presenter))?.presenter
const presenter = hierarchy.classHierarchyMixin(
attrClass,
mixin,
(m) => hasResource(m.presenter) ?? false
)?.presenter
if (presenter === undefined) return
const clazz = hierarchy.getClass(attribute.attributeOf)
const extraProps = viewlet.configOptions?.extraProps

View File

@ -103,7 +103,11 @@ export async function getObjectPresenter (
const mixin = isCollectionAttr ? view.mixin.CollectionPresenter : view.mixin.ObjectPresenter
const clazz = hierarchy.getClass(_class)
const presenterMixin = hierarchy.classHierarchyMixin(_class, mixin, (m) => !checkResource || hasResource(m.presenter))
const presenterMixin = hierarchy.classHierarchyMixin(
_class,
mixin,
(m) => !checkResource || hasResource(m.presenter) === true
)
if (presenterMixin?.presenter === undefined) {
console.error(
`object presenter not found for class=${_class}, mixin=${mixin}, preserve key ${JSON.stringify(preserveKey)}`
@ -895,8 +899,10 @@ export async function getObjectLinkFragment (
props: Record<string, any> = {},
component: AnyComponent = view.component.EditDoc
): Promise<Location> {
const provider = hierarchy.classHierarchyMixin(Hierarchy.mixinOrClass(object), view.mixin.LinkProvider, (m) =>
hasResource(m.encode)
const provider = hierarchy.classHierarchyMixin(
Hierarchy.mixinOrClass(object),
view.mixin.LinkProvider,
(m) => hasResource(m.encode) ?? false
)
if (provider?.encode !== undefined) {
const f = await getResource(provider.encode)
@ -906,7 +912,7 @@ export async function getObjectLinkFragment (
}
}
const loc = getCurrentResolvedLocation()
if (hasResource(component)) {
if (hasResource(component) === true) {
loc.fragment = getPanelURI(component, object._id, Hierarchy.mixinOrClass(object), 'content')
}
return loc