datajunction-ui 0.0.1-a1 → 0.0.1-a101
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/Makefile +7 -1
- package/package.json +18 -7
- package/public/index.html +1 -1
- package/src/app/components/AddNodeDropdown.jsx +44 -0
- package/src/app/components/ListGroupItem.jsx +2 -1
- package/src/app/components/NodeListActions.jsx +69 -0
- package/src/app/components/NodeMaterializationDelete.jsx +80 -0
- package/src/app/components/QueryInfo.jsx +96 -1
- package/src/app/components/Search.jsx +94 -0
- package/src/app/components/__tests__/NodeListActions.test.jsx +94 -0
- package/src/app/components/__tests__/Search.test.jsx +63 -0
- package/src/app/components/__tests__/__snapshots__/ListGroupItem.test.tsx.snap +5 -3
- package/src/app/components/djgraph/Collapse.jsx +3 -2
- package/src/app/components/djgraph/DJNode.jsx +1 -1
- package/src/app/components/djgraph/DJNodeColumns.jsx +5 -1
- package/src/app/components/djgraph/LayoutFlow.jsx +5 -3
- package/src/app/components/forms/Action.jsx +8 -0
- package/src/app/components/forms/NodeNameField.jsx +64 -0
- package/src/app/components/search.css +17 -0
- package/src/app/icons/AddItemIcon.jsx +16 -0
- package/src/app/icons/CommitIcon.jsx +45 -0
- package/src/app/icons/DiffIcon.jsx +63 -0
- package/src/app/icons/EyeIcon.jsx +20 -0
- package/src/app/icons/FilterIcon.jsx +7 -0
- package/src/app/icons/JupyterExportIcon.jsx +25 -0
- package/src/app/icons/LoadingIcon.jsx +10 -10
- package/src/app/icons/PythonIcon.jsx +6 -44
- package/src/app/index.tsx +24 -0
- package/src/app/pages/AddEditNodePage/AlertMessage.jsx +10 -0
- package/src/app/pages/AddEditNodePage/ColumnsSelect.jsx +84 -0
- package/src/app/pages/AddEditNodePage/DescriptionField.jsx +17 -0
- package/src/app/pages/AddEditNodePage/DisplayNameField.jsx +16 -0
- package/src/app/pages/AddEditNodePage/FormikSelect.jsx +5 -0
- package/src/app/pages/AddEditNodePage/FullNameField.jsx +3 -2
- package/src/app/pages/AddEditNodePage/Loadable.jsx +6 -2
- package/src/app/pages/AddEditNodePage/MetricMetadataFields.jsx +75 -0
- package/src/app/pages/AddEditNodePage/MetricQueryField.jsx +71 -0
- package/src/app/pages/AddEditNodePage/NamespaceField.jsx +40 -0
- package/src/app/pages/AddEditNodePage/NodeModeField.jsx +14 -0
- package/src/app/pages/AddEditNodePage/NodeQueryField.jsx +8 -3
- package/src/app/pages/AddEditNodePage/RequiredDimensionsSelect.jsx +54 -0
- package/src/app/pages/AddEditNodePage/TagsField.jsx +47 -0
- package/src/app/pages/AddEditNodePage/UpstreamNodeField.jsx +49 -0
- package/src/app/pages/AddEditNodePage/__tests__/AddEditNodePageFormFailed.test.jsx +15 -9
- package/src/app/pages/AddEditNodePage/__tests__/AddEditNodePageFormSuccess.test.jsx +167 -24
- package/src/app/pages/AddEditNodePage/__tests__/index.test.jsx +55 -25
- package/src/app/pages/AddEditNodePage/index.jsx +275 -194
- package/src/app/pages/CubeBuilderPage/DimensionsSelect.jsx +154 -0
- package/src/app/pages/CubeBuilderPage/Loadable.jsx +16 -0
- package/src/app/pages/CubeBuilderPage/MetricsSelect.jsx +77 -0
- package/src/app/pages/CubeBuilderPage/__tests__/index.test.jsx +405 -0
- package/src/app/pages/CubeBuilderPage/index.jsx +267 -0
- package/src/app/pages/NamespacePage/AddNamespacePopover.jsx +5 -5
- package/src/app/pages/NamespacePage/Explorer.jsx +6 -2
- package/src/app/pages/NamespacePage/FieldControl.jsx +21 -0
- package/src/app/pages/NamespacePage/NodeTypeSelect.jsx +30 -0
- package/src/app/pages/NamespacePage/TagSelect.jsx +44 -0
- package/src/app/pages/NamespacePage/UserSelect.jsx +47 -0
- package/src/app/pages/NamespacePage/__tests__/index.test.jsx +98 -19
- package/src/app/pages/NamespacePage/index.jsx +272 -89
- package/src/app/pages/NodePage/AddBackfillPopover.jsx +60 -61
- package/src/app/pages/NodePage/AddMaterializationPopover.jsx +104 -51
- package/src/app/pages/NodePage/ClientCodePopover.jsx +73 -25
- package/src/app/pages/NodePage/DimensionFilter.jsx +86 -0
- package/src/app/pages/NodePage/EditColumnDescriptionPopover.jsx +116 -0
- package/src/app/pages/NodePage/LinkDimensionPopover.jsx +38 -23
- package/src/app/pages/NodePage/MaterializationConfigField.jsx +60 -0
- package/src/app/pages/NodePage/NodeColumnTab.jsx +183 -113
- package/src/app/pages/NodePage/NodeDependenciesTab.jsx +153 -0
- package/src/app/pages/NodePage/NodeGraphTab.jsx +56 -29
- package/src/app/pages/NodePage/NodeHistory.jsx +165 -161
- package/src/app/pages/NodePage/NodeInfoTab.jsx +148 -14
- package/src/app/pages/NodePage/NodeMaterializationTab.jsx +201 -104
- package/src/app/pages/NodePage/NodeStatus.jsx +96 -21
- package/src/app/pages/NodePage/NodeValidateTab.jsx +367 -0
- package/src/app/pages/NodePage/NotebookDownload.jsx +36 -0
- package/src/app/pages/NodePage/PartitionColumnPopover.jsx +3 -5
- package/src/app/pages/NodePage/PartitionValueForm.jsx +60 -0
- package/src/app/pages/NodePage/RevisionDiff.jsx +209 -0
- package/src/app/pages/NodePage/WatchNodeButton.jsx +226 -0
- package/src/app/pages/NodePage/__tests__/AddBackfillPopover.test.jsx +13 -4
- package/src/app/pages/NodePage/__tests__/AddMaterializationPopover.test.jsx +87 -0
- package/src/app/pages/NodePage/__tests__/DimensionFilter.test.jsx +74 -0
- package/src/app/pages/NodePage/__tests__/EditColumnDescriptionPopover.test.jsx +149 -0
- package/src/app/pages/NodePage/__tests__/LinkDimensionPopover.test.jsx +10 -14
- package/src/app/pages/NodePage/__tests__/NodeColumnTab.test.jsx +166 -0
- package/src/app/pages/NodePage/__tests__/NodeDependenciesTab.test.jsx +151 -0
- package/src/app/pages/NodePage/__tests__/NodeGraphTab.test.jsx +6 -2
- package/src/app/pages/NodePage/__tests__/NodeLineageTab.test.jsx +3 -2
- package/src/app/pages/NodePage/__tests__/NodeMaterializationTab.test.jsx +148 -0
- package/src/app/pages/NodePage/__tests__/NodePage.test.jsx +159 -57
- package/src/app/pages/NodePage/__tests__/RevisionDiff.test.jsx +164 -0
- package/src/app/pages/NodePage/__tests__/__snapshots__/NodePage.test.jsx.snap +2 -386
- package/src/app/pages/NodePage/index.jsx +94 -57
- package/src/app/pages/Root/__tests__/index.test.jsx +3 -1
- package/src/app/pages/Root/index.tsx +62 -12
- package/src/app/services/DJService.js +587 -55
- package/src/app/services/__tests__/DJService.test.jsx +382 -45
- package/src/index.tsx +1 -0
- package/src/mocks/mockNodes.jsx +265 -227
- package/src/styles/dag.css +4 -2
- package/src/styles/index.css +474 -10
- package/src/styles/loading.css +1 -1
- package/src/styles/node-creation.scss +84 -5
- package/src/styles/node-list.css +4 -0
- package/src/styles/sorted-table.css +15 -0
- package/src/app/components/DeleteNode.jsx +0 -55
- package/src/app/components/__tests__/DeleteNode.test.jsx +0 -53
- package/src/app/pages/NodePage/NodeSQLTab.jsx +0 -82
- package/src/app/pages/NodePage/__tests__/ClientCodePopover.test.jsx +0 -49
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import { lazyLoad } from '../../../utils/loadable';
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const LazyAddEditNodePage = props => {
|
|
9
9
|
return lazyLoad(
|
|
10
10
|
() => import('./index'),
|
|
11
11
|
module => module.AddEditNodePage,
|
|
12
12
|
{
|
|
13
13
|
fallback: <div></div>,
|
|
14
14
|
},
|
|
15
|
-
)();
|
|
15
|
+
)(props);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const AddEditNodePage = props => {
|
|
19
|
+
return <LazyAddEditNodePage {...props} />;
|
|
16
20
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metric unit select component
|
|
3
|
+
*/
|
|
4
|
+
import { ErrorMessage, Field } from 'formik';
|
|
5
|
+
import { useContext, useEffect, useState } from 'react';
|
|
6
|
+
import DJClientContext from '../../providers/djclient';
|
|
7
|
+
import { labelize } from '../../../utils/form';
|
|
8
|
+
|
|
9
|
+
export const MetricMetadataFields = () => {
|
|
10
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
11
|
+
|
|
12
|
+
// Metric metadata
|
|
13
|
+
const [metricUnits, setMetricUnits] = useState([]);
|
|
14
|
+
const [metricDirections, setMetricDirections] = useState([]);
|
|
15
|
+
|
|
16
|
+
// Get metric metadata values
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const fetchData = async () => {
|
|
19
|
+
const metadata = await djClient.listMetricMetadata();
|
|
20
|
+
setMetricDirections(metadata.directions);
|
|
21
|
+
setMetricUnits(metadata.units);
|
|
22
|
+
};
|
|
23
|
+
fetchData().catch(console.error);
|
|
24
|
+
}, [djClient]);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
style={{
|
|
29
|
+
borderRadius: '8px',
|
|
30
|
+
padding: '10px 10px 20px 10px',
|
|
31
|
+
margin: '32px 0',
|
|
32
|
+
background: '#f9f9f9',
|
|
33
|
+
width: 'max-content',
|
|
34
|
+
display: 'flex',
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<div style={{ margin: '15px 25px' }}>
|
|
38
|
+
<ErrorMessage name="metric_direction" component="span" />
|
|
39
|
+
<label htmlFor="MetricDirection">Metric Direction</label>
|
|
40
|
+
<Field as="select" name="metric_direction" id="MetricDirection">
|
|
41
|
+
<option value=""></option>
|
|
42
|
+
{metricDirections.map(direction => (
|
|
43
|
+
<option value={direction} key={direction}>
|
|
44
|
+
{labelize(direction)}
|
|
45
|
+
</option>
|
|
46
|
+
))}
|
|
47
|
+
</Field>
|
|
48
|
+
</div>
|
|
49
|
+
<div style={{ margin: '15px 25px' }}>
|
|
50
|
+
<ErrorMessage name="metric_unit" component="span" />
|
|
51
|
+
<label htmlFor="MetricUnit">Metric Unit</label>
|
|
52
|
+
<Field as="select" name="metric_unit" id="MetricUnit">
|
|
53
|
+
<option value=""></option>
|
|
54
|
+
{metricUnits.map(unit => (
|
|
55
|
+
<option value={unit.name} key={unit.name}>
|
|
56
|
+
{unit.label}
|
|
57
|
+
</option>
|
|
58
|
+
))}
|
|
59
|
+
</Field>
|
|
60
|
+
</div>
|
|
61
|
+
<div style={{ margin: '15px 25px' }}>
|
|
62
|
+
<ErrorMessage name="significant_digits" component="span" />
|
|
63
|
+
<label htmlFor="SignificantDigits">Significant Digits</label>
|
|
64
|
+
<Field as="select" name="significant_digits" id="SignificantDigits">
|
|
65
|
+
<option value=""></option>
|
|
66
|
+
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(val => (
|
|
67
|
+
<option value={val} key={val}>
|
|
68
|
+
{val}
|
|
69
|
+
</option>
|
|
70
|
+
))}
|
|
71
|
+
</Field>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metric aggregate expression input field, which consists of a CodeMirror SQL
|
|
3
|
+
* editor with autocompletion for node columns and syntax highlighting.
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { ErrorMessage, Field, useFormikContext } from 'formik';
|
|
7
|
+
import CodeMirror from '@uiw/react-codemirror';
|
|
8
|
+
import { langs } from '@uiw/codemirror-extensions-langs';
|
|
9
|
+
|
|
10
|
+
export const MetricQueryField = ({ djClient, value }) => {
|
|
11
|
+
const [schema, setSchema] = React.useState([]);
|
|
12
|
+
const formik = useFormikContext();
|
|
13
|
+
const sqlExt = langs.sql({ schema: schema });
|
|
14
|
+
|
|
15
|
+
const initialAutocomplete = async context => {
|
|
16
|
+
// Based on the selected upstream, we load the upstream node's columns
|
|
17
|
+
// into the autocomplete schema
|
|
18
|
+
const nodeName = formik.values['upstream_node'];
|
|
19
|
+
const nodeDetails = await djClient.node(nodeName);
|
|
20
|
+
nodeDetails.columns.forEach(col => {
|
|
21
|
+
schema[col.name] = [];
|
|
22
|
+
});
|
|
23
|
+
setSchema(schema);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const updateFormik = val => {
|
|
27
|
+
formik.setFieldValue('aggregate_expression', val);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className="QueryInput MetricQueryInput NodeCreationInput">
|
|
32
|
+
<ErrorMessage name="query" component="span" />
|
|
33
|
+
<label htmlFor="Query">Aggregate Expression *</label>
|
|
34
|
+
<Field
|
|
35
|
+
type="textarea"
|
|
36
|
+
style={{ display: 'none' }}
|
|
37
|
+
as="textarea"
|
|
38
|
+
name="aggregate_expression"
|
|
39
|
+
id="Query"
|
|
40
|
+
/>
|
|
41
|
+
<div role="button" tabIndex={0} className="relative flex bg-[#282a36]">
|
|
42
|
+
<CodeMirror
|
|
43
|
+
id={'aggregate_expression'}
|
|
44
|
+
name={'aggregate_expression'}
|
|
45
|
+
extensions={[
|
|
46
|
+
sqlExt,
|
|
47
|
+
sqlExt.language.data.of({
|
|
48
|
+
autocomplete: initialAutocomplete,
|
|
49
|
+
}),
|
|
50
|
+
]}
|
|
51
|
+
value={value}
|
|
52
|
+
options={{
|
|
53
|
+
theme: 'default',
|
|
54
|
+
lineNumbers: true,
|
|
55
|
+
}}
|
|
56
|
+
width="100%"
|
|
57
|
+
height="100px"
|
|
58
|
+
style={{
|
|
59
|
+
margin: '0 0 23px 0',
|
|
60
|
+
flex: 1,
|
|
61
|
+
fontSize: '150%',
|
|
62
|
+
textAlign: 'left',
|
|
63
|
+
}}
|
|
64
|
+
onChange={(value, viewUpdate) => {
|
|
65
|
+
updateFormik(value);
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ErrorMessage } from 'formik';
|
|
2
|
+
import { FormikSelect } from './FormikSelect';
|
|
3
|
+
import { useContext, useEffect, useState } from 'react';
|
|
4
|
+
import DJClientContext from '../../providers/djclient';
|
|
5
|
+
|
|
6
|
+
export const NamespaceField = ({ initialNamespace }) => {
|
|
7
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
8
|
+
|
|
9
|
+
const [namespaces, setNamespaces] = useState([]);
|
|
10
|
+
|
|
11
|
+
// Get namespaces, only necessary when creating a node
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const fetchData = async () => {
|
|
14
|
+
const namespaces = await djClient.namespaces();
|
|
15
|
+
setNamespaces(
|
|
16
|
+
namespaces.map(m => ({
|
|
17
|
+
value: m['namespace'],
|
|
18
|
+
label: m['namespace'],
|
|
19
|
+
})),
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
fetchData().catch(console.error);
|
|
23
|
+
}, [djClient]);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="NamespaceInput">
|
|
27
|
+
<ErrorMessage name="namespace" component="span" />
|
|
28
|
+
<label htmlFor="namespace">Namespace *</label>
|
|
29
|
+
<FormikSelect
|
|
30
|
+
selectOptions={namespaces}
|
|
31
|
+
formikFieldName="namespace"
|
|
32
|
+
placeholder="Choose Namespace"
|
|
33
|
+
defaultValue={{
|
|
34
|
+
value: initialNamespace,
|
|
35
|
+
label: initialNamespace,
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ErrorMessage, Field } from 'formik';
|
|
2
|
+
|
|
3
|
+
export const NodeModeField = () => {
|
|
4
|
+
return (
|
|
5
|
+
<div className="NodeModeInput NodeCreationInput">
|
|
6
|
+
<ErrorMessage name="mode" component="span" />
|
|
7
|
+
<label htmlFor="Mode">Mode</label>
|
|
8
|
+
<Field as="select" name="mode" id="Mode">
|
|
9
|
+
<option value="draft">Draft</option>
|
|
10
|
+
<option value="published">Published</option>
|
|
11
|
+
</Field>
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (for node names and columns) and syntax highlighting.
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { Field, useFormikContext } from 'formik';
|
|
6
|
+
import { ErrorMessage, Field, useFormikContext } from 'formik';
|
|
7
7
|
import CodeMirror from '@uiw/react-codemirror';
|
|
8
8
|
import { langs } from '@uiw/codemirror-extensions-langs';
|
|
9
9
|
|
|
@@ -47,7 +47,9 @@ export const NodeQueryField = ({ djClient, value }) => {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
return (
|
|
50
|
-
|
|
50
|
+
<div className="QueryInput NodeCreationInput">
|
|
51
|
+
<ErrorMessage name="query" component="span" />
|
|
52
|
+
<label htmlFor="Query">Query *</label>
|
|
51
53
|
<Field
|
|
52
54
|
type="textarea"
|
|
53
55
|
style={{ display: 'none' }}
|
|
@@ -66,6 +68,9 @@ export const NodeQueryField = ({ djClient, value }) => {
|
|
|
66
68
|
}),
|
|
67
69
|
]}
|
|
68
70
|
value={value}
|
|
71
|
+
placeholder={
|
|
72
|
+
'SELECT\n\tprimary_key,\n\tmeasure1,\n\tmeasure2,\n\tforeign_key_for_dimension1,\n\tforeign_key_for_dimension2\nFROM source.source_node\nWHERE ...'
|
|
73
|
+
}
|
|
69
74
|
options={{
|
|
70
75
|
theme: 'default',
|
|
71
76
|
lineNumbers: true,
|
|
@@ -84,6 +89,6 @@ export const NodeQueryField = ({ djClient, value }) => {
|
|
|
84
89
|
}}
|
|
85
90
|
/>
|
|
86
91
|
</div>
|
|
87
|
-
|
|
92
|
+
</div>
|
|
88
93
|
);
|
|
89
94
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Required dimensions select component
|
|
3
|
+
*/
|
|
4
|
+
import { ErrorMessage, useFormikContext } from 'formik';
|
|
5
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
6
|
+
import DJClientContext from '../../providers/djclient';
|
|
7
|
+
import { FormikSelect } from './FormikSelect';
|
|
8
|
+
|
|
9
|
+
export const RequiredDimensionsSelect = ({
|
|
10
|
+
defaultValue,
|
|
11
|
+
style,
|
|
12
|
+
className = 'MultiSelectInput',
|
|
13
|
+
}) => {
|
|
14
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
15
|
+
|
|
16
|
+
// Used to pull out current form values for node validation
|
|
17
|
+
const { values } = useFormikContext();
|
|
18
|
+
|
|
19
|
+
// Select options, i.e., the available dimensions
|
|
20
|
+
const [selectOptions, setSelectOptions] = useState([]);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const fetchData = async () => {
|
|
24
|
+
if (values.upstream_node) {
|
|
25
|
+
const data = await djClient.node(values.upstream_node);
|
|
26
|
+
setSelectOptions(
|
|
27
|
+
data.columns.map(col => {
|
|
28
|
+
return {
|
|
29
|
+
value: col.name,
|
|
30
|
+
label: col.name,
|
|
31
|
+
};
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
fetchData().catch(console.error);
|
|
37
|
+
}, [djClient, values.upstream_node]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className="RequiredDimensionsInput CubeCreationInput">
|
|
41
|
+
<ErrorMessage name="required_dimensions" component="span" />
|
|
42
|
+
<label htmlFor="requiredDimensions">Required Dimensions</label>
|
|
43
|
+
<FormikSelect
|
|
44
|
+
className={className}
|
|
45
|
+
defaultValue={defaultValue}
|
|
46
|
+
selectOptions={selectOptions}
|
|
47
|
+
formikFieldName={'required_dimensions'}
|
|
48
|
+
placeholder={'Choose Required Dimensions'}
|
|
49
|
+
styles={style}
|
|
50
|
+
isMulti={true}
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tags select field
|
|
3
|
+
*/
|
|
4
|
+
import { ErrorMessage } from 'formik';
|
|
5
|
+
import { useContext, useEffect, useState } from 'react';
|
|
6
|
+
import DJClientContext from '../../providers/djclient';
|
|
7
|
+
import { FormikSelect } from './FormikSelect';
|
|
8
|
+
|
|
9
|
+
export const TagsField = ({ defaultValue }) => {
|
|
10
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
11
|
+
|
|
12
|
+
// All available tags
|
|
13
|
+
const [tags, setTags] = useState([]);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const fetchData = async () => {
|
|
17
|
+
const tags = await djClient.listTags();
|
|
18
|
+
setTags(
|
|
19
|
+
tags.map(tag => ({
|
|
20
|
+
value: tag.name,
|
|
21
|
+
label: tag.display_name,
|
|
22
|
+
})),
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
fetchData().catch(console.error);
|
|
26
|
+
}, [djClient]);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className="TagsInput"
|
|
31
|
+
style={{ width: '25%', margin: '1rem 0 1rem 1.2rem' }}
|
|
32
|
+
>
|
|
33
|
+
<ErrorMessage name="tags" component="span" />
|
|
34
|
+
<label htmlFor="tags">Tags</label>
|
|
35
|
+
<span data-testid="select-tags">
|
|
36
|
+
<FormikSelect
|
|
37
|
+
isMulti={true}
|
|
38
|
+
selectOptions={tags}
|
|
39
|
+
formikFieldName="tags"
|
|
40
|
+
className="MultiSelectInput"
|
|
41
|
+
placeholder="Choose Tags"
|
|
42
|
+
defaultValue={defaultValue}
|
|
43
|
+
/>
|
|
44
|
+
</span>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upstream node select field
|
|
3
|
+
*/
|
|
4
|
+
import { ErrorMessage } from 'formik';
|
|
5
|
+
import { useContext, useEffect, useState } from 'react';
|
|
6
|
+
import DJClientContext from '../../providers/djclient';
|
|
7
|
+
import { FormikSelect } from './FormikSelect';
|
|
8
|
+
|
|
9
|
+
export const UpstreamNodeField = ({ defaultValue }) => {
|
|
10
|
+
const djClient = useContext(DJClientContext).DataJunctionAPI;
|
|
11
|
+
|
|
12
|
+
// All available nodes
|
|
13
|
+
const [availableNodes, setAvailableNodes] = useState([]);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
async function fetchData() {
|
|
17
|
+
const sources = await djClient.nodesWithType('source');
|
|
18
|
+
const transforms = await djClient.nodesWithType('transform');
|
|
19
|
+
const dimensions = await djClient.nodesWithType('dimension');
|
|
20
|
+
const nodes = sources.concat(transforms).concat(dimensions);
|
|
21
|
+
setAvailableNodes(
|
|
22
|
+
nodes.map(node => {
|
|
23
|
+
return {
|
|
24
|
+
value: node,
|
|
25
|
+
label: node,
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
fetchData();
|
|
31
|
+
}, [djClient]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="NodeCreationInput">
|
|
35
|
+
<ErrorMessage name="mode" component="span" />
|
|
36
|
+
<label htmlFor="Mode">Upstream Node *</label>
|
|
37
|
+
<span data-testid="select-upstream-node">
|
|
38
|
+
<FormikSelect
|
|
39
|
+
className="SelectInput"
|
|
40
|
+
defaultValue={defaultValue}
|
|
41
|
+
selectOptions={availableNodes}
|
|
42
|
+
formikFieldName="upstream_node"
|
|
43
|
+
placeholder="Select Upstream Node"
|
|
44
|
+
isMulti={false}
|
|
45
|
+
/>
|
|
46
|
+
</span>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -32,10 +32,13 @@ describe('AddEditNodePage submission failed', () => {
|
|
|
32
32
|
const { container } = renderCreateNode(element);
|
|
33
33
|
|
|
34
34
|
await userEvent.type(
|
|
35
|
-
screen.getByLabelText('Display Name'),
|
|
35
|
+
screen.getByLabelText('Display Name *'),
|
|
36
36
|
'Some Test Metric',
|
|
37
37
|
);
|
|
38
|
-
await userEvent.type(
|
|
38
|
+
await userEvent.type(
|
|
39
|
+
screen.getByLabelText('Query *'),
|
|
40
|
+
'SELECT * FROM test',
|
|
41
|
+
);
|
|
39
42
|
await userEvent.click(screen.getByText('Create dimension'));
|
|
40
43
|
|
|
41
44
|
await waitFor(() => {
|
|
@@ -46,9 +49,12 @@ describe('AddEditNodePage submission failed', () => {
|
|
|
46
49
|
'Some Test Metric',
|
|
47
50
|
'',
|
|
48
51
|
'SELECT * FROM test',
|
|
49
|
-
'
|
|
52
|
+
'published',
|
|
50
53
|
'default',
|
|
51
54
|
null,
|
|
55
|
+
undefined,
|
|
56
|
+
undefined,
|
|
57
|
+
undefined,
|
|
52
58
|
);
|
|
53
59
|
expect(
|
|
54
60
|
screen.getByText(/Some columns in the primary key \[] were not found/),
|
|
@@ -61,7 +67,9 @@ describe('AddEditNodePage submission failed', () => {
|
|
|
61
67
|
|
|
62
68
|
it('for editing a node', async () => {
|
|
63
69
|
const mockDjClient = initializeMockDJClient();
|
|
64
|
-
mockDjClient.DataJunctionAPI.
|
|
70
|
+
mockDjClient.DataJunctionAPI.getNodeForEditing.mockReturnValue(
|
|
71
|
+
mocks.mockGetMetricNode,
|
|
72
|
+
);
|
|
65
73
|
mockDjClient.DataJunctionAPI.patchNode.mockReturnValue({
|
|
66
74
|
status: 500,
|
|
67
75
|
json: { message: 'Update failed' },
|
|
@@ -80,7 +88,7 @@ describe('AddEditNodePage submission failed', () => {
|
|
|
80
88
|
const element = testElement(mockDjClient);
|
|
81
89
|
renderEditNode(element);
|
|
82
90
|
|
|
83
|
-
await userEvent.type(screen.getByLabelText('Display Name'), '!!!');
|
|
91
|
+
await userEvent.type(screen.getByLabelText('Display Name *'), '!!!');
|
|
84
92
|
await userEvent.type(screen.getByLabelText('Description'), '!!!');
|
|
85
93
|
await userEvent.click(screen.getByText('Save'));
|
|
86
94
|
await waitFor(async () => {
|
|
@@ -88,16 +96,14 @@ describe('AddEditNodePage submission failed', () => {
|
|
|
88
96
|
expect(mockDjClient.DataJunctionAPI.tagsNode).toBeCalled();
|
|
89
97
|
expect(mockDjClient.DataJunctionAPI.tagsNode).toBeCalledWith(
|
|
90
98
|
'default.num_repair_orders',
|
|
91
|
-
[
|
|
99
|
+
['purpose'],
|
|
92
100
|
);
|
|
93
101
|
expect(mockDjClient.DataJunctionAPI.tagsNode).toReturnWith({
|
|
94
102
|
json: { message: 'Some tags were not found' },
|
|
95
103
|
status: 404,
|
|
96
104
|
});
|
|
97
105
|
|
|
98
|
-
expect(
|
|
99
|
-
await screen.getByText('Update failed, Some tags were not found'),
|
|
100
|
-
).toBeInTheDocument();
|
|
106
|
+
expect(await screen.getByText('Update failed')).toBeInTheDocument();
|
|
101
107
|
});
|
|
102
108
|
}, 60000);
|
|
103
109
|
});
|