EQMS-1484: Fixed permission checks when sending a QMS document for approval from the Workflow Validation tab (#8628)

Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
Victor Ilyushchenko 2025-04-21 12:25:27 +03:00 committed by GitHub
parent 5423aa5047
commit d4517bbbdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts">
import documents from '@hcengineering/controlled-documents'
import documents, { ControlledDocumentState } from '@hcengineering/controlled-documents'
import { Label, Button, showPopup } from '@hcengineering/ui'
import TeamPopup from '../../TeamPopup.svelte'
@ -15,9 +15,12 @@
return
}
const isReviewed = $controlledDocument.controlledState === ControlledDocumentState.Reviewed
const teamPopupData: TeamPopupData = {
controlledDoc: $controlledDocument,
requestClass: documents.class.DocumentApprovalRequest
requestClass: documents.class.DocumentApprovalRequest,
requireSignature: !isReviewed
}
showPopup(TeamPopup, teamPopupData, 'center')

View File

@ -15,7 +15,8 @@
import documentsRes from '../../../plugin'
import {
$controlledDocument as controlledDocument,
$documentSnapshots as documentSnapshots
$documentSnapshots as documentSnapshots,
$isDocumentOwner as isDocumentOwner
} from '../../../stores/editors/document'
import DocumentApprovalGuideItem from './DocumentApprovalGuideItem.svelte'
import DocumentApprovalItem from './DocumentApprovalItem.svelte'
@ -61,7 +62,8 @@
ControlledDocumentState.Rejected,
ControlledDocumentState.InApproval
]
$: hasGuide = doc && doc.state === DocumentState.Draft && !noGuideStates.includes(doc.controlledState)
$: hasGuide =
doc && doc.state === DocumentState.Draft && !noGuideStates.includes(doc.controlledState) && $isDocumentOwner
</script>
<RightPanelTabHeader>

View File

@ -17,7 +17,14 @@ import { ControlledDocumentState, DocumentState } from '@hcengineering/controlle
import { TrainingState } from '@hcengineering/training'
import { combine } from 'effector'
import { $documentComments } from './documentComments'
import { $controlledDocument, $documentState, $isLatestVersion, $reviewRequestHistory, $training } from './editor'
import {
$controlledDocument,
$documentState,
$isDocumentOwner,
$isLatestVersion,
$reviewRequestHistory,
$training
} from './editor'
export const $canSendForApproval = combine(
$controlledDocument,
@ -26,7 +33,10 @@ export const $canSendForApproval = combine(
$documentComments,
$training,
$reviewRequestHistory,
(document, isLatestVersion, state, comments, training, reviewHistory) => {
$isDocumentOwner,
(document, isLatestVersion, state, comments, training, reviewHistory, isDocumentOwner) => {
if (!isDocumentOwner) return false
let haveBeenReviewedOnce = false
if (document !== null) {
const reviews = (reviewHistory ?? []).filter((review) => review.attachedTo === document._id)

View File

@ -15,10 +15,11 @@
import { DocumentState } from '@hcengineering/controlled-documents'
import { combine } from 'effector'
import { $documentState, $isLatestVersion } from './editor'
import { $documentState, $isDocumentOwner, $isLatestVersion } from './editor'
export const $canSendForReview = combine(
$isLatestVersion,
$documentState,
(isLatestVersion, state) => isLatestVersion && state === DocumentState.Draft
$isDocumentOwner,
(isLatestVersion, state, isDocumentOwner) => isLatestVersion && state === DocumentState.Draft && isDocumentOwner
)