You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/01/28 18:41:19 UTC

[GitHub] [airflow] XD-DENG commented on a change in pull request #13957: Use template strings for string concatenation in JS code in dags.html

XD-DENG commented on a change in pull request #13957:
URL: https://github.com/apache/airflow/pull/13957#discussion_r566324130



##########
File path: airflow/www/templates/airflow/dags.html
##########
@@ -401,15 +401,15 @@ <h2>DAGs</h2>
         .attr('transform', function(d, i) {
           x = (i * (diameter + circle_margin)) + (diameter/2 + circle_margin);
           y = (diameter/2) + stroke_width_hover;
-          return 'translate(' + x + ',' + y + ')';
+          return `translate(${x},${y})`;
         });
 
       g.append('svg:a')
         .attr('href', function(d) {
-          return '{{ url_for('DagRunModelView.list') }}?_flt_3_dag_id=' + dag_id + '&_flt_3_state=' + d.state;
+          return `{{ url_for('DagRunModelView.list') }}?_flt_3_dag_id=${dag_id}&_flt_3_state=${d.state}`;
         })
       .append('circle')
-        .attr('id', function(d) {return 'run-' + dag_id.replace(/\./g, '_') + d.state || 'none'})

Review comment:
       This is the bug I'm referring to. 
   
   Sample code:
   ```javascript
   'a-' + null || 'none'
   ```
   
   This gives us `a-null`, while we actually expect `a-none`. So this should be
   ```javascript
   'a-' + (null || 'none')
   ```
   
   But of course this is fixed if we use template string for this.




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