diff --git a/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOPS.js b/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOPS.js index ed635faf0..11874789e 100644 --- a/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOPS.js +++ b/src/pages/workflow/composables/useWorkflowConfig/workflowConfigEditorialOPS.js @@ -1,11 +1,15 @@ import {useLocalize} from '@/composables/useLocalize'; -import {Actions} from '../useWorkflowActions'; +import {Actions as WorkflowActions} from '../useWorkflowActions'; import {useSubmission} from '@/composables/useSubmission'; import {Actions as DecisionActions} from '../useWorkflowDecisions'; import {addItemIf} from './workflowConfigHelpers'; +import {useCurrentUser} from '@/composables/useCurrentUser'; const {hasSubmissionPassedStage, isDecisionAvailable, getActiveStage} = useSubmission(); + +const {hasCurrentUserAtLeastOneAssignedRoleInAnyStage} = useCurrentUser(); + const {t} = useLocalize(); export function getHeaderItems({ @@ -25,7 +29,7 @@ export function getHeaderItems({ component: 'WorkflowActionButton', props: { label: t('common.view'), - action: Actions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION, + action: WorkflowActions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION, }, }); } @@ -35,7 +39,7 @@ export function getHeaderItems({ component: 'WorkflowActionButton', props: { label: t('editor.activityLog'), - action: Actions.WORKFLOW_VIEW_ACTIVITY_LOG, + action: WorkflowActions.WORKFLOW_VIEW_ACTIVITY_LOG, }, }); } @@ -43,7 +47,7 @@ export function getHeaderItems({ component: 'WorkflowActionButton', props: { label: t('editor.submissionLibrary'), - action: Actions.WORKFLOW_VIEW_LIBRARY, + action: WorkflowActions.WORKFLOW_VIEW_LIBRARY, }, }); @@ -118,6 +122,27 @@ export const WorkflowConfig = { ), ); + // Delete submission + addItemIf( + items, + { + component: 'WorkflowActionButton', + props: { + label: t('common.delete'), + isWarnable: true, + action: WorkflowActions.WORKFLOW_DELETE_SUBMISSION, + }, + }, + isDecisionAvailable( + submission, + pkp.const.DECISION_REVERT_INITIAL_DECLINE, + ) && + hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [ + pkp.const.ROLE_ID_MANAGER, + pkp.const.ROLE_ID_SITE_ADMIN, + ]), + ); + return items; }, }, @@ -188,7 +213,7 @@ export const PublicationConfig = { props: { label: t('common.preview'), isSecondary: true, - action: Actions.WORKFLOW_PREVIEW_PUBLICATION, + action: WorkflowActions.WORKFLOW_PREVIEW_PUBLICATION, }, }); } @@ -200,7 +225,7 @@ export const PublicationConfig = { label: t('publication.publish'), isSecondary: true, - action: Actions.WORKFLOW_SCHEDULE_FOR_PUBLICATION, + action: WorkflowActions.WORKFLOW_SCHEDULE_FOR_PUBLICATION, }, }); } else if (selectedPublication.status === pkp.const.STATUS_SCHEDULED) { @@ -209,7 +234,7 @@ export const PublicationConfig = { props: { label: t('dashboard.summary.preview'), isSecondary: true, - action: Actions.WORKFLOW_PREVIEW_PUBLICATION, + action: WorkflowActions.WORKFLOW_PREVIEW_PUBLICATION, }, }); @@ -218,7 +243,7 @@ export const PublicationConfig = { props: { label: t('publication.unschedule'), isWarnable: true, - action: Actions.WORKFLOW_UNSCHEDULE_PUBLICATION, + action: WorkflowActions.WORKFLOW_UNSCHEDULE_PUBLICATION, }, }); } else if (selectedPublication.status === pkp.const.STATUS_PUBLISHED) { @@ -227,7 +252,7 @@ export const PublicationConfig = { props: { label: t('publication.unpublish'), isWarnable: true, - action: Actions.WORKFLOW_UNPUBLISH_PUBLICATION, + action: WorkflowActions.WORKFLOW_UNPUBLISH_PUBLICATION, }, }); @@ -240,7 +265,7 @@ export const PublicationConfig = { props: { label: t('publication.createVersion'), isSecondary: true, - action: Actions.WORKFLOW_CREATE_NEW_VERSION, + action: WorkflowActions.WORKFLOW_CREATE_NEW_VERSION, }, }); }