@manuscripts/style-guide 2.1.11-LEAN-4122.0 → 2.1.11-LEAN-4511.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.
@@ -11,42 +11,61 @@ var Actions;
11
11
  Actions["updateDueDate"] = "update-due-date";
12
12
  Actions["addNote"] = "add-note";
13
13
  Actions["setMainManuscript"] = "set-main-manuscript";
14
- Actions["editWithoutTracking"] = "edit-without-tracking";
15
14
  })(Actions || (Actions = {}));
16
15
  const getCapabilities = (project, profile, role, actions, isViewingMode) => {
17
- const userID = profile === null || profile === void 0 ? void 0 : profile.userID;
18
- const isMemberOf = (group) => { var _a; return (_a = group === null || group === void 0 ? void 0 : group.includes(userID !== null && userID !== void 0 ? userID : '')) !== null && _a !== void 0 ? _a : false; };
19
- const isOwner = isMemberOf(project === null || project === void 0 ? void 0 : project.owners);
20
- const isEditor = isMemberOf(project === null || project === void 0 ? void 0 : project.editors);
21
- const isAnnotator = isMemberOf(project === null || project === void 0 ? void 0 : project.annotators);
22
- const isProofer = isMemberOf(project === null || project === void 0 ? void 0 : project.proofers);
23
- const isViewer = isMemberOf(project === null || project === void 0 ? void 0 : project.viewers) || isViewingMode;
16
+ const isEditor = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.editors) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
17
+ const isOwner = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.owners) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
18
+ const isWriter = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.writers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
19
+ const isAnnotator = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.annotators) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
20
+ const isProofer = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.proofers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
21
+ const isViewer = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.viewers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))) || isViewingMode; };
22
+ const isProdEditor = () => role == 'pe';
24
23
  const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
25
- const canEditWithoutTracking = allowed(Actions.editWithoutTracking);
26
- const isPrivileged = isOwner || isEditor || canEditWithoutTracking;
27
- const canHandleAttachments = (isPrivileged || isAnnotator) && allowed(Actions.updateAttachment);
28
24
  return {
29
- handleSuggestion: isPrivileged,
30
- editWithoutTracking: canEditWithoutTracking,
31
- rejectOwnSuggestion: !isViewer,
32
- handleOwnComments: !isViewer,
33
- handleOthersComments: isOwner,
34
- resolveOwnComment: !isViewer,
35
- resolveOthersComment: isOwner || isEditor,
36
- createComment: !isViewer,
25
+ handleSuggestion: isOwner() || isEditor() || isWriter(),
26
+ editWithoutTracking: isWriter(),
27
+ rejectOwnSuggestion: !isViewer(),
28
+ createSuggestion: !isViewer(),
29
+ viewSuggestion: true,
30
+ seeEditorToolbar: !isViewer(),
31
+ seeReferencesButtons: !isViewer(),
32
+ handleOwnComments: !isViewer(),
33
+ handleOthersComments: isOwner(),
34
+ resolveOwnComment: !isViewer(),
35
+ resolveOthersComment: !(isViewer() || isAnnotator() || isProofer()),
36
+ createComment: !isViewer(),
37
+ viewNotes: true,
38
+ createNotes: !isViewer() && allowed(Actions.addNote),
39
+ handleNotes: isOwner() || isEditor() || isWriter() || isAnnotator(),
40
+ viewHistory: false,
41
+ restoreVersion: isOwner() || isEditor() || isWriter(),
37
42
  downloadFiles: true,
38
- changeDesignation: canHandleAttachments,
39
- moveFile: isPrivileged || isAnnotator,
40
- replaceFile: canHandleAttachments,
41
- uploadFile: canHandleAttachments,
42
- detachFile: isPrivileged || isAnnotator,
43
+ changeDesignation: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
44
+ allowed(Actions.updateAttachment),
45
+ moveFile: isOwner() || isEditor() || isWriter() || isAnnotator(),
46
+ replaceFile: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
47
+ allowed(Actions.updateAttachment) &&
48
+ !isViewingMode,
49
+ uploadFile: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
50
+ allowed(Actions.updateAttachment) &&
51
+ !isViewingMode,
52
+ detachFile: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
53
+ !isViewingMode,
54
+ handleQualityReport: isOwner() || isEditor() || isWriter(),
43
55
  setMainManuscript: allowed(Actions.setMainManuscript),
44
- editArticle: !isViewer,
45
- formatArticle: !isViewer,
46
- editMetadata: !(isViewer || isProofer),
47
- editCitationsAndRefs: !(isViewer || isProofer),
48
- seeEditorToolbar: !isViewer,
49
- seeReferencesButtons: !isViewer,
56
+ rejectTask: isProdEditor(),
57
+ acceptTask: isProdEditor(),
58
+ resolveOnHoldTask: isProdEditor(),
59
+ putOnHoldTask: isProdEditor(),
60
+ changeDueDate: isProdEditor() && allowed(Actions.updateDueDate),
61
+ previewAccess: true,
62
+ accessEditor: true,
63
+ formatArticle: !isViewer(),
64
+ editArticle: !isViewer(),
65
+ editMetadata: !(isViewer() || isProofer()) || isAnnotator(),
66
+ editCitationsAndRefs: !(isViewer() || isProofer()),
67
+ shareProject: isOwner(),
68
+ applySaveChanges: !(isAnnotator() || isProofer()),
50
69
  };
