Skip to content

Conversation

Anemy
Copy link
Member

@Anemy Anemy commented Jan 23, 2022

COMPASS-5435

This adds auth inputs for the Username/Password authentication tab.
Drive by cleanup - removed the directConnection setting handler and made the toggle use the general search param one we've added.
How do y'all feel on the behavior around setting a username empty or setting a password when there's no username?

Here's how it looks:

authentication.inputs.mp4

(event: React.ChangeEvent<HTMLInputElement>) => {
event.preventDefault();
updateConnectionFormField({
type: 'update-search-param',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Currently this action also sets empty values, ie. it would set &authMechanism=& for a null value, could we also add updatedSearchParams.delete(action.currentKey); in case the value is empty here https://github.com/mongodb-js/compass/blob/main/packages/connect-form/src/hooks/use-connect-form.ts#L386-L393?

Copy link
Member Author

Choose a reason for hiding this comment

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

I see how that helper could be useful here, but I think we want to allow empty values to be set since we use this in the advanced tab to help populate the advanced options. In that case setting something to empty is useful as part of the process of entering those options:
Screen Shot 2022-01-24 at 1 43 41 PM

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure that is so useful though, there is no search param that makes sense as empty, and I don't know why someone would prefer to populate the value in the connection string rather than in the form after they selected the key there. I believe is a good feature if we produce a cleaner connection string without random empty search params.

Do you have an alternative to at least delete authMechanism and the other params if they are empty?

Copy link
Member Author

@Anemy Anemy Jan 24, 2022

Choose a reason for hiding this comment

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

On this page the authMechanism will always be set since it's a radio with 3 options and unsetting isn't one.
Yup we can use the delete-search-param action.
I see what you mean. I'm cool with either in that case, could be nice to have that logic in the update search param handler, but we'll have to update the uri options component to keep a bit of state. Not sure this is the pr for that change.

errors: ConnectionFormError[];
updateConnectionFormField: UpdateConnectionFormField;
}): React.ReactElement {
const password = connectionStringUrl.password;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this relevant here? https://jira.mongodb.org/browse/COMPASS-5097

can we at least add a test or 2 with the weird password there?

Copy link
Member Author

@Anemy Anemy Jan 24, 2022

Choose a reason for hiding this comment

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

Could we do that work when we do that ticket? This work is definitely related, but since we have a ticket for it, that might be a better place to make a pr, test all of the cases and make those changes.
Moved it into this sprint, can pickup after this is merged.

@Anemy Anemy merged commit ff5e430 into main Jan 24, 2022
@Anemy Anemy deleted the COMPASS-5435-add-username-password-auth branch January 24, 2022 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants