@manuscripts/style-guide 1.3.6 → 1.3.7-LEAN-2852-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59,7 +59,6 @@ const MapUserRole = {
59
59
  };
60
60
  const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userRole, canCompleteTask, submitProceed, goBack, status, isAnnotator, isProofer, message, exceptionDialog: ExceptionDialog, disabelProceedNote, }) => {
61
61
  var _a, _b, _c, _d, _e;
62
- const [confirmationDialog, toggleConfirmationDialog] = (0, react_1.useState)(false);
63
62
  const [noteValue, setNoteValue] = (0, react_1.useState)('');
64
63
  const [selectedTransitionIndex, setSelectedTransitionIndex] = (0, react_1.useState)();
65
64
  const { dialogData, submit } = submitProceed;
@@ -81,20 +80,13 @@ const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userR
81
80
  ]);
82
81
  const onTransitionClick = (0, react_1.useCallback)((event) => {
83
82
  updateState(DialogState.INIT);
84
- toggleConfirmationDialog(true);
85
83
  setSelectedTransitionIndex(event.target.value || event.target.parentNode.value);
86
- }, [setSelectedTransitionIndex, toggleConfirmationDialog, updateState]);
84
+ }, [setSelectedTransitionIndex, updateState]);
87
85
  const onCancelClick = (0, react_1.useCallback)(() => {
88
- toggleConfirmationDialog(false);
89
86
  setSelectedTransitionIndex(undefined);
90
87
  clearError();
91
88
  updateState(DialogState.CLOSED);
92
- }, [
93
- toggleConfirmationDialog,
94
- setSelectedTransitionIndex,
95
- clearError,
96
- updateState,
97
- ]);
89
+ }, [setSelectedTransitionIndex, clearError, updateState]);
98
90
  const onNoteChange = (0, react_1.useCallback)((event) => setNoteValue(event.target.value), [setNoteValue]);
99
91
  const currentStepTransition = submission === null || submission === void 0 ? void 0 : submission.currentStep.type.transitions;
100
92
  const disable = !currentStepTransition || !canCompleteTask;
@@ -105,7 +97,7 @@ const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userR
105
97
  react_1.default.createElement("span", null, "Dashboard"))),
106
98
  handleSnapshot &&
107
99
  typeof hasPendingSuggestions == 'boolean' &&
108
- submission.nextStep && (react_1.default.createElement(ProceedView_1.ProceedView, { isAnnotator: isAnnotator, isProofer: isProofer, disable: disable, onTransitionClick: onTransitionClick, hasPendingSuggestions: hasPendingSuggestions, dialogData: dialogData, noteValue: noteValue, currentStepTransition: currentStepTransition, currentStepType: submission.currentStep.type, previousStepType: (_e = submission.previousStep) === null || _e === void 0 ? void 0 : _e.type, nextStepType: submission.nextStep.type, confirmationDialog: confirmationDialog, onNoteChange: disabelProceedNote ? undefined : onNoteChange, continueDialogAction: continueDialogAction, onCancelClick: onCancelClick, message: message })),
100
+ submission.nextStep && (react_1.default.createElement(ProceedView_1.ProceedView, { isAnnotator: isAnnotator, isProofer: isProofer, disable: disable, onTransitionClick: onTransitionClick, hasPendingSuggestions: hasPendingSuggestions, dialogData: dialogData, noteValue: noteValue, currentStepTransition: currentStepTransition, currentStepType: submission.currentStep.type, previousStepType: (_e = submission.previousStep) === null || _e === void 0 ? void 0 : _e.type, nextStepType: submission.nextStep.type, onNoteChange: disabelProceedNote ? undefined : onNoteChange, continueDialogAction: continueDialogAction, onCancelClick: onCancelClick, message: message })),
109
101
  status && (react_1.default.createElement(ChildWrapper, null,
110
102
  react_1.default.createElement(__1.SaveStatus, { status: status }))),
111
103
  react_1.default.createElement(Spacer, null),
@@ -46,8 +46,11 @@ const StepDetails = ({ icon, label, description, role }) => (react_1.default.cre
46
46
  react_1.default.createElement(__1.SecondarySmallText, null,
47
47
  "Actor: ",
48
48
  role.label))));