51
70
  };
52
71
  exports.getCapabilities = getCapabilities;
@@ -5,42 +5,61 @@ var Actions;
5
5
  Actions["updateDueDate"] = "update-due-date";
6
6
  Actions["addNote"] = "add-note";
7
7
  Actions["setMainManuscript"] = "set-main-manuscript";
8
- Actions["editWithoutTracking"] = "edit-without-tracking";
9
8
  })(Actions || (Actions = {}));
10
9
  export const getCapabilities = (project, profile, role, actions, isViewingMode) => {
11
- const userID = profile === null || profile === void 0 ? void 0 : profile.userID;
12
- const isMemberOf = (group) => { var _a; return (_a = group === null || group === void 0 ? void 0 : group.includes(userID !== null && userID !== void 0 ? userID : '')) !== null && _a !== void 0 ? _a : false; };
13
- const isOwner = isMemberOf(project === null || project === void 0 ? void 0 : project.owners);
14
- const isEditor = isMemberOf(project === null || project === void 0 ? void 0 : project.editors);
15
- const isAnnotator = isMemberOf(project === null || project === void 0 ? void 0 : project.annotators);
16
- const isProofer = isMemberOf(project === null || project === void 0 ? void 0 : project.proofers);
17
- const isViewer = isMemberOf(project === null || project === void 0 ? void 0 : project.viewers) || isViewingMode;
10
+ const isEditor = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.editors) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
11
+ const isOwner = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.owners) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
12
+ const isWriter = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.writers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
13
+ const isAnnotator = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.annotators) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
14
+ const isProofer = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.proofers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
15
+ const isViewer = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.viewers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))) || isViewingMode; };
16
+ const isProdEditor = () => role == 'pe';
18
17
  const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
