@truedat/dd 7.11.1 → 7.11.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 +3 -3
- package/src/api/queries.js +278 -8
- package/src/components/ImplementationStructuresLoader.js +6 -6
- package/src/components/StructureGrants.js +50 -7
- package/src/components/StructureSelectorInputField.js +7 -5
- package/src/components/StructureVersions.js +15 -2
- package/src/components/__tests__/ImplementationStructuresLoader.spec.js +5 -5
- package/src/components/__tests__/ProfileExecutionLoader.spec.js +1 -1
- package/src/components/__tests__/ProfileGroupLoader.spec.js +1 -1
- package/src/components/__tests__/StructureGrants.spec.js +26 -0
- package/src/components/__tests__/StructureVersions.spec.js +26 -0
- package/src/reducers/__tests__/graph.spec.js +3 -3
- package/src/reducers/__tests__/graphLoading.spec.js +3 -3
- package/src/reducers/__tests__/graphRedirect.spec.js +3 -3
- package/src/reducers/__tests__/structureFields.spec.js +7 -7
- package/src/reducers/__tests__/structureImpactGraph.spec.js +3 -3
- package/src/reducers/__tests__/structureImpactId.spec.js +3 -3
- package/src/reducers/__tests__/structureLineageGraph.spec.js +3 -3
- package/src/reducers/__tests__/structureLineageId.spec.js +3 -3
- package/src/reducers/__tests__/structureLinks.spec.js +5 -5
- package/src/reducers/__tests__/structureRedirect.spec.js +1 -1
- package/src/reducers/__tests__/structureRelations.spec.js +3 -3
- package/src/reducers/__tests__/structureSystem.spec.js +3 -3
- package/src/reducers/__tests__/structureVersions.spec.js +3 -3
- package/src/reducers/graph.js +2 -2
- package/src/reducers/graphLoading.js +2 -2
- package/src/reducers/graphRedirect.js +2 -2
- package/src/reducers/structure.js +3 -1
- package/src/reducers/structureFields.js +4 -4
- package/src/reducers/structureImpactGraph.js +2 -2
- package/src/reducers/structureImpactId.js +2 -2
- package/src/reducers/structureLineageGraph.js +2 -2
- package/src/reducers/structureLineageId.js +2 -2
- package/src/reducers/structureLinks.js +3 -3
- package/src/reducers/structureRelations.js +4 -4
- package/src/reducers/structureSiblings.js +7 -1
- package/src/reducers/structureSystem.js +2 -2
- package/src/reducers/structureVersions.js +3 -3
- package/src/routines.js +4 -0
- package/src/sagas/__tests__/legacyFetchStructure.spec.js +148 -0
- package/src/sagas/__tests__/requestGrantRemoval.spec.js +132 -0
- package/src/sagas/createGrantRequestStatus.js +1 -0
- package/src/sagas/fetchStructureChildrens.js +48 -0
- package/src/sagas/fetchStructureParents.js +48 -0
- package/src/sagas/fetchStructureVersions.js +46 -0
- package/src/sagas/index.js +3 -0
- package/src/sagas/legacyFetchStructure.js +55 -0
- package/src/sagas/requestGrantRemoval.js +2 -2
- package/src/selectors/__tests__/getTabVisibility.spec.js +6 -6
- package/src/selectors/getStructuresFields.js +3 -2
- package/src/selectors/getTabVisibility.js +8 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dd",
|
|
3
|
-
"version": "7.11.
|
|
3
|
+
"version": "7.11.3",
|
|
4
4
|
"description": "Truedat Web Data Dictionary",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/react": "^16.3.0",
|
|
50
50
|
"@testing-library/user-event": "^14.6.1",
|
|
51
|
-
"@truedat/test": "7.11.
|
|
51
|
+
"@truedat/test": "7.11.2",
|
|
52
52
|
"identity-obj-proxy": "^3.0.0",
|
|
53
53
|
"jest": "^29.7.0",
|
|
54
54
|
"redux-saga-test-plan": "^4.0.6"
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"svg-pan-zoom": "^3.6.2",
|
|
84
84
|
"swr": "^2.3.3"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "59064d786ac330fd0b9f1d613a7d56f26842caf7"
|
|
87
87
|
}
|
package/src/api/queries.js
CHANGED
|
@@ -238,7 +238,7 @@ export const STRUCTURE_STRUCTURE_LINKS_QUERY = gql`
|
|
|
238
238
|
}
|
|
239
239
|
`;
|
|
240
240
|
|
|
241
|
-
export const
|
|
241
|
+
export const LEGACY_DATA_STRUCTURE_VERSION_QUERY = gql`
|
|
242
242
|
query DataStructureVersion(
|
|
243
243
|
$dataStructureId: ID!
|
|
244
244
|
$version: String!
|
|
@@ -253,6 +253,7 @@ export const DATA_STRUCTURE_VERSION_QUERY = gql`
|
|
|
253
253
|
type
|
|
254
254
|
group
|
|
255
255
|
deleted_at
|
|
256
|
+
metadata
|
|
256
257
|
data_structure {
|
|
257
258
|
alias
|
|
258
259
|
confidential
|
|
@@ -419,6 +420,7 @@ export const DATA_STRUCTURE_VERSION_QUERY = gql`
|
|
|
419
420
|
in
|
|
420
421
|
out
|
|
421
422
|
}
|
|
423
|
+
|
|
422
424
|
data_fields {
|
|
423
425
|
alias
|
|
424
426
|
classes
|
|
@@ -483,16 +485,284 @@ export const DATA_STRUCTURE_VERSION_QUERY = gql`
|
|
|
483
485
|
}
|
|
484
486
|
`;
|
|
485
487
|
|
|
488
|
+
export const DATA_STRUCTURE_VERSION_QUERY = gql`
|
|
489
|
+
query DataStructureVersion($dataStructureId: ID!, $version: String!) {
|
|
490
|
+
dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
|
|
491
|
+
id
|
|
492
|
+
version
|
|
493
|
+
class
|
|
494
|
+
description
|
|
495
|
+
name
|
|
496
|
+
type
|
|
497
|
+
group
|
|
498
|
+
deleted_at
|
|
499
|
+
data_structure {
|
|
500
|
+
alias
|
|
501
|
+
confidential
|
|
502
|
+
domain_ids
|
|
503
|
+
domains {
|
|
504
|
+
external_id
|
|
505
|
+
id
|
|
506
|
+
name
|
|
507
|
+
parent_id
|
|
508
|
+
parents {
|
|
509
|
+
external_id
|
|
510
|
+
id
|
|
511
|
+
name
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
external_id
|
|
515
|
+
id
|
|
516
|
+
inserted_at
|
|
517
|
+
latest_note
|
|
518
|
+
roles
|
|
519
|
+
source {
|
|
520
|
+
external_id
|
|
521
|
+
id
|
|
522
|
+
}
|
|
523
|
+
source_id
|
|
524
|
+
system_id
|
|
525
|
+
updated_at
|
|
526
|
+
}
|
|
527
|
+
parents {
|
|
528
|
+
alias
|
|
529
|
+
classes
|
|
530
|
+
data_structure_id
|
|
531
|
+
id
|
|
532
|
+
name
|
|
533
|
+
type
|
|
534
|
+
note
|
|
535
|
+
}
|
|
536
|
+
children {
|
|
537
|
+
alias
|
|
538
|
+
classes
|
|
539
|
+
data_structure_id
|
|
540
|
+
id
|
|
541
|
+
name
|
|
542
|
+
type
|
|
543
|
+
note
|
|
544
|
+
}
|
|
545
|
+
siblings {
|
|
546
|
+
alias
|
|
547
|
+
classes
|
|
548
|
+
data_structure_id
|
|
549
|
+
id
|
|
550
|
+
name
|
|
551
|
+
type
|
|
552
|
+
}
|
|
553
|
+
version_count
|
|
554
|
+
|
|
555
|
+
ancestry
|
|
556
|
+
|
|
557
|
+
grants_count
|
|
558
|
+
|
|
559
|
+
grant {
|
|
560
|
+
data_structure {
|
|
561
|
+
external_id
|
|
562
|
+
id
|
|
563
|
+
system_id
|
|
564
|
+
}
|
|
565
|
+
data_structure_version {
|
|
566
|
+
ancestry
|
|
567
|
+
name
|
|
568
|
+
}
|
|
569
|
+
detail
|
|
570
|
+
end_date
|
|
571
|
+
external_ref
|
|
572
|
+
id
|
|
573
|
+
inserted_at
|
|
574
|
+
pending_removal
|
|
575
|
+
source_user_name
|
|
576
|
+
start_date
|
|
577
|
+
system {
|
|
578
|
+
external_id
|
|
579
|
+
id
|
|
580
|
+
name
|
|
581
|
+
}
|
|
582
|
+
updated_at
|
|
583
|
+
user {
|
|
584
|
+
email
|
|
585
|
+
full_name
|
|
586
|
+
user_name
|
|
587
|
+
}
|
|
588
|
+
user_id
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
classes
|
|
592
|
+
implementation_count
|
|
593
|
+
data_structure_link_count
|
|
594
|
+
|
|
595
|
+
has_note
|
|
596
|
+
note
|
|
597
|
+
profile {
|
|
598
|
+
max
|
|
599
|
+
min
|
|
600
|
+
null_count
|
|
601
|
+
most_frequent
|
|
602
|
+
total_count
|
|
603
|
+
}
|
|
604
|
+
source {
|
|
605
|
+
id
|
|
606
|
+
external_id
|
|
607
|
+
}
|
|
608
|
+
system {
|
|
609
|
+
id
|
|
610
|
+
name
|
|
611
|
+
}
|
|
612
|
+
structure_type {
|
|
613
|
+
metadata_views {
|
|
614
|
+
name
|
|
615
|
+
fields
|
|
616
|
+
}
|
|
617
|
+
template_id
|
|
618
|
+
translation
|
|
619
|
+
}
|
|
620
|
+
degree {
|
|
621
|
+
in
|
|
622
|
+
out
|
|
623
|
+
}
|
|
624
|
+
data_fields_count
|
|
625
|
+
relations {
|
|
626
|
+
parents {
|
|
627
|
+
id
|
|
628
|
+
structure {
|
|
629
|
+
id
|
|
630
|
+
data_structure_id
|
|
631
|
+
name
|
|
632
|
+
type
|
|
633
|
+
}
|
|
634
|
+
relation_type {
|
|
635
|
+
name
|
|
636
|
+
description
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
children {
|
|
640
|
+
id
|
|
641
|
+
structure {
|
|
642
|
+
id
|
|
643
|
+
data_structure_id
|
|
644
|
+
name
|
|
645
|
+
type
|
|
646
|
+
}
|
|
647
|
+
relation_type {
|
|
648
|
+
name
|
|
649
|
+
description
|
|
650
|
+
}
|
|
651
|
+
links
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
_actions
|
|
656
|
+
user_permissions
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
`;
|
|
660
|
+
|
|
486
661
|
export const DATA_STRUCTURE_VERSION_METADATA_QUERY = gql`
|
|
487
|
-
query DataStructureVersion(
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
662
|
+
query DataStructureVersion($dataStructureId: ID!, $version: String!) {
|
|
663
|
+
dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
|
|
664
|
+
metadata
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
`;
|
|
668
|
+
|
|
669
|
+
export const DATA_STRUCTURE_VERSION_LINKS_QUERY = gql`
|
|
670
|
+
query DataStructureVersion($dataStructureId: ID!, $version: String!) {
|
|
671
|
+
dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
|
|
672
|
+
links
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
`;
|
|
676
|
+
|
|
677
|
+
export const DATA_STRUCTURE_VERSION_VERSIONS_QUERY = gql`
|
|
678
|
+
query DataStructureVersion($dataStructureId: ID!, $version: String!) {
|
|
679
|
+
dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
|
|
680
|
+
versions {
|
|
681
|
+
deleted_at
|
|
682
|
+
inserted_at
|
|
683
|
+
updated_at
|
|
684
|
+
version
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
`;
|
|
689
|
+
|
|
690
|
+
export const DATA_STRUCTURE_VERSION_GRANTS_QUERY = gql`
|
|
691
|
+
query DataStructureVersion($dataStructureId: ID!, $version: String!) {
|
|
692
|
+
dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
|
|
693
|
+
grants {
|
|
694
|
+
data_structure {
|
|
695
|
+
external_id
|
|
696
|
+
id
|
|
697
|
+
system_id
|
|
698
|
+
}
|
|
699
|
+
data_structure_version {
|
|
700
|
+
ancestry
|
|
701
|
+
name
|
|
702
|
+
}
|
|
703
|
+
detail
|
|
704
|
+
end_date
|
|
705
|
+
external_ref
|
|
706
|
+
id
|
|
707
|
+
inserted_at
|
|
708
|
+
pending_removal
|
|
709
|
+
source_user_name
|
|
710
|
+
start_date
|
|
711
|
+
system {
|
|
712
|
+
external_id
|
|
713
|
+
id
|
|
714
|
+
name
|
|
715
|
+
}
|
|
716
|
+
updated_at
|
|
717
|
+
user {
|
|
718
|
+
email
|
|
719
|
+
full_name
|
|
720
|
+
user_name
|
|
721
|
+
}
|
|
722
|
+
user_id
|
|
723
|
+
}
|
|
724
|
+
}
|
|
493
725
|
}
|
|
494
|
-
}
|
|
495
726
|
`;
|
|
727
|
+
|
|
728
|
+
export const DATA_STRUCTURE_PARENTS_QUERY = gql`
|
|
729
|
+
query DataStructureVersion($dataStructureId: ID!, $version: String!) {
|
|
730
|
+
dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
|
|
731
|
+
parents {
|
|
732
|
+
alias
|
|
733
|
+
classes
|
|
734
|
+
data_structure_id
|
|
735
|
+
deleted_at
|
|
736
|
+
id
|
|
737
|
+
metadata
|
|
738
|
+
name
|
|
739
|
+
type
|
|
740
|
+
has_note
|
|
741
|
+
note
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
`;
|
|
746
|
+
|
|
747
|
+
export const DATA_STRUCTURE_CHILDREN_QUERY = gql`
|
|
748
|
+
query DataStructureVersion($dataStructureId: ID!, $version: String!) {
|
|
749
|
+
dataStructureVersion(dataStructureId: $dataStructureId, version: $version) {
|
|
750
|
+
children {
|
|
751
|
+
alias
|
|
752
|
+
classes
|
|
753
|
+
data_structure_id
|
|
754
|
+
deleted_at
|
|
755
|
+
id
|
|
756
|
+
metadata
|
|
757
|
+
name
|
|
758
|
+
type
|
|
759
|
+
has_note
|
|
760
|
+
note
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
`;
|
|
765
|
+
|
|
496
766
|
export const TASKS_QUERY = gql`
|
|
497
767
|
query Tasks {
|
|
498
768
|
tasks {
|
|
@@ -2,11 +2,11 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { connect } from "react-redux";
|
|
5
|
-
import {
|
|
5
|
+
import { legacyFetchStructure, clearStructure } from "../routines";
|
|
6
6
|
|
|
7
7
|
export const ImplementationStructuresLoader = ({
|
|
8
8
|
clearStructure,
|
|
9
|
-
|
|
9
|
+
legacyFetchStructure,
|
|
10
10
|
structureIds,
|
|
11
11
|
structuresFields,
|
|
12
12
|
structuresSiblings,
|
|
@@ -23,14 +23,14 @@ export const ImplementationStructuresLoader = ({
|
|
|
23
23
|
// check structure_ids, will be undefined if structureIds is an empty Array
|
|
24
24
|
if (structure_id && !_.includes(structure_id)(structures)) {
|
|
25
25
|
if (!_.includes(structure_id)(requestedStructures)) {
|
|
26
|
-
|
|
26
|
+
legacyFetchStructure({ id: structure_id });
|
|
27
27
|
setRequestedStructures([...requestedStructures, structure_id]);
|
|
28
28
|
}
|
|
29
29
|
} else if (structureIndex + 1 < _.size(structureIds)) {
|
|
30
30
|
setStructureIndex(structureIndex + 1);
|
|
31
31
|
}
|
|
32
32
|
}, [
|
|
33
|
-
|
|
33
|
+
legacyFetchStructure,
|
|
34
34
|
structureIds,
|
|
35
35
|
structures,
|
|
36
36
|
structureIndex,
|
|
@@ -46,7 +46,7 @@ export const ImplementationStructuresLoader = ({
|
|
|
46
46
|
|
|
47
47
|
ImplementationStructuresLoader.propTypes = {
|
|
48
48
|
clearStructure: PropTypes.func,
|
|
49
|
-
|
|
49
|
+
legacyFetchStructure: PropTypes.func,
|
|
50
50
|
structuresFields: PropTypes.array,
|
|
51
51
|
structuresSiblings: PropTypes.array,
|
|
52
52
|
structureIds: PropTypes.array,
|
|
@@ -57,6 +57,6 @@ export const mapStateToProps = ({ structuresFields, structuresSiblings }) => ({
|
|
|
57
57
|
structuresSiblings: _.keys(structuresSiblings),
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
export default connect(mapStateToProps, {
|
|
60
|
+
export default connect(mapStateToProps, { legacyFetchStructure, clearStructure })(
|
|
61
61
|
ImplementationStructuresLoader
|
|
62
62
|
);
|
|
@@ -8,23 +8,23 @@ import { columnDecorator } from "@truedat/core/services";
|
|
|
8
8
|
import { linkTo } from "@truedat/core/routes";
|
|
9
9
|
import { getGrantsColumns } from "../selectors";
|
|
10
10
|
import GrantRemoval from "./GrantRemoval";
|
|
11
|
+
import { useQuery } from "@apollo/client";
|
|
12
|
+
import { DATA_STRUCTURE_VERSION_GRANTS_QUERY } from "../api/queries";
|
|
11
13
|
|
|
12
14
|
const matchesStructure = ({ id }) => _.pathEq("data_structure.id", id);
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
const StructureGrantsContent = ({
|
|
15
17
|
columns,
|
|
16
|
-
grants,
|
|
17
18
|
grantsActions,
|
|
18
19
|
structure,
|
|
19
20
|
userPermissions,
|
|
21
|
+
grants,
|
|
22
|
+
canUpdateRemoval,
|
|
20
23
|
}) => {
|
|
21
24
|
const { formatMessage } = useIntl();
|
|
22
25
|
const navigate = useNavigate();
|
|
23
|
-
const canUpdateRemoval =
|
|
24
|
-
userPermissions?.update_grant_removal &&
|
|
25
|
-
_.any(matchesStructure(structure))(grants);
|
|
26
26
|
|
|
27
|
-
return
|
|
27
|
+
return (
|
|
28
28
|
<Table basic="very">
|
|
29
29
|
<Table.Header>
|
|
30
30
|
<Table.Row>
|
|
@@ -76,7 +76,50 @@ export const StructureGrants = ({
|
|
|
76
76
|
))}
|
|
77
77
|
</Table.Body>
|
|
78
78
|
</Table>
|
|
79
|
-
)
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
StructureGrantsContent.propTypes = {
|
|
83
|
+
columns: PropTypes.array,
|
|
84
|
+
grantsActions: PropTypes.object,
|
|
85
|
+
structure: PropTypes.object,
|
|
86
|
+
userPermissions: PropTypes.object,
|
|
87
|
+
grants: PropTypes.array,
|
|
88
|
+
canUpdateRemoval: PropTypes.bool,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const StructureGrants = ({
|
|
92
|
+
columns,
|
|
93
|
+
grantsActions,
|
|
94
|
+
structure,
|
|
95
|
+
userPermissions,
|
|
96
|
+
}) => {
|
|
97
|
+
const { data } = useQuery(DATA_STRUCTURE_VERSION_GRANTS_QUERY, {
|
|
98
|
+
fetchPolicy: "network-only",
|
|
99
|
+
variables: { dataStructureId: structure.id, version: "latest" },
|
|
100
|
+
skip: !structure?.id,
|
|
101
|
+
});
|
|
102
|
+
const grants = data?.dataStructureVersion.grants;
|
|
103
|
+
|
|
104
|
+
const canUpdateRemoval =
|
|
105
|
+
userPermissions?.update_grant_removal &&
|
|
106
|
+
grants &&
|
|
107
|
+
_.any(matchesStructure(structure))(grants);
|
|
108
|
+
|
|
109
|
+
if (!grants) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<StructureGrantsContent
|
|
115
|
+
columns={columns}
|
|
116
|
+
grantsActions={grantsActions}
|
|
117
|
+
structure={structure}
|
|
118
|
+
userPermissions={userPermissions}
|
|
119
|
+
grants={grants}
|
|
120
|
+
canUpdateRemoval={canUpdateRemoval}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
80
123
|
};
|
|
81
124
|
|
|
82
125
|
StructureGrants.propTypes = {
|
|
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
import { connect } from "react-redux";
|
|
4
4
|
import { useIntl } from "react-intl";
|
|
5
5
|
import { Container, Form, Icon } from "semantic-ui-react";
|
|
6
|
-
import {
|
|
6
|
+
import { legacyFetchStructure } from "../routines";
|
|
7
7
|
import StructureSelector from "./StructureSelector";
|
|
8
8
|
import StructureSelectorInputFieldJoin from "./StructureSelectorInputFieldJoin";
|
|
9
9
|
|
|
@@ -19,13 +19,13 @@ export const StructureSelectorInputField = ({
|
|
|
19
19
|
selectedStructure,
|
|
20
20
|
selectedSystem,
|
|
21
21
|
systemRequired,
|
|
22
|
-
|
|
22
|
+
legacyFetchStructure,
|
|
23
23
|
structureSelectorOverwriteColumns,
|
|
24
24
|
fieldWidth,
|
|
25
25
|
}) => {
|
|
26
26
|
const { formatMessage } = useIntl();
|
|
27
27
|
const handleSelectStructure = (value) => {
|
|
28
|
-
value &&
|
|
28
|
+
value && legacyFetchStructure({ id: _.prop("id")(value) });
|
|
29
29
|
value && onChange(value);
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -124,7 +124,7 @@ export const StructureSelectorInputField = ({
|
|
|
124
124
|
|
|
125
125
|
StructureSelectorInputField.propTypes = {
|
|
126
126
|
active: PropTypes.bool,
|
|
127
|
-
|
|
127
|
+
legacyFetchStructure: PropTypes.func,
|
|
128
128
|
joined: PropTypes.bool,
|
|
129
129
|
onChange: PropTypes.func,
|
|
130
130
|
onChangeField: PropTypes.func,
|
|
@@ -139,4 +139,6 @@ StructureSelectorInputField.propTypes = {
|
|
|
139
139
|
fieldWidth: PropTypes.number,
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
export default connect(null, {
|
|
142
|
+
export default connect(null, { legacyFetchStructure })(
|
|
143
|
+
StructureSelectorInputField
|
|
144
|
+
);
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { connect } from "react-redux";
|
|
4
|
+
import { useParams } from "react-router";
|
|
4
5
|
import { List } from "semantic-ui-react";
|
|
5
6
|
import StructureVersionListItem from "./StructureVersionListItem";
|
|
7
|
+
import { useQuery } from "@apollo/client";
|
|
8
|
+
import { DATA_STRUCTURE_VERSION_VERSIONS_QUERY } from "../api/queries";
|
|
6
9
|
|
|
7
|
-
export const StructureVersions = (
|
|
10
|
+
export const StructureVersions = () =>{
|
|
11
|
+
const { id } = useParams();
|
|
12
|
+
|
|
13
|
+
const { data } = useQuery(DATA_STRUCTURE_VERSION_VERSIONS_QUERY, {
|
|
14
|
+
fetchPolicy: "network-only",
|
|
15
|
+
variables: { dataStructureId: id, version: "latest" },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const versions = data?.dataStructureVersion.versions;
|
|
19
|
+
return (
|
|
8
20
|
!_.isEmpty(versions) && (
|
|
9
21
|
<List selection>
|
|
10
22
|
{versions.map((v, i) => (
|
|
11
23
|
<StructureVersionListItem key={i} id={id} {...v} />
|
|
12
24
|
))}
|
|
13
25
|
</List>
|
|
14
|
-
);
|
|
26
|
+
));
|
|
27
|
+
}
|
|
15
28
|
|
|
16
29
|
StructureVersions.propTypes = {
|
|
17
30
|
id: PropTypes.number,
|
|
@@ -2,19 +2,19 @@ import { render } from "@truedat/test/render";
|
|
|
2
2
|
import { ImplementationStructuresLoader } from "../ImplementationStructuresLoader";
|
|
3
3
|
|
|
4
4
|
describe("<ImplementationStructuresLoader/>", () => {
|
|
5
|
-
it("calls
|
|
5
|
+
it("calls legacyFetchStructure on mount and clearStructure on unmount", () => {
|
|
6
6
|
const props = {
|
|
7
7
|
clearStructure: jest.fn(),
|
|
8
|
-
|
|
8
|
+
legacyFetchStructure: jest.fn(),
|
|
9
9
|
structureIds: [42],
|
|
10
10
|
};
|
|
11
11
|
const { unmount } = render(<ImplementationStructuresLoader {...props} />);
|
|
12
12
|
expect(props.clearStructure).toHaveBeenCalledTimes(0);
|
|
13
|
-
expect(props.
|
|
14
|
-
expect(props.
|
|
13
|
+
expect(props.legacyFetchStructure).toHaveBeenCalledTimes(1);
|
|
14
|
+
expect(props.legacyFetchStructure).toHaveBeenCalledWith({ id: 42 });
|
|
15
15
|
|
|
16
16
|
unmount();
|
|
17
17
|
expect(props.clearStructure).toHaveBeenCalledTimes(1);
|
|
18
|
-
expect(props.
|
|
18
|
+
expect(props.legacyFetchStructure).toHaveBeenCalledTimes(1);
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -16,7 +16,7 @@ describe("<ProfileExecutionLoader />", () => {
|
|
|
16
16
|
expect(rendered.container).toMatchSnapshot();
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("calls
|
|
19
|
+
it("calls fetchProfileExecution when component mounts but not when it unmounts", async () => {
|
|
20
20
|
const clearProfileExecution = jest.fn();
|
|
21
21
|
const fetchProfileExecution = jest.fn();
|
|
22
22
|
const props = { clearProfileExecution, fetchProfileExecution };
|
|
@@ -16,7 +16,7 @@ describe("<ProfileGroupLoader />", () => {
|
|
|
16
16
|
expect(rendered.container).toMatchSnapshot();
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("calls
|
|
19
|
+
it("calls fetchProfileGroup when component mounts but not when it unmounts", async () => {
|
|
20
20
|
const clearProfileGroup = jest.fn();
|
|
21
21
|
const fetchProfileGroup = jest.fn();
|
|
22
22
|
const props = { clearProfileGroup, fetchProfileGroup };
|
|
@@ -2,6 +2,32 @@ import _ from "lodash/fp";
|
|
|
2
2
|
import { render } from "@truedat/test/render";
|
|
3
3
|
import { StructureGrants } from "../StructureGrants";
|
|
4
4
|
|
|
5
|
+
jest.mock("@apollo/client", () => ({
|
|
6
|
+
gql: jest.fn((query) => query),
|
|
7
|
+
useQuery: jest.fn(() => ({
|
|
8
|
+
data: {
|
|
9
|
+
dataStructureVersion: {
|
|
10
|
+
grants: [
|
|
11
|
+
{
|
|
12
|
+
id: 1,
|
|
13
|
+
user: { id: 1, full_name: "foo user" },
|
|
14
|
+
data_structure: { id: 99, external_id: "foo_strucutre" },
|
|
15
|
+
end_date: "2021/08/02",
|
|
16
|
+
pending_removal: false,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 2,
|
|
20
|
+
user: { id: 2, full_name: "bar user" },
|
|
21
|
+
data_structure: { name: "bar structure" },
|
|
22
|
+
end_date: "2021/09/02",
|
|
23
|
+
pending_removal: false,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
})),
|
|
29
|
+
}));
|
|
30
|
+
|
|
5
31
|
describe("<StructureGrants />", () => {
|
|
6
32
|
const idDecorator = ({ id }) => <p>{id}</p>;
|
|
7
33
|
const userDecorator = ({ user }) => <p>{user.full_name}</p>;
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { render, waitForLoad } from "@truedat/test/render";
|
|
2
2
|
import { StructureVersions } from "../StructureVersions";
|
|
3
3
|
|
|
4
|
+
jest.mock("react-router", () => ({
|
|
5
|
+
...jest.requireActual("react-router"),
|
|
6
|
+
useParams: jest.fn(() => ({ id: "1" })),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
jest.mock("@apollo/client", () => ({
|
|
10
|
+
gql: jest.fn((query) => query),
|
|
11
|
+
useQuery: jest.fn(() => ({
|
|
12
|
+
data: {
|
|
13
|
+
dataStructureVersion: {
|
|
14
|
+
versions: [
|
|
15
|
+
{
|
|
16
|
+
version: "0",
|
|
17
|
+
inserted_at: "2018-01-01T01:01:01.123456Z",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
version: "1",
|
|
21
|
+
inserted_at: "2018-02-01T01:01:01.123456Z",
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
})),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
|
|
4
30
|
describe("<StructureVersions />", () => {
|
|
5
31
|
it("matches the latest snapshot", async () => {
|
|
6
32
|
const versions = [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { graph, initialState } from "../graph";
|
|
2
|
-
import { clearGraph, fetchGraph,
|
|
2
|
+
import { clearGraph, fetchGraph, legacyFetchStructure } from "../../routines";
|
|
3
3
|
|
|
4
4
|
const fooState = { foo: "bar" };
|
|
5
5
|
|
|
@@ -12,8 +12,8 @@ describe("reducers: graph", () => {
|
|
|
12
12
|
expect(graph(fooState, { type: clearGraph.TRIGGER })).toEqual(initialState);
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it("should be the initial state after receiving the
|
|
16
|
-
expect(graph(fooState, { type:
|
|
15
|
+
it("should be the initial state after receiving the legacyFetchStructure.TRIGGER action", () => {
|
|
16
|
+
expect(graph(fooState, { type: legacyFetchStructure.TRIGGER })).toEqual(
|
|
17
17
|
initialState
|
|
18
18
|
);
|
|
19
19
|
});
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createGraph,
|
|
5
5
|
createStructureGraph,
|
|
6
6
|
fetchGraph,
|
|
7
|
-
|
|
7
|
+
legacyFetchStructure,
|
|
8
8
|
fetchStructureGraph,
|
|
9
9
|
} from "../../routines";
|
|
10
10
|
import { graphLoading } from "..";
|
|
@@ -56,8 +56,8 @@ describe("reducers: graphLoading", () => {
|
|
|
56
56
|
expect(graphLoading(true, { type: fetchGraph.FULFILL })).toBe(false);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
it("should be false after receiving the
|
|
60
|
-
expect(graphLoading(true, { type:
|
|
59
|
+
it("should be false after receiving the legacyFetchStructure.TRIGGER action", () => {
|
|
60
|
+
expect(graphLoading(true, { type: legacyFetchStructure.TRIGGER })).toBe(false);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
it("should be false after receiving the fetchStructureGraph.FULFILL action", () => {
|