@truedat/core 5.17.2 → 5.17.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "5.17.2",
3
+ "version": "5.17.3",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -117,5 +117,5 @@
117
117
  "react-dom": ">= 16.8.6 < 17",
118
118
  "semantic-ui-react": ">= 2.0.3 < 2.2"
119
119
  },
120
- "gitHead": "1120a6efa4dfec423696957c5e72d752c9db284f"
120
+ "gitHead": "ec07aeeabffbb6e46d2d22ade283de203dd94c88"
121
121
  }
@@ -1,7 +1,7 @@
1
1
  import { gql } from "@apollo/client";
2
2
 
3
3
  export const DOMAINS_QUERY = gql`
4
- query DomainsQuery($action: String!, $domainActions: [String!], $ids: [ID]) {
4
+ query DomainsQuery($action: String!, $domainActions: [String], $ids: [ID]) {
5
5
  domains(action: $action, ids: $ids) {
6
6
  id
7
7
  externalId
@@ -12,6 +12,12 @@ export const DOMAINS_QUERY = gql`
12
12
  }
13
13
  `;
14
14
 
15
+ export const HAS_ANY_DOMAIN_QUERY = gql`
16
+ query HasAnyDomainQuery($action: String!) {
17
+ has_any_domain(action: $action)
18
+ }
19
+ `;
20
+
15
21
  export const DOMAIN_QUERY = gql`
