@manuscripts/style-guide 1.13.9 → 1.13.11-LEAN-3771.0

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.
Files changed (61) hide show
  1. package/dist/cjs/index.js +0 -4
  2. package/dist/cjs/lib/files.js +125 -77
  3. package/dist/es/index.js +0 -4
  4. package/dist/es/lib/files.js +117 -73
  5. package/dist/types/index.d.ts +0 -4
  6. package/dist/types/lib/files.d.ts +19 -24
  7. package/package.json +1 -1
  8. package/dist/cjs/components/EditorHeader/EditorHeader.js +0 -210
  9. package/dist/cjs/components/EditorHeader/ProceedView.js +0 -195
  10. package/dist/cjs/components/FileManager/FileActions.js +0 -134
  11. package/dist/cjs/components/FileManager/FileContainer.js +0 -39
  12. package/dist/cjs/components/FileManager/FileCreatedDate.js +0 -25
  13. package/dist/cjs/components/FileManager/FileManager.js +0 -60
  14. package/dist/cjs/components/FileManager/FileManagerDragLayer.js +0 -55
  15. package/dist/cjs/components/FileManager/FileManagerProvider.js +0 -39
  16. package/dist/cjs/components/FileManager/FileName.js +0 -27
  17. package/dist/cjs/components/FileManager/FileSectionAlert.js +0 -170
  18. package/dist/cjs/components/FileManager/FileTypeIcon.js +0 -20
  19. package/dist/cjs/components/FileManager/FileUploader.js +0 -85
  20. package/dist/cjs/components/FileManager/InlineFilesSection.js +0 -133
  21. package/dist/cjs/components/FileManager/OtherFilesSection.js +0 -101
  22. package/dist/cjs/components/FileManager/SupplementsSection.js +0 -118
  23. package/dist/cjs/components/FileManager/index.js +0 -32
  24. package/dist/cjs/components/FileManager/util.js +0 -138
  25. package/dist/cjs/hooks/use-files.js +0 -39
  26. package/dist/es/components/EditorHeader/EditorHeader.js +0 -180
  27. package/dist/es/components/EditorHeader/ProceedView.js +0 -165
  28. package/dist/es/components/FileManager/FileActions.js +0 -104
  29. package/dist/es/components/FileManager/FileContainer.js +0 -33
  30. package/dist/es/components/FileManager/FileCreatedDate.js +0 -18
  31. package/dist/es/components/FileManager/FileManager.js +0 -33
  32. package/dist/es/components/FileManager/FileManagerDragLayer.js +0 -48
  33. package/dist/es/components/FileManager/FileManagerProvider.js +0 -12
  34. package/dist/es/components/FileManager/FileName.js +0 -20
  35. package/dist/es/components/FileManager/FileSectionAlert.js +0 -163
  36. package/dist/es/components/FileManager/FileTypeIcon.js +0 -13
  37. package/dist/es/components/FileManager/FileUploader.js +0 -58
  38. package/dist/es/components/FileManager/InlineFilesSection.js +0 -103
  39. package/dist/es/components/FileManager/OtherFilesSection.js +0 -74
  40. package/dist/es/components/FileManager/SupplementsSection.js +0 -91
  41. package/dist/es/components/FileManager/index.js +0 -16
  42. package/dist/es/components/FileManager/util.js +0 -128
  43. package/dist/es/hooks/use-files.js +0 -35
  44. package/dist/types/components/EditorHeader/EditorHeader.d.ts +0 -68
  45. package/dist/types/components/EditorHeader/ProceedView.d.ts +0 -22
  46. package/dist/types/components/FileManager/FileActions.d.ts +0 -19
  47. package/dist/types/components/FileManager/FileContainer.d.ts +0 -1
  48. package/dist/types/components/FileManager/FileCreatedDate.d.ts +0 -8
  49. package/dist/types/components/FileManager/FileManager.d.ts +0 -30
  50. package/dist/types/components/FileManager/FileManagerDragLayer.d.ts +0 -2
  51. package/dist/types/components/FileManager/FileManagerProvider.d.ts +0 -15
  52. package/dist/types/components/FileManager/FileName.d.ts +0 -6
  53. package/dist/types/components/FileManager/FileSectionAlert.d.ts +0 -13
  54. package/dist/types/components/FileManager/FileTypeIcon.d.ts +0 -5
  55. package/dist/types/components/FileManager/FileUploader.d.ts +0 -5
  56. package/dist/types/components/FileManager/InlineFilesSection.d.ts +0 -6
  57. package/dist/types/components/FileManager/OtherFilesSection.d.ts +0 -5
  58. package/dist/types/components/FileManager/SupplementsSection.d.ts +0 -5
  59. package/dist/types/components/FileManager/index.d.ts +0 -16
  60. package/dist/types/components/FileManager/util.d.ts +0 -25
  61. package/dist/types/hooks/use-files.d.ts +0 -8
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.SupplementsSection = void 0;
36
- const json_schema_1 = require("@manuscripts/json-schema");
37
- const react_1 = __importStar(require("react"));
38
- const react_dnd_1 = require("react-dnd");
39
- const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
40
- const FileActions_1 = require("./FileActions");
41
- const FileContainer_1 = require("./FileContainer");
42
- const FileCreatedDate_1 = require("./FileCreatedDate");
43
- const FileManager_1 = require("./FileManager");
44
- const FileManagerProvider_1 = require("./FileManagerProvider");
45
- const FileName_1 = require("./FileName");
46
- const FileSectionAlert_1 = require("./FileSectionAlert");
47
- const FileUploader_1 = require("./FileUploader");
48
- const util_1 = require("./util");
49
- const SupplementsSection = ({ supplements }) => {
50
- const { modelMap, saveModel, deleteModel, fileManagement } = (0, react_1.useContext)(FileManagerProvider_1.FileManagerContext);
51
- const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
52
- const [alert, setAlert] = (0, react_1.useState)({
53
- type: FileSectionAlert_1.FileSectionAlertType.NONE,
54
- message: '',
55
- });
56
- const upload = (file) => __awaiter(void 0, void 0, void 0, function* () {
57
- setAlert({
58
- type: FileSectionAlert_1.FileSectionAlertType.UPLOAD_IN_PROGRESS,
59
- message: file.name,
60
- });
61
- const uploaded = yield fileManagement.upload(file);
62
- setAlert({
63
- type: FileSectionAlert_1.FileSectionAlertType.UPLOAD_SUCCESSFUL,
64
- message: '',
65
- });
66
- return uploaded;
67
- });
68
- const handleUpload = (file) => __awaiter(void 0, void 0, void 0, function* () {
69
- const uploaded = yield upload(file);
70
- const supplement = (0, json_schema_1.buildSupplement)('', uploaded.id);
71
- yield saveModel(Object.assign(Object.assign({}, supplement), { MIME: file.type }));
72
- });
73
- const handleReplace = (modelId, file) => __awaiter(void 0, void 0, void 0, function* () {
74
- const uploaded = yield upload(file);
75
- const supplement = (0, json_schema_1.buildSupplement)('', uploaded.id);
76
- yield deleteModel(modelId);
77
- yield saveModel(Object.assign(Object.assign({}, supplement), { MIME: file.type }));
78
- });
79
- const handleMoveToOtherFiles = (modelId) => __awaiter(void 0, void 0, void 0, function* () {
80
- yield deleteModel(modelId);
81
- setAlert({
82
- type: FileSectionAlert_1.FileSectionAlertType.MOVE_SUCCESSFUL,
83
- message: util_1.FileSectionType.OtherFile,
84
- });
85
- });
86
- return (react_1.default.createElement(react_1.default.Fragment, null,
87
- (can === null || can === void 0 ? void 0 : can.uploadFile) && react_1.default.createElement(FileUploader_1.FileUploader, { onUpload: handleUpload }),
88
- react_1.default.createElement(FileSectionAlert_1.FileSectionAlert, { alert: alert }),
89
- supplements.map((supplement) => (react_1.default.createElement(SupplementFile, { key: supplement.modelId, file: supplement, handleDownload: () => fileManagement.download(supplement), handleReplace: (f) => __awaiter(void 0, void 0, void 0, function* () { return yield handleReplace(supplement.modelId, f); }), handleDetach: () => __awaiter(void 0, void 0, void 0, function* () { return yield handleMoveToOtherFiles(supplement.modelId); }) })))));
90
- };
91
- exports.SupplementsSection = SupplementsSection;
92
- const SupplementFile = ({ file, handleDownload, handleReplace, handleDetach }) => {
93
- const [{ isDragging }, dragRef, preview] = (0, react_dnd_1.useDrag)({
94
- type: 'file',
95
- item: {
96
- file,
97
- model: {
98
- _id: file.modelId,
99
- objectType: json_schema_1.ObjectTypes.Supplement,
100
- },
101
- },
102
- collect: (monitor) => ({
103
- isDragging: monitor.isDragging(),
104
- }),
105
- });
106
- (0, react_1.useEffect)(() => {
107
- preview((0, react_dnd_html5_backend_1.getEmptyImage)());
108
- }, [preview]);
109
- return (react_1.default.createElement(FileContainer_1.FileContainer, { "data-cy": "file-container", key: file.id, ref: dragRef, className: isDragging ? 'dragging' : '' },
110
- react_1.default.createElement(FileName_1.FileName, { file: file }),
111
- react_1.default.createElement(FileCreatedDate_1.FileCreatedDate, { file: file, className: "show-on-hover" }),
112
- react_1.default.createElement(FileActions_1.FileActions, { "data-cy": "file-actions", sectionType: util_1.FileSectionType.Supplements, handleDownload: file.id ? handleDownload : undefined, handleReplace: handleReplace, move: file.id
113
- ? {
114
- sectionType: util_1.FileSectionType.OtherFile,
115
- handler: handleDetach,
116
- }
117
- : undefined })));
118
- };
@@ -1,32 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- __exportStar(require("./FileManager"), exports);
@@ -1,138 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isImageFile = exports.getFileTypeIcon = exports.getFileIcon = exports.getFileType = exports.FileType = exports.FileSectionType = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const icons_1 = require("../icons");
9
- var FileSectionType;
10
- (function (FileSectionType) {
11
- FileSectionType["Inline"] = "Inline files";
12
- FileSectionType["Supplements"] = "Supplements";
13
- FileSectionType["OtherFile"] = "Other files";
14
- })(FileSectionType = exports.FileSectionType || (exports.FileSectionType = {}));
15
- var FileType;
16
- (function (FileType) {
17
- FileType[FileType["Image"] = 0] = "Image";
18
- FileType[FileType["Audio"] = 1] = "Audio";
19
- FileType[FileType["Video"] = 2] = "Video";
20
- FileType[FileType["PlainDocument"] = 3] = "PlainDocument";
21
- FileType[FileType["SheetsWorkbooks"] = 4] = "SheetsWorkbooks";
22
- FileType[FileType["Latex"] = 5] = "Latex";
23
- FileType[FileType["CodeFile"] = 6] = "CodeFile";
24
- FileType[FileType["PdfFile"] = 7] = "PdfFile";
25
- FileType[FileType["CompressedFile"] = 8] = "CompressedFile";
26
- FileType[FileType["PlainText"] = 9] = "PlainText";
27
- FileType[FileType["Figure"] = 10] = "Figure";
28
- FileType[FileType["GraphicalAbstract"] = 11] = "GraphicalAbstract";
29
- })(FileType = exports.FileType || (exports.FileType = {}));
30
- const extension2type = new Map([
31
- ['png', FileType.Image],
32
- ['jpg', FileType.Image],
33
- ['jpeg', FileType.Image],
34
- ['jfif', FileType.Image],
35
- ['gif', FileType.Image],
36
- ['svg', FileType.Image],
37
- ['tif', FileType.Image],
38
- ['tiff', FileType.Image],
39
- ['mp3', FileType.Audio],
40
- ['wav', FileType.Audio],
41
- ['wma', FileType.Audio],
42
- ['flac', FileType.Audio],
43
- ['avi', FileType.Video],
44
- ['mp4', FileType.Video],
45
- ['mov', FileType.Video],
46
- ['wmv', FileType.Video],
47
- ['doc', FileType.PlainDocument],
48
- ['docx', FileType.PlainDocument],
49
- ['rtf', FileType.PlainDocument],
50
- ['xls', FileType.SheetsWorkbooks],
51
- ['xlsx', FileType.SheetsWorkbooks],
52
- ['xml', FileType.SheetsWorkbooks],
53
- ['tex', FileType.Latex],
54
- ['js', FileType.CodeFile],
55
- ['py', FileType.CodeFile],
56
- ['tsx', FileType.CodeFile],
57
- ['html', FileType.CodeFile],
58
- ['pdf', FileType.PdfFile],
59
- ['zip', FileType.CompressedFile],
60
- ['rar', FileType.CompressedFile],
61
- ['arj', FileType.CompressedFile],
62
- ['tar.gz', FileType.CompressedFile],
63
- ['tgz', FileType.CompressedFile],
64
- ['txt', FileType.PlainText],
65
- ]);
66
- const type2icon = new Map([
67
- [
68
- FileType.Audio,
69
- react_1.default.createElement(icons_1.FileAudioIcon, { key: FileType.Audio, className: "file-icon" }),
70
- ],
71
- [
72
- FileType.Video,
73
- react_1.default.createElement(icons_1.FileVideoIcon, { key: FileType.Video, className: "file-icon" }),
74
- ],
75
- [
76
- FileType.PlainDocument,
77
- react_1.default.createElement(icons_1.FileDocumentIcon, { key: FileType.PlainDocument, color: "#1A9BC7", className: "file-icon" }),
78
- ],
79
- [
80
- FileType.SheetsWorkbooks,
81
- react_1.default.createElement(icons_1.FileTableIcon, { key: FileType.SheetsWorkbooks, className: "file-icon" }),
82
- ],
83
- [
84
- FileType.Latex,
85
- react_1.default.createElement(icons_1.FileLatexIcon, { key: FileType.Latex, color: "#1A9BC7", className: "file-icon" }),
86
- ],
87
- [
88
- FileType.CodeFile,
89
- react_1.default.createElement(icons_1.FileCodeIcon, { key: FileType.CodeFile, className: "file-icon" }),
90
- ],
91
- [
92
- FileType.PdfFile,
93
- react_1.default.createElement(icons_1.FilePdfIcon, { key: FileType.PdfFile, className: "file-icon" }),
94
- ],
95
- [
96
- FileType.CompressedFile,
97
- react_1.default.createElement(icons_1.FileCompressedIcon, { key: FileType.CompressedFile, className: "file-icon" }),
98
- ],
99
- [
100
- FileType.PlainText,
101
- react_1.default.createElement(icons_1.FileDocumentIcon, { key: FileType.PlainText, color: "#FFBD26", className: "file-icon" }),
102
- ],
103
- [
104
- FileType.Image,
105
- react_1.default.createElement(icons_1.FileImageIcon, { key: FileType.Image, className: "file-icon" }),
106
- ],
107
- [
108
- FileType.Figure,
109
- react_1.default.createElement(icons_1.FileFigureIcon, { key: FileType.Figure, className: "file-icon" }),
110
- ],
111
- [
112
- FileType.GraphicalAbstract,
113
- react_1.default.createElement(icons_1.FileGraphicalAbstractIcon, { key: FileType.GraphicalAbstract, className: "file-icon" }),
114
- ],
115
- [undefined, react_1.default.createElement(icons_1.FileUnknownIcon, { key: undefined, className: "file-icon" })],
116
- ]);
117
- const getFileType = (file) => {
118
- const extension = getExtension(file.name);
119
- return extension2type.get(extension.toLowerCase());
120
- };
121
- exports.getFileType = getFileType;
122
- const getFileIcon = (file) => {
123
- const type = (0, exports.getFileType)(file);
124
- return type2icon.get(type);
125
- };
126
- exports.getFileIcon = getFileIcon;
127
- const getFileTypeIcon = (type) => {
128
- return type2icon.get(type);
129
- };
130
- exports.getFileTypeIcon = getFileTypeIcon;
131
- const isImageFile = (file) => {
132
- return (0, exports.getFileType)(file) === FileType.Image;
133
- };
134
- exports.isImageFile = isImageFile;
135
- const getExtension = (name) => {
136
- const index = name.indexOf('.');
137
- return index ? name.substring(index + 1) : '';
138
- };
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFiles = void 0;
4
- const json_schema_1 = require("@manuscripts/json-schema");
5
- const files_1 = require("../lib/files");
6
- const use_deep_compare_1 = require("./use-deep-compare");
7
- const types = [
8
- json_schema_1.ObjectTypes.Section,
9
- json_schema_1.ObjectTypes.FigureElement,
10
- json_schema_1.ObjectTypes.Figure,
11
- json_schema_1.ObjectTypes.Supplement,
12
- json_schema_1.ObjectTypes.ElementsOrder,
13
- ];
14
- const getOtherFiles = (inlineFiles, supplements, files) => {
15
- const excluded = new Set();
16
- inlineFiles.flatMap((f) => f.files).forEach((f) => excluded.add(f.id));
17
- supplements.forEach((s) => excluded.add(s.id));
18
- return files.filter((f) => !excluded.has(f.id));
19
- };
20
- const useFiles = (modelMap, files) => {
21
- const models = [];
22
- for (const [_, model] of modelMap.entries()) {
23
- if (types.includes(model.objectType)) {
24
- models.push(model);
25
- }
26
- }
27
- return (0, use_deep_compare_1.useDeepCompareMemo)(() => {
28
- const inlineFiles = (0, files_1.getInlineFiles)(modelMap, files);
29
- const supplements = (0, files_1.getSupplements)(modelMap, files);
30
- const otherFiles = getOtherFiles(inlineFiles, supplements, files);
31
- return {
32
- inlineFiles,
33
- supplements,
34
- otherFiles,
35
- };
36
- }, [models, files]);
37
- };
38
- exports.useFiles = useFiles;
39
- exports.default = exports.useFiles;
@@ -1,180 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import React, { useCallback, useState } from 'react';
11
- import styled from 'styled-components';
12
- import { ArrowLeftIcon, DropdownContainer, DropdownList, EditIcon, NavDropdownContainer, NavDropdownToggle, PrimaryButton, RoleAnnotatingIcon, RoleReadingIcon, SaveStatus, SecondaryButton, TextArea, useDropdown, } from '../..';
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 = {}));
22
- const Editing = { label: 'Editing', icon: EditIcon };
23
- const MapUserRole = {
24
- Editor: Editing,
25
- Owner: Editing,
26
- Writer: Editing,
27
- Annotator: { label: 'Suggesting', icon: RoleAnnotatingIcon },
28
- Viewer: { label: 'Reading', icon: RoleReadingIcon },
29
- Proofer: { label: 'Proofing', icon: RoleAnnotatingIcon },
30
- };
31
- export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userRole, canCompleteTask, submitProceed, goBack, status, isAnnotator, isProofer, message, exceptionDialog: ExceptionDialog, disabelProceedNote, }) => {
32
- var _a, _b, _c, _d, _e;
33
- const [noteValue, setNoteValue] = useState('');
34
- const [selectedTransitionIndex, setSelectedTransitionIndex] = useState();
35
- const { dialogData, submit } = submitProceed;
36
- const { updateState, clearError } = dialogData;
37
- const continueDialogAction = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
38
- if (submission && selectedTransitionIndex && handleSnapshot) {
39
- const { status } = submission.currentStep.type.transitions[selectedTransitionIndex];
40
- updateState(DialogState.LOADING);
41
- yield handleSnapshot();
42
- yield submit(status.id, noteValue);
43
- }
44
- }), [
45
- submission,
46
- selectedTransitionIndex,
47
- handleSnapshot,
48
- updateState,
49
- submit,
50
- noteValue,
51
- ]);
52
- const onTransitionClick = useCallback((event) => {
53
- updateState(DialogState.INIT);
54
- setSelectedTransitionIndex(event.target.value || event.target.parentNode.value);
55
- }, [setSelectedTransitionIndex, updateState]);
56
- const onCancelClick = useCallback(() => {
57
- setSelectedTransitionIndex(undefined);
58
- clearError();
59
- updateState(DialogState.CLOSED);
60
- }, [setSelectedTransitionIndex, clearError, updateState]);
61
- const onNoteChange = useCallback((event) => setNoteValue(event.target.value), [setNoteValue]);
62
- const currentStepTransition = submission === null || submission === void 0 ? void 0 : submission.currentStep.type.transitions;
63
- const disable = !currentStepTransition || !canCompleteTask;
64
- const errorCode = (_d = (_c = (_b = (_a = dialogData.mutationError) === null || _a === void 0 ? void 0 : _a.graphQLErrors) === null || _b === void 0 ? void 0 : _b.find((error) => { var _a; return (_a = error === null || error === void 0 ? void 0 : error.extensions) === null || _a === void 0 ? void 0 : _a.code; })) === null || _c === void 0 ? void 0 : _c.extensions) === null || _d === void 0 ? void 0 : _d.code.name;
65
- return (React.createElement(Wrapper, null,
66
- goBack && (React.createElement(SecondaryButtonSmall, { onClick: goBack, type: "button" },
67
- React.createElement(ArrowLeftIcon, null),
68
- React.createElement("span", null, "Dashboard"))),
69
- handleSnapshot &&
70
- typeof hasPendingSuggestions == 'boolean' &&
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 })),
72
- status && (React.createElement(ChildWrapper, null,
73
- React.createElement(SaveStatus, { status: status }))),
74
- React.createElement(Spacer, null),
75
- React.createElement(CurrentStepLabel, null, submission.currentStep.type.label),
76
- React.createElement(CurrentActionLablel, null,
77
- userRole &&
78
- MapUserRole[userRole] &&
79
- React.createElement(MapUserRole[userRole].icon),
80
- React.createElement("span", null, userRole && MapUserRole[userRole].label)),
81
- React.createElement(HelpDropdown, null),
82
- errorCode && React.createElement(ExceptionDialog, { errorCode: errorCode })));
83
- };
84
- const HelpDropdown = () => {
85
- const { isOpen, toggleOpen, wrapperRef } = useDropdown();
86
- return (React.createElement(HelpDropdownContainer, { ref: wrapperRef },
87
- React.createElement(HelpDropdownButton, { onClick: toggleOpen },
88
- React.createElement("span", null, "Help"),
89
- React.createElement(NavDropdownToggle, { className: isOpen ? 'open' : '' })),
90
- isOpen && (React.createElement(DropdownList, { top: 12, direction: "right" },
91
- React.createElement(DropdownItem, null, "Documentation")))));
92
- };
93
- const SecondaryButtonSmall = styled(SecondaryButton) `
94
- font-size: inherit;
95
- margin-right: ${(props) => props.theme.grid.unit * 2}px;
96
- padding-top: ${(props) => props.theme.grid.unit * 0.75}px;
97
- padding-bottom: ${(props) => props.theme.grid.unit * 0.75}px;
98
- `;
99
- const HelpDropdownButton = styled.button `
100
- background: transparent;
101
- border: none;
102
- cursor: pointer;
103
- `;
104
- const HelpDropdownContainer = styled(DropdownContainer) `
105
- border-left: 1px solid #f2f2f2;
106
- margin: -${(props) => props.theme.grid.unit * 3}px ${(props) => props.theme.grid.unit * 2}px -${(props) => props.theme.grid.unit * 3}px
107
- ${(props) => props.theme.grid.unit * 6}px;
108
- padding: ${(props) => props.theme.grid.unit * 4.75}px 0
109
- ${(props) => props.theme.grid.unit * 5}px
110
- ${(props) => props.theme.grid.unit * 4}px;
111
- `;
112
- const DropdownItem = styled.a `
113
- color: inherit;
114
- display: block;
115
- cursor: pointer;
116
- text-decoration: none;
117
- padding: ${(props) => props.theme.grid.unit * 5}px;
118
- `;
119
- export const PrimaryButtonSmall = styled(PrimaryButton) `
120
- padding-top: ${(props) => props.theme.grid.unit * 0.75}px;
121
- padding-bottom: ${(props) => props.theme.grid.unit * 0.75}px;
122
- font-size: inherit;
123
- `;
124
- const Wrapper = styled.div `
125
- display: flex;
126
- z-index: 6;
127
- padding: ${(props) => props.theme.grid.unit * 3}px
128
- ${(props) => props.theme.grid.unit * 8}px;
129
- width: 100%;
130
- box-sizing: border-box;
131
- align-items: center;
132
- border-bottom: 1px solid #f2f2f2;
133
- font-size: 14px;
134
- background: white;
135
-
136
- ${NavDropdownContainer} + ${NavDropdownContainer} {
137
- margin-left: ${(props) => props.theme.grid.unit * 2}px;
138
- }
139
- ${PrimaryButtonSmall} + ${NavDropdownContainer} {
140
- margin-left: ${(props) => props.theme.grid.unit * 2}px;
141
- }
142
- `;
143
- const CurrentStepLabel = styled.span `
144
- background: #f2f2f2;
145
- border-radius: ${(props) => props.theme.grid.unit * 1.5}px;
146
- padding: ${(props) => props.theme.grid.unit}px;
147
- `;
148
- const CurrentActionLablel = styled.span `
149
- display: flex;
150
- padding: 0 ${(props) => props.theme.grid.unit * 6}px;
151
- svg {
152
- margin-right: ${(props) => props.theme.grid.unit * 2.5}px;
153
- }
154
- `;
155
- const ChildWrapper = styled.div `
156
- display: inline-flex;
157
- margin: 0 2em;
158
- flex-direction: row;
159
- align-items: center;
160
- `;
161
- const Grid = styled.div `
162
- display: grid;
163
- grid-template-columns: max-content auto;
164
- gap: 0 ${(props) => props.theme.grid.unit * 2}px;
165
- margin-top: ${(props) => props.theme.grid.unit * 4}px;
166
- background: ${(props) => props.theme.colors.background.secondary};
167
- padding: ${(props) => props.theme.grid.unit * 6}px;
168
- `;
169
- const Line = styled.hr `
170
- margin: 5px 0 0 0;
171
- flex: 1;
172
- border: 1px dashed #c9c9c9;
173
- `;
174
- const Spacer = styled.div `
175
- flex: auto;
176
- `;
177
- export const MediumTextArea = styled(TextArea) `
178
- padding: 8px;
179
- font-size: 1em;
180
- `;
@@ -1,165 +0,0 @@
1
- import React, { useEffect, useMemo, useRef } from 'react';
2
- import styled from 'styled-components';
3
- import { Category, Dialog, DialogState, LoadingOverlay, NavDropdown, NavDropdownButton, NavDropdownContainer, PrimaryBoldHeading, PrimaryButton, SecondarySmallText, TaskStepDoneIcon, useDropdown, } from '../..';
4
- import { AlertMessage, AlertMessageType } from '../AlertMessage';
5
- import { PrimaryButtonSmall, } from './EditorHeader';
6
- const DropdownWrapper = ({ disabled, button, primary, children }) => {
7
- const { isOpen, toggleOpen, wrapperRef } = useDropdown();
8
- return (React.createElement(NavDropdownContainer, { id: 'user-dropdown', ref: wrapperRef },
9
- React.createElement(NavDropdownButton, { as: (primary && PrimaryButton) || undefined, disabled: disabled, isOpen: isOpen, onClick: toggleOpen }, button),
10
- isOpen && React.createElement(NavDropdown, { direction: "left" }, children)));
11
- };
12
- const StepDetails = ({ icon, label, description, role }) => (React.createElement(React.Fragment, null,
13
- icon && React.createElement(TaskStatus, null, icon),
14
- React.createElement(TaskContainer, null,
15
- React.createElement(PrimaryBoldHeading, null, label),
16
- React.createElement(SecondarySmallText, null, description),
17
- React.createElement(SecondarySmallText, null,
18
- "Actor: ",
19
- role.label))));
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
25
- ? {
26
- header: 'The task can not be transitioned to the next step',
27
- message: `There are still pending suggestions in the document.
28
- It is not possible to complete the task without having them approved or rejected.`,
29
- actions: {
30
- primary: {
31
- action: onCancelClick,
32
- title: 'Ok',
33
- },
34
- onClose: onCancelClick,
35
- },
36
- }
37
- : dialogData.state === DialogState.SUCCESS
38
- ? {
39
- header: 'Content reassigned successfully',
40
- message: `to the ${currentStepType.label}`,
41
- actions: {
42
- primary: {
43
- action: onCancelClick,
44
- title: 'Close',
45
- },
46
- onClose: onCancelClick,
47
- },
48
- }
49
- : {
50
- header: 'Are you sure?',
51
- message: 'You are about to complete your task. If you confirm, you will no longer be able to make any changes.',
52
- actions: {
53
- primary: {
54
- action: continueDialogAction,
55
- title: 'Continue',
56
- },
57
- secondary: {
58
- action: onCancelClick,
59
- title: 'Cancel',
60
- },
61
- onClose: onCancelClick,
62
- },
63
- }, [
64
- dialogData,
65
- continueDialogAction,
66
- onCancelClick,
67
- currentStepType,
68
- hasPendingSuggestions,
69
- isAnnotator,
70
- isProofer,
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;
84
- return (React.createElement(React.Fragment, null,
85
- (currentStepTransition && (currentStepTransition === null || currentStepTransition === void 0 ? void 0 : currentStepTransition.length) > 1 && (React.createElement(DropdownWrapper, { button: 'Complete task', disabled: disable, primary: true },
86
- React.createElement(TaskDropdown, null, currentStepTransition &&
87
- currentStepTransition.map((transition, index) => (React.createElement(Task, { key: 'task_' + transition.type.id, className: transition.status.id === 'success' ? 'happyPath' : '', value: index, onClick: onTransitionClick },
88
- React.createElement("strong", null, transition.type.label),
89
- transition.type.description))))))) || (React.createElement(PrimaryButtonSmall, { value: 0, onClick: onTransitionClick, disabled: disable }, "Complete task")),
90
- finalState === DialogState.LOADING && (React.createElement(LoadingOverlay, null,
91
- React.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026"))),
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,
95
- previousStepType && (React.createElement(StepDetails, Object.assign({}, previousStepType, { icon: React.createElement(React.Fragment, null,
96
- React.createElement(TaskStepDoneIcon, null),
97
- React.createElement(Line, null)) }))),
98
- React.createElement(StepDetails, Object.assign({}, currentStepType)))),
99
- finalState === DialogState.ERROR && (React.createElement(AlertMessage, { type: AlertMessageType.error, hideCloseButton: true }, dialogData.error)))));
100
- };
101
- const TaskDropdown = styled.div `
102
- display: flex;
103
- flex-direction: column;
104
- padding: ${(props) => props.theme.grid.unit * 2}px 0;
105
- `;
106
- const Task = styled.button `
107
- background: transparent;
108
- border: none;
109
- color: ${(props) => props.theme.colors.text.secondary};
110
- cursor: pointer;
111
- font: ${(props) => props.theme.font.weight.normal}
112
- ${(props) => props.theme.font.size.small} /
113
- ${(props) => props.theme.font.lineHeight.normal}
114
- ${(props) => props.theme.font.family.sans};
115
- order: 1;
116
- outline: none;
117
- padding: ${(props) => props.theme.grid.unit * 2}px
118
- ${(props) => props.theme.grid.unit * 4}px;
119
- text-align: left;
120
- width: ${(props) => props.theme.grid.unit * 66}px;
121
-
122
- &:not([disabled]):hover,
123
- &:not([disabled]):focus {
124
- background-color: ${(props) => props.theme.colors.button.default.background.hover};
125
- }
126
-
127
- strong {
128
- color: ${(props) => props.theme.colors.text.primary};
129
- display: block;
130
- font-size: ${(props) => props.theme.font.size.normal};
131
- line-height: ${(props) => props.theme.font.lineHeight.normal};
132
- }
133
-
134
- &.happyPath {
135
- border-bottom: 1px solid ${(props) => props.theme.colors.border.tertiary};
136
- order: 0;
137
- }
138
- `;
139
- const TextAreaWrapper = styled.div `
140
- margin-top: ${(props) => props.theme.grid.unit * 4}px;
141
- `;
142
- const Grid = styled.div `
143
- display: grid;
144
- grid-template-columns: max-content auto;
145
- gap: 0 ${(props) => props.theme.grid.unit * 2}px;
146
- margin-top: ${(props) => props.theme.grid.unit * 4}px;
147
- background: ${(props) => props.theme.colors.background.secondary};
148
- padding: ${(props) => props.theme.grid.unit * 6}px;
149
- `;
150
- const Line = styled.hr `
151
- margin: 5px 0 0 0;
152
- flex: 1;
153
- border: 1px dashed #c9c9c9;
154
- `;
155
- const TaskStatus = styled.div `
156
- grid-column: 1;
157
- display: flex;
158
- flex-direction: column;
159
- align-items: center;
160
- padding-top: 5px;
161
- `;
162
- const TaskContainer = styled.div `
163
- grid-column: 2;
164
- margin-bottom: 8px;
165
- `;