@manuscripts/style-guide 1.1.15-LEAN-2620 → 1.1.15-LEAN-2620-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.
- package/dist/cjs/components/EditorHeader/EditorHeader.js +12 -4
- package/dist/cjs/components/EditorHeader/ProceedView.js +5 -5
- package/dist/es/components/EditorHeader/EditorHeader.js +11 -3
- package/dist/es/components/EditorHeader/ProceedView.js +6 -6
- package/dist/types/components/EditorHeader/EditorHeader.d.ts +7 -1
- package/package.json +1 -1
|
@@ -35,11 +35,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.MediumTextArea = exports.PrimaryButtonSmall = exports.EditorHeader = void 0;
|
|
38
|
+
exports.MediumTextArea = exports.PrimaryButtonSmall = exports.EditorHeader = exports.DialogState = void 0;
|
|
39
39
|
const react_1 = __importStar(require("react"));
|
|
40
40
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
41
41
|
const __1 = require("../..");
|
|
42
42
|
const ProceedView_1 = require("./ProceedView");
|
|
43
|
+
var DialogState;
|
|
44
|
+
(function (DialogState) {
|
|
45
|
+
DialogState[DialogState["INIT"] = 0] = "INIT";
|
|
46
|
+
DialogState[DialogState["LOADING"] = 1] = "LOADING";
|
|
47
|
+
DialogState[DialogState["ERROR"] = 2] = "ERROR";
|
|
48
|
+
DialogState[DialogState["SUCCESS"] = 3] = "SUCCESS";
|
|
49
|
+
DialogState[DialogState["CLOSED"] = 4] = "CLOSED";
|
|
50
|
+
})(DialogState = exports.DialogState || (exports.DialogState = {}));
|
|
43
51
|
const Editing = { label: 'Editing...', icon: __1.EditIcon };
|
|
44
52
|
const MapUserRole = {
|
|
45
53
|
Editor: Editing,
|
|
@@ -58,7 +66,7 @@ const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userR
|
|
|
58
66
|
const continueDialogAction = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
67
|
if (submission && selectedTransitionIndex && handleSnapshot) {
|
|
60
68
|
const { status } = submission.currentStep.type.transitions[selectedTransitionIndex];
|
|
61
|
-
updateState(
|
|
69
|
+
updateState(DialogState.LOADING);
|
|
62
70
|
yield handleSnapshot();
|
|
63
71
|
yield submit(status.id, noteValue);
|
|
64
72
|
}
|
|
@@ -71,7 +79,7 @@ const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userR
|
|
|
71
79
|
noteValue,
|
|
72
80
|
]);
|
|
73
81
|
const onTransitionClick = (0, react_1.useCallback)((event) => {
|
|
74
|
-
updateState(
|
|
82
|
+
updateState(DialogState.INIT);
|
|
75
83
|
toggleConfirmationDialog(true);
|
|
76
84
|
setSelectedTransitionIndex(event.target.value || event.target.parentNode.value);
|
|
77
85
|
}, [setSelectedTransitionIndex, toggleConfirmationDialog, updateState]);
|
|
@@ -79,7 +87,7 @@ const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userR
|
|
|
79
87
|
toggleConfirmationDialog(false);
|
|
80
88
|
setSelectedTransitionIndex(undefined);
|
|
81
89
|
clearError();
|
|
82
|
-
updateState(
|
|
90
|
+
updateState(DialogState.CLOSED);
|
|
83
91
|
}, [
|
|
84
92
|
toggleConfirmationDialog,
|
|
85
93
|
setSelectedTransitionIndex,
|
|
@@ -59,7 +59,7 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialog
|
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
}
|
|
62
|
-
: dialogData.state ===
|
|
62
|
+
: dialogData.state === __1.DialogState.SUCCESS
|
|
63
63
|
? {
|
|
64
64
|
header: 'Content reassigned successfully',
|
|
65
65
|
message: `to the ${currentStepType.label}`,
|
|
@@ -97,15 +97,15 @@ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialog
|
|
|
97
97
|
currentStepTransition.map((transition, index) => (react_1.default.createElement(Task, { key: 'task_' + transition.type.id, className: transition.status.id === 'success' ? 'happyPath' : '', value: index, onClick: onTransitionClick },
|
|
98
98
|
react_1.default.createElement("strong", null, transition.type.label),
|
|
99
99
|
transition.type.description))))))) || (react_1.default.createElement(EditorHeader_1.PrimaryButtonSmall, { value: 0, onClick: onTransitionClick, disabled: disable }, "Complete task")),
|
|
100
|
-
dialogData.state ===
|
|
100
|
+
dialogData.state === __1.DialogState.LOADING && (react_1.default.createElement(__1.LoadingOverlay, null,
|
|
101
101
|
react_1.default.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026"))),
|
|
102
|
-
!(dialogData.state ===
|
|
103
|
-
dialogData.state ===
|
|
102
|
+
!(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 },
|
|
103
|
+
dialogData.state === __1.DialogState.SUCCESS && (react_1.default.createElement(Grid, null,
|
|
104
104
|
previousStepType && (react_1.default.createElement(StepDetails, Object.assign({}, previousStepType, { icon: react_1.default.createElement(react_1.default.Fragment, null,
|
|
105
105
|
react_1.default.createElement(__1.TaskStepDoneIcon, null),
|
|
106
106
|
react_1.default.createElement(Line, null)) }))),
|
|
107
107
|
react_1.default.createElement(StepDetails, Object.assign({}, currentStepType)))),
|
|
108
|
-
dialogData.state ===
|
|
108
|
+
dialogData.state === __1.DialogState.ERROR && (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.error, hideCloseButton: true }, dialogData.error))))));
|
|
109
109
|
};
|
|
110
110
|
exports.ProceedView = ProceedView;
|
|
111
111
|
const TaskDropdown = styled_components_1.default.div `
|
|
@@ -11,6 +11,14 @@ import React, { useCallback, useState } from 'react';
|
|
|
11
11
|
import styled from 'styled-components';
|
|
12
12
|
import { AnnotatorIcon, DropdownContainer, DropdownList, EditIcon, LeftArrow, NavDropdownContainer, NavDropdownToggle, PrimaryButton, ReadingIcon, SaveStatus, SecondaryButton, TextArea, useDropdown, } from '../..';
|
|
13
13
|
import { ProceedView } from './ProceedView';
|
|
14
|
+
export var DialogState;
|
|
15
|
+
(function (DialogState) {
|
|
16
|
+
DialogState[DialogState["INIT"] = 0] = "INIT";
|
|
17
|
+
DialogState[DialogState["LOADING"] = 1] = "LOADING";
|
|
18
|
+
DialogState[DialogState["ERROR"] = 2] = "ERROR";
|
|
19
|
+
DialogState[DialogState["SUCCESS"] = 3] = "SUCCESS";
|
|
20
|
+
DialogState[DialogState["CLOSED"] = 4] = "CLOSED";
|
|
21
|
+
})(DialogState || (DialogState = {}));
|
|
14
22
|
const Editing = { label: 'Editing...', icon: EditIcon };
|
|
15
23
|
const MapUserRole = {
|
|
16
24
|
Editor: Editing,
|
|
@@ -29,7 +37,7 @@ export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions
|
|
|
29
37
|
const continueDialogAction = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
38
|
if (submission && selectedTransitionIndex && handleSnapshot) {
|
|
31
39
|
const { status } = submission.currentStep.type.transitions[selectedTransitionIndex];
|
|
32
|
-
updateState(
|
|
40
|
+
updateState(DialogState.LOADING);
|
|
33
41
|
yield handleSnapshot();
|
|
34
42
|
yield submit(status.id, noteValue);
|
|
35
43
|
}
|
|
@@ -42,7 +50,7 @@ export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions
|
|
|
42
50
|
noteValue,
|
|
43
51
|
]);
|
|
44
52
|
const onTransitionClick = useCallback((event) => {
|
|
45
|
-
updateState(
|
|
53
|
+
updateState(DialogState.INIT);
|
|
46
54
|
toggleConfirmationDialog(true);
|
|
47
55
|
setSelectedTransitionIndex(event.target.value || event.target.parentNode.value);
|
|
48
56
|
}, [setSelectedTransitionIndex, toggleConfirmationDialog, updateState]);
|
|
@@ -50,7 +58,7 @@ export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions
|
|
|
50
58
|
toggleConfirmationDialog(false);
|
|
51
59
|
setSelectedTransitionIndex(undefined);
|
|
52
60
|
clearError();
|
|
53
|
-
updateState(
|
|
61
|
+
updateState(DialogState.CLOSED);
|
|
54
62
|
}, [
|
|
55
63
|
toggleConfirmationDialog,
|
|
56
64
|
setSelectedTransitionIndex,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import { Category, Dialog, LoadingOverlay, NavDropdown, NavDropdownButton, NavDropdownContainer, PrimaryBoldHeading, PrimaryButton, SecondarySmallText, TaskStepDoneIcon, useDropdown, } from '../..';
|
|
3
|
+
import { Category, Dialog, DialogState, LoadingOverlay, NavDropdown, NavDropdownButton, NavDropdownContainer, PrimaryBoldHeading, PrimaryButton, SecondarySmallText, TaskStepDoneIcon, useDropdown, } from '../..';
|
|
4
4
|
import { AlertMessage, AlertMessageType } from '../AlertMessage';
|
|
5
5
|
import { PrimaryButtonSmall, } from './EditorHeader';
|
|
6
6
|
const DropdownWrapper = ({ disabled, button, primary, children }) => {
|
|
@@ -30,7 +30,7 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
|
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
}
|
|
33
|
-
: dialogData.state ===
|
|
33
|
+
: dialogData.state === DialogState.SUCCESS
|
|
34
34
|
? {
|
|
35
35
|
header: 'Content reassigned successfully',
|
|
36
36
|
message: `to the ${currentStepType.label}`,
|
|
@@ -68,15 +68,15 @@ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable,
|
|
|
68
68
|
currentStepTransition.map((transition, index) => (React.createElement(Task, { key: 'task_' + transition.type.id, className: transition.status.id === 'success' ? 'happyPath' : '', value: index, onClick: onTransitionClick },
|
|
69
69
|
React.createElement("strong", null, transition.type.label),
|
|
70
70
|
transition.type.description))))))) || (React.createElement(PrimaryButtonSmall, { value: 0, onClick: onTransitionClick, disabled: disable }, "Complete task")),
|
|
71
|
-
dialogData.state ===
|
|
71
|
+
dialogData.state === DialogState.LOADING && (React.createElement(LoadingOverlay, null,
|
|
72
72
|
React.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026"))),
|
|
73
|
-
!(dialogData.state ===
|
|
74
|
-
dialogData.state ===
|
|
73
|
+
!(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 },
|
|
74
|
+
dialogData.state === DialogState.SUCCESS && (React.createElement(Grid, null,
|
|
75
75
|
previousStepType && (React.createElement(StepDetails, Object.assign({}, previousStepType, { icon: React.createElement(React.Fragment, null,
|
|
76
76
|
React.createElement(TaskStepDoneIcon, null),
|
|
77
77
|
React.createElement(Line, null)) }))),
|
|
78
78
|
React.createElement(StepDetails, Object.assign({}, currentStepType)))),
|
|
79
|
-
dialogData.state ===
|
|
79
|
+
dialogData.state === DialogState.ERROR && (React.createElement(AlertMessage, { type: AlertMessageType.error, hideCloseButton: true }, dialogData.error))))));
|
|
80
80
|
};
|
|
81
81
|
const TaskDropdown = styled.div `
|
|
82
82
|
display: flex;
|
|
@@ -26,7 +26,13 @@ export type SubmissionStepType = {
|
|
|
26
26
|
label: string;
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export declare enum DialogState {
|
|
30
|
+
INIT = 0,
|
|
31
|
+
LOADING = 1,
|
|
32
|
+
ERROR = 2,
|
|
33
|
+
SUCCESS = 3,
|
|
34
|
+
CLOSED = 4
|
|
35
|
+
}
|
|
30
36
|
export type ProceedDialogData = {
|
|
31
37
|
state: DialogState;
|
|
32
38
|
error?: string;
|
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.1.15-LEAN-2620",
|
|
4
|
+
"version": "1.1.15-LEAN-2620-1",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|