Skip to content

Commit bf023f5

Browse files
pkp/pkp-lib#10768 Get the View counts only for relevant roles, warnings for author/reviewer combined with editor
* pkp/pkp-lib#10768 Get the View counts only for relevant roles * pkp/pkp-lib#10768 Add warning messages for author/reviewer combined with editor
1 parent fb32ea0 commit bf023f5

File tree

5 files changed

+113
-7
lines changed

5 files changed

+113
-7
lines changed

src/components/SideNav/SideNav.vue

+17-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,19 @@ const menuItems = ref(convertLinksToArray(props.links));
5050
5151
const {apiUrl: dashboardCountUrl} = useUrl('_submissions/viewsCount');
5252
53-
const {data: dashboardCount, fetch: fetchDashboardCount} =
54-
useFetch(dashboardCountUrl);
53+
const {data: dashboardCount, fetch: fetchDashboardCount} = useFetch(
54+
dashboardCountUrl,
55+
{
56+
query: {
57+
assignedWithRoles: [
58+
pkp.const.ROLE_ID_SITE_ADMIN,
59+
pkp.const.ROLE_ID_MANAGER,
60+
pkp.const.ROLE_ID_SUB_EDITOR,
61+
pkp.const.ROLE_ID_ASSISTANT,
62+
],
63+
},
64+
},
65+
);
5566
5667
const dashboardsMenuItem = menuItems.value.find(
5768
(item) => item.key === 'dashboards',
@@ -67,6 +78,7 @@ const {apiUrl: mySubmissionsCountUrl} = useUrl('_submissions/viewsCount');
6778
6879
const {data: mySubmissionsCount, fetch: fetchMySubmissionsCount} = useFetch(
6980
mySubmissionsCountUrl,
81+
{query: {assignedWithRoles: [pkp.const.ROLE_ID_AUTHOR]}},
7082
);
7183
7284
const mySubmissionsMenuItem = menuItems.value.find(
@@ -82,7 +94,9 @@ if (mySubmissionsMenuItem) {
8294
const {apiUrl: reviewAssignmentCountUrl} = useUrl('_submissions/viewsCount');
8395
8496
const {data: reviewAssignmentCount, fetch: fetchReviewAssignmentCount} =
85-
useFetch(reviewAssignmentCountUrl);
97+
useFetch(reviewAssignmentCountUrl, {
98+
query: {assignedWithRoles: [pkp.const.ROLE_ID_REVIEWER]},
99+
});
86100
87101
const reviewAssignmentMenuItem = menuItems.value.find(
88102
(item) => item.key === 'reviewAssignments',
@@ -186,7 +200,6 @@ const {sideMenuProps} = useSideMenu(menuItemsEnriched, {
186200
watch(
187201
() => props.links,
188202
(newLinks) => {
189-
console.log('SideNav watch');
190203
menuItems.value = convertLinksToArray(newLinks);
191204
},
192205
);

src/composables/useCurrentUser.js

+9
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,19 @@ export function useCurrentUser() {
5050
return roles.some((role) => assignedRoleIds.includes(role));
5151
}
5252

53+
function isCurrentUserAssignedAsReviewer(submission) {
54+
const {getActiveReviewAssignments} = useSubmission();
55+
56+
return getActiveReviewAssignments(submission.reviewAssignments).some(
57+
(reviewAssignment) => reviewAssignment.isCurrentUserAssigned,
58+
);
59+
}
60+
5361
return {
5462
hasCurrentUserAtLeastOneRole,
5563
getCurrentUserId,
5664
hasCurrentUserAtLeastOneAssignedRoleInStage,
5765
hasCurrentUserAtLeastOneAssignedRoleInAnyStage,
66+
isCurrentUserAssignedAsReviewer,
5867
};
5968
}

src/pages/dashboard/components/DashboardTable/DashboardCellSubmissionActions.vue

+39-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,51 @@
1515
import {defineProps, computed} from 'vue';
1616
import PkpButton from '@/components/Button/Button.vue';
1717
import TableCell from '@/components/Table/TableCell.vue';
18-
import {useDashboardPageStore} from '@/pages/dashboard/dashboardPageStore.js';
18+
import {useCurrentUser} from '@/composables/useCurrentUser';
19+
20+
import {
21+
DashboardPageTypes,
22+
useDashboardPageStore,
23+
} from '@/pages/dashboard/dashboardPageStore.js';
24+
25+
const {
26+
hasCurrentUserAtLeastOneAssignedRoleInAnyStage,
27+
isCurrentUserAssignedAsReviewer,
28+
} = useCurrentUser();
1929
2030
const props = defineProps({
2131
item: {type: Object, required: true},
2232
});
2333
24-
const showButton = computed(() => !props.item.submissionProgress);
34+
const showButton = computed(() => {
35+
if (props.item.submissionProgress) {
36+
return false;
37+
}
38+
39+
if (
40+
dashboardPageStore.dashboardPage === DashboardPageTypes.EDITORIAL_DASHBOARD
41+
) {
42+
// Don't show View button, when being author/reviewer on editorial dashboard while not being explicitely assigned to editorial role
2543
44+
const isCurrentUserAssignedAsAuthorOrReviewer =
45+
isCurrentUserAssignedAsReviewer(props.item) ||
46+
hasCurrentUserAtLeastOneAssignedRoleInAnyStage(props.item, [
47+
pkp.const.ROLE_ID_AUTHOR,
48+
]);
49+
if (
50+
isCurrentUserAssignedAsAuthorOrReviewer &&
51+
!hasCurrentUserAtLeastOneAssignedRoleInAnyStage(props.item, [
52+
pkp.const.ROLE_ID_MANAGER,
53+
pkp.const.ROLE_ID_SUB_EDITOR,
54+
pkp.const.ROLE_ID_ASSISTANT,
55+
])
56+
) {
57+
return false;
58+
}
59+
}
60+
61+
return true;
62+
});
2663
function handleAction() {
2764
dashboardPageStore.openWorkflowModal(props.item.id);
2865
}

src/pages/dashboard/components/DashboardTable/DashboardCellSubmissionActivity/DashboardCellSubmissionActivityActionAlert.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex items-center gap-x-2">
2+
<div class="flex max-w-sm items-center gap-x-2 break-words">
33
<div v-if="alert">{{ alert }}</div>
44
<PkpButton v-if="actionName" size-variant="compact" @click="handleAction">
55
{{ actionLabel }}

src/pages/dashboard/composables/useDashboardConfigEditorialActivity.js

+47
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {
22
useSubmission,
33
CompletedReviewAssignmentStatuses,
44
} from '@/composables/useSubmission.js';
5+
import {useCurrentUser} from '@/composables/useCurrentUser';
6+
57
import {useLocalize} from '@/composables/useLocalize';
68
import {useDate} from '@/composables/useDate';
79
import {Actions as ParticipantManagerActions} from '@/managers/ParticipantManager/useParticipantManagerActions';
@@ -20,6 +22,11 @@ const {
2022
getStageLabel,
2123
} = useSubmission();
2224

25+
const {
26+
hasCurrentUserAtLeastOneAssignedRoleInAnyStage,
27+
isCurrentUserAssignedAsReviewer,
28+
} = useCurrentUser();
29+
2330
export function useDashboardConfigEditorialActivity() {
2431
function getEditorialActivityForEditorialDashboard(submission) {
2532
const activeStage = getActiveStage(submission);
@@ -51,6 +58,46 @@ export function useDashboardConfigEditorialActivity() {
5158
];
5259
}
5360

61+
// Warning that I am assigned as author, relevant if I am NOT assigned via any editorial role
62+
if (
63+
hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
64+
pkp.const.ROLE_ID_AUTHOR,
65+
]) &&
66+
!hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
67+
pkp.const.ROLE_ID_MANAGER,
68+
pkp.const.ROLE_ID_SUB_EDITOR,
69+
pkp.const.ROLE_ID_ASSISTANT,
70+
])
71+
) {
72+
return [
73+
{
74+
component: 'DashboardCellSubmissionActivityActionAlert',
75+
props: {
76+
alert: t('dashboard.noAccessBeingAuthor'),
77+
},
78+
},
79+
];
80+
}
81+
82+
// Warning that I am assigned as author, relevant if I am NOT assigned via any editorial role
83+
if (
84+
isCurrentUserAssignedAsReviewer(submission) &&
85+
!hasCurrentUserAtLeastOneAssignedRoleInAnyStage(submission, [
86+
pkp.const.ROLE_ID_MANAGER,
87+
pkp.const.ROLE_ID_SUB_EDITOR,
88+
pkp.const.ROLE_ID_ASSISTANT,
89+
])
90+
) {
91+
return [
92+
{
93+
component: 'DashboardCellSubmissionActivityActionAlert',
94+
props: {
95+
alert: t('dashboard.noAccessBeingReviewer'),
96+
},
97+
},
98+
];
99+
}
100+
54101
if (activeStage.id === pkp.const.WORKFLOW_STAGE_ID_SUBMISSION) {
55102
if (!submission.editorAssigned) {
56103
return [

0 commit comments

Comments
 (0)