@truedat/dq 4.47.5 → 4.47.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.47.6] 2022-07-01
4
+
5
+ ### Fixed
6
+
7
+ - [TD-4993]
8
+ - RuleImplementationForm visibility with correct permissions
9
+ - Show quality event errors on results view using graphql
10
+ - Add exclusive subscription events
11
+
3
12
  ## [4.47.5] 2022-06-30
4
13
 
5
14
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/dq",
3
- "version": "4.47.5",
3
+ "version": "4.47.8",
4
4
  "description": "Truedat Web Data Quality Module",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -34,7 +34,7 @@
34
34
  "@testing-library/jest-dom": "^5.16.4",
35
35
  "@testing-library/react": "^12.0.0",
36
36
  "@testing-library/user-event": "^13.2.1",
37
- "@truedat/test": "4.47.5",
37
+ "@truedat/test": "4.47.8",
38
38
  "babel-jest": "^28.1.0",
39
39
  "babel-plugin-dynamic-import-node": "^2.3.3",
40
40
  "babel-plugin-lodash": "^3.3.4",
@@ -88,8 +88,8 @@
88
88
  },
89
89
  "dependencies": {
90
90
  "@apollo/client": "^3.6.4",
91
- "@truedat/core": "4.47.5",
92
- "@truedat/df": "4.47.5",
91
+ "@truedat/core": "4.47.8",
92
+ "@truedat/df": "4.47.8",
93
93
  "axios": "^0.19.2",
94
94
  "graphql": "^15.5.3",
95
95
  "path-to-regexp": "^1.7.0",
@@ -110,5 +110,5 @@
110
110
  "react-dom": ">= 16.8.6 < 17",
111
111
  "semantic-ui-react": ">= 0.88.2 < 2.1"
112
112
  },
113
- "gitHead": "1265272aa7b8fcb415592916f0e557ae226befe3"
113
+ "gitHead": "dccc0d92c419a5ee257a8e15b64c1b98d909809a"
114
114
  }
