@truedat/cx 7.5.9 → 7.5.10

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.
Files changed (110) hide show
  1. package/package.json +40 -70
  2. package/src/configurations/components/Configuration.js +3 -3
  3. package/src/configurations/components/ConfigurationActions.js +1 -2
  4. package/src/configurations/components/ConfigurationBreadcrumbs.js +2 -3
  5. package/src/configurations/components/ConfigurationCards.js +1 -2
  6. package/src/configurations/components/ConfigurationForm.js +6 -11
  7. package/src/configurations/components/ConfigurationLoader.js +1 -2
  8. package/src/configurations/components/ConfigurationRoutes.js +61 -72
  9. package/src/configurations/components/ConfigurationTokenLoader.js +0 -1
  10. package/src/configurations/components/Configurations.js +2 -2
  11. package/src/configurations/components/ConfigurationsLoader.js +0 -1
  12. package/src/configurations/components/DynamicConfigurationForm.js +5 -7
  13. package/src/configurations/components/EditConfiguration.js +0 -1
  14. package/src/configurations/components/NewConfiguration.js +0 -1
  15. package/src/configurations/components/__tests__/Configuration.spec.js +17 -10
  16. package/src/configurations/components/__tests__/ConfigurationCards.spec.js +22 -13
  17. package/src/configurations/components/__tests__/ConfigurationForm.spec.js +5 -5
  18. package/src/configurations/components/__tests__/ConfigurationLoader.spec.js +44 -36
  19. package/src/configurations/components/__tests__/ConfigurationTokenLoader.spec.js +46 -45
  20. package/src/configurations/components/__tests__/Configurations.spec.js +20 -22
  21. package/src/configurations/components/__tests__/ConfigurationsLoader.spec.js +32 -33
  22. package/src/configurations/components/__tests__/EditConfiguration.spec.js +5 -5
  23. package/src/configurations/components/__tests__/NewConfiguration.spec.js +0 -1
  24. package/src/configurations/components/__tests__/__snapshots__/Configuration.spec.js.snap +122 -57
  25. package/src/configurations/components/__tests__/__snapshots__/ConfigurationCards.spec.js.snap +160 -361
  26. package/src/configurations/components/__tests__/__snapshots__/ConfigurationForm.spec.js.snap +7 -6
  27. package/src/configurations/components/__tests__/__snapshots__/ConfigurationLoader.spec.js.snap +5 -31
  28. package/src/configurations/components/__tests__/__snapshots__/ConfigurationTokenLoader.spec.js.snap +5 -9
  29. package/src/configurations/components/__tests__/__snapshots__/Configurations.spec.js.snap +91 -72
  30. package/src/configurations/components/__tests__/__snapshots__/ConfigurationsLoader.spec.js.snap +5 -27
  31. package/src/configurations/components/__tests__/__snapshots__/EditConfiguration.spec.js.snap +12 -10
  32. package/src/configurations/components/__tests__/__snapshots__/NewConfiguration.spec.js.snap +11 -9
  33. package/src/configurations/components/index.js +1 -1
  34. package/src/configurations/reducers/configurationRedirect.js +1 -1
  35. package/src/configurations/reducers/configurations.js +1 -1
  36. package/src/configurations/reducers/index.js +1 -1
  37. package/src/configurations/reducers/systemConfigurations.js +1 -1
  38. package/src/configurations/sagas/signConfiguration.js +3 -1
  39. package/src/jobs/components/Job.js +0 -1
  40. package/src/jobs/components/JobBreadcrumbs.js +2 -3
  41. package/src/jobs/components/JobLoader.js +2 -2
  42. package/src/jobs/components/JobRoutes.js +28 -40
  43. package/src/jobs/components/JobRow.js +4 -4
  44. package/src/jobs/components/Jobs.js +5 -4
  45. package/src/jobs/components/JobsLabelResults.js +2 -3
  46. package/src/jobs/components/JobsSearch.js +0 -1
  47. package/src/jobs/components/JobsTable.js +3 -3
  48. package/src/jobs/components/JobsView.js +0 -1
  49. package/src/jobs/components/SourceJobs.js +0 -1
  50. package/src/jobs/components/__tests__/Job.spec.js +9 -11
  51. package/src/jobs/components/__tests__/JobBreadcrumbs.spec.js +5 -5
  52. package/src/jobs/components/__tests__/JobLoader.spec.js +12 -12
  53. package/src/jobs/components/__tests__/JobRow.spec.js +21 -20
  54. package/src/jobs/components/__tests__/Jobs.spec.js +1 -7
  55. package/src/jobs/components/__tests__/JobsLoader.spec.js +9 -9
  56. package/src/jobs/components/__tests__/JobsTable.spec.js +33 -28
  57. package/src/jobs/components/__tests__/JobsView.spec.js +1 -7
  58. package/src/jobs/components/__tests__/SourceJobs.spec.js +1 -7
  59. package/src/jobs/components/__tests__/__snapshots__/Job.spec.js.snap +143 -36
  60. package/src/jobs/components/__tests__/__snapshots__/JobBreadcrumbs.spec.js.snap +20 -30
  61. package/src/jobs/components/__tests__/__snapshots__/Jobs.spec.js.snap +10 -23
  62. package/src/jobs/components/__tests__/__snapshots__/JobsTable.spec.js.snap +7 -7
  63. package/src/jobs/components/__tests__/__snapshots__/JobsView.spec.js.snap +12 -24
  64. package/src/jobs/components/__tests__/__snapshots__/SourceJobs.spec.js.snap +8 -21
  65. package/src/jobs/reducers/jobActiveFilters.js +1 -1
  66. package/src/jobs/sagas/fetchJob.js +1 -1
  67. package/src/jobs/selectors/jobColumnsSelector.js +0 -1
  68. package/src/jobs/selectors/sourceJobColumnsSelector.js +0 -1
  69. package/src/sources/components/EditSource.js +0 -1
  70. package/src/sources/components/JobForm.js +1 -1
  71. package/src/sources/components/NewJob.js +0 -1
  72. package/src/sources/components/NewSource.js +0 -1
  73. package/src/sources/components/Source.js +0 -1
  74. package/src/sources/components/SourceActions.js +1 -2
  75. package/src/sources/components/SourceBreadcrumbs.js +1 -2
  76. package/src/sources/components/SourceConfiguration.js +3 -3
  77. package/src/sources/components/SourceDetail.js +46 -50
  78. package/src/sources/components/SourceForm.js +4 -7
  79. package/src/sources/components/SourceHeader.js +0 -1
  80. package/src/sources/components/SourceRoutes.js +30 -23
  81. package/src/sources/components/SourceSelector.js +0 -1
  82. package/src/sources/components/SourceTabs.js +14 -7
  83. package/src/sources/components/Sources.js +2 -2
  84. package/src/sources/components/SourcesTable.js +1 -2
  85. package/src/sources/components/__tests__/EditSource.spec.js +10 -12
  86. package/src/sources/components/__tests__/NewSource.spec.js +5 -10
  87. package/src/sources/components/__tests__/Source.spec.js +19 -27
  88. package/src/sources/components/__tests__/SourceActions.spec.js +1 -2
  89. package/src/sources/components/__tests__/SourceBreadcrumbs.spec.js +0 -1
  90. package/src/sources/components/__tests__/SourceDetail.spec.js +62 -38
  91. package/src/sources/components/__tests__/SourceForm.spec.js +109 -86
  92. package/src/sources/components/__tests__/SourceHeader.spec.js +1 -2
  93. package/src/sources/components/__tests__/SourceRoutes.spec.js +79 -7
  94. package/src/sources/components/__tests__/SourceSelector.spec.js +0 -1
  95. package/src/sources/components/__tests__/SourceTabs.spec.js +3 -4
  96. package/src/sources/components/__tests__/Sources.spec.js +24 -39
  97. package/src/sources/components/__tests__/SourcesTable.spec.js +48 -65
  98. package/src/sources/components/__tests__/__snapshots__/EditSource.spec.js.snap +134 -15
  99. package/src/sources/components/__tests__/__snapshots__/NewSource.spec.js.snap +36 -23
  100. package/src/sources/components/__tests__/__snapshots__/Source.spec.js.snap +28 -31
  101. package/src/sources/components/__tests__/__snapshots__/SourceActions.spec.js.snap +1 -1
  102. package/src/sources/components/__tests__/__snapshots__/SourceBreadcrumbs.spec.js.snap +2 -1
  103. package/src/sources/components/__tests__/__snapshots__/SourceDetail.spec.js.snap +13 -172
  104. package/src/sources/components/__tests__/__snapshots__/SourceForm.spec.js.snap +132 -106
  105. package/src/sources/components/__tests__/__snapshots__/SourceHeader.spec.js.snap +4 -4
  106. package/src/sources/components/__tests__/__snapshots__/SourceRoutes.spec.js.snap +47 -5
  107. package/src/sources/components/__tests__/__snapshots__/SourceTabs.spec.js.snap +5 -3
  108. package/src/sources/components/__tests__/__snapshots__/Sources.spec.js.snap +14 -11
  109. package/src/sources/components/__tests__/__snapshots__/SourcesTable.spec.js.snap +17 -12
  110. package/src/jobs/components/ConfigurationRoutes.js +0 -31
