Skip to content

Commit 84b1834

Browse files
2 parents c632e61 + ad50c88 commit 84b1834

File tree

11 files changed

+144
-21
lines changed

11 files changed

+144
-21
lines changed

desktop/src/ui/platform.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { recruitId } from '@hcengineering/recruit'
5858
import rekoni from '@hcengineering/rekoni'
5959
import { requestId } from '@hcengineering/request'
6060
import setting, { settingId } from '@hcengineering/setting'
61-
import { supportId } from '@hcengineering/support'
61+
import support, { supportId, supportLink, reportBugLink, docsLink, privacyPolicyLink } from '@hcengineering/support'
6262
import { surveyId } from '@hcengineering/survey'
6363
import { tagsId } from '@hcengineering/tags'
6464
import { taskId } from '@hcengineering/task'
@@ -401,6 +401,12 @@ export async function configurePlatform (onWorkbenchConnect?: () => Promise<void
401401

402402
setMetadata(billingPlugin.metadata.BillingURL, config.BILLING_URL ?? '')
403403
setMetadata(presentation.metadata.PaymentUrl, config.PAYMENT_URL ?? '')
404+
setMetadata(presentation.metadata.SignupUrl, config.SIGNUP_URL ?? 'https://huly.io/signup')
405+
406+
setMetadata(support.metadata.SupportLink, myBranding.support?.supportLink ?? supportLink)
407+
setMetadata(support.metadata.ReportBugLink, myBranding.support?.reportBugLink ?? reportBugLink)
408+
setMetadata(support.metadata.DocsLink, myBranding.support?.docsLink ?? docsLink)
409+
setMetadata(support.metadata.PrivacyPolicyLink, myBranding.support?.privacyPolicyLink ?? privacyPolicyLink)
404410

405411
const languages =
406412
myBranding.languages !== undefined && myBranding.languages !== ''

desktop/src/ui/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface Config {
7070
EXCLUDED_APPLICATIONS_FOR_ANONYMOUS?: string
7171
HULYLAKE_URL?: string
7272
DISABLED_FEATURES?: string
73+
SIGNUP_URL?: string
7374
}
7475

7576
export interface Branding {
@@ -80,6 +81,12 @@ export interface Branding {
8081
type?: string
8182
sizes?: string
8283
}[]
84+
support?: {
85+
supportLink?: string
86+
reportBugLink?: string
87+
docsLink?: string
88+
privacyPolicyLink?: string
89+
}
8390
languages?: string
8491
lastNameFirst?: string
8592
defaultLanguage?: string

dev/prod/src/platform.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import rekoni from '@hcengineering/rekoni'
5252
import { requestId } from '@hcengineering/request'
5353
import setting, { settingId } from '@hcengineering/setting'
5454
import sign from '@hcengineering/sign'
55-
import { supportId } from '@hcengineering/support'
55+
import support, { supportId, supportLink, reportBugLink, docsLink, privacyPolicyLink } from '@hcengineering/support'
5656
import { surveyId } from '@hcengineering/survey'
5757
import { tagsId } from '@hcengineering/tags'
5858
import { taskId } from '@hcengineering/task'
@@ -202,6 +202,7 @@ export interface Config {
202202
PULSE_URL?: string
203203
HULYLAKE_URL?: string
204204
DISABLED_FEATURES?: string
205+
SIGNUP_URL?: string
205206
}
206207

207208
export interface Branding {
@@ -212,6 +213,12 @@ export interface Branding {
212213
type?: string
213214
sizes?: string
214215
}>
216+
support?: {
217+
supportLink?: string
218+
reportBugLink?: string
219+
docsLink?: string
220+
privacyPolicyLink?: string
221+
}
215222
languages?: string
216223
lastNameFirst?: string
217224
defaultLanguage?: string
@@ -480,6 +487,7 @@ export async function configurePlatform() {
480487
setMetadata(presentation.metadata.StatsUrl, config.STATS_URL)
481488
setMetadata(presentation.metadata.LinkPreviewUrl, config.LINK_PREVIEW_URL)
482489
setMetadata(presentation.metadata.MailUrl, config.MAIL_URL)
490+
setMetadata(presentation.metadata.SignupUrl, config.SIGNUP_URL ?? 'https://huly.io/signup')
483491

484492
const disabledFeatures = (config.DISABLED_FEATURES ??'').split(',').map(it => it.trim()).filter(it => it.length > 0)
485493
setMetadata(presentation.metadata.DisabledFeatures, new Set(disabledFeatures))
@@ -527,6 +535,11 @@ export async function configurePlatform() {
527535
setMetadata(presentation.metadata.PulseUrl, config.PULSE_URL)
528536
setMetadata(presentation.metadata.HulylakeUrl, config.HULYLAKE_URL ?? '')
529537

538+
setMetadata(support.metadata.SupportLink, myBranding.support?.supportLink ?? supportLink)
539+
setMetadata(support.metadata.ReportBugLink, myBranding.support?.reportBugLink ?? reportBugLink)
540+
setMetadata(support.metadata.DocsLink, myBranding.support?.docsLink ?? docsLink)
541+
setMetadata(support.metadata.PrivacyPolicyLink, myBranding.support?.privacyPolicyLink ?? privacyPolicyLink)
542+
530543
const languages = myBranding.languages
531544
? myBranding.languages.split(',').map((l) => l.trim())
532545
: ['en', 'ru', 'es', 'pt', 'zh', 'fr', 'cs', 'it', 'de', 'ja', 'tr']

packages/presentation/src/plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ export default plugin(presentationId, {
187187
PreviewUrl: '' as Metadata<string>,
188188
PulseUrl: '' as Metadata<string>,
189189
HulylakeUrl: '' as Metadata<string>,
190-
PaymentUrl: '' as Metadata<string>
190+
PaymentUrl: '' as Metadata<string>,
191+
SignupUrl: '' as Metadata<string>
191192
},
192193
status: {
193194
FileTooLarge: '' as StatusCode

plugins/card-resources/src/components/settings/view/ViewSetting.svelte

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<script lang="ts">
1616
import { createEventDispatcher } from 'svelte'
1717
18-
import core, { AnyAttribute, Class, Doc, Ref, Type } from '@hcengineering/core'
19-
import { Asset, IntlString } from '@hcengineering/platform'
18+
import core, { AnyAttribute, Association, AssociationQuery, Class, Doc, Ref, Type } from '@hcengineering/core'
19+
import { Asset, getEmbeddedLabel, IntlString } from '@hcengineering/platform'
2020
import { getAttributePresenterClass, getClient, hasResource } from '@hcengineering/presentation'
2121
import { resizeObserver } from '@hcengineering/ui'
2222
import view, { BuildModelKey, Viewlet, ViewletPreference } from '@hcengineering/view'
@@ -203,8 +203,25 @@
203203
})
204204
})
205205
206-
const ancestors = new Set(hierarchy.getAncestors(viewlet.attachTo))
207-
const parent = hierarchy.getParentClass(viewlet.attachTo)
206+
const desc = hierarchy.getDescendants(viewlet.attachTo)
207+
for (const d of desc) {
208+
if (!hierarchy.isMixin(d)) continue
209+
hierarchy.getOwnAttributes(d).forEach((attr) => {
210+
processAttribute(attr, result, true)
211+
})
212+
}
213+
214+
addAssociations(result, viewlet.attachTo, preference)
215+
}
216+
217+
function addAssociations (
218+
result: Config[],
219+
_class: Ref<Class<Doc>>,
220+
preference: ViewletPreference | undefined,
221+
parents: AssociationQuery[] = []
222+
): void {
223+
const ancestors = new Set(hierarchy.getAncestors(_class))
224+
const parent = hierarchy.getParentClass(_class)
208225
const parentMixins = hierarchy
209226
.getDescendants(parent)
210227
.map((p) => hierarchy.getClass(p))
@@ -215,6 +232,72 @@
215232
processAttribute(attr, result, true)
216233
})
217234
})
235+
236+
const allClasses = [...ancestors, ...parentMixins.map((it) => it._id)]
237+
238+
const associationsB = client.getModel().findAllSync(core.class.Association, { classA: { $in: allClasses } })
239+
const associationsA = client.getModel().findAllSync(core.class.Association, { classB: { $in: allClasses } })
240+
241+
associationsB.forEach((a) => {
242+
processAssociation(a, 'b', result, preference, parents)
243+
})
244+
associationsA.forEach((a) => {
245+
processAssociation(a, 'a', result, preference, parents)
246+
})
247+
}
248+
249+
function getParentsString (parents: AssociationQuery[]): string {
250+
return parents.map(([assocId, direction]) => `$associations.${assocId}_${direction === 1 ? 'a' : 'b'}`).join('.')
251+
}
252+
253+
function processAssociation (
254+
association: Association,
255+
direction: 'a' | 'b',
256+
result: Config[],
257+
preference: ViewletPreference | undefined,
258+
parents: AssociationQuery[]
259+
): void {
260+
const associationName = `$associations.${association._id}_${direction}`
261+
const resultName = parents.length > 0 ? `${getParentsString(parents)}.${associationName}` : associationName
262+
263+
const name = direction === 'a' ? association.nameA : association.nameB
264+
const targetClass = direction === 'a' ? association.classA : association.classB
265+
266+
if (name.trim().length === 0) return
267+
const model = client.getModel()
268+
269+
const resultLabels = parents
270+
.map((r) => {
271+
const assoc = model.findObject(r[0])
272+
if (assoc === undefined) return ''
273+
return r[1] === 1 ? assoc.nameA : assoc.nameB
274+
})
275+
.filter((it) => it.length > 0)
276+
resultLabels.push(name)
277+
const fullLabel = resultLabels.join('')
278+
279+
const clazz = hierarchy.getClass(targetClass)
280+
const newValue: AttributeConfig = {
281+
type: 'attribute',
282+
value: resultName,
283+
label: getEmbeddedLabel(fullLabel),
284+
enabled: false,
285+
_class: targetClass,
286+
icon: clazz.icon
287+
}
288+
289+
if (!isExist(result, newValue)) {
290+
result.push(newValue)
291+
}
292+
293+
if (preference === undefined) return
294+
const exists = preference.config.find((p) => {
295+
const key = typeof p === 'string' ? p : p.key
296+
return key === resultName
297+
})
298+
if (exists) {
299+
addAssociations(result, targetClass, preference, [...parents, [association._id, direction === 'a' ? 1 : -1]])
300+
}
218301
}
219302
220303
return preference === undefined ? result : []

