You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/03/15 23:29:46 UTC

[GitHub] [incubator-druid] shuqi7 commented on a change in pull request #7259: Add lookups view to allow adding/editing/deleting of druid lookups

shuqi7 commented on a change in pull request #7259: Add lookups view to allow adding/editing/deleting of druid lookups
URL: https://github.com/apache/incubator-druid/pull/7259#discussion_r266174458
 
 

 ##########
 File path: web-console/src/dialogs/lookup-edit-dialog.tsx
 ##########
 @@ -0,0 +1,154 @@
+/*
+ * 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 * as React from "react";
+import {Button, Classes, Dialog, Intent, InputGroup } from "@blueprintjs/core";
+import "./lookup-edit-dialog.scss"
+import {validJson} from "../utils";
+import AceEditor from "react-ace";
+import {FormGroup} from "../components/filler";
+
+export interface LookupEditDialogProps extends React.Props<any> {
+  isOpen: boolean,
+  onClose: () => void,
+  onSubmit: () => void,
+  onChange: (field: string, value: string) => void
+  lookupName: string,
+  lookupTier: string,
+  lookupVersion: string,
+  lookupSpec: string,
+  isEdit: boolean,
+  allLookupTiers: string[]
+}
+
+export interface LookupEditDialogState {
+}
+
+export class LookupEditDialog extends React.Component<LookupEditDialogProps, LookupEditDialogState> {
+
+  constructor(props: LookupEditDialogProps) {
+    super(props);
+    this.state = {
+
+    }
+  }
+
+  private addISOVersion = () => {
+    const {onChange} = this.props;
+    const currentDate = new Date();
+    const ISOString = currentDate.toISOString();
+    onChange("lookupEditVersion", ISOString);
+  }
+
+  private renderTierInput() {
+    const { isEdit, lookupTier, allLookupTiers, onChange } = this.props;
+    if (isEdit) {
+      return <FormGroup className={"lookup-label"} label={"Tier: "}>
+        <InputGroup
+          value={lookupTier}
+          onChange={(e: any) => onChange("lookupEditTier", e.target.value)}
+          disabled={true}
+        />
+      </FormGroup>
+    } else {
+      return <FormGroup className={"lookup-label"} label={"Tier:"}>
+        <div className="pt-select">
+          <select disabled={isEdit} value={lookupTier} onChange={(e:any) => onChange("lookupEditTier", e.target.value)}>
+            {
+              allLookupTiers.map(tier => {
+                return <option key={tier} value={tier}>{tier}</option>
+              })
+            }
+          </select>
+        </div>
+      </FormGroup>
+    }
+  }
+
+  render() {
+    const { isOpen, onClose, onSubmit, lookupSpec, lookupTier, lookupName, lookupVersion, onChange, isEdit, allLookupTiers } = this.props;
+
+    const disableSubmit = lookupName === "" || lookupVersion === "" ||
+      lookupTier === "" || !validJson(lookupSpec);
+
+    return <Dialog
+      className={"lookup-edit-dialog"}
+      isOpen={isOpen}
+      onClose={onClose}
+      title={isEdit ? "Edit lookup" : "Add lookup"}
+    >
+      <FormGroup className={"lookup-label"} label={"Name: "}>
+        <InputGroup
+          value={lookupName}
+          onChange={(e: any) => onChange("lookupEditName", e.target.value)}
+          disabled={isEdit}
+          placeholder={"Enter the lookup name"}
+        />
+      </FormGroup>
+
+      { this.renderTierInput() }
+
+      <FormGroup className={"lookup-label"} label={"Version:"}>
+        <InputGroup
+          value={lookupVersion}
+          onChange={(e: any) => onChange("lookupEditVersion", e.target.value)}
+          placeholder={"Enter the lookup version"}
+          rightElement={<Button className={"pt-minimal"} text={"Use ISO as version"} onClick={() => this.addISOVersion()} />}
+        />
+      </FormGroup>
+
+      <FormGroup className={"lookup-label"} label={"Spec:"}/>
+
+      <AceEditor
+        className={"bp3-fill lookup-edit-dialog-textarea"}
 
 Review comment:
   Should be. Must have missed this after downgrading from bp3.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org