@@ -12,7 +12,7 @@ exports[`<JobsTable /> matches the latest snapshot (no jobs) 1`] = `
12
12
  <div
13
13
  class="content"
14
14
  >
15
- No jobs found
15
+ jobs.search.results.empty
16
16
  </div>
17
17
  </h4>
18
18
  </div>
@@ -32,32 +32,32 @@ exports[`<JobsTable /> matches the latest snapshot 1`] = `
32
32
  <th
33
33
  class="two wide"
34
34
  >
35
- Source
35
+ source.external_id
36
36
  </th>
37
37
  <th
38
38
  class="two wide"
39
39
  >
40
- Source Type
40
+ source.type
41
41
  </th>
42
42
  <th
43
43
  class="two wide"
44
44
  >
45
- Type
45
+ type
46
46
  </th>
47
47
  <th
48
48
  class="two wide"
49
49
  >
50
- Status
50
+ status
51
51
  </th>
52
52
  <th
53
53
  class="two wide disabled"
54
54
  >
55
- Message
55
+ message
56
56
  </th>
57
57
  <th
58
58
  class="two wide descending sorted"
59
59
  >
60
- Updated At
60
+ end_date
61
61
  </th>
62
62
  </tr>
63
63
  </thead>
@@ -15,11 +15,11 @@ exports[`<JobsView /> matches the latest snapshot 1`] = `
15
15
  <div
16
16
  class="content"
17
17
  >
18
- Jobs
18
+ jobs.header
19
19
  <div
20
20
  class="sub header"
21
21
  >
22
- Connectors execution by defined sources
22
+ jobs.subheader
23
23
  </div>
24
24
  </div>
25
25
  </h2>
@@ -30,7 +30,7 @@ exports[`<JobsView /> matches the latest snapshot 1`] = `
30
30
  class="ui action left icon input"
