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/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 } diff --git a/plugins/process-resources/src/components/RequestsCardSection.svelte b/plugins/process-resources/src/components/RequestsCardSection.svelte index 2b45ff4d1b1..51d11b6e33a 100644 --- a/plugins/process-resources/src/components/RequestsCardSection.svelte +++ b/plugins/process-resources/src/components/RequestsCardSection.svelte @@ -14,14 +14,30 @@ --> -{#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> } })