@manuscripts/style-guide 2.1.12 → 2.1.13-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,61 +11,44 @@ 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 isWriter = isMemberOf(project === null || project === void 0 ? void 0 : project.writers);
22
+ const isAnnotator = isMemberOf(project === null || project === void 0 ? void 0 : project.annotators);
23
+ const isProofer = isMemberOf(project === null || project === void 0 ? void 0 : project.proofers);
24
+ const isViewer = isMemberOf(project === null || project === void 0 ? void 0 : project.viewers) || isViewingMode;
23
25
  const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
26
+ const canEditWithoutTracking = allowed(Actions.editWithoutTracking);
27
+ const isPrivileged = isOwner || isEditor || isWriter;
28
+ const canEditFiles = (isPrivileged || isAnnotator) && !isViewingMode;
29
+ const canUpdateAttachments = canEditFiles && allowed(Actions.updateAttachment);
24
30
  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(),
31
+ handleSuggestion: isPrivileged,
32
+ editWithoutTracking: canEditWithoutTracking,
33
+ rejectOwnSuggestion: !isViewer,
34
+ handleOwnComments: !isViewer,
35
+ handleOthersComments: isOwner,
36
+ resolveOwnComment: !isViewer,
37
+ resolveOthersComment: isOwner || isEditor,
38
+ createComment: !isViewer,
42
39
  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
- !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(),
40
+ changeDesignation: canUpdateAttachments,
41
+ moveFile: canEditFiles,
42
+ replaceFile: canUpdateAttachments,
43
+ uploadFile: canUpdateAttachments,
44
+ detachFile: canEditFiles,
55
45
  setMainManuscript: allowed(Actions.setMainManuscript),
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()),
46
+ editArticle: !isViewer,
47
+ formatArticle: !isViewer,
48
+ editMetadata: !(isViewer || isProofer),
49
+ editCitationsAndRefs: !(isViewer || isProofer),
50
+ seeEditorToolbar: !isViewer,
51
+ seeReferencesButtons: !isViewer,
69
52
  };
70
53
  };
71
54
  exports.getCapabilities = getCapabilities;
@@ -5,61 +5,44 @@ 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 isWriter = isMemberOf(project === null || project === void 0 ? void 0 : project.writers);
16
+ const isAnnotator = isMemberOf(project === null || project === void 0 ? void 0 : project.annotators);
17
+ const isProofer = isMemberOf(project === null || project === void 0 ? void 0 : project.proofers);
18
+ const isViewer = isMemberOf(project === null || project === void 0 ? void 0 : project.viewers) || isViewingMode;
17
19
  const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
20
+ const canEditWithoutTracking = allowed(Actions.editWithoutTracking);
21
+ const isPrivileged = isOwner || isEditor || isWriter;
22
+ const canEditFiles = (isPrivileged || isAnnotator) && !isViewingMode;
23
+ const canUpdateAttachments = canEditFiles && allowed(Actions.updateAttachment);
18
24
  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(),
25
+ handleSuggestion: isPrivileged,
26
+ editWithoutTracking: canEditWithoutTracking,
27
+ rejectOwnSuggestion: !isViewer,
28
+ handleOwnComments: !isViewer,
29
+ handleOthersComments: isOwner,
30
+ resolveOwnComment: !isViewer,
31
+ resolveOthersComment: isOwner || isEditor,
32
+ createComment: !isViewer,
36
33
  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
- !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(),
34
+ changeDesignation: canUpdateAttachments,
35
+ moveFile: canEditFiles,
36
+ replaceFile: canUpdateAttachments,
37
+ uploadFile: canUpdateAttachments,
38
+ detachFile: canEditFiles,
49
39
  setMainManuscript: allowed(Actions.setMainManuscript),
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()),
40
+ editArticle: !isViewer,
41
+ formatArticle: !isViewer,
42
+ editMetadata: !(isViewer || isProofer),
43
+ editCitationsAndRefs: !(isViewer || isProofer),
44
+ seeEditorToolbar: !isViewer,
45
+ seeReferencesButtons: !isViewer,
63
46
  };
64
47
  };
65
48
  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.12",
4
+ "version": "2.1.13-LEAN-4122.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",