cccs-Dustin opened a new pull request #18951:
URL: https://github.com/apache/superset/pull/18951


   <!---
   Please write the PR title following the conventions at 
https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   The reason why the bug (view attached issue) occurred in the first place was 
because there was a local variable within the TabbedSqlEditors component called 
"queryCount". Whenever the component was reloaded/re-rendered, it caused this 
local variable to reset to it's default integer value of: '1'. Since this 
variable is reset to 1, the naming of the new query tabs would not work as 
intended.
   
   To fix this issue, I decided to use a more dynamic method of naming the new 
query tabs:
   - If there are no currently open query tabs, create the new one with a name 
of: "Untitled Query 1"
   - If there are currently open query tabs, but none of them are named 
"Untitled Query #" (Where # is a valid integer value), the new query tab will 
be named: "Untitled Query 1"
   - If there are currently open query tabs and one or more of them are named 
"Untitled Query #" (Where # is a valid integer value), parse the untitled query 
names so that you are left with a list of all of the numbers. Select the 
highest number, and add one to it. The new query tab will have the name: 
"Untitled Query #" (Where # is a valid integer value, and is +1 of the previous 
largest untitled query number)
   
   By using this more dynamic method of naming new query tabs, it allows us to 
avoid creating and maintaining unnecessary state. It also fixes the issue where 
there never used to be an "Untitled Query 1".
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   Before: 
   (the far right tab was created by selecting the "SQL query" button from the 
“+“ icon drop down on the top right of the web page beside the settings drop 
down)
   
   ![After SQL query 
button](https://user-images.githubusercontent.com/96579982/155753292-7cdcf32b-0caa-4bbb-9807-77c8364c403a.PNG)
   
   After:
   (The query tabs were created using a combination of the two add query 
buttons, this image shows that the naming now works correctly regardless of 
which way you decide to create a new query tab)
   
   ![After SQL query button - with 
fix](https://user-images.githubusercontent.com/96579982/155753255-bfd05206-d662-4350-bfc8-1a798f439997.PNG)
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   1. Go to the SQL Editor page by selecting it from the main menu under the 
"SQL Lab" drop down.
   2. Click on the "+" button next to the list of query tabs, it should 
properly increment the query tab names.
   3. Select the “+“ icon on the top right of the web page beside the settings 
drop down, and then click "SQL query".
   4. With the new code modifications, this second method of creating a query 
tab should also properly increment the query tab names.
   
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: https://github.com/apache/superset/issues/18949
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to