From f1a841d9472d7eff84fda074f2847b688367bb3c Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Mon, 16 Mar 2026 12:26:16 +0500 Subject: [PATCH 1/3] move RequestsCardSection visibility check into the component. Signed-off-by: Denis Bykhov --- models/process/src/index.ts | 1 - .../src/components/RequestsCardSection.svelte | 22 ++++++++++++++++++- plugins/process-resources/src/index.ts | 2 -- plugins/process-resources/src/utils.ts | 6 ----- plugins/process/src/index.ts | 3 +-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/models/process/src/index.ts b/models/process/src/index.ts index 0db367ced1d..6ba0a1ab06c 100644 --- a/models/process/src/index.ts +++ b/models/process/src/index.ts @@ -734,7 +734,6 @@ export function createModel (builder: Builder): void { { label: process.string.ApproveRequest, component: process.component.RequestsCardSection, - checkVisibility: process.function.CheckRequestsSectionVisibility, order: 360, navigation: [] }, diff --git a/plugins/process-resources/src/components/RequestsCardSection.svelte b/plugins/process-resources/src/components/RequestsCardSection.svelte index 2b45ff4d1b1..519d6ac58aa 100644 --- a/plugins/process-resources/src/components/RequestsCardSection.svelte +++ b/plugins/process-resources/src/components/RequestsCardSection.svelte @@ -14,14 +14,34 @@ --> -{#if !hidden} +{#if !hidden && hasRequests}
diff --git a/plugins/process-resources/src/index.ts b/plugins/process-resources/src/index.ts index 86a92ac8dec..9d71ad96fb0 100644 --- a/plugins/process-resources/src/index.ts +++ b/plugins/process-resources/src/index.ts @@ -101,7 +101,6 @@ import { approveRequestApproved, approveRequestRejected, checkProcessSectionVisibility, - checkRequestsSectionVisibility, continueExecution, eventCheck, fieldChangesCheck, @@ -224,7 +223,6 @@ export default async (): Promise => ({ ImportProcess: importProcess, ShowDoneQuery: showDoneQuery, CheckProcessSectionVisibility: checkProcessSectionVisibility, - CheckRequestsSectionVisibility: checkRequestsSectionVisibility, // eslint-disable-next-line @typescript-eslint/unbound-method CreateMiddleware: ProcessMiddleware.create } diff --git a/plugins/process-resources/src/utils.ts b/plugins/process-resources/src/utils.ts index 4eea85593ea..006289a13e8 100644 --- a/plugins/process-resources/src/utils.ts +++ b/plugins/process-resources/src/utils.ts @@ -877,9 +877,3 @@ export async function checkProcessSectionVisibility (doc: Card): Promise 0 } - -export async function checkRequestsSectionVisibility (doc: Card): Promise { - const client = getClient() - const requests = await client.findOne(process.class.ApproveRequest, { card: doc._id }) - return requests !== undefined -} diff --git a/plugins/process/src/index.ts b/plugins/process/src/index.ts index e4fa55020ff..bbf9224e6bf 100644 --- a/plugins/process/src/index.ts +++ b/plugins/process/src/index.ts @@ -375,7 +375,6 @@ export default plugin(processId, { EmptyArray: '' as Ref, CurrentDate: '' as Ref, ExportProcess: '' as Resource, - CheckProcessSectionVisibility: '' as Resource<(doc: Card) => Promise>, - CheckRequestsSectionVisibility: '' as Resource<(doc: Card) => Promise> + CheckProcessSectionVisibility: '' as Resource<(doc: Card) => Promise> } }) From b21b01d24f2ca2a0953c602a980723fb9c4761ea Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Mon, 16 Mar 2026 12:48:41 +0500 Subject: [PATCH 2/3] Hide card activity for guests Signed-off-by: Denis Bykhov --- .../src/components/EditCardNewContent.svelte | 4 ++-- plugins/card-resources/src/utils.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/card-resources/src/components/EditCardNewContent.svelte b/plugins/card-resources/src/components/EditCardNewContent.svelte index 6a94fbd19e9..47b139b5c30 100644 --- a/plugins/card-resources/src/components/EditCardNewContent.svelte +++ b/plugins/card-resources/src/components/EditCardNewContent.svelte @@ -17,7 +17,7 @@ import { Card } from '@hcengineering/card' import communication from '@hcengineering/communication' import { NotificationContext } from '@hcengineering/communication-types' - import { Ref } from '@hcengineering/core' + import { AccountRole, getCurrentAccount, hasAccountRole, Ref } from '@hcengineering/core' import { resizeObserver } from '@hcengineering/ui' import { MessageInput } from '@hcengineering/communication-resources' @@ -57,7 +57,7 @@ {/key} {/if} -{#if !readonly && getMetadata(communication.metadata.Enabled) === true} +{#if !readonly && getMetadata(communication.metadata.Enabled) === true && hasAccountRole(getCurrentAccount(), AccountRole.User)}
{ + if (!hasAccountRole(getCurrentAccount(), AccountRole.User)) { + return false + } + return getMetadata(communication.metadata.Enabled) !== true } export async function checkCommunicationMessagesSectionVisibility (doc: Card): Promise { + if (!hasAccountRole(getCurrentAccount(), AccountRole.User)) { + return false + } + return getMetadata(communication.metadata.Enabled) === true } From 78c3d5cd7e8b2de6a118ea86d175580bbf99ee98 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Mon, 16 Mar 2026 13:51:37 +0500 Subject: [PATCH 3/3] Fix formatting Signed-off-by: Denis Bykhov --- .../src/components/RequestsCardSection.svelte | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/plugins/process-resources/src/components/RequestsCardSection.svelte b/plugins/process-resources/src/components/RequestsCardSection.svelte index 519d6ac58aa..51d11b6e33a 100644 --- a/plugins/process-resources/src/components/RequestsCardSection.svelte +++ b/plugins/process-resources/src/components/RequestsCardSection.svelte @@ -27,13 +27,9 @@ $: { if (doc) { - query.query( - process.class.ApproveRequest, - { card: doc._id }, - (res) => { - hasRequests = res.length > 0 - } - ) + query.query(process.class.ApproveRequest, { card: doc._id }, (res) => { + hasRequests = res.length > 0 + }) } else { query.unsubscribe() hasRequests = false