31
31
  >
32
32
  <input
33
- placeholder="Search jobs..."
33
+ placeholder="jobs.search.placeholder"
34
34
  type="text"
35
35
  value=""
36
36
  />
@@ -64,7 +64,7 @@ exports[`<JobsView /> matches the latest snapshot 1`] = `
64
64
  role="option"
65
65
  >
66
66
  <em>
67
- (reset all filters)
67
+ (reset filters)
68
68
  </em>
69
69
  </div>
70
70
  </div>
@@ -75,23 +75,11 @@ exports[`<JobsView /> matches the latest snapshot 1`] = `
75
75
  />
76
76
  <div
77
77
  class="dimmable"
78
- >
79
- <div
80
- class="ui inverted dimmer"
81
- >
82
- <div
83
- class="content"
84
- >
85
- <div
86
- class="ui loader"
87
- />
88
- </div>
89
- </div>
90
- </div>
78
+ />
91
79
  <div
92
80
  class="ui label jobs-label-results"
93
81
  >
94
- jobs found
82
+ jobs.retrieved.results
95
83
  </div>
96
84
  <table
97
85
  class="ui selectable sortable table"
@@ -105,32 +93,32 @@ exports[`<JobsView /> matches the latest snapshot 1`] = `
105
93
  <th
106
94
  class="two wide"
107
95
  >
108
- Source
96
+ source.external_id
109
97
  </th>
110
98
  <th
111
99
  class="two wide"
112
100
  >
113
- Source Type
101
+ source.type
114
102
  </th>
115
103
  <th
116
104
  class="two wide"
117
105
  >
118
- Type
106
+ type
119
107
  </th>
120
108
  <th
121
109
  class="two wide"
122
110
  >
123
- Status
111
+ status
124
112
  </th>
125
113
  <th
126
114
  class="two wide disabled"
127
115
  >
128
- Message
116
+ message
129
117
  </th>
130
118
  <th
131
119
  class="two wide descending sorted"
132
120
  >
133
- Updated At
121
+ end_date
134
122
  </th>
135
123
  </tr>
136
124
  </thead>
@@ -6,9 +6,8 @@ exports[`<SourceJobs /> matches the latest snapshot 1`] = `
6
6
  class="ui action left icon input"
