Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: convert exploreresultsbutton from class component to functional component #17987

Closed
wants to merge 3 commits into from
Closed

refactor: convert exploreresultsbutton from class component to functional component #17987

wants to merge 3 commits into from

Conversation

jcahela
Copy link
Contributor

@jcahela jcahela commented Jan 10, 2022

SUMMARY

I converted the ExploreResultsButton from class component to functional component.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@lyndsiWilliams lyndsiWilliams added the Superset-Community-Partners Preset community partner program participants label Jan 10, 2022
Copy link
Member

@lyndsiWilliams lyndsiWilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few changes needed here, let me know if you have any questions! 😁

@@ -60,57 +52,55 @@ class ExploreResultsButton extends React.PureComponent {
return [];
}

getQueryDuration() {
function getQueryDuration() {
Copy link
Member

@lyndsiWilliams lyndsiWilliams Jan 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert all of your functions to arrow functions (I'll mark the others with comments)

.asSeconds();
}

getInvalidColumns() {
function getInvalidColumns() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert this to an arrow function.

.map(col => col.name)
.filter(col => re1.test(col) || re2.test(col));
}

datasourceName() {
const { query } = this.props;
function datasourceName() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert this to an arrow function.

}
return datasourceName;
}

buildVizOptions() {
const { schema, sql, dbId, templateParams } = this.props.query;
function buildVizOptions() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert this to an arrow function.

Also - GH actions says that this function is defined but never used. If you come across any unused functions like this, please remove them.

};
}

renderTimeoutWarning() {
function renderTimeoutWarning() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert this to an arrow function.

Also - GH actions says that this function is defined but never used. If you come across any unused functions like this, please remove them.

</>
);
}
const allowsSubquery = props.database && props.database.allows_subquery;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const allowsSubquery = props.database && props.database.allows_subquery;
const allowsSubquery = props.database?.allows_subquery;

Nit: This code can be cleaned with optional chaining.

onClick={props.onClick}
disabled={!allowsSubquery}
tooltip={t(
'Explore the result set in the data exploration viewwwwwwwwwwwwww',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Explore the result set in the data exploration viewwwwwwwwwwwwww',
'Explore the result set in the data exploration view',

placement="top"
label="explore"
/>{' '}
{t('Jason')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{t('Jason')}
{t('Explore')}

getColumns() {
const { props } = this;
function ExploreResultsButton(props) {
function getColumns() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert this to an arrow function.


getColumns() {
const { props } = this;
function ExploreResultsButton(props) {
Copy link
Member

@lyndsiWilliams lyndsiWilliams Jan 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert this to an arrow function.

Copy link
Member

@AAfghahi AAfghahi Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the others I completely agree with, but I think that this, being the functional component itself, does not need to be an arrow function.

You need to destructure props here, you can do that by console logging the props and writing them out individually, its more explicit.

Copy link
Member

@geido geido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jcahela thanks for contributing! In addition to what Lyndsi suggested here, I think it would be great to convert it to typescript as well. Let me know if you'd like to do it in this PR or another. I am happy to help you with that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Superset-Community-Partners Preset community partner program participants
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants