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 2022/03/02 14:16:18 UTC

[GitHub] [superset] cccs-Dustin commented on a change in pull request #18951: fix(SQL Editor): names new query tabs correctly

cccs-Dustin commented on a change in pull request #18951:
URL: https://github.com/apache/superset/pull/18951#discussion_r817731707



##########
File path: superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx
##########
@@ -260,8 +256,31 @@ class TabbedSqlEditors extends React.PureComponent {
       : t(
           '-- Note: Unless you save your query, these tabs will NOT persist if you clear your cookies or change browsers.\n\n',
         );
+
+    let newTitle;
+
+    if (this.props.queryEditors.length > 0) {
+      const untitledQueryNumbers = this.props.queryEditors
+        .filter(x => x.title.includes('Untitled Query '))
+        .map(x => x.title.replace('Untitled Query ', ''))
+        .filter(x => !Number.isNaN(Number(x)));
+      if (untitledQueryNumbers.length > 0) {
+        // When there are query tabs open, and at least one is called "Untitled Query #"
+        // Where # is a valid number
+        const largestNumber = Math.max.apply(null, untitledQueryNumbers);
+        newTitle = t('Untitled Query %s', largestNumber + 1);
+      } else {
+        // When there are query tabs open but none of them are called "Untitled Query #"
+        // Where # is a valid number
+        newTitle = 'Untitled Query 1';
+      }
+    } else {
+      // When there are no query tabs currently open
+      newTitle = 'Untitled Query 1';
+    }

Review comment:
       That is a great idea! I have added this modification to the newest commit :)




-- 
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: notifications-unsubscribe@superset.apache.org

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