plugins/card-resources/src/exporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async function exportType (
159159
required.push(...at.required)
160160
}
161161

162-
if (!withoutDesc || _id === card.class.Card) {
162+
if (!withoutDesc && _id !== card.class.Card) {
163163
const descendants = h.getDescendants(_id)
164164
for (const desc of descendants) {
165165
if (h.getClass(desc).extends !== _id) continue

plugins/support/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import { Class, Ref } from '@hcengineering/core'
1717
import type { Asset, IntlString, Plugin, Resource } from '@hcengineering/platform'
18-
import { plugin } from '@hcengineering/platform'
18+
import { plugin, Metadata } from '@hcengineering/platform'
1919
import { SupportClientFactory, SupportConversation, SupportSystem } from './types'
2020

2121
export * from './types'
@@ -42,6 +42,12 @@ export default plugin(supportId, {
4242
icon: {
4343
Support: '' as Asset
4444
},
45+
metadata: {
46+
SupportLink: '' as Metadata<string>,
47+
ReportBugLink: '' as Metadata<string>,
48+
DocsLink: '' as Metadata<string>,
49+
PrivacyPolicyLink: '' as Metadata<string>
50+
},
4551
string: {
4652
ContactUs: '' as IntlString,
4753
ReportBug: '' as IntlString,

plugins/view-resources/src/components/ReadOnlyNotification.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script lang="ts">
2+
import { getMetadata } from '@hcengineering/platform'
23
import { Button, navigate, Notification, NotificationToast } from '@hcengineering/ui'
34
import view from '@hcengineering/view'
4-
import { getCurrentWorkspaceUrl } from '@hcengineering/presentation'
5+
import presentation, { getCurrentWorkspaceUrl } from '@hcengineering/presentation'
56
import { allowGuestSignUpStore } from '../utils'
67
78
export let onRemove: () => void
@@ -22,7 +23,7 @@
2223
{#if $allowGuestSignUpStore}
2324
<Button label={view.string.ReadOnlyJoinWorkspace} stopPropagation={false} on:click={joinWorkspace} />
2425
{/if}
25-
<a href="https://huly.io/signup" target="_blank">
26+
<a href={getMetadata(presentation.metadata.SignupUrl)} target="_blank">
2627
<Button label={view.string.ReadOnlySignUp} stopPropagation={false} kind="primary" />
2728
</a>
2829
</div>

plugins/workbench-resources/src/components/AccountPopup.svelte

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
import core, { AccountRole, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
1919
import rating, { type PersonRating } from '@hcengineering/rating'
2020
import login, { loginId } from '@hcengineering/login'
21-
import { createQuery, getCurrentWorkspaceUrl, hasResource, isDisabled } from '@hcengineering/presentation'
21+
import presentation, {
22+
createQuery,
23+
getCurrentWorkspaceUrl,
24+
hasResource,
25+
isDisabled
26+
} from '@hcengineering/presentation'
2227
import setting, { settingId, SettingsCategory } from '@hcengineering/setting'
2328
import {
2429
Action,
@@ -37,7 +42,7 @@
3742
import HelpAndSupport from './HelpAndSupport.svelte'
3843
import { Analytics } from '@hcengineering/analytics'
3944
import { allowGuestSignUpStore } from '@hcengineering/view-resources'
40-
import { getClient } from '@hcengineering/account-client'
45+
import { getMetadata } from '@hcengineering/platform'
4146
4247
let items: SettingsCategory[] = []
4348
@@ -179,7 +184,7 @@
179184
icon: setting.icon.InviteWorkspace,
180185
label: view.string.ReadOnlySignUp,
181186
action: async () => {
182-
open('https://huly.io/signup')
187+
open(getMetadata(presentation.metadata.SignupUrl))
183188
},
184189
group: 'end'
185190
})

plugins/workbench-resources/src/components/HelpAndSupport.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
// limitations under the License.
1414
-->
1515
<script lang="ts">
16-
import { Asset, IntlString } from '@hcengineering/platform'
16+
import { Asset, getMetadata, IntlString } from '@hcengineering/platform'
1717
import { getClient } from '@hcengineering/presentation'
1818
import setting, { settingId } from '@hcengineering/setting'
19-
import support, { docsLink, reportBugLink, supportLink, privacyPolicyLink } from '@hcengineering/support'
19+
import support from '@hcengineering/support'
2020
import {
2121
AnySvelteComponent,
2222
Button,
@@ -95,7 +95,7 @@
9595
title: workbench.string.Documentation,
9696
description: workbench.string.OpenPlatformGuide,
9797
onClick: () => {
98-
window.open(docsLink, '_blank')
98+
window.open(getMetadata(support.metadata.DocsLink), '_blank')
9999
Analytics.handleEvent(WorkbenchEvents.DocumentationOpened)
100100
}
101101
},
@@ -203,13 +203,13 @@
203203
</Scroller>
204204
{/if}
205205
<div class="footer">
206-
<a href={privacyPolicyLink} target="_blank">
206+
<a href={getMetadata(support.metadata.PrivacyPolicyLink)} target="_blank">
207207
<Button id="privacy-policy" kind={'ghost'} label={support.string.PrivacyPolicy} stopPropagation={false} />
208208
</a>
209-
<a href={reportBugLink} target="_blank">
209+
<a href={getMetadata(support.metadata.ReportBugLink)} target="_blank">
210210
<Button id="report-a-bug" kind={'primary'} label={support.string.ReportBug} stopPropagation={false} />
211211
</a>
212-
<a href={supportLink}>
212+
<a href={getMetadata(support.metadata.SupportLink)} target="_blank">
213213
<Button
214214
id="contact-us"
215215
icon={support.icon.Support}

0 commit comments

Comments
 (0)