Skip to content

Commit

Permalink
Web console: reflect the changes to interval requirement in the data …
Browse files Browse the repository at this point in the history
…loader flow (apache#10647)

* no need for intervals

* don't set redundant fields

* fix tests

* better filter control

* work with not

* wrap callout with form group

* update snapshot

* add split hint

* highlight issues with spec

* fixes

* fix default value

* move intervals back to partition step

* work with all sorts of chars

* fix enabled view
  • Loading branch information
vogievetsky authored and JulianJaffePinterest committed Jan 22, 2021
1 parent d59cfbe commit abffd8b
Show file tree
Hide file tree
Showing 26 changed files with 952 additions and 747 deletions.
2 changes: 1 addition & 1 deletion web-console/e2e-tests/reindexing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Reindexing from Druid', () => {
const configureSchemaConfig = new ConfigureSchemaConfig({ rollup: false });
const partitionConfig = new PartitionConfig({
segmentGranularity: SegmentGranularity.DAY,
timeIntervals: interval,
timeIntervals: null,
partitionsSpec: new SingleDimPartitionsSpec({
partitionDimension: 'channel',
targetRowsPerSegment: 10_000,
Expand Down
9 changes: 6 additions & 3 deletions web-console/e2e-tests/tutorial-batch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
* limitations under the License.
*/

import { SqlRef } from 'druid-query-toolkit';
import * as playwright from 'playwright-chromium';

import { DatasourcesOverview } from './component/datasources/overview';
import { IngestionOverview } from './component/ingestion/overview';
import { ConfigureSchemaConfig } from './component/load-data/config/configure-schema';
import { PartitionConfig } from './component/load-data/config/partition';
import { SegmentGranularity } from './component/load-data/config/partition';
import { PartitionConfig } from './component/load-data/config/partition';
import { PublishConfig } from './component/load-data/config/publish';
import { LocalFileDataConnector } from './component/load-data/data-connector/local-file';
import { DataLoader } from './component/load-data/data-loader';
Expand All @@ -37,6 +38,8 @@ import { waitTillWebConsoleReady } from './util/setup';

jest.setTimeout(5 * 60 * 1000);

const ALL_SORTS_OF_CHARS = '<>|!@#$%^&`\'".,:;\\*()[]{}Россия 한국 中国!?~';

describe('Tutorial: Loading a file', () => {
let browser: playwright.Browser;
let page: playwright.Page;
Expand All @@ -56,7 +59,7 @@ describe('Tutorial: Loading a file', () => {

it('Loads data from local disk', async () => {
const testName = 'load-data-from-local-disk-';
const datasourceName = testName + new Date().toISOString();
const datasourceName = testName + ALL_SORTS_OF_CHARS + new Date().toISOString();
const dataConnector = new LocalFileDataConnector(page, {
baseDirectory: DRUID_EXAMPLES_QUICKSTART_TUTORIAL_DIR,
fileFilter: 'wikiticker-2015-09-12-sampled.json.gz',
Expand Down Expand Up @@ -168,7 +171,7 @@ async function validateDatasourceStatus(page: playwright.Page, datasourceName: s

async function validateQuery(page: playwright.Page, datasourceName: string) {
const queryOverview = new QueryOverview(page, UNIFIED_CONSOLE_URL);
const query = `SELECT * FROM "${datasourceName}" ORDER BY __time`;
const query = `SELECT * FROM ${SqlRef.table(datasourceName)} ORDER BY __time`;
const results = await queryOverview.runQuery(query);
expect(results).toBeDefined();
expect(results.length).toBeGreaterThan(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,13 @@ exports[`AutoForm matches snapshot 1`] = `
key="testOne"
label="Test one"
>
<Blueprint3.NumericInput
allowNumericCharactersOnly={true}
buttonPosition="right"
clampValueOnBlur={false}
defaultValue=""
<Memo(NumericInputWithDefault)
disabled={false}
fill={true}
large={false}
majorStepSize={10}
min={0}
minorStepSize={0.1}
onBlur={[Function]}
onValueChange={[Function]}
placeholder=""
selectAllOnFocus={false}
selectAllOnIncrement={false}
stepSize={1}
/>
</Memo(FormGroupWithInfo)>
<Memo(FormGroupWithInfo)
Expand Down
20 changes: 11 additions & 9 deletions web-console/src/components/auto-form/auto-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ArrayInput } from '../array-input/array-input';
import { FormGroupWithInfo } from '../form-group-with-info/form-group-with-info';
import { IntervalInput } from '../interval-input/interval-input';
import { JsonInput } from '../json-input/json-input';
import { NumericInputWithDefault } from '../numeric-input-with-default/numeric-input-with-default';
import { PopoverText } from '../popover-text/popover-text';
import { SuggestibleInput, Suggestion } from '../suggestible-input/suggestible-input';

Expand Down Expand Up @@ -82,7 +83,8 @@ export class AutoForm<T extends Record<string, any>> extends React.PureComponent
static REQUIRED_INTENT = Intent.PRIMARY;

static makeLabelName(label: string): string {
let newLabel = label
const parts = label.split('.');
let newLabel = parts[parts.length - 1]
.split(/(?=[A-Z])/)
.join(' ')
.toLowerCase()
Expand Down Expand Up @@ -203,17 +205,17 @@ export class AutoForm<T extends Record<string, any>> extends React.PureComponent
private renderNumberInput(field: Field<T>): JSX.Element {
const { model, large, onFinalize } = this.props;

let modelValue = deepGet(model as any, field.name);
if (typeof modelValue !== 'number') modelValue = field.defaultValue;
const modelValue = deepGet(model as any, field.name);
return (
<NumericInput
<NumericInputWithDefault
value={modelValue}
defaultValue={field.defaultValue}
onValueChange={(valueAsNumber: number, valueAsString: string) => {
if (valueAsString === '' || isNaN(valueAsNumber)) return;
this.fieldChange(
field,
valueAsNumber === 0 && field.zeroMeansUndefined ? undefined : valueAsNumber,
);
let newValue: number | undefined;
if (valueAsString !== '' && !isNaN(valueAsNumber)) {
newValue = valueAsNumber === 0 && field.zeroMeansUndefined ? undefined : valueAsNumber;
}
this.fieldChange(field, newValue);
}}
onBlur={e => {
if (e.target.value === '') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`NumericInputWithDefault matches snapshot 1`] = `
<Blueprint3.NumericInput
allowNumericCharactersOnly={true}
buttonPosition="right"
clampValueOnBlur={false}
defaultValue=""
large={false}
majorStepSize={10}
minorStepSize={0.1}
onBlur={[Function]}
onValueChange={[Function]}
selectAllOnFocus={false}
selectAllOnIncrement={false}
stepSize={1}
value={5}
/>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { shallow } from 'enzyme';
import React from 'react';

import { NumericInputWithDefault } from './numeric-input-with-default';

describe('NumericInputWithDefault', () => {
it('matches snapshot', () => {
const numericInputWithDefault = shallow(<NumericInputWithDefault value={5} defaultValue={3} />);

expect(numericInputWithDefault).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { HTMLInputProps, INumericInputProps, NumericInput } from '@blueprintjs/core';
import React, { useState } from 'react';

export type NumericInputWithDefaultProps = HTMLInputProps & INumericInputProps;

export const NumericInputWithDefault = React.memo(function NumericInputWithDefault(
props: NumericInputWithDefaultProps,
) {
const { value, defaultValue, onValueChange, onBlur, ...rest } = props;
const [hasChanged, setHasChanged] = useState(false);

let effectiveValue = value;
if (effectiveValue == null) {
effectiveValue = hasChanged ? '' : typeof defaultValue !== 'undefined' ? defaultValue : '';
}

return (
<NumericInput
value={effectiveValue}
onValueChange={(valueAsNumber, valueAsString, inputElement) => {
setHasChanged(true);
if (!onValueChange) return;
return onValueChange(valueAsNumber, valueAsString, inputElement);
}}
onBlur={e => {
setHasChanged(false);
if (!onBlur) return;
return onBlur(e);
}}
{...rest}
/>
);
});
Loading

0 comments on commit abffd8b

Please sign in to comment.