7
7
  >
8
8
  <input
9
- placeholder="Search jobs..."
9
+ placeholder="jobs.search.placeholder"
10
10
  type="text"
11
- value=""
12
11
  />
13
12
  <i
14
13
  aria-hidden="true"
@@ -40,7 +39,7 @@ exports[`<SourceJobs /> matches the latest snapshot 1`] = `
40
39
  role="option"
41
40
  >
42
41
  <em>
43
- (reset all filters)
42
+ (reset filters)
44
43
  </em>
45
44
  </div>
46
45
  </div>
@@ -51,23 +50,11 @@ exports[`<SourceJobs /> matches the latest snapshot 1`] = `
51
50
  />
52
51
  <div
53
52
  class="dimmable"
54
- >
55
- <div
56
- class="ui inverted dimmer"
57
- >
58
- <div
59
- class="content"
60
- >
61
- <div
62
- class="ui loader"
63
- />
64
- </div>
65
- </div>
66
- </div>
53
+ />
67
54
  <div
68
55
  class="ui label jobs-label-results"
69
56
  >
70
- 42 jobs found
57
+ jobs.retrieved.results
71
58
  </div>
72
59
  <table
73
60
  class="ui selectable sortable table"
@@ -81,22 +68,22 @@ exports[`<SourceJobs /> matches the latest snapshot 1`] = `
81
68
  <th
82
69
  class="three wide"
83
70
  >
84
- Updated At
71
+ end_date
85
72
  </th>
86
73
  <th
87
74
  class="two wide"
88
75
  >
89
- Type
76
+ type
90
77
  </th>
91
78
  <th
92
79
  class="two wide"
93
80
  >
94
- Status
81
+ status
95
82
  </th>
96
83
  <th
97
84
  class="nine wide ascending sorted disabled"
98
85
  >
99
- Message
86
+ message
100
87
  </th>
101
88
  </tr>
102
89
  </thead>
@@ -4,7 +4,7 @@ import {
4
4
  closeJobFilter,
5
5
  removeJobFilter,
6
6
  resetJobFilters,
7
- toggleJobFilterValue
7
+ toggleJobFilterValue,
8
8
  } from "../routines";
9
9
 
10
10
  export const initialState = {};
@@ -9,7 +9,7 @@ const toApiPath = compile(API_JOB);
9
9
  export function* fetchJobSaga({ payload }) {
10
10
  try {
11
11
  const { id } = payload;
12
- const url = toApiPath({ id });
12
+ const url = toApiPath({ id: `${id}` });
13
13
  yield put(fetchJob.request({ id }));
14
14
  const { data } = yield call(apiJson, url, JSON_OPTS);
15
15
  yield put(fetchJob.success(data));
@@ -1,5 +1,4 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
3
2
  import { createSelector } from "reselect";
4
3
  import Moment from "react-moment";
5
4
 
@@ -1,5 +1,4 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
3
2
  import { createSelector } from "reselect";
4
3
  import Moment from "react-moment";
5
4
 
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import PropTypes from "prop-types";
3
2
  import { connect } from "react-redux";
4
3
  import { updateSource } from "../routines";
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import { useState } from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import { Button, Form } from "semantic-ui-react";
4
4
  import { useIntl } from "react-intl";
@@ -1,5 +1,4 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
3
2
  import PropTypes from "prop-types";
4
3
  import { connect } from "react-redux";
5
4
  import { useIntl } from "react-intl";
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import PropTypes from "prop-types";
3
2
  import { connect } from "react-redux";
4
3
  import { Container, Header, Icon, Segment } from "semantic-ui-react";
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import PropTypes from "prop-types";
3
2
  import { Segment } from "semantic-ui-react";
4
3
  import SourceBreadcrumbs from "./SourceBreadcrumbs";
@@ -1,5 +1,4 @@
1
- import React from "react";
2
- import { Link } from "react-router-dom";
1
+ import { Link } from "react-router";
3
2
  import { connect } from "react-redux";
4
3
  import PropTypes from "prop-types";
5
4
  import { useIntl } from "react-intl";
@@ -1,7 +1,6 @@
1
- import React from "react";
2
1
  import PropTypes from "prop-types";
3
2
  import { Breadcrumb } from "semantic-ui-react";
4
- import { Link } from "react-router-dom";
3
+ import { Link } from "react-router";
5
4
  import { FormattedMessage } from "react-intl";
6
5
  import { SOURCES } from "@truedat/core/routes";
7
6
 
@@ -1,11 +1,11 @@
1
1
  import _ from "lodash/fp";
2
- import React, { useState, useEffect } from "react";
2
+ import { lazy, useState, useEffect } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { connect } from "react-redux";
5
5
  import { updateSource } from "../routines";
6
6
 
7
- const DynamicFormViewer = React.lazy(() =>
8
- import("@truedat/df/components/DynamicFormViewer")
7
+ const DynamicFormViewer = lazy(
8
+ () => import("@truedat/df/components/DynamicFormViewer")
9
9
  );
10
10
 
11
11
  export const SourceConfiguration = ({
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import PropTypes from "prop-types";
3
- import { Switch, Route } from "react-router-dom";
3
+ import { Route, Routes } from "react-router";
4
4
  import { Segment } from "semantic-ui-react";
5
5
  import {
6
6
  SOURCE_EDIT,
@@ -16,71 +16,67 @@ import EditSource from "./EditSource";
16
16
  import NewJob from "./NewJob";
17
17
  import SourceConfiguration from "./SourceConfiguration";
18
18
  import SourceTabs from "./SourceTabs";
19
-
20
19
  export const SourceDetail = ({ source }) => (
21
- <Switch>
22
- <Route
23
- path={SOURCE_JOBS_NEW}
24
- exact
25
- render={() => (
26
- <>
27
- <SourceTabs source={source} />
28
- <Segment attached="bottom">
29
- <NewJob source={source} />
30
- </Segment>
31
- </>
32
- )}
33
- />
34
- <Route
35
- path={SOURCE_JOB}
36
- exact
37
- render={() => (
38
- <>
39
- <JobLoader />
40
- <SourceTabs source={source} />
41
- <Segment attached="bottom">
42
- <Job />
43
- </Segment>
44
- </>
45
- )}
46
- />
20
+ <Routes>
47
21
  <Route
48
- path={SOURCE_JOBS}
49
- exact
50
- render={() => (
22
+ index
23
+ element={
51
24
  <>
52
25
  <SourceTabs source={source} />
53
26
  <Segment attached="bottom">
54
- <SourceJobs source={source} />
27
+ <SourceConfiguration source={source} />
55
28
  </Segment>
56
29
  </>
57
- )}
30
+ }
58
31
  />
59
32
  <Route
60
- path={SOURCE_EDIT}
61
- exact
62
- render={() => (
33
+ path="edit"
34
+ element={
63
35
  <>
64
36
  <SourceTabs source={source} />
65
37
  <Segment attached="bottom">
66
38
  <EditSource source={source} />
67
39
  </Segment>
68
40
  </>
69
- )}
70
- />
71
- <Route
72
- path={SOURCE}
73
- exact
74
- render={() => (
75
- <>
76
- <SourceTabs source={source} />
77
- <Segment attached="bottom">
78
- <SourceConfiguration source={source} />
79
- </Segment>
80
- </>
81
- )}
41
+ }
82
42
  />
83
- </Switch>
43
+ <Route path="jobs">
44
+ <Route
45
+ index
46
+ element={
47
+ <>
48
+ <SourceTabs source={source} />
49
+ <Segment attached="bottom">
50
+ <SourceJobs source={source} />
51
+ </Segment>
52
+ </>
53
+ }
54
+ />
55
+ <Route
56
+ path="new"
57
+ element={
58
+ <>
59
+ <SourceTabs source={source} />
60
+ <Segment attached="bottom">
61
+ <NewJob source={source} />
62
+ </Segment>
63
+ </>
64
+ }
65
+ />
66
+ <Route
67
+ path=":id"
68
+ element={
69
+ <>
70
+ <JobLoader />
71
+ <SourceTabs source={source} />
72
+ <Segment attached="bottom">
73
+ <Job />
74
+ </Segment>
75
+ </>
76
+ }
77
+ />
78
+ </Route>
79
+ </Routes>
84
80
  );
85
81
 
86
82
  SourceDetail.propTypes = {
@@ -1,5 +1,5 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
2
+ import { lazy, Component } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { Button, Form, Label } from "semantic-ui-react";
5
5
  import { injectIntl, FormattedMessage } from "react-intl";
@@ -9,9 +9,7 @@ import { HistoryBackButton, Loading } from "@truedat/core/components";
9
9
  import { accentInsensitivePathOrder } from "@truedat/core/services/sort";
10
10
  import { applyTemplate, validateContent } from "@truedat/df/utils";
11
11
 
12
- const DynamicForm = React.lazy(() =>
13
- import("@truedat/df/components/DynamicForm")
14
- );
12
+ const DynamicForm = lazy(() => import("@truedat/df/components/DynamicForm"));
15
13
 
16
14
  const staticFields = ["external_id"];
17
15
 
@@ -30,7 +28,7 @@ const isValid = _.conforms({
30
28
  contentErrors: isEmptyArray,
31
29
  });
32
30
 
33
- export class SourceForm extends React.Component {
31
+ export class SourceForm extends Component {
34
32
  static propTypes = {
35
33
  intl: PropTypes.object,
36
34
  source: PropTypes.object,
@@ -129,7 +127,7 @@ export class SourceForm extends React.Component {
129
127
  </label>
130
128
  <Form.Input
131
129
  name="external_id"
132
- value={external_id}
130
+ value={external_id || ""}
133
131
  onChange={this.handleChange}
134
132
  disabled={!_.isEmpty(source)}
135
133
  />
@@ -151,7 +149,6 @@ export class SourceForm extends React.Component {
151
149
  disabled={!_.isEmpty(source)}
152
150
  />
153
151
  </Form.Field>
154
-
155
152
  {type && !templatesLoading && (
156
153
  <Form.Field>
157
154
  <label className="label">
@@ -1,5 +1,4 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
3
2
  import PropTypes from "prop-types";
4
3
  import { useIntl } from "react-intl";
5
4
  import { Header, Icon, Grid } from "semantic-ui-react";
@@ -1,10 +1,13 @@
1
1
  import _ from "lodash/fp";
2
2
  import React from "react";
3
- import { Route, Switch, useParams } from "react-router-dom";
3
+ import { Routes, Route } from "react-router";
4
+ import { useParams } from "react-router";
4
5
  import { useQuery } from "@apollo/client";
5
- import { Unauthorized, Loading } from "@truedat/core/components";
6
- import { useAuthorized } from "@truedat/core/hooks";
7
- import { SOURCE, SOURCES, SOURCES_NEW } from "@truedat/core/routes";
6
+ import { useIntl } from "react-intl";
7
+ import { Loading } from "@truedat/core/components";
8
+ import { SOURCES } from "@truedat/core/routes";
9
+ import { ProtectedRoute } from "@truedat/core/router";
10
+ import { Message } from "semantic-ui-react";
8
11
  import { SOURCE_QUERY } from "../api/queries";
9
12
  import NewSource from "./NewSource";
10
13
  import Source from "./Source";
@@ -12,33 +15,37 @@ import Sources from "./Sources";
12
15
 
13
16
  export const SourceLoader = () => {
14
17
  const { sourceId } = useParams();
18
+ const { formatMessage } = useIntl();
15
19
  const { loading, error, data } = useQuery(SOURCE_QUERY, {
16
20
  variables: { sourceId },
17
21
  });
18
22
  if (error) return null;
19
23
  if (loading) return <Loading />;
20
24
  const source = data?.source;
21
- return _.isEmpty(source) ? null : <Source source={source} />;
22
- };
23
-
24
- export const AuthorizedSourcesRoutes = () => (
25
- <Switch>
26
- <Route exact path={SOURCES_NEW} render={() => <NewSource />} />
27
- <Route exact path={SOURCES} render={() => <Sources />} />
28
- <Route path={SOURCE} render={() => <SourceLoader />} />
29
- </Switch>
30
- );
31
-
32
- export const SourceRoutes = () => {
33
- const authorized = useAuthorized();
34
- return (
35
- <Route
36
- path={SOURCES}
37
- render={() =>
38
- authorized ? <AuthorizedSourcesRoutes /> : <Unauthorized />
39
- }
25
+ return _.isEmpty(source) ? (
26
+ <Message
27
+ error
28
+ icon="warning sign"
29
+ header={formatMessage({
30
+ id: "error.header",
31
+ defaultMessage: "Eek! Something went wrong...",
32
+ })}
33
+ list={["404 - Not found"]}
40
34
  />
35
+ ) : (
36
+ <Source source={source} />
41
37
  );
42
38
  };
43
39
 
40
+ export const SourceRoutes = () => (
41
+ <Routes>
42
+ <Route path={SOURCES} element={<ProtectedRoute />}>
43
+ <Route index element={<Sources />} />
44
+ <Route path="new" element={<NewSource />} />
45
+ <Route path=":sourceId/*" element={<SourceLoader />} />
46
+ </Route>
47
+ <Route path="*" element={null} />
48
+ </Routes>
49
+ );
50
+
44
51
  export default SourceRoutes;
@@ -1,5 +1,4 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
3
2
  import PropTypes from "prop-types";
4
3
  import { useIntl } from "react-intl";
5
4
  import { Form } from "semantic-ui-react";
@@ -1,9 +1,8 @@
1
- import React from "react";
2
1
  import PropTypes from "prop-types";
3
- import { Link } from "react-router-dom";
2
+ import { Link } from "react-router";
4
3
  import { FormattedMessage } from "react-intl";
5
4
  import { Menu } from "semantic-ui-react";
6
- import { usePath } from "@truedat/core/hooks";
5
+ import { useActiveRoute } from "@truedat/core/hooks";
7
6
  import {
8
7
  linkTo,
9
8
  SOURCE_EDIT,
@@ -14,20 +13,28 @@ import {
14
13
  } from "@truedat/core/routes";
15
14
 
16
15
  export const SourceTabs = ({ source }) => {
17
- const path = usePath();
16
+ const sourceActive = useActiveRoute(SOURCE);
17
+ const sourceEditActive = useActiveRoute(SOURCE_EDIT);
18
+ const jobsActive = useActiveRoute(SOURCE_JOBS);
19
+ const jobActive = useActiveRoute(SOURCE_JOB);
20
+ const newJobActive = useActiveRoute(SOURCE_JOBS_NEW);
21
+
22
+ const isSourceActive = sourceActive || sourceEditActive;
23
+ const isJobsActive = (jobsActive || jobActive) && !newJobActive;
24
+
18
25
  const { id } = source;
19
26
  return (
20
27
  <>
21
28
  <Menu attached="top" secondary pointing tabular>
22
29
  <Menu.Item
23
- active={path === SOURCE || path === SOURCE_EDIT}
30
+ active={isSourceActive}
24
31
  as={Link}
25
32
  to={linkTo.SOURCE({ sourceId: id })}
26
33
  >
27
34
  <FormattedMessage id="source.config.label" />
28
35
  </Menu.Item>
29
36
  <Menu.Item
30
- active={path === SOURCE_JOBS || path === SOURCE_JOB}
37
+ active={isJobsActive}
31
38
  as={Link}
32
39
  to={linkTo.SOURCE_JOBS({ sourceId: id })}
33
40
  >
@@ -35,7 +42,7 @@ export const SourceTabs = ({ source }) => {
35
42
  </Menu.Item>
36
43
  {source?.active ? (
37
44
  <Menu.Item
38
- active={path === SOURCE_JOBS_NEW}
45
+ active={newJobActive}
39
46
  as={Link}
40
47
  to={linkTo.SOURCE_JOBS_NEW({ sourceId: id })}
41
48
  >
@@ -1,7 +1,7 @@
1
1
  import _ from "lodash/fp";
2
- import React, { useState } from "react";
2
+ import { useState } from "react";
3
3
  import { matchSorter } from "match-sorter";
4
- import { Link } from "react-router-dom";
4
+ import { Link } from "react-router";
5
5
  import { Button, Header, Icon, Input, Segment } from "semantic-ui-react";
6
6
  import { FormattedMessage, useIntl } from "react-intl";
7
7
  import { useQuery } from "@apollo/client";
@@ -1,8 +1,7 @@
1
1
  import _ from "lodash/fp";
2
- import React from "react";
3
2
  import PropTypes from "prop-types";
4
3
  import { Table } from "semantic-ui-react";
5
- import { Link } from "react-router-dom";
4
+ import { Link } from "react-router";
6
5
  import { FormattedMessage } from "react-intl";
7
6
  import { useIntl } from "react-intl";
8
7
  import { DateTime } from "@truedat/core/components";