@@ -20,6 +20,11 @@ export const IMPLEMENTATION_RESULTS = gql`
20
20
  implementation(id: $id) {
21
21
  id
22
22
  implementation_key
23
+ last_quality_event {
24
+ inserted_at
25
+ message
26
+ type
27
+ }
23
28
  versions {
24
29
  id
25
30
  implementation_key
@@ -4,8 +4,6 @@ import PropTypes from "prop-types";
4
4
  import { connect } from "react-redux";
5
5
  import { Divider, Header, Grid } from "semantic-ui-react";
6
6
  import { FormattedMessage } from "react-intl";
7
- import { gql, useQuery } from "@apollo/client";
8
- import { Loading } from "@truedat/core/components";
9
7
  import { getFieldType } from "@truedat/core/services/fieldType";
10
8
  import {
11
9
  createRuleImplementation,
@@ -248,8 +246,6 @@ export const NewRuleImplementation = ({
248
246
  edition,
249
247
  rule,
250
248
  ruleImplementationProps,
251
- sources,
252
- sourcesLoading,
253
249
  structuresFields,
254
250
  structuresSiblings,
255
251
  operators,
@@ -458,8 +454,9 @@ export const NewRuleImplementation = ({
458
454
  const setImplementationKey = (implementationKey) =>
459
455
  setRuleImplementation({ ...ruleImplementation, implementationKey });
460
456
 
461
- const setImplementationRawContent = (rawContent) =>
457
+ const setImplementationRawContent = (rawContent) => {
462
458
  setRuleImplementation({ ...ruleImplementation, rawContent });
459
+ };
463
460
 
464
461
  const doSubmit = (props = {}) => {
465
462
  const populations = _.reject(_.isEmpty)(ruleImplementation.populations);
@@ -467,8 +464,6 @@ export const NewRuleImplementation = ({
467
464
  const segments = _.reject(_.isEmpty)(ruleImplementation.segments);
468
465
 
469
466
  const raw_content = _.prop("rawContent")(ruleImplementation);
470
- const source_id = _.prop("source_id")(raw_content);
471
- const source = _.find({ id: source_id })(sources);
472
467
 
473
468
  const rule_implementation =
474
469
  ruleImplementation.implementationType == "raw"
@@ -479,7 +474,7 @@ export const NewRuleImplementation = ({
479
474
  df_name: ruleImplementation?.dfName,
480
475
  df_content: ruleImplementation?.dfContent,
481
476
  rule_id: rule ? rule.id : ruleImplementation.rule_id,
482
- raw_content: { ...raw_content, source },
477
+ raw_content: { ...raw_content },
483
478
  result_type: ruleImplementation.result_type,
484
479
  minimum: ruleImplementation.minimum,
485
480
  goal: ruleImplementation.goal,
@@ -546,8 +541,6 @@ export const NewRuleImplementation = ({
546
541
  ruleImplementation={ruleImplementation}
547
542
  onChange={onChange}
548
543
  onSubmit={doSubmit}
549
- sources={sources}
550
- sourcesLoading={sourcesLoading}
551
544
  />
552
545
  ) : (
553
546
  <RuleImplementationForm
@@ -583,39 +576,11 @@ NewRuleImplementation.propTypes = {
583
576
  operators: PropTypes.object,
584
577
  rule: PropTypes.object,
585
578
  ruleImplementationProps: PropTypes.object,
586
- sources: PropTypes.array,
587
- sourcesLoading: PropTypes.bool,
588
579
  structuresFields: PropTypes.object,
589
580
  structuresSiblings: PropTypes.object,
590
581
  updateRuleImplementation: PropTypes.func,
591
582
  };
592
583
 
593
- export const SOURCES_WITH_CONFIG = gql`
594
- query SOURCES_WITH_CONFIG($jobTypes: String) {
595
- sources(jobTypes: $jobTypes) {
596
- id
597
- externalId
598
- config
599
- }
600
- }
601
- `;
602
-
603
- export const NewRuleImplementationLoader = (props) => {
604
- const { data, error, loading } = useQuery(SOURCES_WITH_CONFIG, {
605
- variables: { jobTypes: "quality" },
606
- });
607
- if (error) return null;
608
- if (loading) return <Loading />;
609
- const sources = data?.sources || [];
610
- return (
611
- <NewRuleImplementation
612
- sources={sources}
613
- sourcesLoading={loading}
614
- {...props}
615
- />
616
- );
617
- };
618
-
619
584
  const mapStateToProps = (state) => ({
620
585
  rule: state.rule,
621
586
  ruleImplementationProps: {
@@ -631,4 +596,4 @@ const mapStateToProps = (state) => ({
631
596
  export default connect(mapStateToProps, {
632
597
  createRuleImplementation,
633
598
  updateRuleImplementation,
634
- })(NewRuleImplementationLoader);
599
+ })(NewRuleImplementation);
@@ -46,9 +46,11 @@ export const RuleImplementationResults = ({
46
46
  formatMessage,
47
47
  };
48
48
 
49
+ const { last_quality_event } = ruleImplementation;
50
+
49
51
  return (
50
52
  <>
51
- {ruleImplementation.event_type === "FAILED" ? (
53
+ {last_quality_event?.type === "FAILED" ? (
52
54
  <Message negative style={{ marginTop: "14px" }}>
53
55
  <Message.Header>
54
56
  {formatMessage({
@@ -63,7 +65,7 @@ export const RuleImplementationResults = ({
63
65
  right: "21px",
64
66
  }}
65
67
  locale={locale}
66
- date={ruleImplementation.event_inserted_at}
68
+ date={last_quality_event.inserted_at}
67
69
  format="YYYY-MM-DD HH:mm"
68
70
  />
69
71
  <p
@@ -71,7 +73,7 @@ export const RuleImplementationResults = ({
71
73
  whiteSpace: "pre-wrap",
72
74
  }}
73
75
  >
74
- {ruleImplementation.event_message}
76
+ {last_quality_event.message}
75
77
  </p>
76
78
  </Message>
77
79
  ) : null}
@@ -956,272 +956,272 @@ const ruleImplementationOperators = {
956
956
  },
957
957
  };
958
958
 
959
- export const sourcesRuleImplementationLoader = [
960
- {
961
- __typename: "Source",
962
- id: "190",
963
- externalId: "Redshift",
964
- config: {
965
- alias: "Redshift",
966
- databases: ["dev"],
967
- domain: {
968
- external_id: "Truedat",
969
- id: 2,
970
- name: "Truedat",
971
- parent_id: null,
972
- updated_at: "2020-07-28 13:21:21.938189Z",
973
- },
974
- host: "redshift-cluster-1.czitmavv4gjx.eu-west-1.redshift.amazonaws.com",
975
- job_types: ["quality", "profile", "catalog"],
976
- port: "5439",
977
- system: {
978
- external_id: "Redshift",
979
- id: 139,
980
- name: "Redshift",
981
- },
982
- user: "awsuser",
983
- },
984
- },
985
- {
986
- __typename: "Source",
987
- id: "178",
988
- externalId: "test_athena",
989
- config: {
990
- aliases: ["asd", "glue"],
991
- aws_region: "eu-west-1",
992
- aws_role_arn: "",
993
- job_types: ["profile", "quality"],
994
- output_location: "",
995
- workgroup: "primary",
996
- },
997
- },
998
- {
999
- __typename: "Source",
1000
- id: "187",
1001
- externalId: "postgres-temp",
1002
- config: {
1003
- alias: "postgres-temp",
1004
- blacklist_schemas: [],
1005
- databases: ["prueba", "postgres"],
1006
- domain: {
1007
- external_id: "Truedat",
1008
- id: 2,
1009
- name: "Truedat",
1010
- parent_id: null,
1011
- updated_at: "2020-07-28 13:21:21.938189Z",
1012
- },
1013
- host: "localhost",
1014
- job_types: ["profile", "quality", "catalog"],
1015
- password: "yourStrong(!)Password",
1016
- port: "5432",
1017
- system: {
1018
- external_id: "Postgres-Test",
1019
- id: 106,
1020
- name: "Postgres-Test",
1021
- },
1022
- user: "postgres",
1023
- },
1024
- },
1025
- {
1026
- __typename: "Source",
1027
- id: "119",
1028
- externalId: "Teradata",
1029
- config: {
1030
- alias: "Teradata",
1031
- databases: ["HR"],
1032
- domain: {
1033
- external_id: "Dominio Prueba",
1034
- id: 83,
1035
- name: "Dominio Prueba",
1036
- parent_id: null,
1037
- updated_at: "2022-02-16 09:28:19.391331Z",
1038
- },
1039
- evidences_host: "localhost",
1040
- evidences_path: "interfases",
1041
- evidences_port: "445",
1042
- evidences_size: "10",
1043
- job_types: ["profile", "quality", "catalog"],
1044
- object_types: ["View", "Table"],
1045
- protocol: "SMB",
1046
- save_evidences: "No",
1047
- system: {
1048
- external_id: "Teradata",
1049
- id: 79,
1050
- name: "Teradata",
1051
- },
1052
- },
1053
- },
1054
- {
1055
- __typename: "Source",
1056
- id: "130",
1057
- externalId: "SQLServer",
1058
- config: {},
1059
- },
1060
- {
1061
- __typename: "Source",
1062
- id: "177",
1063
- externalId: "SQLServer test",
1064
- config: {},
1065
- },
1066
- {
1067
- __typename: "Source",
1068
- id: "176",
1069
- externalId: "borrar",
1070
- config: {
1071
- alias: "borrar",
1072
- databases: ["ORCLPDB1.localdomain"],
1073
- domain: {
1074
- external_id: "Truedat",
1075
- id: 2,
1076
- name: "Truedat",
1077
- parent_id: null,
1078
- updated_at: "2020-07-28 13:21:21.938189Z",
1079
- },
1080
- host: "localhost",
1081
- job_types: ["quality", "profile", "catalog"],
1082
- password: "yourpassword",
1083
- port: "1521",
1084
- save_evidences: "No",
1085
- schemas: ["OT"],
1086
- system: null,
1087
- user: "OT",
1088
- },
1089
- },
1090
- {
1091
- __typename: "Source",
1092
- id: "201",
1093
- externalId: "Athena_eu_west_2",
1094
- config: {
1095
- aliases: ["Glue_eu_west_2"],
1096
- aws_region: "eu-west-2",
1097
- aws_role_arn: "",
1098
- job_types: ["profile", "quality"],
1099
- workgroup: "primary",
1100
- },
1101
- },
1102
- {
1103
- __typename: "Source",
1104
- id: "151",
1105
- externalId: "MySQL",
1106
- config: {
1107
- alias: "MySQL",
1108
- domain: {
1109
- external_id: "Truedat",
1110
- id: 2,
1111
- name: "Truedat",
1112
- parent_id: null,
1113
- updated_at: "2020-07-28 13:21:21.938189Z",
1114
- },
1115
- filter_type: "Whitelist Databases",
1116
- host: "localhost",
1117
- job_types: ["profile", "quality", "catalog"],
1118
- port: "3306",
1119
- system: {
1120
- external_id: "MySQL",
1121
- id: 103,
1122
- name: "MySQL",
1123
- },
1124
- whitelist_databases: ["classicmodels"],
1125
- },
1126
- },
1127
- {
1128
- __typename: "Source",
1129
- id: "196",
1130
- externalId: "Oracle 12",
1131
- config: {
1132
- alias: "Oracle 12",
1133
- databases: ["ORCLPDB1.localdomain"],
1134
- domain: {
1135
- external_id: "Truedat",
1136
- id: 2,
1137
- name: "Truedat",
1138
- parent_id: null,
1139
- updated_at: "2020-07-28 13:21:21.938189Z",
1140
- },
1141
- evidences_host: "samba",
1142
- evidences_password: "badpass",
1143
- evidences_path: "interfases",
1144
- evidences_port: "445",
1145
- evidences_size: "10",
1146
- evidences_user: "example1",
1147
- filter_type: "Whitelist",
1148
- host: "oracle_12",
1149
- job_types: ["profile", "quality", "catalog"],
1150
- password: "Oradoc_db1",
1151
- port: "1521",
1152
- protocol: "SMB",
1153
- save_evidences: "Yes",
1154
- schemas: ["OT"],
1155
- system: {
1156
- external_id: "Oracle 12",
1157
- id: 141,
1158
- name: "Oracle 12",
1159
- },
1160
- tables_whitelist: ["REGIONS", "CUSTOMERS"],
1161
- user: "system",
1162
- },
1163
- },
1164
- {
1165
- __typename: "Source",
1166
- id: "181",
1167
- externalId: "PostgreSQL",
1168
- config: {
1169
- alias: "PostgreSQL",
1170
- databases: [
1171
- "td_audit",
1172
- "td_auth",
1173
- "td_bg",
1174
- "td_dd",
1175
- "td_df",
1176
- "td_ie",
1177
- "td_lm",
1178
- "td_metrics",
1179
- ],
1180
- domain: {
1181
- external_id: "Truedat",
1182
- id: 2,
1183
- name: "Truedat",
1184
- parent_id: null,
1185
- updated_at: "2020-07-28 13:21:21.938189Z",
1186
- },
1187
- job_types: ["profile", "quality", "catalog"],
1188
- system: {
1189
- external_id: "postgres",
1190
- id: 7,
1191
- name: "Truedat PostgreSQL",
1192
- },
1193
- },
1194
- },
1195
- {
1196
- __typename: "Source",
1197
- id: "162",
1198
- externalId: "oracle-temp",
1199
- config: {
1200
- alias: "oracle-temp",
1201
- databases: ["xe"],
1202
- domain: {
1203
- external_id: "Truedat",
1204
- id: 2,
1205
- name: "Truedat",
1206
- parent_id: null,
1207
- updated_at: "2020-07-28 13:21:21.938189Z",
1208
- },
1209
- filter_type: null,
1210
- host: "localhost",
1211
- job_types: ["profile", "catalog", "quality"],
1212
- password: "oracle",
1213
- port: "1521",
1214
- save_evidences: "No",
1215
- schemas: ["HR"],
1216
- system: {
1217
- external_id: "oracle2",
1218
- id: 2,
1219
- name: "BBDD Oracle",
1220
- },
1221
- user: "system",
1222
- },
1223
- },
1224
- ];
959
+ // export const sourcesRuleImplementationLoader = [
960
+ // {
961
+ // __typename: "Source",
962
+ // id: "190",
963
+ // externalId: "Redshift",
964
+ // config: {
965
+ // alias: "Redshift",
966
+ // databases: ["dev"],
967
+ // domain: {
968
+ // external_id: "Truedat",
969
+ // id: 2,
970
+ // name: "Truedat",
971
+ // parent_id: null,
972
+ // updated_at: "2020-07-28 13:21:21.938189Z",
973
+ // },
974
+ // host: "redshift-cluster-1.czitmavv4gjx.eu-west-1.redshift.amazonaws.com",
975
+ // job_types: ["quality", "profile", "catalog"],
976
+ // port: "5439",
977
+ // system: {
978
+ // external_id: "Redshift",
979
+ // id: 139,
980
+ // name: "Redshift",
981
+ // },
982
+ // user: "awsuser",
983
+ // },
984
+ // },
985
+ // {
986
+ // __typename: "Source",
987
+ // id: "178",
988
+ // externalId: "test_athena",
989
+ // config: {
990
+ // aliases: ["asd", "glue"],
991
+ // aws_region: "eu-west-1",
992
+ // aws_role_arn: "",
993
+ // job_types: ["profile", "quality"],
994
+ // output_location: "",
995
+ // workgroup: "primary",
996
+ // },
997
+ // },
998
+ // {
999
+ // __typename: "Source",
1000
+ // id: "187",
1001
+ // externalId: "postgres-temp",
1002
+ // config: {
1003
+ // alias: "postgres-temp",
1004
+ // blacklist_schemas: [],
1005
+ // databases: ["prueba", "postgres"],
1006
+ // domain: {
1007
+ // external_id: "Truedat",
1008
+ // id: 2,
1009
+ // name: "Truedat",
1010
+ // parent_id: null,
1011
+ // updated_at: "2020-07-28 13:21:21.938189Z",
1012
+ // },
1013
+ // host: "localhost",
1014
+ // job_types: ["profile", "quality", "catalog"],
1015
+ // password: "yourStrong(!)Password",
1016
+ // port: "5432",
1017
+ // system: {
1018
+ // external_id: "Postgres-Test",
1019
+ // id: 106,
1020
+ // name: "Postgres-Test",
1021
+ // },
1022
+ // user: "postgres",
1023
+ // },
1024
+ // },
1025
+ // {
1026
+ // __typename: "Source",
1027
+ // id: "119",
1028
+ // externalId: "Teradata",
1029
+ // config: {
1030
+ // alias: "Teradata",
1031
+ // databases: ["HR"],
1032
+ // domain: {
1033
+ // external_id: "Dominio Prueba",
1034
+ // id: 83,
1035
+ // name: "Dominio Prueba",
1036
+ // parent_id: null,
1037
+ // updated_at: "2022-02-16 09:28:19.391331Z",
1038
+ // },
1039
+ // evidences_host: "localhost",
1040
+ // evidences_path: "interfases",
1041
+ // evidences_port: "445",
1042
+ // evidences_size: "10",
1043
+ // job_types: ["profile", "quality", "catalog"],
1044
+ // object_types: ["View", "Table"],
1045
+ // protocol: "SMB",
1046
+ // save_evidences: "No",
1047
+ // system: {
1048
+ // external_id: "Teradata",
1049
+ // id: 79,
1050
+ // name: "Teradata",
1051
+ // },
1052
+ // },
1053
+ // },
1054
+ // {
1055
+ // __typename: "Source",
1056
+ // id: "130",
1057
+ // externalId: "SQLServer",
1058
+ // config: {},
1059
+ // },
1060
+ // {
1061
+ // __typename: "Source",
1062
+ // id: "177",
1063
+ // externalId: "SQLServer test",
1064
+ // config: {},
1065
+ // },
1066
+ // {
1067
+ // __typename: "Source",
1068
+ // id: "176",
1069
+ // externalId: "borrar",
1070
+ // config: {
1071
+ // alias: "borrar",
1072
+ // databases: ["ORCLPDB1.localdomain"],
1073
+ // domain: {
1074
+ // external_id: "Truedat",
1075
+ // id: 2,
1076
+ // name: "Truedat",
1077
+ // parent_id: null,
1078
+ // updated_at: "2020-07-28 13:21:21.938189Z",
1079
+ // },
1080
+ // host: "localhost",
1081
+ // job_types: ["quality", "profile", "catalog"],
1082
+ // password: "yourpassword",
1083
+ // port: "1521",
1084
+ // save_evidences: "No",
1085
+ // schemas: ["OT"],
1086
+ // system: null,
1087
+ // user: "OT",
1088
+ // },
1089
+ // },
1090
+ // {
1091
+ // __typename: "Source",
1092
+ // id: "201",
1093
+ // externalId: "Athena_eu_west_2",
1094
+ // config: {
1095
+ // aliases: ["Glue_eu_west_2"],
1096
+ // aws_region: "eu-west-2",
1097
+ // aws_role_arn: "",
1098
+ // job_types: ["profile", "quality"],
1099
+ // workgroup: "primary",
1100
+ // },
1101
+ // },
1102
+ // {
1103
+ // __typename: "Source",
1104
+ // id: "151",
1105
+ // externalId: "MySQL",
1106
+ // config: {
1107
+ // alias: "MySQL",
1108
+ // domain: {
1109
+ // external_id: "Truedat",
1110
+ // id: 2,
1111
+ // name: "Truedat",
1112
+ // parent_id: null,
1113
+ // updated_at: "2020-07-28 13:21:21.938189Z",
1114
+ // },
1115
+ // filter_type: "Whitelist Databases",
1116
+ // host: "localhost",
1117
+ // job_types: ["profile", "quality", "catalog"],
1118
+ // port: "3306",
1119
+ // system: {
1120
+ // external_id: "MySQL",
1121
+ // id: 103,
1122
+ // name: "MySQL",
1123
+ // },
1124
+ // whitelist_databases: ["classicmodels"],
1125
+ // },
1126
+ // },
1127
+ // {
1128
+ // __typename: "Source",
1129
+ // id: "196",
1130
+ // externalId: "Oracle 12",
1131
+ // config: {
1132
+ // alias: "Oracle 12",
1133
+ // databases: ["ORCLPDB1.localdomain"],
1134
+ // domain: {
1135
+ // external_id: "Truedat",
1136
+ // id: 2,
1137
+ // name: "Truedat",
1138
+ // parent_id: null,
1139
+ // updated_at: "2020-07-28 13:21:21.938189Z",
1140
+ // },
1141
+ // evidences_host: "samba",
1142
+ // evidences_password: "badpass",
1143
+ // evidences_path: "interfases",
1144
+ // evidences_port: "445",
1145
+ // evidences_size: "10",
1146
+ // evidences_user: "example1",
1147
+ // filter_type: "Whitelist",
1148
+ // host: "oracle_12",
1149
+ // job_types: ["profile", "quality", "catalog"],
1150
+ // password: "Oradoc_db1",
1151
+ // port: "1521",
1152
+ // protocol: "SMB",
1153
+ // save_evidences: "Yes",
1154
+ // schemas: ["OT"],
1155
+ // system: {
1156
+ // external_id: "Oracle 12",
1157
+ // id: 141,
1158
+ // name: "Oracle 12",
1159
+ // },
1160
+ // tables_whitelist: ["REGIONS", "CUSTOMERS"],
1161
+ // user: "system",
1162
+ // },
1163
+ // },
1164
+ // {
1165
+ // __typename: "Source",
1166
+ // id: "181",
1167
+ // externalId: "PostgreSQL",
1168
+ // config: {
1169
+ // alias: "PostgreSQL",
1170
+ // databases: [
1171
+ // "td_audit",
1172
+ // "td_auth",
1173
+ // "td_bg",
1174
+ // "td_dd",
1175
+ // "td_df",
1176
+ // "td_ie",
1177
+ // "td_lm",
1178
+ // "td_metrics",
1179
+ // ],
1180
+ // domain: {
1181
+ // external_id: "Truedat",
1182
+ // id: 2,
1183
+ // name: "Truedat",
1184
+ // parent_id: null,
1185
+ // updated_at: "2020-07-28 13:21:21.938189Z",
1186
+ // },
1187
+ // job_types: ["profile", "quality", "catalog"],
1188
+ // system: {
1189
+ // external_id: "postgres",
1190
+ // id: 7,
1191
+ // name: "Truedat PostgreSQL",
1192
+ // },
1193
+ // },
1194
+ // },
1195
+ // {
1196
+ // __typename: "Source",
1197
+ // id: "162",
1198
+ // externalId: "oracle-temp",
1199
+ // config: {
1200
+ // alias: "oracle-temp",
1201
+ // databases: ["xe"],
1202
+ // domain: {
1203
+ // external_id: "Truedat",
1204
+ // id: 2,
1205
+ // name: "Truedat",
1206
+ // parent_id: null,
1207
+ // updated_at: "2020-07-28 13:21:21.938189Z",
1208
+ // },
1209
+ // filter_type: null,
1210
+ // host: "localhost",
1211
+ // job_types: ["profile", "catalog", "quality"],
1212
+ // password: "oracle",
1213
+ // port: "1521",
1214
+ // save_evidences: "No",
1215
+ // schemas: ["HR"],
1216
+ // system: {
1217
+ // external_id: "oracle2",
1218
+ // id: 2,
1219
+ // name: "BBDD Oracle",
1220
+ // },
1221
+ // user: "system",
1222
+ // },
1223
+ // },
1224
+ // ];
1225
1225
 
1226
1226
  export const ruleImplementationLoaderGlobalState = {
1227
1227
  rule: {},
@@ -1230,6 +1230,7 @@ export const ruleImplementationLoaderGlobalState = {
1230
1230
  ruleImplementationOperators,
1231
1231
  structuresFields,
1232
1232
  structuresSiblings,
1233
+ domains: [{ id: 2, name: "domain1" }],
1233
1234
  };
1234
1235
 
1235
1236
  export const ruleImplementationLoaderActions = {
@@ -5,28 +5,25 @@ import { render } from "@truedat/test/render";
5
5
  import { multipleTemplatesMock } from "@truedat/test/mocks";
6
6
  import userEvent from "@testing-library/user-event";
7
7
  import defaultMessages from "@truedat/test/messages";
8
- import {
9
- NewRuleImplementation,
10
- SOURCES_WITH_CONFIG,
8
+ import NewRuleImplementation, {
9
+ NewRuleImplementation as NewRuleImplementationComponent,
11
10
  } from "../NewRuleImplementation";
12
- import NewRuleImplementationLoader from "../NewRuleImplementation";
13
11
  import { newRuleImplementationProps } from "../__test_samples__/NewRuleImplementationProps";
14
12
  import {
15
13
  ruleImplementationLoaderGlobalState,
16
14
  ruleImplementationLoaderActions,
17
- sourcesRuleImplementationLoader,
18
- } from "../__test_samples__/newRuleImplementationLoader";
15
+ } from "../__test_samples__/newRuleImplementationHelper";
19
16
 
20
17
  describe("<NewRuleImplementation />", () => {
21
18
  const createRuleImplementation = jest.fn();
22
19
  const updateRuleImplementation = jest.fn();
23
- const sources = [{ id: 1, external_id: "foo", config: { alias: ["foo"] } }];
20
+
24
21
  const ruleImplementationProps = { id: 1, name: "nn", executable: true };
22
+
25
23
  const props = {
26
24
  ruleImplementationProps,
27
25
  createRuleImplementation,
28
26
  updateRuleImplementation,
29
- sources,
30
27
  };
31
28
  const renderOpts = {
32
29
  mocks: [
@@ -44,11 +41,11 @@ describe("<NewRuleImplementation />", () => {
44
41
  <NewRuleImplementation {...props} />,
45
42
  renderOpts
46
43
  );
44
+
47
45
  await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
48
46
  await waitFor(() =>
49
47
  expect(queryByText(/loading/i)).not.toBeInTheDocument()
50
48
  );
51
-
52
49
  expect(container).toMatchSnapshot();
53
50
  });
54
51
 
@@ -59,7 +56,7 @@ describe("<NewRuleImplementation />", () => {
59
56
  applyTemplate: applyTemplate,
60
57
  };
61
58
  const { container, queryByText } = render(
62
- <NewRuleImplementation {...props} />,
59
+ <NewRuleImplementationComponent {...props} />,
63
60
  renderOpts
64
61
  );
65
62
  await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
@@ -70,24 +67,15 @@ describe("<NewRuleImplementation />", () => {
70
67
  });
71
68
  });
72
69
 
73
- describe("<NewRuleImplementationLoader> NewRuleImplementation doSubmit", () => {
70
+ describe("<NewRuleImplementation> NewRuleImplementation doSubmit", () => {
74
71
  const dispatch = jest.fn();
75
72
 
76
- const sourcesWithConfigMock = {
77
- request: {
78
- query: SOURCES_WITH_CONFIG,
79
- variables: { jobTypes: "quality" },
80
- },
81
- result: { data: { sources: sourcesRuleImplementationLoader } },
82
- };
83
-
84
73
  const renderOptsImplementationEdit = {
85
74
  mocks: [
86
75
  multipleTemplatesMock({
87
76
  scope: "ri",
88
77
  domainIds: [2],
89
78
  }),
90
- sourcesWithConfigMock,
91
79
  ],
92
80
  messages: {
93
81
  en: {
@@ -146,7 +134,7 @@ describe("<NewRuleImplementationLoader> NewRuleImplementation doSubmit", () => {
146
134
  };
147
135
 
148
136
  const { queryByText, getByRole, findByRole, findByTestId } = render(
149
- <NewRuleImplementationLoader {...props} />,
137
+ <NewRuleImplementation {...props} />,
150
138
  renderOptsImplementationEdit
151
139
  );
152
140
 
@@ -247,7 +235,7 @@ describe("<NewRuleImplementationLoader> NewRuleImplementation doSubmit", () => {
247
235
  };
248
236
 
249
237
  const { queryByText, getByRole, findByRole, findByTestId } = render(
250
- <NewRuleImplementationLoader {...props} />,
238
+ <NewRuleImplementation {...props} />,
251
239
  renderOptsImplementationEdit
252
240
  );
253
241
 
@@ -4,6 +4,8 @@ import PropTypes from "prop-types";
4
4
  import { connect } from "react-redux";
5
5
  import { useHistory } from "react-router-dom";
6
6
  import { FormattedMessage, useIntl } from "react-intl";
7
+ import { gql, useQuery } from "@apollo/client";
8
+ import { Loading } from "@truedat/core/components";
7
9
  import { Button, Form, Icon, Popup } from "semantic-ui-react";
8
10
  import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
9
11
  import LimitsForm from "./LimitsForm";
@@ -80,6 +82,7 @@ export const RuleImplementationRawForm = ({
80
82
  setImplementationRawContent({
81
83
  ...rawContent,
82
84
  source_id: value,
85
+ source: _.find({ id: value })(sources),
83
86
  database: "",
84
87
  });
85
88
  };
@@ -334,6 +337,32 @@ RuleImplementationRawForm.propTypes = {
334
337
  sourcesLoading: PropTypes.bool,
335
338
  };
336
339
 
340
+ export const SOURCES_WITH_CONFIG = gql`
341
+ query SOURCES_WITH_CONFIG($jobTypes: String) {
342
+ sources(jobTypes: $jobTypes) {
343
+ id
344
+ externalId
345
+ config
346
+ }
347
+ }
348
+ `;
349
+
350
+ export const RuleImplementationRawFormLoader = (props) => {
351
+ const { data, error, loading } = useQuery(SOURCES_WITH_CONFIG, {
352
+ variables: { jobTypes: "quality" },
353
+ });
354
+ if (error) return null;
355
+ if (loading) return <Loading />;
356
+ const sources = data?.sources || [];
357
+ return (
358
+ <RuleImplementationRawForm
359
+ sources={sources}
360
+ sourcesLoading={loading}
361
+ {...props}
362
+ />
363
+ );
364
+ };
365
+
337
366
  const mapStateToProps = ({
338
367
  implementationActions,
339
368
  rule,
@@ -344,4 +373,4 @@ const mapStateToProps = ({
344
373
  rule,
345
374
  });
346
375
 
347
- export default connect(mapStateToProps)(RuleImplementationRawForm);
376
+ export default connect(mapStateToProps)(RuleImplementationRawFormLoader);
@@ -4,7 +4,7 @@ import { waitFor } from "@testing-library/react";
4
4
  import userEvent from "@testing-library/user-event";
5
5
  import { render } from "@truedat/test/render";
6
6
  import { multipleTemplatesMock } from "@truedat/test/mocks";
7
- import RuleImplementationRawForm from "../RuleImplementationRawForm";
7
+ import { RuleImplementationRawForm } from "../RuleImplementationRawForm";
8
8
 
9
9
  jest.setTimeout(30000);
10
10
 
@@ -13,6 +13,7 @@ const renderOpts = {
13
13
  state: {
14
14
  rule: { domain_id: 1 },
15
15
  ruleImplementationCreating: false,
16
+ domains: [{ id: 1, name: "domain1" }],
16
17
  },
17
18
  fallback: "lazy",
18
19
  };
@@ -35,6 +36,7 @@ const props = {
35
36
  minimum: "1",
36
37
  result_type: "percentage",
37
38
  },
39
+ sourcesLoading: false,
38
40
  sources: [
39
41
  {
40
42
  id: "1",
@@ -56,8 +58,11 @@ const props = {
56
58
 
57
59
  describe("<RuleImplementationRawForm />", () => {
58
60
  it("matches the latest snapshot", async () => {
61
+ const updatedProps = _.flow(_.set("ruleImplementation.domain_id", 1))(
62
+ props
63
+ );
59
64
  const { container, queryByText } = render(
60
- <RuleImplementationRawForm {...props} />,
65
+ <RuleImplementationRawForm {...updatedProps} />,
61
66
  renderOpts
62
67
  );
63
68
  await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument(), {
@@ -141,6 +146,7 @@ describe("<RuleImplementationRawForm />", () => {
141
146
 
142
147
  it("submit button enabled if there is valid content in form with database", async () => {
143
148
  const updatedProps = _.flow(
149
+ _.set("ruleImplementation.domain_id", 1),
144
150
  _.set("ruleImplementation.dfName", "template1"),
145
151
  _.set("ruleImplementation.dfContent", { field1: "foo" })
146
152
  )(props);
@@ -156,13 +162,11 @@ describe("<RuleImplementationRawForm />", () => {
156
162
  rule: { id: 5, name: "regla" },
157
163
  };
158
164
 
159
- const { queryByRole } = render(
165
+ const { findByRole } = render(
160
166
  <RuleImplementationRawForm {...customProps} />,
161
167
  renderOpts
162
168
  );
163
- await waitFor(() =>
164
- expect(queryByRole("button", { name: /save/i })).toBeEnabled()
165
- );
169
+ expect(await findByRole("button", { name: /save/i })).toBeEnabled();
166
170
  });
167
171
 
168
172
  it("submit button disabled if databases are available and not selected", async () => {
@@ -176,14 +180,10 @@ describe("<RuleImplementationRawForm />", () => {
176
180
  },
177
181
  };
178
182
 
179
- const { queryByText, getByRole } = render(
183
+ const { getByRole } = render(
180
184
  <RuleImplementationRawForm {...customProps} />,
181
185
  renderOpts
182
186
  );
183
- await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
184
- await waitFor(() =>
185
- expect(queryByText(/loading/i)).not.toBeInTheDocument()
186
- );
187
187
  expect(getByRole("button", { name: "Save" })).toBeDisabled();
188
188
  });
189
189
 
@@ -221,6 +221,15 @@ describe("<RuleImplementationRawForm />", () => {
221
221
  population: "",
222
222
  source_id: "2",
223
223
  validations: "",
224
+ source: {
225
+ id: "2",
226
+ config: {
227
+ alias: "source2",
228
+ job_types: ["quality"],
229
+ databases: ["db1", "db2"],
230
+ },
231
+ externalId: "ext_id_2",
232
+ },
224
233
  });
225
234
  });
226
235
 
@@ -239,17 +248,12 @@ describe("<RuleImplementationRawForm />", () => {
239
248
  validations: "a.city='MADRID'",
240
249
  },
241
250
  };
242
- const { queryByRole, queryByText } = render(
251
+ const { findByRole } = render(
243
252
  <RuleImplementationRawForm {...customProps} />,
244
253
  renderOpts
245
254
  );
246
- await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
247
- await waitFor(() =>
248
- expect(queryByText(/loading/i)).not.toBeInTheDocument()
249
- );
250
- await waitFor(() =>
251
- expect(queryByRole("button", { name: /save/i })).toBeEnabled()
252
- );
255
+
256
+ expect(await findByRole("button", { name: /save/i })).toBeEnabled();
253
257
  });
254
258
 
255
259
  it("submit button disabled if there is invalid content in form", async () => {
@@ -266,14 +270,10 @@ describe("<RuleImplementationRawForm />", () => {
266
270
  validations: "a.city='MADRID'",
267
271
  },
268
272
  };
269
- const { queryByRole, queryByText } = render(
273
+ const { queryByRole } = render(
270
274
  <RuleImplementationRawForm {...customProps} />,
271
275
  renderOpts
272
276
  );
273
- await waitFor(() => expect(queryByText(/lazy/i)).not.toBeInTheDocument());
274
- await waitFor(() =>
275
- expect(queryByText(/loading/i)).not.toBeInTheDocument()
276
- );
277
277
  expect(queryByRole("button", { name: /save/i })).toBeDisabled();
278
278
  });
279
279
 
@@ -53,6 +53,72 @@ exports[`<RuleImplementationRawForm /> matches the latest snapshot 1`] = `
53
53
  </div>
