datajunction-ui 0.0.1-a86.dev0 → 0.0.1-a86.dev2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datajunction-ui",
3
- "version": "0.0.1-a86.dev0",
3
+ "version": "0.0.1-a86.dev2",
4
4
  "description": "DataJunction Metrics Platform UI",
5
5
  "module": "src/index.tsx",
6
6
  "repository": {
@@ -47,7 +47,7 @@ export default function Search() {
47
47
  };
48
48
  fetchNodes();
49
49
  }, []);
50
-
50
+
51
51
  const handleChange = e => {
52
52
  setSearchValue(e.target.value);
53
53
  if (fuse) {
@@ -6,7 +6,12 @@ import { useContext, useMemo, useState, useEffect } from 'react';
6
6
  import DJClientContext from '../../providers/djclient';
7
7
  import { FormikSelect } from './FormikSelect';
8
8
 
9
- export const ColumnsSelect = ({ defaultValue, fieldName, label, isMulti = false }) => {
9
+ export const ColumnsSelect = ({
10
+ defaultValue,
11
+ fieldName,
12
+ label,
13
+ isMulti = false,
14
+ }) => {
10
15
  const djClient = useContext(DJClientContext).DataJunctionAPI;
11
16
 
12
17
  // Used to pull out current form values for node validation
@@ -32,7 +37,7 @@ export const ColumnsSelect = ({ defaultValue, fieldName, label, isMulti = false
32
37
  );
33
38
  if (json?.columns) {
34
39
  setAvailableColumns(
35
- json.columns.map(col => ({ value: col.name, label: col.name }))
40
+ json.columns.map(col => ({ value: col.name, label: col.name })),
36
41
  );
37
42
  }
38
43
  } catch (error) {
@@ -44,18 +49,25 @@ export const ColumnsSelect = ({ defaultValue, fieldName, label, isMulti = false
44
49
  fetchColumns();
45
50
  }, [values.type, values.name, values.query]);
46
51
 
47
- return selectableOptions === undefined ? '' : (
52
+ return selectableOptions === undefined ? (
53
+ ''
54
+ ) : (
48
55
  <div className="CubeCreationInput">
49
56
  <ErrorMessage name={fieldName} component="span" />
50
57
  <label htmlFor="react-select-3-input">{label}</label>
51
58
  <span data-testid={`select-${fieldName}`}>
52
59
  <FormikSelect
53
- className={isMulti ? "MultiSelectInput" : "SelectInput"}
54
- defaultValue={isMulti ? defaultValue.map(val => {return {
55
- value: val,
56
- label: val,
57
- }}) : {value: defaultValue,
58
- label: defaultValue,}}
60
+ className={isMulti ? 'MultiSelectInput' : 'SelectInput'}
61
+ defaultValue={
62
+ isMulti
63
+ ? defaultValue.map(val => {
64
+ return {
65
+ value: val,
66
+ label: val,
67
+ };
68
+ })
69
+ : { value: defaultValue, label: defaultValue }
70
+ }
59
71
  selectOptions={selectableOptions}
60
72
  formikFieldName={fieldName}
61
73
  onFocus={event => fetchColumns(event)}
@@ -5,12 +5,16 @@
5
5
  import * as React from 'react';
6
6
  import { lazyLoad } from '../../../utils/loadable';
7
7
 
8
- export const AddEditNodePage = () => {
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
  };
@@ -330,17 +330,17 @@ export function AddEditNodePage({ extensions = {} }) {
330
330
  <Formik
331
331
  initialValues={initialValues}
332
332
  validate={validator}
333
- onSubmit={
334
- (values, { setSubmitting, setStatus }) => {
335
- try {
336
- submitHandlers.map(handler => handler(values, { setSubmitting, setStatus }));
337
- } catch (error) {
338
- console.error("Error in submission", error);
339
- } finally {
340
- setSubmitting(false);
341
- }
333
+ onSubmit={(values, { setSubmitting, setStatus }) => {
334
+ try {
335
+ submitHandlers.map(handler =>
336
+ handler(values, { setSubmitting, setStatus }),
337
+ );
338
+ } catch (error) {
339
+ console.error('Error in submission', error);
340
+ } finally {
341
+ setSubmitting(false);
342
342
  }
343
- }
343
+ }}
344
344
  >
345
345
  {function Render({ isSubmitting, status, setFieldValue }) {
346
346
  const [node, setNode] = useState([]);
@@ -425,15 +425,21 @@ export function AddEditNodePage({ extensions = {} }) {
425
425
  ) : (
426
426
  <RequiredDimensionsSelect />
427
427
  )}
428
- {Object.entries(extensions).map(([key, ExtensionComponent]) => (
429
- <div key={key} className="mt-4 border-t pt-4">
430
- <ExtensionComponent
431
- node={node}
432
- action={action}
433
- registerSubmitHandler={onSubmit => submitHandlers.indexOf(onSubmit) === -1 ? submitHandlers.push(onSubmit) : null}
434
- />
435
- </div>
436
- ))}
428
+ {Object.entries(extensions).map(
429
+ ([key, ExtensionComponent]) => (
430
+ <div key={key} className="mt-4 border-t pt-4">
431
+ <ExtensionComponent
432
+ node={node}
433
+ action={action}
434
+ registerSubmitHandler={onSubmit =>
435
+ submitHandlers.indexOf(onSubmit) === -1
436
+ ? submitHandlers.push(onSubmit)
437
+ : null
438
+ }
439
+ />
440
+ </div>
441
+ ),
442
+ )}
437
443
  {action === Action.Edit ? selectTags : <TagsField />}
438
444
  <NodeModeField />
439
445
 
@@ -44,23 +44,22 @@ export default function AddMaterializationPopover({ node, onSubmit }) {
44
44
  if (!values.job_type) {
45
45
  values.job_type = 'spark_sql';
46
46
  }
47
- const { status, json } = (
48
- values.job_type === 'druid_cube' ?
49
- await djClient.materializeCube(
50
- values.node,
51
- values.job_type,
52
- values.strategy,
53
- values.schedule,
54
- values.lookback_window,
55
- ) :
56
- await djClient.materialize(
57
- values.node,
58
- values.job_type,
59
- values.strategy,
60
- values.schedule,
61
- config,
62
- )
63
- );
47
+ const { status, json } =
48
+ values.job_type === 'druid_cube'
49
+ ? await djClient.materializeCube(
50
+ values.node,
51
+ values.job_type,
52
+ values.strategy,
53
+ values.schedule,
54
+ values.lookback_window,
55
+ )
56
+ : await djClient.materialize(
57
+ values.node,
58
+ values.job_type,
59
+ values.strategy,
60
+ values.schedule,
61
+ config,
62
+ );
64
63
  if (status === 200 || status === 201) {
65
64
  setStatus({ success: json.message });
66
65
  window.location.reload();
@@ -110,9 +109,9 @@ export default function AddMaterializationPopover({ node, onSubmit }) {
110
109
  <Formik
111
110
  initialValues={{
112
111
  node: node?.name,
113
- job_type:
114
- node?.type === 'cube' ? 'druid_cube' : 'spark_sql',
115
- strategy: timePartitionColumns.length == 1 ? 'incremental_time' : 'full',
112
+ job_type: node?.type === 'cube' ? 'druid_cube' : 'spark_sql',
113
+ strategy:
114
+ timePartitionColumns.length == 1 ? 'incremental_time' : 'full',
116
115
  schedule: '@daily',
117
116
  lookback_window: '1 DAY',
118
117
  spark_config: {
@@ -133,10 +132,7 @@ export default function AddMaterializationPopover({ node, onSubmit }) {
133
132
 
134
133
  <Field as="select" name="job_type">
135
134
  <>
136
- <option
137
- key={'druid_cube'}
138
- value={'druid_cube'}
139
- >
135
+ <option key={'druid_cube'} value={'druid_cube'}>
140
136
  Druid
141
137
  </option>
142
138
  </>
@@ -153,7 +149,10 @@ export default function AddMaterializationPopover({ node, onSubmit }) {
153
149
  value={node?.name}
154
150
  readOnly={true}
155
151
  />
156
- {console.log('timePartitionColumns.length', timePartitionColumns.length)}
152
+ {console.log(
153
+ 'timePartitionColumns.length',
154
+ timePartitionColumns.length,
155
+ )}
157
156
  <span data-testid="edit-partition">
158
157
  <label htmlFor="strategy">Strategy</label>
159
158
  <Field as="select" name="strategy">
@@ -980,7 +980,13 @@ export const DataJunctionAPI = {
980
980
  );
981
981
  return { status: response.status, json: await response.json() };
982
982
  },
983
- materializeCube: async function (nodeName, jobType, strategy, schedule, lookbackWindow) {
983
+ materializeCube: async function (
984
+ nodeName,
985
+ jobType,
986
+ strategy,
987
+ schedule,
988
+ lookbackWindow,
989
+ ) {
984
990
  const response = await fetch(
985
991
  `${DJ_URL}/nodes/${nodeName}/materialization`,
986
992
  {