@truedat/qx 5.14.1 → 5.15.0
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.js +3 -2
- package/src/components/QxRoutes.js +4 -4
- package/src/components/common/ResourceSelector.js +80 -0
- package/src/components/common/TestFormWrapper.js +9 -6
- package/src/components/common/TypeSelector.js +3 -1
- package/src/components/common/__tests__/DescriptionInput.spec.js +48 -0
- package/src/components/common/__tests__/ResourceSelector.spec.js +124 -0
- package/src/components/common/__tests__/TypeSelector.spec.js +29 -0
- package/src/components/common/__tests__/__snapshots__/DescriptionInput.spec.js.snap +19 -0
- package/src/components/common/__tests__/__snapshots__/ResourceSelector.spec.js.snap +484 -0
- package/src/components/common/__tests__/__snapshots__/TypeSelector.spec.js.snap +230 -0
- package/src/components/common/expressions/Clauses.js +100 -0
- package/src/components/common/expressions/Condition.js +178 -0
- package/src/components/common/expressions/Expression.js +54 -0
- package/src/components/common/expressions/FieldSelector.js +66 -0
- package/src/components/{functions → common}/expressions/FunctionArgs.js +1 -0
- package/src/components/{functions → common}/expressions/FunctionSelector.js +24 -4
- package/src/components/{functions → common}/expressions/ParamSelector.js +3 -3
- package/src/components/{functions → common}/expressions/ShapeSelector.js +22 -6
- package/src/components/common/expressions/__tests__/Clauses.spec.js +53 -0
- package/src/components/common/expressions/__tests__/Condition.spec.js +33 -0
- package/src/components/{functions → common}/expressions/__tests__/ConstantSelector.spec.js +6 -1
- package/src/components/{functions → common}/expressions/__tests__/Expression.spec.js +7 -5
- package/src/components/common/expressions/__tests__/FieldSelector.spec.js +24 -0
- package/src/components/{functions → common}/expressions/__tests__/FunctionArgs.spec.js +20 -6
- package/src/components/{functions → common}/expressions/__tests__/FunctionSelector.spec.js +1 -1
- package/src/components/{functions → common}/expressions/__tests__/ParamSelector.spec.js +22 -10
- package/src/components/{functions → common}/expressions/__tests__/ShapeSelector.spec.js +3 -3
- package/src/components/common/expressions/__tests__/__snapshots__/Clauses.spec.js.snap +64 -0
- package/src/components/common/expressions/__tests__/__snapshots__/Condition.spec.js.snap +316 -0
- package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ConstantSelector.spec.js.snap +1 -1
- package/src/components/common/expressions/__tests__/__snapshots__/Expression.spec.js.snap +939 -0
- package/src/components/common/expressions/__tests__/__snapshots__/FieldSelector.spec.js.snap +5 -0
- package/src/components/common/expressions/__tests__/__snapshots__/FunctionArgs.spec.js.snap +344 -0
- package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ParamSelector.spec.js.snap +4 -4
- package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ShapeSelector.spec.js.snap +17 -24
- package/src/components/common/expressions/constantInputs/AnySelector.js +44 -0
- package/src/components/{functions → common}/expressions/constantInputs/__tests__/AnySelector.spec.js +21 -14
- package/src/components/{functions → common}/expressions/constantInputs/__tests__/DefaultSelector.spec.js +5 -2
- package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/AnySelector.spec.js.snap +2 -2
- package/src/components/common/expressions/index.js +4 -0
- package/src/components/common/resourceSelectors/DataStructureSelector.js +63 -0
- package/src/components/common/resourceSelectors/DataViewSelector.js +65 -0
- package/src/components/common/resourceSelectors/ReferenceDatasetSelector.js +61 -0
- package/src/components/common/resourceSelectors/__tests__/DataStructureSelector.spec.js +31 -0
- package/src/components/common/resourceSelectors/__tests__/DataViewSelector.spec.js +133 -0
- package/src/components/common/resourceSelectors/__tests__/ReferenceDatasetSelector.spec.js +97 -0
- package/src/components/common/resourceSelectors/__tests__/__snapshots__/DataStructureSelector.spec.js.snap +105 -0
- package/src/components/common/resourceSelectors/__tests__/__snapshots__/DataViewSelector.spec.js.snap +50 -0
- package/src/components/common/resourceSelectors/__tests__/__snapshots__/ReferenceDatasetSelector.spec.js.snap +50 -0
- package/src/components/common/resourceSelectors/index.js +5 -0
- package/src/components/dataViews/DataViewEditor.js +170 -0
- package/src/components/dataViews/DataViewSelect.js +47 -0
- package/src/components/dataViews/DataViews.js +169 -0
- package/src/components/dataViews/Queryable.js +138 -0
- package/src/components/dataViews/Queryables.js +53 -0
- package/src/components/dataViews/__tests__/DataViewEditor.spec.js +293 -0
- package/src/components/dataViews/__tests__/DataViewSelect.spec.js +28 -0
- package/src/components/dataViews/__tests__/DataViews.spec.js +57 -0
- package/src/components/dataViews/__tests__/Queryable.spec.js +201 -0
- package/src/components/dataViews/__tests__/Queryables.spec.js +183 -0
- package/src/components/dataViews/__tests__/__snapshots__/DataViewEditor.spec.js.snap +1000 -0
- package/src/components/dataViews/__tests__/__snapshots__/DataViewSelect.spec.js.snap +55 -0
- package/src/components/dataViews/__tests__/__snapshots__/DataViews.spec.js.snap +77 -0
- package/src/components/dataViews/__tests__/__snapshots__/Queryable.spec.js.snap +874 -0
- package/src/components/dataViews/__tests__/__snapshots__/Queryables.spec.js.snap +911 -0
- package/src/components/dataViews/__tests__/queryableFunctions.spec.js +193 -0
- package/src/components/dataViews/queryableFunctions.js +80 -0
- package/src/components/dataViews/queryableProperties/From.js +15 -0
- package/src/components/dataViews/queryableProperties/GroupBy.js +124 -0
- package/src/components/dataViews/queryableProperties/Join.js +62 -0
- package/src/components/dataViews/queryableProperties/JoinTypeIcon.js +49 -0
- package/src/components/dataViews/queryableProperties/Select.js +76 -0
- package/src/components/dataViews/queryableProperties/SelectField.js +116 -0
- package/src/components/dataViews/queryableProperties/Where.js +15 -0
- package/src/components/dataViews/queryableProperties/__tests__/From.spec.js +30 -0
- package/src/components/dataViews/queryableProperties/__tests__/GroupBy.spec.js +75 -0
- package/src/components/dataViews/queryableProperties/__tests__/Join.spec.js +38 -0
- package/src/components/dataViews/queryableProperties/__tests__/JoinTypeIcon.spec.js +36 -0
- package/src/components/dataViews/queryableProperties/__tests__/Select.spec.js +144 -0
- package/src/components/dataViews/queryableProperties/__tests__/SelectField.spec.js +107 -0
- package/src/components/dataViews/queryableProperties/__tests__/Where.spec.js +27 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/From.spec.js.snap +75 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/GroupBy.spec.js.snap +276 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Join.spec.js.snap +252 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/JoinTypeIcon.spec.js.snap +77 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Select.spec.js.snap +411 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/SelectField.spec.js.snap +343 -0
- package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Where.spec.js.snap +22 -0
- package/src/components/dataViews/queryableProperties/index.js +7 -0
- package/src/components/functions/FunctionEditor.js +30 -29
- package/src/components/functions/Functions.js +3 -11
- package/src/components/functions/__tests__/FunctionEditor.spec.js +6 -0
- package/src/components/functions/__tests__/FunctionParams.spec.js +6 -0
- package/src/components/functions/__tests__/__snapshots__/FunctionEditor.spec.js.snap +490 -466
- package/src/components/functions/__tests__/__snapshots__/FunctionParams.spec.js.snap +1 -1
- package/src/hooks/__tests__/{useDataSets.spec.js → useDataViews.spec.js} +5 -5
- package/src/hooks/useDataViews.js +33 -0
- package/src/styles/Expression.less +150 -0
- package/src/types.js +11 -3
- package/src/components/DataSets.js +0 -64
- package/src/components/__tests__/DataSets.spec.js +0 -46
- package/src/components/__tests__/__snapshots__/DataSets.spec.js.snap +0 -82
- package/src/components/functions/expressions/Expression.js +0 -40
- package/src/components/functions/expressions/FieldSelector.js +0 -56
- package/src/components/functions/expressions/__tests__/__snapshots__/Expression.spec.js.snap +0 -904
- package/src/components/functions/expressions/__tests__/__snapshots__/FunctionArgs.spec.js.snap +0 -392
- package/src/components/functions/expressions/constantInputs/AnySelector.js +0 -29
- package/src/hooks/useDataSets.js +0 -8
- /package/src/components/{functions → common}/expressions/ConstantSelector.js +0 -0
- /package/src/components/{functions → common}/expressions/__tests__/__snapshots__/FunctionSelector.spec.js.snap +0 -0
- /package/src/components/{functions → common/expressions}/__tests__/useWatchParams.spec.js +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/BooleanSelector.js +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/DefaultSelector.js +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/__tests__/BooleanSelector.spec.js +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/BooleanSelector.spec.js.snap +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/DefaultSelector.spec.js.snap +0 -0
- /package/src/components/{functions → common}/expressions/constantInputs/index.js +0 -0
- /package/src/components/{functions → common/expressions}/useWatchParams.js +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import useSWR from "swr";
|
|
2
2
|
import { renderHook } from "@testing-library/react-hooks";
|
|
3
3
|
import { apiJson } from "@truedat/core/services/api";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { API_DATA_VIEWS } from "../../api";
|
|
5
|
+
import { useDataViews } from "../useDataViews";
|
|
6
6
|
|
|
7
7
|
jest.mock("swr", () => ({
|
|
8
8
|
__esModule: true,
|
|
@@ -13,9 +13,9 @@ jest.mock("swr", () => ({
|
|
|
13
13
|
})),
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
|
-
describe("
|
|
16
|
+
describe("useDataViews", () => {
|
|
17
17
|
it("calls useSWR with correct api route", () => {
|
|
18
|
-
const { result } = renderHook(() =>
|
|
18
|
+
const { result } = renderHook(() => useDataViews());
|
|
19
19
|
|
|
20
20
|
expect(result.current).toMatchObject({
|
|
21
21
|
data: "data",
|
|
@@ -23,6 +23,6 @@ describe("useDataSets", () => {
|
|
|
23
23
|
loading: false,
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
expect(useSWR).toHaveBeenCalledWith(
|
|
26
|
+
expect(useSWR).toHaveBeenCalledWith(API_DATA_VIEWS, apiJson);
|
|
27
27
|
});
|
|
28
28
|
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { compile } from "path-to-regexp";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
import useSWRMutations from "swr/mutation";
|
|
4
|
+
import {
|
|
5
|
+
apiJson,
|
|
6
|
+
apiJsonPost,
|
|
7
|
+
apiJsonPatch,
|
|
8
|
+
apiJsonDelete,
|
|
9
|
+
} from "@truedat/core/services/api";
|
|
10
|
+
import { API_DATA_VIEWS, API_DATA_VIEW } from "../api";
|
|
11
|
+
|
|
12
|
+
export const useDataViews = () => {
|
|
13
|
+
const { data, error, mutate } = useSWR(API_DATA_VIEWS, apiJson);
|
|
14
|
+
return { data: data?.data, error, loading: !error && !data, mutate };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const useDataViewCreate = () => {
|
|
18
|
+
return useSWRMutations(API_DATA_VIEWS, (url, { arg }) =>
|
|
19
|
+
apiJsonPost(url, arg)
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const useDataViewUpdate = (dataView) => {
|
|
24
|
+
const id = dataView?.id || 0;
|
|
25
|
+
const url = compile(API_DATA_VIEW)({ id });
|
|
26
|
+
return useSWRMutations(url, (url, { arg }) => apiJsonPatch(url, arg));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const useDataViewDelete = (dataView) => {
|
|
30
|
+
const id = dataView?.id || 0;
|
|
31
|
+
const url = compile(API_DATA_VIEW)({ id });
|
|
32
|
+
return useSWRMutations(url, (url, { arg }) => apiJsonDelete(url, arg));
|
|
33
|
+
};
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
display: flex;
|
|
11
11
|
align-items: center;
|
|
12
12
|
}
|
|
13
|
+
.flex-center-gap {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 5px;
|
|
17
|
+
}
|
|
18
|
+
.flex-justify-center {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
13
23
|
.flex-column {
|
|
14
24
|
display: flex;
|
|
15
25
|
flex-direction: column;
|
|
@@ -100,3 +110,143 @@ ul.function-tree {
|
|
|
100
110
|
.function-tree li:last-child:after {
|
|
101
111
|
display: none;
|
|
102
112
|
}
|
|
113
|
+
|
|
114
|
+
.clause-and-group {
|
|
115
|
+
display: flex;
|
|
116
|
+
width: 100%;
|
|
117
|
+
justify-content: flex-end;
|
|
118
|
+
margin-bottom: 5px;
|
|
119
|
+
height: 32px;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.condition-row {
|
|
123
|
+
display: flex;
|
|
124
|
+
justify-content: space-evenly;
|
|
125
|
+
align-items: center;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.condition-operator-trigger {
|
|
129
|
+
margin-right: 15px;
|
|
130
|
+
margin-left: 15px;
|
|
131
|
+
padding: 6.5px;
|
|
132
|
+
border: 1px solid rgba(34,36,38, 0.15);
|
|
133
|
+
border-radius: 4px;
|
|
134
|
+
min-width: 50px;
|
|
135
|
+
text-align: center;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.vertical-space {
|
|
139
|
+
margin: 10px 0px 5px 0px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.queryable-label {
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: flex-start;
|
|
145
|
+
justify-content: space-between;
|
|
146
|
+
height: 32px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.delete-expression-column {
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: flex-end;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
.join_type{
|
|
161
|
+
display:inline-flex;
|
|
162
|
+
left: 25%;
|
|
163
|
+
}
|
|
164
|
+
.join_type .circle{
|
|
165
|
+
display:flex;
|
|
166
|
+
box-sizing: border-box;
|
|
167
|
+
width:20px;
|
|
168
|
+
height:20px;
|
|
169
|
+
border-radius:50%;
|
|
170
|
+
border: 2px solid black;
|
|
171
|
+
z-index: 1;
|
|
172
|
+
}
|
|
173
|
+
.join_type .circle.fill{
|
|
174
|
+
background:orange;
|
|
175
|
+
}
|
|
176
|
+
.join_type .circle.fill.white {
|
|
177
|
+
background:white;
|
|
178
|
+
}
|
|
179
|
+
.join_type .circle-left{
|
|
180
|
+
display:block;
|
|
181
|
+
overflow:hidden;
|
|
182
|
+
position:relative;
|
|
183
|
+
}
|
|
184
|
+
.join_type .circle-center{
|
|
185
|
+
top: -2px;
|
|
186
|
+
right: calc(-75% + 2px);
|
|
187
|
+
position:absolute;
|
|
188
|
+
}
|
|
189
|
+
.join_type .circle-right{
|
|
190
|
+
overflow:hidden;
|
|
191
|
+
position:relative;
|
|
192
|
+
right: 25%;
|
|
193
|
+
z-index: 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.error-popup {
|
|
197
|
+
white-space: normal;
|
|
198
|
+
background: #ffffff !important;
|
|
199
|
+
border: 1px solid #E0B4B4 !important;
|
|
200
|
+
color: #9F3A38 !important;
|
|
201
|
+
padding: 0.5833em 0.833em !important;
|
|
202
|
+
font-size: 0.85714286rem !important;
|
|
203
|
+
font-weight: 700 !important;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.select-field-dropdown {
|
|
207
|
+
padding: 0.36em 1em !important;
|
|
208
|
+
display: flex !important;
|
|
209
|
+
align-items: center;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//JOIN TYPE ICONS
|
|
213
|
+
|
|
214
|
+
.join-type-dropdown {
|
|
215
|
+
padding: 0.57em 1em !important;
|
|
216
|
+
cursor: pointer;
|
|
217
|
+
word-wrap: break-word;
|
|
218
|
+
line-height: 1em;
|
|
219
|
+
white-space: normal;
|
|
220
|
+
outline: 0;
|
|
221
|
+
transform: rotateZ(0deg);
|
|
222
|
+
min-width: 14em;
|
|
223
|
+
min-height: 2.71428571em;
|
|
224
|
+
background: #ffffff;
|
|
225
|
+
color: #0d0d0d;
|
|
226
|
+
box-shadow: none;
|
|
227
|
+
border: 1px solid rgba(34, 36, 38, 0.15);
|
|
228
|
+
border-radius: 0.28571429rem;
|
|
229
|
+
display: flex !important;
|
|
230
|
+
align-items: center;
|
|
231
|
+
justify-content: space-between;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.join-type-dropdown-menu {
|
|
235
|
+
overflow-x: hidden;
|
|
236
|
+
overflow-y: auto;
|
|
237
|
+
backface-visibility: hidden;
|
|
238
|
+
-webkit-overflow-scrolling: touch;
|
|
239
|
+
border-top-width: 0px !important;
|
|
240
|
+
width: auto;
|
|
241
|
+
outline: none;
|
|
242
|
+
margin: 0px -1px;
|
|
243
|
+
min-width: calc(100% + 2px );
|
|
244
|
+
width: calc(100% + 2px );
|
|
245
|
+
border-radius: 0em 0em 0.28571429rem 0.28571429rem;
|
|
246
|
+
box-shadow: 0px 2px 3px 0px rgba(34, 36, 38, 0.15);
|
|
247
|
+
transition: opacity 0.1s ease;
|
|
248
|
+
}
|
|
249
|
+
.join-type-dropdown-item {
|
|
250
|
+
display: flex !important;
|
|
251
|
+
align-items: center;
|
|
252
|
+
}
|
package/src/types.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Label } from "semantic-ui-react";
|
|
2
4
|
|
|
3
5
|
export const types = [
|
|
4
6
|
"boolean",
|
|
5
7
|
"string",
|
|
6
|
-
"
|
|
8
|
+
"number",
|
|
7
9
|
"date",
|
|
8
10
|
"timestamp",
|
|
9
11
|
"any",
|
|
@@ -16,7 +18,7 @@ export const typeToIcon = (value) => {
|
|
|
16
18
|
value
|
|
17
19
|
)({
|
|
18
20
|
string: "font",
|
|
19
|
-
|
|
21
|
+
number: "hashtag",
|
|
20
22
|
date: "calendar alternate outline",
|
|
21
23
|
timestamp: "clock outline",
|
|
22
24
|
// "any": "asterisk",
|
|
@@ -31,8 +33,14 @@ export const typeToColor = (value) => {
|
|
|
31
33
|
)({
|
|
32
34
|
boolean: "teal",
|
|
33
35
|
string: "purple",
|
|
34
|
-
|
|
36
|
+
number: "blue",
|
|
35
37
|
date: "olive",
|
|
36
38
|
timestamp: "brown",
|
|
37
39
|
});
|
|
38
40
|
};
|
|
41
|
+
|
|
42
|
+
export const typeLabel = (value) => (
|
|
43
|
+
<Label size="tiny" circular color={typeToColor(value)} width="100px">
|
|
44
|
+
{value[0]}
|
|
45
|
+
</Label>
|
|
46
|
+
);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useIntl, FormattedMessage } from "react-intl";
|
|
3
|
-
import { columnDecorator } from "@truedat/core/services";
|
|
4
|
-
import { Header, Icon, Table, Segment } from "semantic-ui-react";
|
|
5
|
-
|
|
6
|
-
import { useDataSets } from "../hooks/useDataSets";
|
|
7
|
-
|
|
8
|
-
export default function DataSets() {
|
|
9
|
-
const { formatMessage } = useIntl();
|
|
10
|
-
const { data, loading } = useDataSets();
|
|
11
|
-
|
|
12
|
-
const dataSets = data?.data;
|
|
13
|
-
|
|
14
|
-
const columns = [
|
|
15
|
-
{ name: "name" },
|
|
16
|
-
{
|
|
17
|
-
name: "data_structure",
|
|
18
|
-
fieldDecorator: (ds) => ds?.external_id,
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Segment loading={loading}>
|
|
24
|
-
<Header as="h2">
|
|
25
|
-
<Icon circular name="archive" />
|
|
26
|
-
<Header.Content>
|
|
27
|
-
<FormattedMessage id="data_sets.header" />
|
|
28
|
-
<Header.Subheader>
|
|
29
|
-
<FormattedMessage id="data_sets.subheader" />
|
|
30
|
-
</Header.Subheader>
|
|
31
|
-
</Header.Content>
|
|
32
|
-
</Header>
|
|
33
|
-
<Table basic="very">
|
|
34
|
-
<Table.Header>
|
|
35
|
-
<Table.Row>
|
|
36
|
-
{columns.map((column, i) => (
|
|
37
|
-
<Table.HeaderCell
|
|
38
|
-
key={i}
|
|
39
|
-
content={formatMessage({
|
|
40
|
-
id: `data_sets.column.${column.name}`,
|
|
41
|
-
defaultMessage: column.name,
|
|
42
|
-
})}
|
|
43
|
-
/>
|
|
44
|
-
))}
|
|
45
|
-
</Table.Row>
|
|
46
|
-
</Table.Header>
|
|
47
|
-
<Table.Body>
|
|
48
|
-
{dataSets
|
|
49
|
-
? dataSets.map((dataSet, i) => (
|
|
50
|
-
<Table.Row key={i}>
|
|
51
|
-
{columns.map((column, key) => (
|
|
52
|
-
<Table.Cell
|
|
53
|
-
key={key}
|
|
54
|
-
content={columnDecorator(column)(dataSet)}
|
|
55
|
-
/>
|
|
56
|
-
))}
|
|
57
|
-
</Table.Row>
|
|
58
|
-
))
|
|
59
|
-
: null}
|
|
60
|
-
</Table.Body>
|
|
61
|
-
</Table>
|
|
62
|
-
</Segment>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@truedat/test/render";
|
|
3
|
-
import DataSets from "../DataSets";
|
|
4
|
-
|
|
5
|
-
jest.mock("../../hooks/useDataSets.js", () => {
|
|
6
|
-
const originalModule = jest.requireActual("../../hooks/useDataSets.js");
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
__esModule: true,
|
|
10
|
-
...originalModule,
|
|
11
|
-
useDataSets: jest.fn(() => ({
|
|
12
|
-
data: {
|
|
13
|
-
data: [
|
|
14
|
-
{
|
|
15
|
-
name: "DataSet1",
|
|
16
|
-
data_structure: { external_id: "Structure1" },
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: "DataSet2",
|
|
20
|
-
data_structure: { external_id: "Structure2" },
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
loading: false,
|
|
25
|
-
})),
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("<DataSets />", () => {
|
|
30
|
-
const renderOpts = {
|
|
31
|
-
messages: {
|
|
32
|
-
en: {
|
|
33
|
-
"data_sets.header": "data_sets.header",
|
|
34
|
-
"data_sets.subheader": "data_sets.subheader",
|
|
35
|
-
"data_sets.column.name": "data_sets.column.name",
|
|
36
|
-
"data_sets.column.data_structure": "data_sets.column.data_structure",
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
fallback: "lazy",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
it("matches the latest snapshot", () => {
|
|
43
|
-
const { container } = render(<DataSets />, renderOpts);
|
|
44
|
-
expect(container).toMatchSnapshot();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<DataSets /> matches the latest snapshot 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="ui segment"
|
|
7
|
-
>
|
|
8
|
-
<h2
|
|
9
|
-
class="ui header"
|
|
10
|
-
>
|
|
11
|
-
<i
|
|
12
|
-
aria-hidden="true"
|
|
13
|
-
class="archive circular icon"
|
|
14
|
-
/>
|
|
15
|
-
<div
|
|
16
|
-
class="content"
|
|
17
|
-
>
|
|
18
|
-
data_sets.header
|
|
19
|
-
<div
|
|
20
|
-
class="sub header"
|
|
21
|
-
>
|
|
22
|
-
data_sets.subheader
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</h2>
|
|
26
|
-
<table
|
|
27
|
-
class="ui very basic table"
|
|
28
|
-
>
|
|
29
|
-
<thead
|
|
30
|
-
class=""
|
|
31
|
-
>
|
|
32
|
-
<tr
|
|
33
|
-
class=""
|
|
34
|
-
>
|
|
35
|
-
<th
|
|
36
|
-
class=""
|
|
37
|
-
>
|
|
38
|
-
data_sets.column.name
|
|
39
|
-
</th>
|
|
40
|
-
<th
|
|
41
|
-
class=""
|
|
42
|
-
>
|
|
43
|
-
data_sets.column.data_structure
|
|
44
|
-
</th>
|
|
45
|
-
</tr>
|
|
46
|
-
</thead>
|
|
47
|
-
<tbody
|
|
48
|
-
class=""
|
|
49
|
-
>
|
|
50
|
-
<tr
|
|
51
|
-
class=""
|
|
52
|
-
>
|
|
53
|
-
<td
|
|
54
|
-
class=""
|
|
55
|
-
>
|
|
56
|
-
DataSet1
|
|
57
|
-
</td>
|
|
58
|
-
<td
|
|
59
|
-
class=""
|
|
60
|
-
>
|
|
61
|
-
Structure1
|
|
62
|
-
</td>
|
|
63
|
-
</tr>
|
|
64
|
-
<tr
|
|
65
|
-
class=""
|
|
66
|
-
>
|
|
67
|
-
<td
|
|
68
|
-
class=""
|
|
69
|
-
>
|
|
70
|
-
DataSet2
|
|
71
|
-
</td>
|
|
72
|
-
<td
|
|
73
|
-
class=""
|
|
74
|
-
>
|
|
75
|
-
Structure2
|
|
76
|
-
</td>
|
|
77
|
-
</tr>
|
|
78
|
-
</tbody>
|
|
79
|
-
</table>
|
|
80
|
-
</div>
|
|
81
|
-
</div>
|
|
82
|
-
`;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import React, { useContext, useEffect } from "react";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import { useFormContext } from "react-hook-form";
|
|
5
|
-
import QxContext from "@truedat/qx/components/QxContext";
|
|
6
|
-
import ShapeSelector from "./ShapeSelector";
|
|
7
|
-
import FunctionSelector from "./FunctionSelector";
|
|
8
|
-
import ParamSelector from "./ParamSelector";
|
|
9
|
-
import FieldSelector from "./FieldSelector";
|
|
10
|
-
import ConstantSelector from "./ConstantSelector";
|
|
11
|
-
|
|
12
|
-
export default function Expression({ defaultShape = "function" }) {
|
|
13
|
-
const { field } = useContext(QxContext);
|
|
14
|
-
const { watch, setValue } = useFormContext();
|
|
15
|
-
const shape = watch(`${field}.shape`);
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (!shape) {
|
|
19
|
-
setValue(`${field}.shape`, defaultShape, { shouldValidate: true });
|
|
20
|
-
}
|
|
21
|
-
}, [shape]);
|
|
22
|
-
|
|
23
|
-
const valueComponentForShape = {
|
|
24
|
-
function: <FunctionSelector />,
|
|
25
|
-
constant: <ConstantSelector />,
|
|
26
|
-
param: <ParamSelector />,
|
|
27
|
-
field: <FieldSelector />,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="expression-container">
|
|
32
|
-
<ShapeSelector />
|
|
33
|
-
{shape ? valueComponentForShape[shape] : null}
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
Expression.propTypes = {
|
|
39
|
-
defaultShape: PropTypes.string,
|
|
40
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import _ from "lodash/fp";
|
|
2
|
-
import React, { useContext } from "react";
|
|
3
|
-
import { Controller, useFormContext } from "react-hook-form";
|
|
4
|
-
import { Dropdown, Label } from "semantic-ui-react";
|
|
5
|
-
|
|
6
|
-
import QxContext from "@truedat/qx/components/QxContext";
|
|
7
|
-
|
|
8
|
-
export const fieldsToOptions = (fields) =>
|
|
9
|
-
_.map((field) => ({
|
|
10
|
-
key: JSON.stringify(field),
|
|
11
|
-
value: field,
|
|
12
|
-
text: field.name,
|
|
13
|
-
content: (
|
|
14
|
-
<>
|
|
15
|
-
{field.dataset ? (
|
|
16
|
-
<Label
|
|
17
|
-
color={field.dataset?.color}
|
|
18
|
-
content={field.dataset?.alias || field.dataset?.name}
|
|
19
|
-
/>
|
|
20
|
-
) : null}
|
|
21
|
-
{field.name}
|
|
22
|
-
</>
|
|
23
|
-
),
|
|
24
|
-
color: field.dataset?.color,
|
|
25
|
-
}))(fields);
|
|
26
|
-
|
|
27
|
-
export default function FieldSelector() {
|
|
28
|
-
const { field, type, fields } = useContext(QxContext);
|
|
29
|
-
const { control } = useFormContext();
|
|
30
|
-
const fieldOptions = _.flow(
|
|
31
|
-
_.filter((field) => type === "any" || field.type == type),
|
|
32
|
-
fieldsToOptions
|
|
33
|
-
)(fields);
|
|
34
|
-
|
|
35
|
-
return _.isEmpty(fieldOptions) ? null : (
|
|
36
|
-
<Controller
|
|
37
|
-
control={control}
|
|
38
|
-
name={`${field}.value`}
|
|
39
|
-
rules={{ required: true }}
|
|
40
|
-
render={({
|
|
41
|
-
field: { onBlur, onChange, value },
|
|
42
|
-
fieldState: { error },
|
|
43
|
-
}) => (
|
|
44
|
-
<Dropdown
|
|
45
|
-
selection
|
|
46
|
-
fluid
|
|
47
|
-
onBlur={onBlur}
|
|
48
|
-
error={!!error}
|
|
49
|
-
options={fieldOptions}
|
|
50
|
-
value={value}
|
|
51
|
-
onChange={(_e, { value }) => onChange(value)}
|
|
52
|
-
/>
|
|
53
|
-
)}
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
56
|
-
}
|