From 3b536eea7f5bdb4c6f299fd39fffbe7c67c982a9 Mon Sep 17 00:00:00 2001
From: Vadim Ogievetsky
Date: Wed, 18 Mar 2020 15:32:12 -0700
Subject: [PATCH] Web console: expose props for S3 (#9432)
* expose props for S3
* added env inputs
* add scarry warning
* use .password
* put the warning front and center
* Update web-console/src/views/load-data-view/load-data-view.tsx
Co-Authored-By: Suneet Saldanha <44787917+suneet-s@users.noreply.github.com>
* let prettier rewrap the text
Co-authored-by: Suneet Saldanha <44787917+suneet-s@users.noreply.github.com>
---
.../__snapshots__/auto-form.spec.tsx.snap | 3 +
.../src/components/auto-form/auto-form.tsx | 39 ++++---
.../suggestible-input/suggestible-input.tsx | 16 ++-
.../compaction-dialog.spec.tsx.snap | 4 +
web-console/src/utils/ingestion-spec.tsx | 104 +++++++++++++++++-
.../views/load-data-view/load-data-view.tsx | 23 +++-
6 files changed, 161 insertions(+), 28 deletions(-)
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 865a7f8ac6d..c30d781fab3 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
@@ -29,6 +29,7 @@ exports[`auto-form snapshot matches snapshot 1`] = `
autocomplete="off"
class="bp3-input"
min="0"
+ placeholder=""
style="padding-right: 10px;"
type="text"
value=""
@@ -194,6 +195,7 @@ exports[`auto-form snapshot matches snapshot 1`] = `
>
diff --git a/web-console/src/components/auto-form/auto-form.tsx b/web-console/src/components/auto-form/auto-form.tsx
index 66dffded426..67f45923cbe 100644
--- a/web-console/src/components/auto-form/auto-form.tsx
+++ b/web-console/src/components/auto-form/auto-form.tsx
@@ -47,7 +47,7 @@ export interface Field {
defaultValue?: any;
emptyValue?: any;
suggestions?: Functor;
- placeholder?: string;
+ placeholder?: Functor;
min?: number;
zeroMeansUndefined?: boolean;
disabled?: Functor;
@@ -56,13 +56,14 @@ export interface Field {
adjustment?: (model: M) => M;
}
-export interface AutoFormProps {
- fields: Field[];
- model: T | undefined;
- onChange: (newModel: T) => void;
+export interface AutoFormProps {
+ fields: Field[];
+ model: M | undefined;
+ onChange: (newModel: M) => void;
onFinalize?: () => void;
- showCustom?: (model: T) => boolean;
+ showCustom?: (model: M) => boolean;
large?: boolean;
+ globalAdjustment?: (model: M) => M;
}
export class AutoForm> extends React.PureComponent> {
@@ -111,11 +112,15 @@ export class AutoForm> extends React.PureComponent
newModel = deepSet(model, field.name, newValue);
}
+ if (field.adjustment) {
+ newModel = field.adjustment(newModel);
+ }
+
this.modelChange(newModel);
};
private modelChange = (newModel: T) => {
- const { fields, onChange, model } = this.props;
+ const { globalAdjustment, fields, onChange, model } = this.props;
// Delete things that are not defined now (but were defined prior to the change)
for (const someField of fields) {
@@ -127,11 +132,9 @@ export class AutoForm> extends React.PureComponent
}
}
- // Perform any adjustments if needed
- for (const someField of fields) {
- if (someField.adjustment) {
- newModel = someField.adjustment(newModel);
- }
+ // Perform any global adjustments if needed
+ if (globalAdjustment) {
+ newModel = globalAdjustment(newModel);
}
onChange(newModel);
@@ -162,7 +165,7 @@ export class AutoForm> extends React.PureComponent
fill
large={large}
disabled={AutoForm.evaluateFunctor(field.disabled, model, false)}
- placeholder={field.placeholder}
+ placeholder={AutoForm.evaluateFunctor(field.placeholder, model, '')}
intent={
AutoForm.evaluateFunctor(field.required, model, false) && modelValue == null
? AutoForm.REQUIRED_INTENT
@@ -203,14 +206,14 @@ export class AutoForm> extends React.PureComponent
{
- if (sanitize) v = sanitize(v);
+ if (sanitize && typeof v === 'string') v = sanitize(v);
this.fieldChange(field, v);
}}
onBlur={() => {
if (modelValue === '') this.fieldChange(field, undefined);
}}
onFinalize={onFinalize}
- placeholder={field.placeholder}
+ placeholder={AutoForm.evaluateFunctor(field.placeholder, model, '')}
suggestions={AutoForm.evaluateFunctor(field.suggestions, model, undefined)}
large={large}
disabled={AutoForm.evaluateFunctor(field.disabled, model, false)}
@@ -268,7 +271,7 @@ export class AutoForm> extends React.PureComponent
this.fieldChange(field, v)}
- placeholder={field.placeholder}
+ placeholder={AutoForm.evaluateFunctor(field.placeholder, model, '')}
/>
);
}
@@ -282,7 +285,7 @@ export class AutoForm> extends React.PureComponent
onChange={(v: any) => {
this.fieldChange(field, v);
}}
- placeholder={field.placeholder}
+ placeholder={AutoForm.evaluateFunctor(field.placeholder, model, '')}
large={large}
disabled={AutoForm.evaluateFunctor(field.disabled, model, false)}
intent={
@@ -304,7 +307,7 @@ export class AutoForm> extends React.PureComponent
onValueChange={(v: any) => {
this.fieldChange(field, v);
}}
- placeholder={field.placeholder}
+ placeholder={AutoForm.evaluateFunctor(field.placeholder, model, '')}
/>
);
}
diff --git a/web-console/src/components/suggestible-input/suggestible-input.tsx b/web-console/src/components/suggestible-input/suggestible-input.tsx
index 39d40028690..d6b48493479 100644
--- a/web-console/src/components/suggestible-input/suggestible-input.tsx
+++ b/web-console/src/components/suggestible-input/suggestible-input.tsx
@@ -35,10 +35,10 @@ export interface SuggestionGroup {
suggestions: string[];
}
-export type Suggestion = string | SuggestionGroup;
+export type Suggestion = undefined | string | SuggestionGroup;
export interface SuggestibleInputProps extends HTMLInputProps {
- onValueChange: (newValue: string) => void;
+ onValueChange: (newValue: undefined | string) => void;
onFinalize?: () => void;
suggestions?: Suggestion[];
large?: boolean;
@@ -53,7 +53,7 @@ export class SuggestibleInput extends React.PureComponent
// this.state = {};
}
- public handleSuggestionSelect(suggestion: string) {
+ public handleSuggestionSelect(suggestion: undefined | string) {
const { onValueChange, onFinalize } = this.props;
onValueChange(suggestion);
if (onFinalize) onFinalize();
@@ -66,7 +66,15 @@ export class SuggestibleInput extends React.PureComponent
return (
),
- adjustment: adjustTuningConfig,
},
{
name: 'partitionsSpec.type',
diff --git a/web-console/src/views/load-data-view/load-data-view.tsx b/web-console/src/views/load-data-view/load-data-view.tsx
index ebb68debbd1..991ebcddb2c 100644
--- a/web-console/src/views/load-data-view/load-data-view.tsx
+++ b/web-console/src/views/load-data-view/load-data-view.tsx
@@ -70,6 +70,7 @@ import { NUMERIC_TIME_FORMATS, possibleDruidFormatForValues } from '../../utils/
import { updateSchemaWithSample } from '../../utils/druid-type';
import {
adjustIngestionSpec,
+ adjustTuningConfig,
DimensionMode,
DimensionSpec,
DimensionsSpec,
@@ -1075,11 +1076,22 @@ export class LoadDataView extends React.PureComponent
{ingestionComboType ? (
- this.updateSpecPreview(deepSet(spec, 'spec.ioConfig', c))}
- />
+ <>
+ this.updateSpecPreview(deepSet(spec, 'spec.ioConfig', c))}
+ />
+ {deepGet(spec, 'spec.ioConfig.inputSource.properties.secretAccessKey.password') && (
+
+
+ This key will be visible to anyone accessing this console and may appear in
+ server logs. For production scenarios, use of a more secure secret key type is
+ strongly recommended.
+
+
+ )}
+ >
) : (
this.updateSpec(deepSet(spec, 'spec.tuningConfig', t))}
/>