49
- const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialogData, confirmationDialog, previousStepType, currentStepType, isAnnotator, isProofer, hasPendingSuggestions, onCancelClick, continueDialogAction, message: Message, }) => {
50
- const dialogMessages = (0, react_1.useMemo)(() => hasPendingSuggestions && !isAnnotator && !isProofer
49
+ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialogData, previousStepType, currentStepType, isAnnotator, isProofer, hasPendingSuggestions, onCancelClick, continueDialogAction, message: Message, }) => {
50
+ const dialogMessages = (0, react_1.useMemo)(() => hasPendingSuggestions &&
51
+ !isAnnotator &&
52
+ !isProofer &&
53
+ dialogData.state !== __1.DialogState.SUCCESS
51
54
  ? {
52
55
  header: 'The task can not be transitioned to the next step',
53
56
  message: `There are still pending suggestions in the document.
@@ -57,6 +60,7 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialog
57
60
  action: onCancelClick,
58
61
  title: 'Ok',
59
62
  },
63
+ onClose: onCancelClick,
60
64
  },
61
65
  }
62
66
  : dialogData.state === __1.DialogState.SUCCESS
@@ -68,6 +72,7 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialog
68
72
  action: onCancelClick,
69
73
  title: 'Close',
70
74
  },
75
+ onClose: onCancelClick,
71
76
  },
72
77
  }
73
78
  : {
@@ -82,6 +87,7 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialog
82
87
  action: onCancelClick,
83
88
  title: 'Cancel',
84
89
  },
90
+ onClose: onCancelClick,
85
91
  },
86
92
  }, [
87
93
  dialogData,
@@ -92,21 +98,34 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialog
92
98
  isAnnotator,
93
99
  isProofer,
94
100
  ]);
101
+ const prevDialogMsgs = (0, react_1.useRef)();
102
+ const prevDialogueState = (0, react_1.useRef)();
103
+ (0, react_1.useEffect)(() => {
104
+ prevDialogMsgs.current = dialogMessages;
105
+ prevDialogueState.current = dialogData.state;
106
+ }, [dialogData.state]);
107
+ const messages = dialogData.state === __1.DialogState.CLOSED && prevDialogMsgs.current
108
+ ? prevDialogMsgs.current
109
+ : dialogMessages;
110
+ const finalState = dialogData.state === __1.DialogState.CLOSED && prevDialogueState.current
111
+ ? prevDialogueState.current
112
+ : dialogData.state;
95
113
  return (react_1.default.createElement(react_1.default.Fragment, null,
96
114
  (currentStepTransition && (currentStepTransition === null || currentStepTransition === void 0 ? void 0 : currentStepTransition.length) > 1 && (react_1.default.createElement(DropdownWrapper, { button: 'Complete task', disabled: disable, primary: true },
97
115
  react_1.default.createElement(TaskDropdown, null, currentStepTransition &&
98
116
  currentStepTransition.map((transition, index) => (react_1.default.createElement(Task, { key: 'task_' + transition.type.id, className: transition.status.id === 'success' ? 'happyPath' : '', value: index, onClick: onTransitionClick },
99
117
  react_1.default.createElement("strong", null, transition.type.label),
100
118
  transition.type.description))))))) || (react_1.default.createElement(EditorHeader_1.PrimaryButtonSmall, { value: 0, onClick: onTransitionClick, disabled: disable }, "Complete task")),
101
- dialogData.state === __1.DialogState.LOADING && (react_1.default.createElement(__1.LoadingOverlay, null,
119
+ finalState === __1.DialogState.LOADING && (react_1.default.createElement(__1.LoadingOverlay, null,
102
120
  react_1.default.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026"))),
103
- !(dialogData.state === __1.DialogState.CLOSED) && (react_1.default.createElement(__1.Dialog, { isOpen: confirmationDialog && !(dialogData.state === __1.DialogState.LOADING), category: __1.Category.confirmation, header: dialogMessages.header, message: dialogMessages.message, actions: dialogMessages.actions },
104
- dialogData.state === __1.DialogState.SUCCESS && (react_1.default.createElement(Grid, null,
121
+ react_1.default.createElement(__1.Dialog, { isOpen: dialogData.state !== __1.DialogState.CLOSED &&
122
+ dialogData.state !== __1.DialogState.LOADING, category: __1.Category.confirmation, header: messages.header, message: messages.message, actions: messages.actions },
123
+ finalState === __1.DialogState.SUCCESS && (react_1.default.createElement(Grid, null,
105
124
  previousStepType && (react_1.default.createElement(StepDetails, Object.assign({}, previousStepType, { icon: react_1.default.createElement(react_1.default.Fragment, null,
106
125
  react_1.default.createElement(__1.TaskStepDoneIcon, null),
107
126
  react_1.default.createElement(Line, null)) }))),
108
127
  react_1.default.createElement(StepDetails, Object.assign({}, currentStepType)))),
109
- dialogData.state === __1.DialogState.ERROR && (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.error, hideCloseButton: true }, dialogData.error))))));
128
+ finalState === __1.DialogState.ERROR && (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.error, hideCloseButton: true }, dialogData.error)))));
110
129
  };
111
130
  exports.ProceedView = ProceedView;
112
131
  const TaskDropdown = styled_components_1.default.div `
@@ -59,6 +59,7 @@ const getCapabilities = (project, profile, role, actions) => {
59
59
  editMetadata: !(isViewer() || isAnnotator() || isProofer()),
60
60
  editCitationsAndRefs: !(isViewer() || isAnnotator() || isProofer()),
61
61
  shareProject: isOwner(),
62
+ applySaveChanges: !(isAnnotator() || isProofer()),
62
63
  };
63
64
  };
64
65
  exports.getCapabilities = getCapabilities;
@@ -30,7 +30,6 @@ const MapUserRole = {
30
30
  };
31
31
  export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userRole, canCompleteTask, submitProceed, goBack, status, isAnnotator, isProofer, message, exceptionDialog: ExceptionDialog, disabelProceedNote, }) => {
32
32
  var _a, _b, _c, _d, _e;
33
- const [confirmationDialog, toggleConfirmationDialog] = useState(false);
34
33
  const [noteValue, setNoteValue] = useState('');
35
34
  const [selectedTransitionIndex, setSelectedTransitionIndex] = useState();
36
35
  const { dialogData, submit } = submitProceed;
@@ -52,20 +51,13 @@ export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions
52
51
  ]);