19
- const canEditWithoutTracking = allowed(Actions.editWithoutTracking);
20
- const isPrivileged = isOwner || isEditor || canEditWithoutTracking;
21
- const canHandleAttachments = (isPrivileged || isAnnotator) && allowed(Actions.updateAttachment);
22
18
  return {
23
- handleSuggestion: isPrivileged,
24
- editWithoutTracking: canEditWithoutTracking,
25
- rejectOwnSuggestion: !isViewer,
26
- handleOwnComments: !isViewer,
27
- handleOthersComments: isOwner,
28
- resolveOwnComment: !isViewer,
29
- resolveOthersComment: isOwner || isEditor,
30
- createComment: !isViewer,
19
+ handleSuggestion: isOwner() || isEditor() || isWriter(),
20
+ editWithoutTracking: isWriter(),
21
+ rejectOwnSuggestion: !isViewer(),
22
+ createSuggestion: !isViewer(),
23
+ viewSuggestion: true,
24
+ seeEditorToolbar: !isViewer(),
25
+ seeReferencesButtons: !isViewer(),
26
+ handleOwnComments: !isViewer(),
27
+ handleOthersComments: isOwner(),
28
+ resolveOwnComment: !isViewer(),
29
+ resolveOthersComment: !(isViewer() || isAnnotator() || isProofer()),
30
+ createComment: !isViewer(),
31
+ viewNotes: true,
32
+ createNotes: !isViewer() && allowed(Actions.addNote),
33
+ handleNotes: isOwner() || isEditor() || isWriter() || isAnnotator(),
34
+ viewHistory: false,
35
+ restoreVersion: isOwner() || isEditor() || isWriter(),
31
36
  downloadFiles: true,
32
- changeDesignation: canHandleAttachments,
33
- moveFile: isPrivileged || isAnnotator,
34
- replaceFile: canHandleAttachments,
35
- uploadFile: canHandleAttachments,
36
- detachFile: isPrivileged || isAnnotator,
37
+ changeDesignation: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
38
+ allowed(Actions.updateAttachment),
39
+ moveFile: isOwner() || isEditor() || isWriter() || isAnnotator(),
40
+ replaceFile: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
41
+ allowed(Actions.updateAttachment) &&
42
+ !isViewingMode,
43
+ uploadFile: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
44
+ allowed(Actions.updateAttachment) &&
45
+ !isViewingMode,
46
+ detachFile: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
47
+ !isViewingMode,
48
+ handleQualityReport: isOwner() || isEditor() || isWriter(),
37
49
  setMainManuscript: allowed(Actions.setMainManuscript),
38
- editArticle: !isViewer,
39
- formatArticle: !isViewer,
40
- editMetadata: !(isViewer || isProofer),
41
- editCitationsAndRefs: !(isViewer || isProofer),
42
- seeEditorToolbar: !isViewer,
43
- seeReferencesButtons: !isViewer,
50
+ rejectTask: isProdEditor(),
51
+ acceptTask: isProdEditor(),
52
+ resolveOnHoldTask: isProdEditor(),
53
+ putOnHoldTask: isProdEditor(),
54
+ changeDueDate: isProdEditor() && allowed(Actions.updateDueDate),
55
+ previewAccess: true,
56
+ accessEditor: true,
57
+ formatArticle: !isViewer(),
58
+ editArticle: !isViewer(),
59
+ editMetadata: !(isViewer() || isProofer()) || isAnnotator(),
60
+ editCitationsAndRefs: !(isViewer() || isProofer()),
61
+ shareProject: isOwner(),
62
+ applySaveChanges: !(isAnnotator() || isProofer()),
44
63
  };
45
64
  };
46
65
  export const getAllPermitted = () => {
@@ -2,26 +2,43 @@ import { Project, UserProfile } from '@manuscripts/json-schema';
2
2
  import React from 'react';
3
3
  export type Capabilities = {
4
4
  handleSuggestion: boolean;
5
- editWithoutTracking: boolean;
6
5
  rejectOwnSuggestion: boolean;
6
+ createSuggestion: boolean;
7
+ viewSuggestion: boolean;
8
+ seeEditorToolbar: boolean;
9
+ seeReferencesButtons: boolean;
7
10
  handleOwnComments: boolean;
8
11
  resolveOwnComment: boolean;
9
12
  handleOthersComments: boolean;
10
13
  resolveOthersComment: boolean;
11
14
  createComment: boolean;
15
+ viewNotes: boolean;
16
+ createNotes: boolean;
17
+ handleNotes: boolean;
18
+ viewHistory: boolean;
19
+ restoreVersion: boolean;
12
20
  downloadFiles: boolean;
13
21
  changeDesignation: boolean;
14
22
  moveFile: boolean;
15
23
  replaceFile: boolean;
16
24
  uploadFile: boolean;
17
25
  detachFile: boolean;
26
+ handleQualityReport: boolean;
18
27
  setMainManuscript: boolean;
28
+ rejectTask: boolean;
29
+ acceptTask: boolean;
30
+ resolveOnHoldTask: boolean;
31
+ putOnHoldTask: boolean;
32
+ changeDueDate: boolean;
33
+ previewAccess: boolean;
34
+ editWithoutTracking: boolean;
35
+ accessEditor: boolean;
19
36
  formatArticle: boolean;
20
37
  editArticle: boolean;
21
38
  editMetadata: boolean;
39
+ shareProject: boolean;
22
40
  editCitationsAndRefs: boolean;
23
- seeEditorToolbar: boolean;
24
- seeReferencesButtons: boolean;
41
+ applySaveChanges: boolean;
25
42
  };
26
43
  export interface ProviderProps {
27
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": "2.1.11-LEAN-4122.0",
4
+ "version": "2.1.11-LEAN-4511.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",