You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/01/11 05:16:24 UTC

[GitHub] [superset] zhaoyongjie commented on a change in pull request #12401: feat(explore): add tooltip to timepicker label

zhaoyongjie commented on a change in pull request #12401:
URL: https://github.com/apache/superset/pull/12401#discussion_r554736341



##########
File path: superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterControl.tsx
##########
@@ -181,27 +182,42 @@ export default function DateFilterControl(props: DateFilterLabelProps) {
   const [timeRangeValue, setTimeRangeValue] = useState(value);
   const [validTimeRange, setValidTimeRange] = useState<boolean>(false);
   const [evalResponse, setEvalResponse] = useState<string>(value);
+  const [tooltipTitle, setTooltipTitle] = useState<string>(value);
 
   useEffect(() => {
-    const valueToLower = value.toLowerCase();
-    if (
-      valueToLower.startsWith('last') ||
-      valueToLower.startsWith('next') ||
-      valueToLower.startsWith('previous')
-    ) {
-      setActualTimeRange(value);
-      setValidTimeRange(true);
-    } else {
-      fetchTimeRange(value, endpoints).then(({ value, error }) => {
-        if (error) {
-          setEvalResponse(error || '');
-          setValidTimeRange(false);
+    fetchTimeRange(value, endpoints).then(({ value: actualRange, error }) => {
+      if (error) {
+        setEvalResponse(error || '');
+        setValidTimeRange(false);
+        setTooltipTitle(value || '');
+      } else {
+        /*
+          HRT == human readable text
+          ADR == actual datetime range
+          +--------------+------+----------+--------+----------+-----------+
+          |              | Last | Previous | Custom | Advanced | No Filter |
+          +--------------+------+----------+--------+----------+-----------+
+          | control pill | HRT  | HRT      | ADR    | ADR      |   ADR     |
+          +--------------+------+----------+--------+----------+-----------+
+          | tooltip      | ADR  | ADR      | HRT    | HRT      |   HRT     |
+          +--------------+------+----------+--------+----------+-----------+
+        */
+        const valueToLower = value.toLowerCase();
+        if (
+          valueToLower.startsWith('last') ||
+          valueToLower.startsWith('next') ||
+          valueToLower.startsWith('previous')
+        ) {
+          setActualTimeRange(value);
+          setValidTimeRange(true);

Review comment:
       Thanks for your reminder. I have changed




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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org