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 2020/10/16 10:05:58 UTC

[GitHub] [incubator-superset] kgabryje commented on a change in pull request #11216: refactor: Refactor QueryTable to use react-table

kgabryje commented on a change in pull request #11216:
URL: https://github.com/apache/incubator-superset/pull/11216#discussion_r506251955



##########
File path: superset-frontend/src/SqlLab/components/QueryTable.jsx
##########
@@ -74,151 +75,162 @@ class QueryTable extends React.PureComponent {
   }
 
   render() {
-    const data = this.props.queries
-      .map(query => {
-        const q = { ...query };
-        if (q.endDttm) {
-          q.duration = fDuration(q.startDttm, q.endDttm);
-        }
-        const time = moment(q.startDttm).format().split('T');
-        q.time = (
-          <div>
-            <span>
-              {time[0]} <br /> {time[1]}
-            </span>
-          </div>
-        );
-        q.user = (
-          <Button
-            buttonSize="small"
-            buttonStyle="link"
-            onClick={this.props.onUserClicked.bind(this, q.userId)}
-          >
-            {q.user}
-          </Button>
-        );
-        q.db = (
-          <Button
-            buttonSize="small"
-            buttonStyle="link"
-            onClick={this.props.onDbClicked.bind(this, q.dbId)}
-          >
-            {q.db}
-          </Button>
-        );
-        q.started = moment(q.startDttm).format('HH:mm:ss');
-        q.querylink = (
-          <div style={{ width: '100px' }}>
+    const data = memoize(() =>

Review comment:
       I refactored it into functional component

##########
File path: superset-frontend/src/SqlLab/components/QueryTable.jsx
##########
@@ -74,151 +75,162 @@ class QueryTable extends React.PureComponent {
   }
 
   render() {
-    const data = this.props.queries
-      .map(query => {
-        const q = { ...query };
-        if (q.endDttm) {
-          q.duration = fDuration(q.startDttm, q.endDttm);
-        }
-        const time = moment(q.startDttm).format().split('T');
-        q.time = (
-          <div>
-            <span>
-              {time[0]} <br /> {time[1]}
-            </span>
-          </div>
-        );
-        q.user = (
-          <Button
-            buttonSize="small"
-            buttonStyle="link"
-            onClick={this.props.onUserClicked.bind(this, q.userId)}
-          >
-            {q.user}
-          </Button>
-        );
-        q.db = (
-          <Button
-            buttonSize="small"
-            buttonStyle="link"
-            onClick={this.props.onDbClicked.bind(this, q.dbId)}
-          >
-            {q.db}
-          </Button>
-        );
-        q.started = moment(q.startDttm).format('HH:mm:ss');
-        q.querylink = (
-          <div style={{ width: '100px' }}>
+    const data = memoize(() =>

Review comment:
       I refactored it into functional component. Feels better




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