• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / crdc-datahub-ui / 18789341118

24 Oct 2025 06:57PM UTC coverage: 78.178% (+15.5%) from 62.703%
18789341118

push

github

web-flow
Merge pull request #888 from CBIIT/3.4.0

3.4.0 Release

4977 of 5488 branches covered (90.69%)

Branch coverage included in aggregate %.

8210 of 9264 new or added lines in 257 files covered. (88.62%)

6307 existing lines in 120 files now uncovered.

30203 of 39512 relevant lines covered (76.44%)

213.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.52
/src/utils/formModeUtils.ts
1
import { hasPermission } from "../config/AuthPermissions";
1✔
2

3
export type FormMode = "Unauthorized" | "Edit" | "View Only" | "Review";
4

5
export const ViewOnlyStatuses = ["Submitted", "In Review", "Approved", "Rejected"];
1✔
6
export const EditStatuses = ["New", "In Progress", "Inquired"];
1✔
7
export const ReviewStatuses = ["In Review"];
1✔
8
export const FormModes = {
1✔
9
  UNAUTHORIZED: "Unauthorized",
1✔
10
  EDIT: "Edit",
1✔
11
  VIEW_ONLY: "View Only",
1✔
12
  REVIEW: "Review",
1✔
13
} as const;
1✔
14

15
/**
16
 * Get updated form mode based on user permissions and form status
17
 *
18
 * @param {User} user - The current user
19
 * @param {Application} data - The current application/submission
20
 * @returns {FormMode} - Updated form mode based on role, organization role, and form status
21
 */
22
export const getFormMode = (user: User, data: Application): FormMode => {
1✔
23
  if (!data) {
104✔
24
    return FormModes.UNAUTHORIZED;
2✔
25
  }
2✔
26
  const isFormOwner = user?._id === data.applicant?.applicantID;
104✔
27
  if (!hasPermission(user, "submission_request", "view") && !isFormOwner) {
104✔
28
    return FormModes.UNAUTHORIZED;
33✔
29
  }
33✔
30

31
  if (
69✔
32
    !isFormOwner &&
69✔
33
    !hasPermission(user, "submission_request", "view") &&
18!
UNCOV
34
    !hasPermission(user, "submission_request", "create") &&
×
UNCOV
35
    !hasPermission(user, "submission_request", "review")
×
36
  ) {
104!
37
    return FormModes.UNAUTHORIZED;
×
UNCOV
38
  }
✔
39

40
  if (
69✔
41
    hasPermission(user, "submission_request", "review") &&
69✔
42
    ReviewStatuses.includes(data?.status)
14✔
43
  ) {
104✔
44
    return FormModes.REVIEW;
1✔
45
  }
1✔
46

47
  // User is only allowed to edit their own Submission Request
48
  if (
68✔
49
    isFormOwner &&
68✔
50
    hasPermission(user, "submission_request", "create") &&
50✔
51
    EditStatuses.includes(data?.status)
26✔
52
  ) {
104✔
53
    return FormModes.EDIT;
13✔
54
  }
13✔
55

56
  return FormModes.VIEW_ONLY;
55✔
57
};
55✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc