vogievetsky commented on a change in pull request #9587: Use auto-form for add 
an edit lookups
URL: https://github.com/apache/druid/pull/9587#discussion_r405115366
 
 

 ##########
 File path: web-console/src/dialogs/lookup-edit-dialog/lookup-edit-dialog.tsx
 ##########
 @@ -124,34 +202,302 @@ export const LookupEditDialog = React.memo(function 
LookupEditDialog(props: Look
           }
         />
       </FormGroup>
-
-      <FormGroup className="lookup-label" label="Spec:" />
-
-      <AceEditor
-        className="lookup-edit-dialog-textarea"
-        mode="hjson"
-        theme="solarized_dark"
-        onChange={(e: any) => onChange('lookupEditSpec', e)}
-        fontSize={12}
-        height="40vh"
-        width="auto"
-        showPrintMargin={false}
-        showGutter={false}
-        value={lookupSpec}
-        editorProps={{ $blockScrolling: Infinity }}
-        setOptions={{
-          tabSize: 2,
+      <AutoForm
+        fields={[
+          {
+            name: 'type',
+            type: 'string',
+            suggestions: ['map', 'cachedNamespace'],
+            adjustment: model => {
+              if (
+                model.type === 'map' &&
+                model.extractionNamespace &&
+                model.extractionNamespace.type
+              ) {
+                return model;
+              }
+              model.extractionNamespace = { type: 'uri', namespaceParseSpec: { 
format: 'csv' } };
+              return model;
+            },
+          },
+          {
+            name: 'map',
+            type: 'json',
+            defined: model => {
+              return model.type === 'map';
+            },
+          },
+          {
+            name: 'extractionNamespace.type',
+            type: 'string',
+            label: 'Globally cached lookup type',
+            placeholder: 'uri',
+            suggestions: ['uri', 'jdbc'],
+            defined: model => model.type === 'cachedNamespace',
+          },
+          {
+            name: 'extractionNamespace.uriPrefix',
+            type: 'string',
+            label: 'URI prefix',
+            info:
+              'A URI which specifies a directory (or other searchable 
resource) in which to search for files',
+            placeholder: 's3://bucket/some/key/prefix/',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri',
+          },
+          {
+            name: 'extractionNamespace.fileRegex',
+            type: 'string',
+            label: 'File regex',
+            placeholder: 'renames-[0-9]*\\.gz',
+            info:
+              'Optional regex for matching the file name under uriPrefix. Only 
used if uriPrefix is used',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.format',
+            type: 'string',
+            label: 'Format',
+            defaultValue: 'csv',
+            suggestions: ['csv', 'tsv', 'customJson', 'simpleJson'],
+            // todo needs info
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.columns',
+            type: 'string-array',
+            label: 'Columns',
+            placeholder: `["key", "value"]`,
+            info: 'The list of columns in the csv file',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.keyColumn',
+            type: 'string',
+            label: 'Key column',
+            placeholder: 'Key',
+            info: 'The name of the column containing the key',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.valueColumn',
+            type: 'string',
+            label: 'Value column',
+            placeholder: 'Value',
+            info: 'The name of the column containing the value',
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.hasHeaderRow',
+            type: 'boolean',
+            label: 'Has header row',
+            defaultValue: false,
+            info: `A flag to indicate that column information can be extracted 
from the input files' header row`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.skipHeaderRows',
+            type: 'number',
+            label: 'Skip header rows',
+            placeholder: '0',
+            info: `Number of header rows to be skipped`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              (model.extractionNamespace.namespaceParseSpec.format === 'csv' ||
+                model.extractionNamespace.namespaceParseSpec.format === 'tsv'),
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.delimiter',
+            type: 'string',
+            label: 'Delimiter',
+            placeholder: `\t`,
+            info: `The delimiter in the file`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.listDelimiter',
+            type: 'string',
+            label: 'List delimiter',
+            placeholder: `\u0001`,
+            info: `The list delimiter in the file\t`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              model.extractionNamespace.namespaceParseSpec.format === 'tsv',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.keyFieldName',
+            type: 'string',
+            label: 'Key field name',
+            placeholder: `key`,
+            info: `The field name of the key`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              model.extractionNamespace.namespaceParseSpec.format === 
'customJson',
+          },
+          {
+            name: 'extractionNamespace.namespaceParseSpec.valueFieldName',
+            type: 'string',
+            label: 'Value field name',
+            placeholder: `value`,
+            info: `The field name of the value`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'uri' &&
+              model.extractionNamespace.namespaceParseSpec &&
+              model.extractionNamespace.namespaceParseSpec.format === 
'customJson',
+          },
+          {
+            name: 'extractionNamespace.namespace',
+            type: 'string',
+            label: 'Namespace',
+            placeholder: 'some_lookup',
+            info: `The namespace to define`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.table',
+            type: 'string',
+            label: 'Table',
+            placeholder: 'some_lookup_table',
+            info: `The table which contains the key value pairs`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.keyColumn',
+            type: 'string',
+            label: 'Key column',
+            placeholder: 'the_old_dim_value',
+            info: `The column in table which contains the keys`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.valueColumn',
+            type: 'string',
+            label: 'Value column',
+            placeholder: 'the_new_dim_value',
+            info: `The column in table which contains the values`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.filter',
+            type: 'json',
+            label: 'Filter',
+            info: `The filter to use when selecting lookups, this is used to 
create a where clause on lookup population`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.tsColumn',
+            type: 'string',
+            label: 'TsColumn',
+            info: `The column in table which contains when the key was 
updated`,
+            defined: model =>
+              model.type === 'cachedNamespace' &&
+              !!model.extractionNamespace &&
+              model.extractionNamespace.type === 'jdbc',
+          },
+          {
+            name: 'extractionNamespace.pollPeriod',
+            type: 'string',
+            label: 'Poll Period',
 
 Review comment:
   caps?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to