From 9964dd4cb260058194772c7cee638542205b5e33 Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Tue, 17 Nov 2020 13:25:03 -0800 Subject: [PATCH] Web console: fix data loader schema table column ordering bug and other polish (#10588) * remove unused fields * keep tables live * advanced * fix schema view * better indication * tests pass * Show more instead of show advanced * fix tests * extract dynamic configs * update snapshots * fix issues * update snapshot * reword without > --- .../component/load-data/config/partition.ts | 8 +- .../__snapshots__/auto-form.spec.tsx.snap | 13 +- .../components/auto-form/auto-form.spec.tsx | 5 +- .../src/components/auto-form/auto-form.tsx | 52 +- ...inator-dynamic-config-dialog.spec.tsx.snap | 10 +- .../coordinator-dynamic-config-dialog.tsx | 198 +-- .../overlord-dynamic-config-dialog.tsx | 16 +- .../__snapshots__/ingestion-spec.spec.ts.snap | 4 +- .../coordinator-dynamic-config.tsx | 208 +++ web-console/src/druid-models/index.ts | 2 + .../src/druid-models/ingestion-spec.spec.ts | 12 +- .../src/druid-models/ingestion-spec.tsx | 240 ++-- web-console/src/druid-models/input-format.tsx | 35 +- .../druid-models/overlord-dynamic-config.tsx | 35 + .../src/druid-models/timestamp-spec.tsx | 7 +- .../src/druid-models/transform-spec.tsx | 1 + web-console/src/utils/general.spec.ts | 10 + web-console/src/utils/general.tsx | 27 +- web-console/src/utils/query-manager.tsx | 3 + web-console/src/utils/query-state.ts | 15 +- web-console/src/utils/sampler.ts | 54 +- web-console/src/utils/utils.spec.ts | 15 +- .../load-data-view.spec.tsx.snap | 18 +- .../views/load-data-view/info-messages.tsx | 191 +++ .../views/load-data-view/load-data-view.tsx | 1273 ++++++++++------- .../reorder-menu/reorder-menu.tsx | 66 + .../__snapshots__/schema-table.spec.tsx.snap | 104 +- .../schema-table/schema-table.spec.tsx | 9 +- .../schema-table/schema-table.tsx | 79 +- .../src/views/query-view/query-view.tsx | 5 +- 30 files changed, 1703 insertions(+), 1012 deletions(-) create mode 100644 web-console/src/druid-models/coordinator-dynamic-config.tsx create mode 100644 web-console/src/druid-models/overlord-dynamic-config.tsx create mode 100644 web-console/src/views/load-data-view/info-messages.tsx create mode 100644 web-console/src/views/load-data-view/reorder-menu/reorder-menu.tsx diff --git a/web-console/e2e-tests/component/load-data/config/partition.ts b/web-console/e2e-tests/component/load-data/config/partition.ts index f811a531664..375ad550745 100644 --- a/web-console/e2e-tests/component/load-data/config/partition.ts +++ b/web-console/e2e-tests/component/load-data/config/partition.ts @@ -26,10 +26,10 @@ import { getLabeledInput, selectSuggestibleInput, setLabeledInput } from '../../ * Possible values for partition step segment granularity. */ export enum SegmentGranularity { - HOUR = 'HOUR', - DAY = 'DAY', - MONTH = 'MONTH', - YEAR = 'YEAR', + HOUR = 'hour', + DAY = 'day', + MONTH = 'month', + YEAR = 'year', } const PARTITIONING_TYPE = 'Partitioning type'; diff --git a/web-console/src/components/auto-form/__snapshots__/auto-form.spec.tsx.snap b/web-console/src/components/auto-form/__snapshots__/auto-form.spec.tsx.snap index 1a4000ef00f..baf1011bdc8 100644 --- a/web-console/src/components/auto-form/__snapshots__/auto-form.spec.tsx.snap +++ b/web-console/src/components/auto-form/__snapshots__/auto-form.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`auto-form snapshot matches snapshot 1`] = ` +exports[`AutoForm matches snapshot 1`] = `
@@ -132,5 +132,16 @@ exports[`auto-form snapshot matches snapshot 1`] = ` placeholder="" /> + + +
`; diff --git a/web-console/src/components/auto-form/auto-form.spec.tsx b/web-console/src/components/auto-form/auto-form.spec.tsx index 89bd645e9f6..c2beb3d498b 100644 --- a/web-console/src/components/auto-form/auto-form.spec.tsx +++ b/web-console/src/components/auto-form/auto-form.spec.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { AutoForm } from './auto-form'; -describe('auto-form snapshot', () => { +describe('AutoForm', () => { it('matches snapshot', () => { const autoForm = shallow( { { name: 'testFive', type: 'string-array' }, { name: 'testSix', type: 'json' }, { name: 'testSeven', type: 'json' }, + + { name: 'testNotDefined', type: 'string', defined: false }, + { name: 'testAdvanced', type: 'string', hideInMore: true }, ]} model={String} onChange={() => {}} diff --git a/web-console/src/components/auto-form/auto-form.tsx b/web-console/src/components/auto-form/auto-form.tsx index 6ae9e4b3b4d..3b2f6c0da0e 100644 --- a/web-console/src/components/auto-form/auto-form.tsx +++ b/web-console/src/components/auto-form/auto-form.tsx @@ -17,6 +17,7 @@ */ import { Button, ButtonGroup, FormGroup, Intent, NumericInput } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; import React from 'react'; import { deepDelete, deepGet, deepSet } from '../../utils'; @@ -54,6 +55,7 @@ export interface Field { disabled?: Functor; defined?: Functor; required?: Functor; + hideInMore?: Functor; adjustment?: (model: M) => M; issueWithValue?: (value: any) => string | undefined; } @@ -68,7 +70,14 @@ export interface AutoFormProps { globalAdjustment?: (model: M) => M; } -export class AutoForm> extends React.PureComponent> { +export interface AutoFormState { + showMore: boolean; +} + +export class AutoForm> extends React.PureComponent< + AutoFormProps, + AutoFormState +> { static REQUIRED_INTENT = Intent.PRIMARY; static makeLabelName(label: string): string { @@ -138,7 +147,9 @@ export class AutoForm> extends React.PureComponent constructor(props: AutoFormProps) { super(props); - this.state = {}; + this.state = { + showMore: false, + }; } private fieldChange = (field: Field, newValue: any) => { @@ -391,7 +402,6 @@ export class AutoForm> extends React.PureComponent private renderField = (field: Field) => { const { model } = this.props; if (!model) return; - if (!AutoForm.evaluateFunctor(field.defined, model, true)) return; const label = field.label || AutoForm.makeLabelName(field.name); return ( @@ -415,12 +425,46 @@ export class AutoForm> extends React.PureComponent ); } + renderMoreOrLess() { + const { showMore } = this.state; + + return ( + +