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

Reimplement bug fix and account for permissions when accessing preprint requests #2485

Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default class PreprintStatusBanner extends Component<InputArgs>{
}

get reviewerName(): string | undefined {
return this.args.latestAction?.creator.fullName;
return this.args.latestAction?.creator.get('fullName');
}

get isWithdrawn() {
Expand Down
26 changes: 14 additions & 12 deletions app/preprints/detail/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,22 @@ export default class PreprintsDetail extends Route {
let hasPendingWithdrawal = false;
let latestWithdrawalRequest = null;
let latestAction = null;
if (preprintWithdrawableState && preprint.currentUserIsAdmin) {
if (preprint.currentUserPermissions.length > 0) {
const reviewActions = await preprint?.queryHasMany('reviewActions');
latestAction = reviewActions.firstObject;
const withdrawalRequests = await preprint?.queryHasMany('requests');
latestWithdrawalRequest = withdrawalRequests.firstObject;
if (latestWithdrawalRequest) {
hasPendingWithdrawal = latestWithdrawalRequest.machineState === 'pending';
const requestActions = await withdrawalRequests.firstObject?.queryHasMany('actions', {
sort: '-modified',
});
latestAction = requestActions.firstObject;
// @ts-ignore: ActionTrigger is never
if (latestAction && latestAction.actionTrigger === 'reject') {
isWithdrawalRejected = true;
if (preprintWithdrawableState && preprint.currentUserIsAdmin) {
const withdrawalRequests = await preprint?.queryHasMany('requests');
latestWithdrawalRequest = withdrawalRequests.firstObject;
if (latestWithdrawalRequest) {
hasPendingWithdrawal = latestWithdrawalRequest.machineState === 'pending';
const requestActions = await withdrawalRequests.firstObject?.queryHasMany('actions', {
sort: '-modified',
});
latestAction = requestActions.firstObject;
// @ts-ignore: ActionTrigger is never
if (latestAction && latestAction.actionTrigger === 'reject') {
isWithdrawalRejected = true;
}
}
}
}
Expand Down
Loading