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

Remove in-publication step #384

Merged
merged 1 commit into from
Aug 16, 2022
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
6 changes: 1 addition & 5 deletions app/assets/scripts/a11n/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
CLOSED_REVIEW_REQUESTED,
DRAFT,
OPEN_REVIEW,
PUBLICATION,
PUBLICATION_REQUESTED,
REVIEW_PROGRESS
} from '../components/documents/status';
Expand Down Expand Up @@ -46,11 +45,8 @@ export function defineRulesFor(user) {
allow('open-review', 'document-version', {
status: CLOSED_REVIEW
});
allow('manage-req-publication', 'document-version', {
status: PUBLICATION_REQUESTED
});
allow('publish', 'document-version', {
status: PUBLICATION
status: PUBLICATION_REQUESTED
});
allow('access-comments', 'document-version');
allow('download-journal-pdf', 'document-version');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ function getDocAbilitySortRating(doc, ability) {
ability.can('open-review', doc) ||
ability.can('req-publication', doc) ||
ability.can('cancel-req-publication', doc) ||
ability.can('manage-req-publication', doc) ||
ability.can('publish', doc)
? -1
: 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ export function useDocumentHubMenuAction() {
case 'change-leading':
case 'req-review-allow':
case 'req-review-deny':
case 'req-publication-allow':
case 'req-publication-deny':
case 'toggle-comments':
// To trigger the modals to open from other pages, we use the history
// state as the user is sent from one page to another. See explanation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function DocumentGovernanceAction(props) {
<Can do='req-publication' on={atbd}>
<control.El
{...control.props}
title='Submit document for publication'
title='Make-public request'
useIcon='arrow-up-right'
disabled={isMutating}
onClick={() => onAction('req-publication', { atbd })}
Expand All @@ -111,27 +111,18 @@ export default function DocumentGovernanceAction(props) {
<Can do='cancel-req-publication' on={atbd}>
<control.El
{...control.props}
title='Cancel publication request'
title='Cancel make-public request'
useIcon='xmark--small'
disabled={isMutating}
onClick={() => onAction('cancel-req-publication', { atbd })}
>
Cancel request
</control.El>
</Can>
<Can do='manage-req-publication' on={atbd}>
<AllowDeny
id='req-publication'
triggerLabel='Approve request'
triggerProps={control.triggerProps}
dropTitle='Request for publication'
onSelect={onAction}
/>
</Can>
<Can do='publish' on={atbd}>
<control.El
{...control.props}
title='Publish document'
title='Make public'
useIcon='arrow-up'
disabled={isMutating}
onClick={() => onAction('publish', { atbd })}
Expand Down
84 changes: 3 additions & 81 deletions app/assets/scripts/components/documents/use-document-modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const MODAL_DOCUMENT_COLLABORATOR = 'modal-document-collaborator';
const MODAL_DOCUMENT_LEAD_AUTHOR = 'modal-document-lead-author';
const MODAL_REQ_REVIEW_DENY = 'modal-req-review-deny';
const MODAL_REQ_REVIEW_ALLOW = 'modal-req-review-allow';
const MODAL_REQ_PUBLICATION_DENY = 'modal-req-publication-deny';

/**
* Waits for a promise showing a message in case of error or success.
Expand Down Expand Up @@ -72,8 +71,7 @@ export function DocumentModals(props) {
hideModal,
onCollaboratorsSubmit,
onReviewReqDenySubmit,
onReviewReqApproveSubmit,
onPublicationReqDenySubmit
onReviewReqApproveSubmit
} = props;

return (
Expand Down Expand Up @@ -121,19 +119,6 @@ export function DocumentModals(props) {
onSubmit={onReviewReqApproveSubmit}
onClose={hideModal}
/>
<ReqDenyModal
revealed={activeModal === MODAL_REQ_PUBLICATION_DENY}
title='Deny publication request'
content={
<p>
You are about to deny the publication request for version{' '}
<strong>{atbd.version}</strong> of document{' '}
<strong>{atbd.title}</strong>
</p>
}
onSubmit={onPublicationReqDenySubmit}
onClose={hideModal}
/>
</React.Fragment>
);
}
Expand All @@ -144,8 +129,7 @@ DocumentModals.propTypes = {
hideModal: T.func,
onCollaboratorsSubmit: T.func,
onReviewReqDenySubmit: T.func,
onReviewReqApproveSubmit: T.func,
onPublicationReqDenySubmit: T.func
onReviewReqApproveSubmit: T.func
};

const composeOnSubmitSuccess = (fn, cb) => async (...args) => {
Expand All @@ -168,8 +152,6 @@ export const useDocumentModals = ({
fevOpenReview,
fevReqPublication,
fevCancelPublicationReq,
fevApprovePublicationReq,
fevDenyPublicationReq,
fevPublish,
fevMinorVersion
}) => {
Expand Down Expand Up @@ -256,15 +238,6 @@ export const useDocumentModals = ({
fn: fevCancelPublicationReq
});
break;
case 'req-publication-allow':
await handleRequestPublicationAllow({
atbd,
fn: fevApprovePublicationReq
});
break;
case 'req-publication-deny':
setActiveModal(MODAL_REQ_PUBLICATION_DENY);
break;
default:
// Was not handled
return false;
Expand All @@ -284,7 +257,6 @@ export const useDocumentModals = ({
fevSetOwnReviewStatus,
fevOpenReview,
fevReqPublication,
fevApprovePublicationReq,
fevCancelPublicationReq
]
);
Expand Down Expand Up @@ -312,15 +284,6 @@ export const useDocumentModals = ({
}
);

const onPublicationReqDenySubmitFn = useSubmitForGovernance(
fevDenyPublicationReq,
{
start: 'Denying request for publication',
success: 'Publication request denied successfully',
error: 'Error denying publication request'
}
);

// Update submit function adding actions when the process is successful.
const onReviewReqDenySubmit = composeOnSubmitSuccess(
onReviewReqDenySubmitFn,
Expand All @@ -337,14 +300,6 @@ export const useDocumentModals = ({
}
);

const onPublicationReqDenySubmit = composeOnSubmitSuccess(
onPublicationReqDenySubmitFn,
() => {
hideModal();
refreshThreadStats();
}
);

// To trigger the modals to open from other pages, we use the history state as
// the user is sent from one page to another. This is happening with the
// dashboards for example. When the user selects one of the options from
Expand Down Expand Up @@ -373,8 +328,7 @@ export const useDocumentModals = ({
hideModal,
onCollaboratorsSubmit,
onReviewReqDenySubmit,
onReviewReqApproveSubmit,
onPublicationReqDenySubmit
onReviewReqApproveSubmit
}
};
};
Expand Down Expand Up @@ -494,38 +448,6 @@ export async function handleCancelRequestPublication({ fn, args = [] }) {
});
}

export async function handleRequestPublicationAllow({ atbd, fn, args = [] }) {
const { result } = await showConfirmationPrompt({
title: 'Are you sure?',
content: (
<ConfirmationModalProse>
<p>
You&apos;re about to transition the version{' '}
<strong>{atbd.version}</strong> of document{' '}
<strong>{atbd.title}</strong> to the publication stage.
</p>
</ConfirmationModalProse>
),
/* eslint-disable-next-line react/display-name, react/prop-types */
renderControls: createBinaryControlsRenderer({
confirmVariation: 'primary-raised-dark',
confirmIcon: 'tick--small',
confirmTitle: 'Transition document to publication',
cancelVariation: 'base-raised-light',
cancelIcon: 'xmark--small'
})
});

if (result) {
return eventProcessToasts({
promise: fn(...args),
start: 'Transitioning document to publication',
success: 'Document is now in publication',
error: 'Error while moving to publication'
});
}
}

export async function handlePublishing({ atbd, fn, args = [] }) {
const { result } = await showConfirmationPrompt({
title: 'Publish document',
Expand Down
8 changes: 0 additions & 8 deletions app/assets/scripts/context/atbds-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,14 +628,6 @@ export const useSingleAtbdEvents = ({ id, version }) => {
() => createFireEvent('cancel_publication_request'),
[createFireEvent]
),
fevApprovePublicationReq: useMemo(
() => createFireEvent('accept_publication_request'),
[createFireEvent]
),
fevDenyPublicationReq: useMemo(
() => createFireEvent('deny_publication_request'),
[createFireEvent]
),
fevPublish: useMemo(() => createFireEvent('publish'), [createFireEvent]),
fevMinorVersion: useMemo(() => createFireEvent('bump_minor_version'), [
createFireEvent
Expand Down