ashb commented on a change in pull request #18675:
URL: https://github.com/apache/airflow/pull/18675#discussion_r745491511



##########
File path: airflow/www/static/js/tree/InstanceTooltip.jsx
##########
@@ -0,0 +1,145 @@
+/*!
+ * 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.
+ */
+
+/* global moment */
+
+import React from 'react';
+import { Box, Text } from '@chakra-ui/react';
+
+import { formatDateTime } from '../datetime_utils';
+import { getDuration, formatDuration } from './utils';
+
+const InstanceTooltip = ({
+  group,
+  instance: {
+    duration, operator, startDate, endDate, state, taskId, runId,
+  },
+}) => {
+  const isGroup = !!group.children;
+  const groupSummary = [];
+
+  if (isGroup) {
+    const numMap = new Map([
+      ['success', 0],
+      ['failed', 0],
+      ['upstream_failed', 0],
+      ['up_for_retry', 0],
+      ['up_for_reschedule', 0],
+      ['running', 0],
+      ['deferred', 0],
+      ['queued', 0],
+      ['scheduled', 0],
+      ['skipped', 0],
+      ['no_status', 0],
+    ]);

Review comment:
       We need "sensing" in this list I think -- or to decide that 2.3 is where 
we are going to remove the experimental SmartSensor feature.

##########
File path: airflow/www/static/js/tree/utils.js
##########
@@ -0,0 +1,31 @@
+/*!
+ * 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.
+ */
+
+/* global moment */
+
+// moment will resolve the enddate to now if it is undefined
+export const getDuration = (startDate, endDate) => (
+  moment(endDate || undefined).diff(startDate || undefined)
+);
+
+export const formatDuration = (duration) => {
+  const days = moment.duration(duration).days();
+  // .as('milliseconds') is necessary for .format() to work correctly
+  return `${days > 0 ? `${days}d` : 
''}${moment.utc(moment.duration(duration).as('milliseconds')).format('HH:mm:ss')}`;
+};

Review comment:
       Rather than a new generic `utils.js` file (which I worry will end up an 
unstructured dumping ground) these Duration functions would be equally at home 
in the existing `datetime_utls` I think.

##########
File path: airflow/www/static/js/tree/utils.js
##########
@@ -0,0 +1,31 @@
+/*!
+ * 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.
+ */
+
+/* global moment */
+
+// moment will resolve the enddate to now if it is undefined
+export const getDuration = (startDate, endDate) => (
+  moment(endDate || undefined).diff(startDate || undefined)
+);
+
+export const formatDuration = (duration) => {
+  const days = moment.duration(duration).days();
+  // .as('milliseconds') is necessary for .format() to work correctly
+  return `${days > 0 ? `${days}d` : 
''}${moment.utc(moment.duration(duration).as('milliseconds')).format('HH:mm:ss')}`;

Review comment:
       No need to call `moment.duration()` twice.
   
   ```suggestion
     duration = moment.duration(duration)
     const days = duration.days();
     // .as('milliseconds') is necessary for .format() to work correctly
     return `${days > 0 ? `${days}d` : 
''}${moment.utc(duration.as('milliseconds')).format('HH:mm:ss')}`;
   ```

##########
File path: airflow/www/templates/airflow/tree.html
##########
@@ -66,12 +54,7 @@
     </div>
   </div>
   <div class="legend-row">
-    <div>
-      {% for op in operators %}<span class="legend-item 
legend-item--no-border">
-        <span class="legend-item__swatch legend-item__swatch--circle" 
style="background: {{ op.ui_color }};"></span>
-        {{ op.task_type }}
-      </span>{% endfor %}
-    </div>
+    <div></div>

Review comment:
       What's this empty div needed for in the HTML?




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to