Skip to content

Commit

Permalink
pkp/pkp-lib#10767 Refine Top controls on workflow page
Browse files Browse the repository at this point in the history
  • Loading branch information
jardakotesovec committed Jan 8, 2025
1 parent fde64d3 commit 7a3a2de
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useLocalize} from '@/composables/useLocalize';
import {Actions} from '../useWorkflowActions';
import {Actions as WorkflowActions} from '../useWorkflowActions';
import {Actions as FileManagerActions} from '@/managers/FileManager/useFileManagerActions';
import {useSubmission} from '@/composables/useSubmission';

const {
Expand All @@ -25,7 +26,7 @@ export function getHeaderItems({
component: 'WorkflowActionButton',
props: {
label: t('editor.submissionLibrary'),
action: Actions.WORKFLOW_VIEW_LIBRARY,
action: WorkflowActions.WORKFLOW_VIEW_LIBRARY,
},
});

Expand Down Expand Up @@ -159,9 +160,37 @@ export const WorkflowConfig = {

return items;
},
getActionItems: ({submission, selectedReviewRound}) => {
const actions = [];

if (
[
pkp.const.REVIEW_ROUND_STATUS_REVISIONS_REQUESTED,
pkp.const.REVIEW_ROUND_STATUS_RESUBMIT_FOR_REVIEW,
pkp.const.REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED,
pkp.const.REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED,
].includes(selectedReviewRound.statusId)
)
actions.push({
component: 'WorkflowActionButton',
props: {
action: FileManagerActions.FILE_UPLOAD,
label: t('dashboard.submitRevisions'),
actionArgs: {
submissionId: submission.id,
fileStage: pkp.const.SUBMISSION_FILE_REVIEW_REVISION,
reviewRoundId: selectedReviewRound.id,
wizardTitleKey: 'editor.submissionReview.uploadFile',
submissionStageId: pkp.const.WORKFLOW_STAGE_ID_EXTERNAL_REVIEW,
},
},
});
return actions;
},
},

[pkp.const.WORKFLOW_STAGE_ID_EDITING]: {
getPrimaryItems: ({submission, selectedStageId, selectedReviewRound}) => {
getPrimaryItems: ({submission, selectedStageId}) => {
const items = [];

items.push({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useLocalize} from '@/composables/useLocalize';
import {Actions} from '../useWorkflowActions';
import {useSubmission} from '@/composables/useSubmission';
import {Actions as FileManagerActions} from '@/managers/FileManager/useFileManagerActions';

const {hasSubmissionPassedStage, getOpenReviewAssignmentsForRound} =
useSubmission();
Expand Down Expand Up @@ -98,6 +99,34 @@ export const WorkflowConfig = {

return items;
},
getActionItems: ({submission, selectedReviewRound}) => {
const actions = [];
const {t} = useLocalize();

if (
[
pkp.const.REVIEW_ROUND_STATUS_REVISIONS_REQUESTED,
pkp.const.REVIEW_ROUND_STATUS_RESUBMIT_FOR_REVIEW,
pkp.const.REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED,
pkp.const.REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED,
].includes(selectedReviewRound.statusId)
)
actions.push({
component: 'WorkflowActionButton',
props: {
action: FileManagerActions.FILE_UPLOAD,
label: t('dashboard.submitRevisions'),
actionArgs: {
submissionId: submission.id,
fileStage: pkp.const.SUBMISSION_FILE_INTERNAL_REVIEW_REVISION,
reviewRoundId: selectedReviewRound.id,
wizardTitleKey: 'editor.submissionReview.uploadFile',
submissionStageId: pkp.const.WORKFLOW_STAGE_ID_INTERNAL_REVIEW,
},
},
});
return actions;
},
},
[pkp.const.WORKFLOW_STAGE_ID_EDITING]: {
getPrimaryItems: ({submission, selectedStageId, selectedReviewRound}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {useLocalize} from '@/composables/useLocalize';
import {Actions} from '../useWorkflowActions';
import {useSubmission} from '@/composables/useSubmission';
import {useCurrentUser} from '@/composables/useCurrentUser';

Expand Down Expand Up @@ -42,7 +41,7 @@ export function getHeaderItems({
component: 'WorkflowActionButton',
props: {
label: t('common.view'),
action: Actions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION,
action: WorkflowActions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION,
},
});
}
Expand All @@ -56,7 +55,7 @@ export function getHeaderItems({
component: 'WorkflowActionButton',
props: {
label: t('common.preview'),
action: Actions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION,
action: WorkflowActions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION,
},
});
}
Expand All @@ -66,15 +65,15 @@ export function getHeaderItems({
component: 'WorkflowActionButton',
props: {
label: t('editor.activityLog'),
action: Actions.WORKFLOW_VIEW_ACTIVITY_LOG,
action: WorkflowActions.WORKFLOW_VIEW_ACTIVITY_LOG,
},
});
}
actions.push({
component: 'WorkflowActionButton',
props: {
label: t('editor.submissionLibrary'),
action: Actions.WORKFLOW_VIEW_LIBRARY,
action: WorkflowActions.WORKFLOW_VIEW_LIBRARY,
},
});

Expand Down Expand Up @@ -710,7 +709,7 @@ export const PublicationConfig = {
props: {
label: t('common.preview'),
isSecondary: true,
action: Actions.WORKFLOW_PREVIEW_PUBLICATION,
action: WorkflowActions.WORKFLOW_PREVIEW_PUBLICATION,
},
});
}
Expand All @@ -726,7 +725,7 @@ export const PublicationConfig = {
: t('editor.submission.schedulePublication'),
isSecondary: true,
action:
Actions.WORKFLOW_ASSIGN_TO_ISSUE_AND_SCHEDULE_FOR_PUBLICATION,
WorkflowActions.WORKFLOW_ASSIGN_TO_ISSUE_AND_SCHEDULE_FOR_PUBLICATION,
},
});
} else if (selectedPublication.status === pkp.const.STATUS_SCHEDULED) {
Expand All @@ -735,7 +734,7 @@ export const PublicationConfig = {
props: {
label: t('common.preview'),
isSecondary: true,
action: Actions.WORKFLOW_PREVIEW_PUBLICATION,
action: WorkflowActions.WORKFLOW_PREVIEW_PUBLICATION,
},
});

Expand All @@ -744,7 +743,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) {
Expand All @@ -753,7 +752,7 @@ export const PublicationConfig = {
props: {
label: t('publication.unpublish'),
isWarnable: true,
action: Actions.WORKFLOW_UNPUBLISH_PUBLICATION,
action: WorkflowActions.WORKFLOW_UNPUBLISH_PUBLICATION,
},
});

Expand All @@ -766,7 +765,7 @@ export const PublicationConfig = {
props: {
label: t('publication.createVersion'),
isSecondary: true,
action: Actions.WORKFLOW_CREATE_NEW_VERSION,
action: WorkflowActions.WORKFLOW_CREATE_NEW_VERSION,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@ export function getHeaderItems({
return [];
}
const {t} = useLocalize();
const items = [];

items.push({
component: 'WorkflowWorkTypeOMP',
props: {
submission: submission,
},
});
const actions = [];

if (submission.status === pkp.const.STATUS_PUBLISHED) {
items.push({
actions.push({
component: 'WorkflowActionButton',
props: {
label: t('common.view'),
Expand All @@ -40,24 +33,45 @@ export function getHeaderItems({
});
}

if (
submission.status !== pkp.const.STATUS_PUBLISHED &&
(submission.stageId === pkp.const.WORKFLOW_STAGE_ID_EDITING ||
submission.stageId === pkp.const.WORKFLOW_STAGE_ID_PRODUCTION)
) {
actions.push({
component: 'WorkflowActionButton',
props: {
label: t('common.preview'),
action: WorkflowActions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION,
},
});
}

if (permissions.canAccessEditorialHistory) {
items.push({
actions.push({
component: 'WorkflowActionButton',
props: {
label: t('editor.activityLog'),
action: WorkflowActions.WORKFLOW_VIEW_ACTIVITY_LOG,
},
});
}
items.push({
actions.push({
component: 'WorkflowActionButton',
props: {
label: t('editor.submissionLibrary'),
action: WorkflowActions.WORKFLOW_VIEW_LIBRARY,
},
});

return items;
actions.push({
component: 'WorkflowWorkTypeOMP',
props: {
submission: submission,
},
});

return actions;
}

export const WorkflowConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ export function getHeaderItems({
});
}

if (
submission.status !== pkp.const.STATUS_PUBLISHED &&
(submission.stageId === pkp.const.WORKFLOW_STAGE_ID_EDITING ||
submission.stageId === pkp.const.WORKFLOW_STAGE_ID_PRODUCTION)
) {
actions.push({
component: 'WorkflowActionButton',
props: {
label: t('common.preview'),
action: WorkflowActions.WORKFLOW_VIEW_PUBLISHED_SUBMISSION,
},
});
}

if (permissions.canAccessEditorialHistory) {
actions.push({
component: 'WorkflowActionButton',
Expand Down
27 changes: 27 additions & 0 deletions src/pages/workflow/workflowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
Actions as DecisionActions,
} from './composables/useWorkflowDecisions';

import {useFileManagerActions} from '@/managers/FileManager/useFileManagerActions';

import {useDataChangedProvider} from '@/composables/useDataChangedProvider';

import {wrapActionFns} from '@/utils/wrapActionFns';
Expand Down Expand Up @@ -149,6 +151,26 @@ export const useWorkflowStore = defineComponentStore(
}),
);

/**
* File Manager actions
*/
/**
* File Manager actions
*/
const _fileManagerActionFns = useFileManagerActions();

function fileUpload(args) {
_fileManagerActionFns.fileUpload(
{
submission: submission.value,
selectedPublication: selectedPublication.value,
reviewRoundId: selectedReviewRound.value?.id,
...args,
},
() => triggerDataChange(),
);
}

/**
* Items
*
Expand Down Expand Up @@ -199,6 +221,11 @@ export const useWorkflowStore = defineComponentStore(
...workflowActions,
...decisionActions,

/**
* File manager actions
*/
fileUpload,

/**
* Summary
*/
Expand Down

0 comments on commit 7a3a2de

Please sign in to comment.