53
52
  const onTransitionClick = useCallback((event) => {
54
53
  updateState(DialogState.INIT);
55
- toggleConfirmationDialog(true);
56
54
  setSelectedTransitionIndex(event.target.value || event.target.parentNode.value);
57
- }, [setSelectedTransitionIndex, toggleConfirmationDialog, updateState]);
55
+ }, [setSelectedTransitionIndex, updateState]);
58
56
  const onCancelClick = useCallback(() => {
59
- toggleConfirmationDialog(false);
60
57
  setSelectedTransitionIndex(undefined);
61
58
  clearError();
62
59
  updateState(DialogState.CLOSED);
63
- }, [
64
- toggleConfirmationDialog,
65
- setSelectedTransitionIndex,
66
- clearError,
67
- updateState,
68
- ]);
60
+ }, [setSelectedTransitionIndex, clearError, updateState]);
69
61
  const onNoteChange = useCallback((event) => setNoteValue(event.target.value), [setNoteValue]);
70
62
  const currentStepTransition = submission === null || submission === void 0 ? void 0 : submission.currentStep.type.transitions;
71
63
  const disable = !currentStepTransition || !canCompleteTask;
@@ -76,7 +68,7 @@ export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions
76
68
  React.createElement("span", null, "Dashboard"))),
77
69
  handleSnapshot &&
78
70
  typeof hasPendingSuggestions == 'boolean' &&
79
- submission.nextStep && (React.createElement(ProceedView, { isAnnotator: isAnnotator, isProofer: isProofer, disable: disable, onTransitionClick: onTransitionClick, hasPendingSuggestions: hasPendingSuggestions, dialogData: dialogData, noteValue: noteValue, currentStepTransition: currentStepTransition, currentStepType: submission.currentStep.type, previousStepType: (_e = submission.previousStep) === null || _e === void 0 ? void 0 : _e.type, nextStepType: submission.nextStep.type, confirmationDialog: confirmationDialog, onNoteChange: disabelProceedNote ? undefined : onNoteChange, continueDialogAction: continueDialogAction, onCancelClick: onCancelClick, message: message })),
71
+ submission.nextStep && (React.createElement(ProceedView, { isAnnotator: isAnnotator, isProofer: isProofer, disable: disable, onTransitionClick: onTransitionClick, hasPendingSuggestions: hasPendingSuggestions, dialogData: dialogData, noteValue: noteValue, currentStepTransition: currentStepTransition, currentStepType: submission.currentStep.type, previousStepType: (_e = submission.previousStep) === null || _e === void 0 ? void 0 : _e.type, nextStepType: submission.nextStep.type, onNoteChange: disabelProceedNote ? undefined : onNoteChange, continueDialogAction: continueDialogAction, onCancelClick: onCancelClick, message: message })),
80
72
  status && (React.createElement(ChildWrapper, null,
81
73
  React.createElement(SaveStatus, { status: status }))),
