refactor: Convert TableElement to TypeScript#14978
Conversation
|
/testenv up |
|
@hughhhh Container image not yet published for this PR. Please try again when build is complete. |
|
@hughhhh Ephemeral environment creation failed. Please check the Actions logs for details. |
Codecov Report
@@ Coverage Diff @@
## master #14978 +/- ##
==========================================
- Coverage 77.61% 77.45% -0.17%
==========================================
Files 965 969 +4
Lines 49503 49944 +441
Branches 6259 6423 +164
==========================================
+ Hits 38422 38682 +260
- Misses 10881 11057 +176
- Partials 200 205 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
AAfghahi
left a comment
There was a problem hiding this comment.
Looks good! Just some questions.
| }; | ||
| isActive: boolean; | ||
| key: string | number; | ||
| panelKey: string | number; |
There was a problem hiding this comment.
oh that's so weird that it can be a string or a number. Wild.
| `; | ||
|
|
||
| const TableElement = props => { | ||
| const TableElement = ({ table, actions, key, ...props }: TableElementProps) => { |
There was a problem hiding this comment.
it still bothers me that I don't know all of the props being passed in here. But I agree that this is much more elegant.
| return ( | ||
| <Collapse.Panel | ||
| {...props} | ||
| key={key} |
There was a problem hiding this comment.
What do you get when console.log key? I am looking at the old component and it looks really weird.

but key is specifically being put in.
https://github.com/apache/superset/blob/master/superset-frontend/src/SqlLab/components/SqlEditorLeftBar.jsx#L191
Also, where is this panelKey thing coming from!
| removeDataPreview: (table: Table) => void; | ||
| removeTable: (table: Table) => void; | ||
| }; | ||
| key: string | number; |
There was a problem hiding this comment.
This looks like it might just be a string? Are there places where it is used as a number? (though it is odd that it is a string, since a key should be a number. . .)
|
|
||
| renderExpandIconWithTooltip = ({ isActive }) => ( | ||
| <IconTooltip | ||
| style={{ transform: 'rotate(90deg)' }} |
There was a problem hiding this comment.
can we use the css prop here and below instead of style? It's a pattern we've been migrating to.
| ); | ||
| } | ||
| let latest = Object.entries(table.partitions?.latest || []).map( | ||
| const latest = Object.entries(table.partitions?.latest || []).map( |
There was a problem hiding this comment.
small nit, but if we're not going to use latest again, can we just define it once as
const latest = Object.entries(table.partitions?.latest || []).map(
([key, value]) => `${key}=${value}`,
).join('/');
| // These props are not defined in their TypeScript type for Panel though because | ||
| // this logic is happening in the Collapse component itself. We have gotten around the TypeScript | ||
| // errors by using the rest and spread operators to pass the necessary extra props to the Panels. | ||
|
|
There was a problem hiding this comment.
I think this comment makes sense, but the pattern below doesn't look confusing. I think it's ok to remove the comment.
There was a problem hiding this comment.
Sounds good! I am removing the comment and adding the two other changes. I will push them all up momentarily.
…ning to make more concise
|
@AAfghahi @corbinrobb would you like me to merge when this passes tests? |
|
/testenv up |
|
/testenv up |
|
Great! I'm going to do a quick visual test when the test environment spins up. |
|
@eschutho Ephemeral environment spinning up at http://52.37.150.225:8080. Credentials are |
|
@corbinrobb this looks great. I wasn't able to sort the columns in the test environment. Can you check and see if that is working for you? It should sort both ascending and descending. |
|
@eschutho Hmm, mine is working as expected. The button originally doesn't sort the columns and just displays the way the table is sent and the button toggles between alphabetical and the original. In the picture it looks like that specific table is in alphabetical order already? That is kinda weird though because I also didn't change the logic in the sort function I just shortened it using ternary operators. Does it work on any of the tables? |
|
You're right, @corbinrobb. That example didn't have anything to sort. I tested on a different list and it's working. I'll go ahead and merge. Thanks for the help on this! |
|
Whew! That's relieving, I got super worried for a moment there lol Thanks for everything! @eschutho |
|
Ephemeral environment shutdown and build artifacts deleted. |
* Convert TableElement to typescript * Change type names to better match naming conventions in other files * Fix import order and update tests on TableElement * Remove defaultProps * Destructure the props * Use Rest and Spread syntax to condense props destructuring * Fix TypeScript errors and add comment to explain antd props and types weirdness * Remove comment, add consistency with other files, and use method chaining to make more concise Co-authored-by: Corbin Robb <corbin@Corbins-MacBook-Pro.local>
* Convert TableElement to typescript * Change type names to better match naming conventions in other files * Fix import order and update tests on TableElement * Remove defaultProps * Destructure the props * Use Rest and Spread syntax to condense props destructuring * Fix TypeScript errors and add comment to explain antd props and types weirdness * Remove comment, add consistency with other files, and use method chaining to make more concise Co-authored-by: Corbin Robb <corbin@Corbins-MacBook-Pro.local>
* Convert TableElement to typescript * Change type names to better match naming conventions in other files * Fix import order and update tests on TableElement * Remove defaultProps * Destructure the props * Use Rest and Spread syntax to condense props destructuring * Fix TypeScript errors and add comment to explain antd props and types weirdness * Remove comment, add consistency with other files, and use method chaining to make more concise Co-authored-by: Corbin Robb <corbin@Corbins-MacBook-Pro.local>
* Convert TableElement to typescript * Change type names to better match naming conventions in other files * Fix import order and update tests on TableElement * Remove defaultProps * Destructure the props * Use Rest and Spread syntax to condense props destructuring * Fix TypeScript errors and add comment to explain antd props and types weirdness * Remove comment, add consistency with other files, and use method chaining to make more concise Co-authored-by: Corbin Robb <corbin@Corbins-MacBook-Pro.local>


SUMMARY
Converted TableElement to TypeScript.
Required me to move the expand icon with tooltip off the Collapse.Panel component on to the Collapse parent component where it was supposed to be. Allowed me to remove most of the inline styling in the expand icon because the styles are now being inherited correctly.
Made code more concise and readable wherever I could.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Should look and behave the same
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION