@manuscripts/style-guide 2.1.10-LEAN-4432.0 → 2.1.11-LEAN-4122.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,58 +11,42 @@ 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";
14
15
  })(Actions || (Actions = {}));
15
16
  const getCapabilities = (project, profile, role, actions, 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';
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;
23
24
  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);
24
28
  return {
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(),
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,
42
37
  downloadFiles: true,
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
- uploadFile: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
49
- allowed(Actions.updateAttachment),
50
- detachFile: isOwner() || isEditor() || isWriter() || isAnnotator(),
51
- handleQualityReport: isOwner() || isEditor() || isWriter(),
38
+ changeDesignation: canHandleAttachments,
39
+ moveFile: isPrivileged || isAnnotator,
40
+ replaceFile: canHandleAttachments,
41
+ uploadFile: canHandleAttachments,
42
+ detachFile: isPrivileged || isAnnotator,
52
43
  setMainManuscript: allowed(Actions.setMainManuscript),
53
- rejectTask: isProdEditor(),
54
- acceptTask: isProdEditor(),
55
- resolveOnHoldTask: isProdEditor(),
56
- putOnHoldTask: isProdEditor(),
57
- changeDueDate: isProdEditor() && allowed(Actions.updateDueDate),
58
- previewAccess: true,
59
- accessEditor: true,
60
- formatArticle: !isViewer(),
61
- editArticle: !isViewer(),
62
- editMetadata: !(isViewer() || isProofer()) || isAnnotator(),
63
- editCitationsAndRefs: !(isViewer() || isProofer()),
64
- shareProject: isOwner(),
65
- applySaveChanges: !(isAnnotator() || isProofer()),
44
+ editArticle: !isViewer,
45
+ formatArticle: !isViewer,
46
+ editMetadata: !(isViewer || isProofer),
47
+ editCitationsAndRefs: !(isViewer || isProofer),
48
+ seeEditorToolbar: !isViewer,
49
+ seeReferencesButtons: !isViewer,
66
50
  };
67
51
  };
68
52
  exports.getCapabilities = getCapabilities;
@@ -5,58 +5,42 @@ 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";
8
9
  })(Actions || (Actions = {}));
9
10
  export const getCapabilities = (project, profile, role, actions, 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';
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;
17
18
  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);
18
22
  return {
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(),
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,
36
31
  downloadFiles: true,
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
- uploadFile: (isOwner() || isEditor() || isWriter() || isAnnotator()) &&
43
- allowed(Actions.updateAttachment),
44
- detachFile: isOwner() || isEditor() || isWriter() || isAnnotator(),
45
- handleQualityReport: isOwner() || isEditor() || isWriter(),
32
+ changeDesignation: canHandleAttachments,
33
+ moveFile: isPrivileged || isAnnotator,
34
+ replaceFile: canHandleAttachments,
35
+ uploadFile: canHandleAttachments,
36
+ detachFile: isPrivileged || isAnnotator,
46
37
  setMainManuscript: allowed(Actions.setMainManuscript),
47
- rejectTask: isProdEditor(),
48
- acceptTask: isProdEditor(),
49
- resolveOnHoldTask: isProdEditor(),
50
- putOnHoldTask: isProdEditor(),
51
- changeDueDate: isProdEditor() && allowed(Actions.updateDueDate),
52
- previewAccess: true,
53
- accessEditor: true,
54
- formatArticle: !isViewer(),
55
- editArticle: !isViewer(),
56
- editMetadata: !(isViewer() || isProofer()) || isAnnotator(),
57
- editCitationsAndRefs: !(isViewer() || isProofer()),
58
- shareProject: isOwner(),
59
- applySaveChanges: !(isAnnotator() || isProofer()),
38
+ editArticle: !isViewer,
39
+ formatArticle: !isViewer,
40
+ editMetadata: !(isViewer || isProofer),
41
+ editCitationsAndRefs: !(isViewer || isProofer),
42
+ seeEditorToolbar: !isViewer,
43
+ seeReferencesButtons: !isViewer,
60
44
  };
61
45
  };
62
46
  export const getAllPermitted = () => {
@@ -2,43 +2,26 @@ 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;
5
6
  rejectOwnSuggestion: boolean;
6
- createSuggestion: boolean;
7
- viewSuggestion: boolean;
8
- seeEditorToolbar: boolean;
9
- seeReferencesButtons: boolean;
10
7
  handleOwnComments: boolean;
11
8
  resolveOwnComment: boolean;
12
9
  handleOthersComments: boolean;
13
10
  resolveOthersComment: boolean;
14
11
  createComment: boolean;
15
- viewNotes: boolean;
16
- createNotes: boolean;
17
- handleNotes: boolean;
18
- viewHistory: boolean;
19
- restoreVersion: boolean;
20
12
  downloadFiles: boolean;
21
13
  changeDesignation: boolean;
22
14
  moveFile: boolean;
23
15
  replaceFile: boolean;
24
16
  uploadFile: boolean;
25
17
  detachFile: boolean;
26
- handleQualityReport: boolean;
27
18
  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;
36
19
  formatArticle: boolean;
37
20
  editArticle: boolean;
38
21
  editMetadata: boolean;
39
- shareProject: boolean;
40
22
  editCitationsAndRefs: boolean;
41
- applySaveChanges: boolean;
23
+ seeEditorToolbar: boolean;
24
+ seeReferencesButtons: boolean;
42
25
  };
43
26
  export interface ProviderProps {
44
27
  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.10-LEAN-4432.0",
4
+ "version": "2.1.11-LEAN-4122.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",