Skip to content

Commit

Permalink
Clarify rejected message in editing timeline (indico#5580)
Browse files Browse the repository at this point in the history
When an author rejects proposed changes by an editor and submits
a new version themselves, the title of the revision item is still
'Submitter rejected proposed changes' which is misleading.

This changes the title to 'Submitter rejected proposed changes
and uploaded a new revision' when a new revision has been
uploaded by the author.
  • Loading branch information
tomasr8 authored Nov 24, 2022
1 parent fc7e6db commit 3986a26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ describe('timeline selectors', () => {
expect(result[1].id).toBe(2);
expect(result[1].items).toStrictEqual([
expect.objectContaining({
header:
revisionStates[InitialRevisionState.needs_submitter_confirmation][
FinalRevisionState.needs_submitter_changes
],
header: revisionStates[InitialRevisionState.needs_submitter_confirmation][
FinalRevisionState.needs_submitter_changes
](result[1], {isLatestRevision: false}),
}),
]);
expect(result[2].id).toBe(3);
Expand Down
17 changes: 10 additions & 7 deletions indico/modules/events/editing/client/js/editing/timeline/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import {filePropTypes} from './FileManager/util';
// with a label referring to its previous state transition
export function processRevisions(revisions) {
let revisionState;
return revisions.map(revision => {
return revisions.map((revision, i) => {
const items = [...revision.comments];
const header = revisionState;
revisionState = getRevisionTransition(revision);
const isLatestRevision = i === revisions.length - 1;
revisionState = getRevisionTransition(revision, {isLatestRevision});
// Generate the comment header
if (revisionState) {
const author = revision.editor || revision.submitter;
Expand Down Expand Up @@ -56,9 +57,11 @@ export const revisionStates = {
? Translate.string('Editor has accepted after making some changes')
: Translate.string('Submitter has accepted proposed changes');
},
[FinalRevisionState.needs_submitter_changes]: Translate.string(
'Submitter rejected proposed changes'
),
[FinalRevisionState.needs_submitter_changes]: (_, {isLatestRevision}) => {
return isLatestRevision
? Translate.string('Submitter rejected proposed changes')
: Translate.string('Submitter rejected proposed changes and uploaded a new revision');
},
},
any: {
[FinalRevisionState.replaced]: Translate.string('Revision has been replaced'),
Expand All @@ -74,10 +77,10 @@ export const revisionStates = {
},
};

export function getRevisionTransition(revision) {
export function getRevisionTransition(revision, revisionMetadata) {
const headerStates = revisionStates[revision.initialState.name] || revisionStates['any'];
const header = headerStates[revision.finalState.name];
return typeof header === 'function' ? header(revision) : header;
return typeof header === 'function' ? header(revision, revisionMetadata) : header;
}

export const userPropTypes = {
Expand Down

0 comments on commit 3986a26

Please sign in to comment.