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

Auth Button now shows re-authenticate when it has been authenticated once #15615

Merged
merged 13 commits into from
Aug 31, 2022

Conversation

krishnaglick
Copy link
Contributor

@krishnaglick krishnaglick commented Aug 12, 2022

Resolves #14226

@krishnaglick krishnaglick requested a review from a team as a code owner August 12, 2022 17:01
@github-actions github-actions bot added area/platform issues related to the platform area/frontend Related to the Airbyte webapp labels Aug 12, 2022
};

const { run, loading, done } = useRunOauthFlow(connector, onDone);
const connectionObjectEmpty = !!Object.keys((values?.connectionConfiguration as object) ?? {}).length;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't that simply check if there is any configuration parameter set, i.e. this could be also any other parameter of the form being set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screen Shot 2022-08-12 at 1 37 59 PM
The oauth interfaces that I interacted with were all like this, so it seemed a safe call. If that's not the case than this may be a good bit more complicated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid calling functions and allocating empty objects unecessarily just to get a length of 0/

Suggested change
const connectionObjectEmpty = !!Object.keys((values?.connectionConfiguration as object) ?? {}).length;
const connectionObjectEmpty = !values?.connectionConfiguration ?? Object.keys(values?.connectionConfiguration as object).length > 0;

@timroes
Copy link
Contributor

timroes commented Aug 12, 2022

I think the original issue talks about the text on the button not the success message? The Authentication button at the moment states "Reauthenticate ..." when you already authenticated. This doesn't seem to be addressed by this PR.

@krishnaglick
Copy link
Contributor Author

I think the original issue talks about the text on the button not the success message? The Authentication button at the moment states "Reauthenticate ..." when you already authenticated. This doesn't seem to be addressed by this PR.

Previously it would always show Authenticate your {connector} account even if you were authenticated. This is the correct behavior based on my reading of the ticket.

@timroes
Copy link
Contributor

timroes commented Aug 12, 2022

@edmundito maybe you could clarify here since you wrote the issue?

@edmundito
Copy link
Contributor

I tested this and it may have fixed some other problem, but what's in the issue can be reproduced:

  1. New Source -> Maichimp
  2. Select OAuth
  3. Authenticate - The button should say "Re-authenticate" afterwards and it does
  4. Select some other method
  5. Switch back to Oauth - The button should say "Re-authenticate" but it does not
  6. Save source - it saves!
  7. Go to the source settings - The button should say "Re-authenticate" but it does not

@edmundito
Copy link
Contributor

Also tested Google Sheets, which seems to have its own custom button:
image

@krishnaglick krishnaglick requested a review from edmundito August 26, 2022 19:57
@krishnaglick
Copy link
Contributor Author

@edmundito Should be fixed! Also can you clarify with Tim about the messaging? I believe this ticket doesn't require any special messaging and should be fine as-is.

};

const { run, loading, done } = useRunOauthFlow(connector, onDone);
const connectionObjectEmpty =
values?.connectionConfiguration?.credentials ?? values?.connectionConfiguration
? Object.keys(values.connectionConfiguration?.credentials ?? values.connectionConfiguration).length <= 1
Copy link
Contributor

Choose a reason for hiding this comment

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

values.connectionConfiguration is the object in the Formik form values that contains all the configuration of the connector, meaning that it may return an incorrect values if the user fills out all the fields except oauth because it would mean that values.connectionConfiguration > 1, therefore not empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed a change that catches this. This is such a complex workflow!

Copy link
Contributor

@edmundito edmundito left a comment

Choose a reason for hiding this comment

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

Code looks good. Tested create new connector (mailchimp and google sheets), and the settings.

@krishnaglick krishnaglick merged commit 4cec0ba into master Aug 31, 2022
@krishnaglick krishnaglick deleted the kc/auth-button-better-persistence branch August 31, 2022 20:42
robbinhan pushed a commit to robbinhan/airbyte that referenced this pull request Sep 29, 2022
…once (airbytehq#15615)

* Auth Button now knows if the connection object is full or empty, and shows the expected value.

* Some types, better oauth finished calculation

* values => preparedValues

* Fixing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp area/platform issues related to the platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After OAuth in connector and switching to a different auth method and back, user is asked to OAuth again
3 participants