82
74
  React.createElement(Spacer, null),
@@ -1,4 +1,4 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useEffect, useMemo, useRef } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { Category, Dialog, DialogState, LoadingOverlay, NavDropdown, NavDropdownButton, NavDropdownContainer, PrimaryBoldHeading, PrimaryButton, SecondarySmallText, TaskStepDoneIcon, useDropdown, } from '../..';
4
4
  import { AlertMessage, AlertMessageType } from '../AlertMessage';
@@ -17,8 +17,11 @@ const StepDetails = ({ icon, label, description, role }) => (React.createElement
17
17
  React.createElement(SecondarySmallText, null,
18
18
  "Actor: ",
19
19
  role.label))));
20
- export const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialogData, confirmationDialog, previousStepType, currentStepType, isAnnotator, isProofer, hasPendingSuggestions, onCancelClick, continueDialogAction, message: Message, }) => {
21
- const dialogMessages = useMemo(() => hasPendingSuggestions && !isAnnotator && !isProofer
20
+ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialogData, previousStepType, currentStepType, isAnnotator, isProofer, hasPendingSuggestions, onCancelClick, continueDialogAction, message: Message, }) => {
21
+ const dialogMessages = useMemo(() => hasPendingSuggestions &&
22
+ !isAnnotator &&
23
+ !isProofer &&
24
+ dialogData.state !== DialogState.SUCCESS
22
25
  ? {
23
26
  header: 'The task can not be transitioned to the next step',
24
27
  message: `There are still pending suggestions in the document.
@@ -28,6 +31,7 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
28
31
  action: onCancelClick,
29
32
  title: 'Ok',
30
33
  },
34
+ onClose: onCancelClick,
31
35
  },
32
36
  }
33
37
  : dialogData.state === DialogState.SUCCESS
@@ -39,6 +43,7 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
39
43
  action: onCancelClick,
40
44
  title: 'Close',
41
45
  },
46
+ onClose: onCancelClick,
42
47
  },
43
48
  }
44
49
  : {
@@ -53,6 +58,7 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
53
58
  action: onCancelClick,
54
59
  title: 'Cancel',
55
60
  },
61
+ onClose: onCancelClick,
56
62
  },
57
63
  }, [
58
64
  dialogData,
@@ -63,21 +69,34 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
63
69
  isAnnotator,
64
70
  isProofer,
65
71
  ]);
72
+ const prevDialogMsgs = useRef();
73
+ const prevDialogueState = useRef();
74
+ useEffect(() => {
75
+ prevDialogMsgs.current = dialogMessages;
76
+ prevDialogueState.current = dialogData.state;
77
+ }, [dialogData.state]);
78
+ const messages = dialogData.state === DialogState.CLOSED && prevDialogMsgs.current
79
+ ? prevDialogMsgs.current
80
+ : dialogMessages;
81
+ const finalState = dialogData.state === DialogState.CLOSED && prevDialogueState.current
82
+ ? prevDialogueState.current
83
+ : dialogData.state;
66
84
  return (React.createElement(React.Fragment, null,
67
85
  (currentStepTransition && (currentStepTransition === null || currentStepTransition === void 0 ? void 0 : currentStepTransition.length) > 1 && (React.createElement(DropdownWrapper, { button: 'Complete task', disabled: disable, primary: true },
68
86
  React.createElement(TaskDropdown, null, currentStepTransition &&
69
87
  currentStepTransition.map((transition, index) => (React.createElement(Task, { key: 'task_' + transition.type.id, className: transition.status.id === 'success' ? 'happyPath' : '', value: index, onClick: onTransitionClick },
70
88
  React.createElement("strong", null, transition.type.label),
71
89
  transition.type.description))))))) || (React.createElement(PrimaryButtonSmall, { value: 0, onClick: onTransitionClick, disabled: disable }, "Complete task")),
72
- dialogData.state === DialogState.LOADING && (React.createElement(LoadingOverlay, null,
90
+ finalState === DialogState.LOADING && (React.createElement(LoadingOverlay, null,
73
91
  React.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026"))),
74
- !(dialogData.state === DialogState.CLOSED) && (React.createElement(Dialog, { isOpen: confirmationDialog && !(dialogData.state === DialogState.LOADING), category: Category.confirmation, header: dialogMessages.header, message: dialogMessages.message, actions: dialogMessages.actions },
75
- dialogData.state === DialogState.SUCCESS && (React.createElement(Grid, null,
92
+ React.createElement(Dialog, { isOpen: dialogData.state !== DialogState.CLOSED &&
93
+ dialogData.state !== DialogState.LOADING, category: Category.confirmation, header: messages.header, message: messages.message, actions: messages.actions },
94
+ finalState === DialogState.SUCCESS && (React.createElement(Grid, null,
76
95
  previousStepType && (React.createElement(StepDetails, Object.assign({}, previousStepType, { icon: React.createElement(React.Fragment, null,
77
96
  React.createElement(TaskStepDoneIcon, null),
78
97
  React.createElement(Line, null)) }))),
79
98
  React.createElement(StepDetails, Object.assign({}, currentStepType)))),
80
- dialogData.state === DialogState.ERROR && (React.createElement(AlertMessage, { type: AlertMessageType.error, hideCloseButton: true }, dialogData.error))))));
99
+ finalState === DialogState.ERROR && (React.createElement(AlertMessage, { type: AlertMessageType.error, hideCloseButton: true }, dialogData.error)))));
81
100
  };
82
101
  const TaskDropdown = styled.div `
83
102
  display: flex;
@@ -53,6 +53,7 @@ export const getCapabilities = (project, profile, role, actions) => {
53
53
  editMetadata: !(isViewer() || isAnnotator() || isProofer()),
54
54
  editCitationsAndRefs: !(isViewer() || isAnnotator() || isProofer()),
55
55
  shareProject: isOwner(),
56
+ applySaveChanges: !(isAnnotator() || isProofer()),
56
57
  };
57
58
  };
58
59
  export const getAllPermitted = () => {
@@ -14,7 +14,6 @@ export declare const ProceedView: React.FC<{
14
14
  previousStepType: SubmissionStepType | undefined;
15
15
  currentStepType: SubmissionStepType;
16
16
  nextStepType: SubmissionStepType;
17
- confirmationDialog: boolean;
18
17
  onCancelClick: () => void;
19
18
  continueDialogAction: () => Promise<void>;
20
19
  message: React.FC<{
@@ -38,6 +38,7 @@ export type Capabilities = {
38
38
  editMetadata: boolean;
39
39
  shareProject: boolean;
40
40
  editCitationsAndRefs: boolean;
41
+ applySaveChanges: boolean;
41
42
  };
42
43
  export interface ProviderProps {
43
44
  project?: Project;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/style-guide",
3
3
  "description": "Shared components for Manuscripts applications",
4
- "version": "1.3.6",
4
+ "version": "1.3.7-LEAN-2852-1",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -36,8 +36,8 @@
36
36
  "@formatjs/intl-relativetimeformat": "^4.5.9",
37
37
  "@formatjs/intl-utils": "^2.2.0",
38
38
  "@manuscripts/assets": "^0.6.2",
39
- "@manuscripts/transform": "^1.4.3",
40
- "@manuscripts/json-schema": "^2.1.2",
39
+ "@manuscripts/transform": "1.4.6-LEAN-2852-5",
40
+ "@manuscripts/json-schema": "2.2.0-LEAN-2852-3",
41
41
  "@manuscripts/title-editor": "^1.1.0",
42
42
  "@manuscripts/comment-editor": "^1.0.3",
43
43
  "@reach/tabs": "^0.11.2",
@@ -141,4 +141,4 @@
141
141
  "resolutions": {
142
142
  "@types/react": "^17.0.2"
143
143
  }
144
- }
144
+ }