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/11/06 01:48:57 UTC

[GitHub] [incubator-druid] vogievetsky commented on a change in pull request #8777: Web console: Interval input component

vogievetsky commented on a change in pull request #8777: Web console: Interval input component
URL: https://github.com/apache/incubator-druid/pull/8777#discussion_r342883396
 
 

 ##########
 File path: web-console/src/components/interval-input/interval-input.tsx
 ##########
 @@ -0,0 +1,114 @@
+/*
+ * 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 { Button, InputGroup, Popover, Position } from '@blueprintjs/core';
+import { DateRange, DateRangePicker } from '@blueprintjs/datetime';
+import { IconNames } from '@blueprintjs/icons';
+import React, { useState } from 'react';
+
+import './interval-input.scss';
+
+const CURRENT_YEAR = new Date().getUTCFullYear();
+
+export interface IntervalInputProps {
+  interval: string;
+  placeholder: string | undefined;
+  onValueChange: (interval: string) => void;
+}
+
+export const IntervalInput = React.memo(function IntervalInput(props: IntervalInputProps) {
+  const [tempInterval, setTempInterval] = useState();
+  const { interval, placeholder, onValueChange } = props;
+
+  function removeLocalTimezone(localDate: Date): Date {
+    // Function removes the local timezone of the date and displays it in UTC
+    return new Date(localDate.getTime() - localDate.getTimezoneOffset() * 60000);
+  }
+
+  function parseInterval(interval: string): DateRange {
 
 Review comment:
   you can lift this function out of the render context (put it next to CURRENT_YEAR). I think the same can be said for the other functions

----------------------------------------------------------------
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