16
22
  query DomainQuery($id: ID!, $actions: [String!]) {
17
23
  domain(id: $id) {
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+ import { Form, Icon, Popup, Label } from "semantic-ui-react";
4
+
5
+ export default function FieldLabel({
6
+ children,
7
+ label,
8
+ required,
9
+ tooltip,
10
+ error,
11
+ }) {
12
+ return (
13
+ <Form.Field>
14
+ <label className="field-label">
15
+ {label}
16
+ {required && <span>*</span>}
17
+ {tooltip && (
18
+ <Popup
19
+ trigger={
20
+ <Icon
21
+ className="field-label-popup"
22
+ name="question circle outline"
23
+ />
24
+ }
25
+ content={tooltip}
26
+ on="click"
27
+ hideOnScroll
28
+ />
29
+ )}
30
+ {error && (
31
+ <Label
32
+ size="small"
33
+ className="field-label-error"
34
+ basic
35
+ pointing="left"
36
+ >
37
+ {error}
38
+ </Label>
39
+ )}
40
+ </label>
41
+ {children}
42
+ </Form.Field>
43
+ );
44
+ }
45
+
46
+ FieldLabel.propTypes = {
47
+ children: PropTypes.node,
48
+ label: PropTypes.string,
49
+ required: PropTypes.bool,
50
+ tooltip: PropTypes.string,
51
+ error: PropTypes.string,
52
+ };
@@ -1,15 +1,16 @@
1
1
  import React from "react";
2
2
  import { useAuthorized } from "../hooks";
3
- import { DATA_VIEWS, FUNCTIONS } from "../routes";
3
+ import { DATA_VIEWS, FUNCTIONS, QUALITY_CONTROLS } from "../routes";
4
4
  import Submenu from "./Submenu";
5
5
 
6
6
  export const ITEMS = [
7
7
  { name: "dataViews", routes: [DATA_VIEWS] },
8
8
  { name: "functions", routes: [FUNCTIONS] },
9
+ { name: "quality_controls", routes: [QUALITY_CONTROLS] },
9
10
  ];
10
11
 
11
12
  export default function QxMenu() {
12
- const authorized = useAuthorized();
13
+ const authorized = useAuthorized("quality_control");
13
14
 
14
15
  return authorized ? (
15
16
  <Submenu items={ITEMS} icon="weight" name="quality_experience" />
@@ -19,6 +19,7 @@ import DescriptionInput from "./DescriptionInput";
19
19
  import DomainSelector from "./DomainSelector";
20
20
  import DropdownMenuItem from "./DropdownMenuItem";
21
21
  import ErrorBoundary from "./ErrorBoundary";
22
+ import FieldLabel from "./FieldLabel";
22
23
  import FiltersLoader from "./FiltersLoader";
23
24
  import GlossaryMenu from "./GlossaryMenu";
24
25
  import GrantMenu from "./GrantMenu";
@@ -72,6 +73,7 @@ export {
72
73
  DomainSelector,
73
74
  DropdownMenuItem,
74
75
  ErrorBoundary,
76
+ FieldLabel,
75
77
  FiltersLoader,
76
78
  GlossaryMenu,
77
79
  GrantMenu,
@@ -0,0 +1,19 @@
1
+ import _ from "lodash/fp";
2
+ import PropTypes from "prop-types";
3
+ import { useQuery } from "@apollo/client";
4
+ import { DOMAINS_QUERY } from "../api/queries";
5
+
6
+ export default function useActionDomains(props) {
7
+ const action = _.propOr("viewDomain", "action")(props);
8
+ const onCompleted = _.prop("onLoad")(props);
9
+ return useQuery(DOMAINS_QUERY, {
10
+ fetchPolicy: "cache-and-network",
11
+ variables: { action },
12
+ onCompleted,
13
+ });
14
+ }
15
+
16
+ useActionDomains.propTypes = {
17
+ action: PropTypes.string,
18
+ onLoad: PropTypes.func,
19
+ };
@@ -0,0 +1,19 @@
1
+ import _ from "lodash/fp";
2
+ import PropTypes from "prop-types";
3
+ import { useQuery } from "@apollo/client";
4
+ import { HAS_ANY_DOMAIN_QUERY } from "../api/queries";
5
+
6
+ export default function useAuthorizedAction(props) {
7
+ const action = _.propOr("viewDomain", "action")(props);
8
+ const onCompleted = _.prop("onLoad")(props);
9
+ return useQuery(HAS_ANY_DOMAIN_QUERY, {
10
+ fetchPolicy: "cache-and-network",
11
+ variables: { action },
12
+ onCompleted,
13
+ });
14
+ }
15
+
16
+ useAuthorizedAction.propTypes = {
17
+ action: PropTypes.string,
18
+ onLoad: PropTypes.func,
19
+ };
package/src/routes.js CHANGED
@@ -145,6 +145,12 @@ export const PENDING_STRUCTURE_NOTES = "/structureNotes";
145
145
  export const PROFILE_EXECUTION =
146
146
  "/profileGroups/:group_id/profileExecutions/:id";
147
147
  export const PROFILE_GROUP = "/profileGroups/:id";
148
+ export const QUALITY_CONTROLS = "/qualityControls";
149
+ export const QUALITY_CONTROL_NEW = "/qualityControls/new";
150
+ export const QUALITY_CONTROL_EDIT = "/qualityControls/:id/edit";
151
+ export const QUALITY_CONTROL_NEW_DRAFT = "/qualityControls/:id/new_draft";
152
+ export const QUALITY_CONTROL = "/qualityControls/:id";
153
+ export const QUALITY_CONTROL_HISTORY = "/qualityControls/:id/history";
148
154
  export const QUALITY_DASHBOARD = "/quality_dashboard";
149
155
  export const REFERENCE_DATASET = "/referenceDatasets/:id";
150
156
  export const REFERENCE_DATASETS = "/referenceDatasets";
@@ -346,6 +352,12 @@ const routes = {
346
352
  PENDING_STRUCTURE_NOTES,
347
353
  PROFILE_EXECUTION,
348
354
  PROFILE_GROUP,
355
+ QUALITY_CONTROLS,
356
+ QUALITY_CONTROL_NEW,
357
+ QUALITY_CONTROL_EDIT,
358
+ QUALITY_CONTROL_NEW_DRAFT,
359
+ QUALITY_CONTROL,
360
+ QUALITY_CONTROL_HISTORY,
349
361
  QUALITY_DASHBOARD,
350
362
  REFERENCE_DATASET,
351
363
  REFERENCE_DATASETS,
@@ -0,0 +1,35 @@
1
+ export const numberRules = ({
2
+ formatMessage,
3
+ required,
4
+ minValue,
5
+ maxValue,
6
+ }) => ({
7
+ required: required
8
+ ? formatMessage({ id: "form.validation.empty_required" })
9
+ : null,
10
+ min:
11
+ minValue || minValue === 0
12
+ ? {
13
+ value: minValue,
14
+ message: formatMessage(
15
+ { id: "form.validation.must_be_greater_than_or_equal" },
16
+ { value: minValue }
17
+ ),
18
+ }
19
+ : null,
20
+ max:
21
+ maxValue || maxValue === 0
22
+ ? {
23
+ value: maxValue,
24
+ message: formatMessage(
25
+ { id: "form.validation.must_be_less_than_or_equal" },
26
+ { value: maxValue }
27
+ ),
28
+ }
29
+ : null,
30
+ pattern: {
31
+ value: /^(-)?\d+(\.\d+)?$/,
32
+ message: formatMessage({ id: "form.validation.must_be_a_number" }),
33
+ },
34
+ valueAsNumber: true,
35
+ });
@@ -5,6 +5,7 @@ import * as filters from "./filters";
5
5
  import * as message from "./message";
6
6
  import * as sort from "./sort";
7
7
  import * as format from "./format";
8
+ import * as formRules from "./formRules";
8
9
  import columnDecorator from "./columnDecorator";
9
10
  import columnDecoratorComponent from "./columnDecoratorComponent";
10
11
  import columnPredicate from "./columnPredicate";
@@ -18,6 +19,7 @@ export {
18
19
  fieldType,
19
20
  filters,
20
21
  format,
22
+ formRules,
21
23
  message,
22
24
  sort,
23
25
  };
@@ -0,0 +1,10 @@
1
+ export const mapStatusColor = {
2
+ deprecated: "grey",
3
+ draft: "olive",
4
+ pending_approval: "teal",
5
+ published: "green",
6
+ rejected: "red",
7
+ versioned: "yellow",
8
+ };
9
+
10
+ export const colorForStatus = (status) => mapStatusColor[status];