Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#10768 Get the View counts only for relevant roles #547

Merged
merged 3 commits into from
Mar 6, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pkp/pkp-lib#10768 Add warning messages for author/reviewer combined w…
…ith editor
jardakotesovec committed Mar 5, 2025
commit 10a8f982a837943237b249d2ee2e85345f998fd8
9 changes: 9 additions & 0 deletions src/composables/useCurrentUser.js
Original file line number Diff line number Diff line change
@@ -50,10 +50,19 @@ export function useCurrentUser() {
return roles.some((role) => assignedRoleIds.includes(role));
}

function isCurrentUserAssignedAsReviewer(submission) {
const {getActiveReviewAssignments} = useSubmission();

return getActiveReviewAssignments(submission.reviewAssignments).some(
(reviewAssignment) => reviewAssignment.isCurrentUserAssigned,
);
}

return {
hasCurrentUserAtLeastOneRole,
getCurrentUserId,
hasCurrentUserAtLeastOneAssignedRoleInStage,
hasCurrentUserAtLeastOneAssignedRoleInAnyStage,
isCurrentUserAssignedAsReviewer,
};
}
Original file line number Diff line number Diff line change
@@ -15,14 +15,51 @@
import {defineProps, computed} from 'vue';
import PkpButton from '@/components/Button/Button.vue';
import TableCell from '@/components/Table/TableCell.vue';
import {useDashboardPageStore} from '@/pages/dashboard/dashboardPageStore.js';
import {useCurrentUser} from '@/composables/useCurrentUser';
import {
DashboardPageTypes,
useDashboardPageStore,
} from '@/pages/dashboard/dashboardPageStore.js';
const {
hasCurrentUserAtLeastOneAssignedRoleInAnyStage,
isCurrentUserAssignedAsReviewer,
} = useCurrentUser();
const props = defineProps({
item: {type: Object, required: true},
});
const showButton = computed(() => !props.item.submissionProgress);
const showButton = computed(() => {
if (props.item.submissionProgress) {
return false;
}
if (
dashboardPageStore.dashboardPage === DashboardPageTypes.EDITORIAL_DASHBOARD
) {
// Don't show View button, when being author/reviewer on editorial dashboard while not being explicitely assigned to editorial role
const isCurrentUserAssignedAsAuthorOrReviewer =
isCurrentUserAssignedAsReviewer(props.item) ||
hasCurrentUserAtLeastOneAssignedRoleInAnyStage(props.item, [
pkp.const.ROLE_ID_AUTHOR,
]);
if (
isCurrentUserAssignedAsAuthorOrReviewer &&
!hasCurrentUserAtLeastOneAssignedRoleInAnyStage(props.item, [
pkp.const.ROLE_ID_MANAGER,
pkp.const.ROLE_ID_SUB_EDITOR,
pkp.const.ROLE_ID_ASSISTANT,
])
) {
return false;
}
}
return true;
});
function handleAction() {
dashboardPageStore.openWorkflowModal(props.item.id);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="flex items-center gap-x-2">
<div class="flex max-w-sm items-center gap-x-2 break-words">
<div v-if="alert">{{ alert }}</div>
<PkpButton v-if="actionName" size-variant="compact" @click="handleAction">
{{ actionLabel }}
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ import {
useSubmission,
CompletedReviewAssignmentStatuses,
} from '@/composables/useSubmission.js';
import {useCurrentUser} from '@/composables/useCurrentUser';

import {useLocalize} from '@/composables/useLocalize';
import {useDate} from '@/composables/useDate';
import {Actions as ParticipantManagerActions} from '@/managers/ParticipantManager/useParticipantManagerActions';
@@ -20,6 +22,11 @@ const {
getStageLabel,
} = useSubmission();

const {
hasCurrentUserAtLeastOneAssignedRoleInAnyStage,
isCurrentUserAssignedAsReviewer,
} = useCurrentUser();

export function useDashboardConfigEditorialActivity() {
function getEditorialActivityForEditorialDashboard(submission) {
const activeStage = getActiveStage(submission);
@@ -51,6 +58,55 @@ export function useDashboardConfigEditorialActivity() {
];
}

// Warning that I am assigned as author, relevant if I am NOT assigned via any editorial role
if (
hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
pkp.const.ROLE_ID_AUTHOR,
]) &&
!hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
pkp.const.ROLE_ID_MANAGER,
pkp.const.ROLE_ID_SUB_EDITOR,
pkp.const.ROLE_ID_ASSISTANT,
])
) {
return [
{
component: 'DashboardCellSubmissionActivityActionAlert',
props: {
alert: t('dashboard.noAccessBeingAuthor'),
},
},
];
}

// Warning that I am assigned as author, relevant if I am NOT assigned via any editorial role
console.log('hola hej!');
console.log(isCurrentUserAssignedAsReviewer(submission));
console.log(
!hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
pkp.const.ROLE_ID_MANAGER,
pkp.const.ROLE_ID_SUB_EDITOR,
pkp.const.ROLE_ID_ASSISTANT,
]),
);
if (
isCurrentUserAssignedAsReviewer(submission) &&
!hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
pkp.const.ROLE_ID_MANAGER,
pkp.const.ROLE_ID_SUB_EDITOR,
pkp.const.ROLE_ID_ASSISTANT,
])
) {
return [
{
component: 'DashboardCellSubmissionActivityActionAlert',
props: {
alert: t('dashboard.noAccessBeingReviewer'),
},
},
];
}

if (activeStage.id === pkp.const.WORKFLOW_STAGE_ID_SUBMISSION) {
if (!submission.editorAssigned) {
return [