54
54
  </div>
55
55
  </div>
56
+ <div
57
+ class="field"
58
+ >
59
+ <div
60
+ class="required field"
61
+ >
62
+ <label>
63
+ Domain
64
+ </label>
65
+ <div
66
+ class="field"
67
+ >
68
+ <div
69
+ aria-expanded="false"
70
+ class="ui fluid search selection dropdown"
71
+ name="domain"
72
+ role="combobox"
73
+ >
74
+ <input
75
+ aria-autocomplete="list"
76
+ autocomplete="off"
77
+ class="search"
78
+ tabindex="0"
79
+ type="text"
80
+ value=""
81
+ />
82
+ <div
83
+ aria-atomic="true"
84
+ aria-live="polite"
85
+ class="divider text"
86
+ role="alert"
87
+ >
88
+ domain1
89
+ </div>
90
+ <i
91
+ aria-hidden="true"
92
+ class="dropdown icon clear"
93
+ />
94
+ <div
95
+ aria-multiselectable="false"
96
+ class="menu transition"
97
+ role="listbox"
98
+ >
99
+ <div
100
+ aria-checked="true"
101
+ aria-selected="true"
102
+ class="active selected item"
103
+ role="option"
104
+ style="pointer-events: all;"
105
+ >
106
+ <div
107
+ class="text"
108
+ style="margin-left: 0px;"
109
+ >
110
+ <i
111
+ aria-hidden="true"
112
+ class="icon"
113
+ />
114
+ domain1
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </div>
121
+ </div>
56
122
  <div
57
123
  class="ui segment"
58
124
  >
@@ -279,6 +345,7 @@ exports[`<RuleImplementationRawForm /> matches the latest snapshot 1`] = `
279
345
  Data source
280
346
  </label>
281
347
  <div
348
+ aria-busy="false"
282
349
  aria-expanded="false"
283
350
  class="ui search selection dropdown"
284
351
  name="source_id"