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

feat: handle connected services in the admin panel #3329

Merged
merged 13 commits into from
Oct 3, 2024

Conversation

lorenzo-cavazzi
Copy link
Member

@lorenzo-cavazzi lorenzo-cavazzi commented Sep 25, 2024

Handle connected services in the admin panel.

image

/deploy

@RenkuBot
Copy link
Contributor

You can access the deployment of this PR at https://renku-ci-ui-3329.dev.renku.ch

Copy link
Member

@leafty leafty left a comment

Choose a reason for hiding this comment

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

Some comments about the API.

client/src/features/admin/AddConnectedServiceButton.tsx Outdated Show resolved Hide resolved
client/src/features/admin/AddConnectedServiceButton.tsx Outdated Show resolved Hide resolved
client/src/features/admin/AddConnectedServiceButton.tsx Outdated Show resolved Hide resolved
@lorenzo-cavazzi
Copy link
Member Author

@leafty Thank you for the early review. I incorporated your suggestions and finished the PR.

P.S. Sorry for rebasing; I changed the target branch to main and the history was 😵‍💫

client/src/features/admin/AddConnectedServiceButton.tsx Outdated Show resolved Hide resolved
client/src/features/admin/ConnectedServicesSection.tsx Outdated Show resolved Hide resolved
Copy link
Member

@leafty leafty Sep 30, 2024

Choose a reason for hiding this comment

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

The update form does not work for the client secret. If the value is not changed, then do not send the field to the API. Also, do not populate the value with redacted.

Note that this is a blocker for the PR. We cannot have admins break connected services by just updating the display name for example.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 1aef2c3

* Add provider button text
* Connected serivces page button color
* italics text
@lorenzo-cavazzi
Copy link
Member Author

@leafty Thank you for the review. I applied your suggestions and fixed the problem with the client secret

Copy link
Member

@leafty leafty 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, there is one change to do, see below:

Comment on lines 113 to 118
useEffect(() => {
if (!result.isSuccess) {
return;
}
toggle();
}, [result.isSuccess, toggle]);
Copy link
Member

Choose a reason for hiding this comment

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

You should also reset the form here. Otherwise the client secret field is still populated when opening the form again.

Copy link
Member Author

Choose a reason for hiding this comment

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

That shouldn't be necessary. After adding a new service, this invokes toggle() so that the other useEffect will trigger and invoke result.reset(). I tried a few combinations to test this.

I can still add a reset here to be safe if you think there are cases that I might be missing.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, add a form reset() in the useEffect() just below then 😄 . The result.reset() is for RTK Query. You also need to reset the form at the same time when you do a result.reset() in almost all cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh sorry, I wrote result.reset() but I meant reset() from the other useEffect. When you open the new modal, the previous client_secret isn't there.

Anyway, adding a reset() here still makes the code more readable (and it makes sense to reset immediately after the successful action) so I added it in d640d83.

control={control}
name="client_secret"
render={({ field }) => (
<Input
Copy link
Member

Choose a reason for hiding this comment

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

Also, this field could be of type password with the button to toggle it to text like we have for some other hidden values. You can push that to a new issue if you like.

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense; I was undecided whether to use text or password here, but since you also mentioned this I'll switch to password -- no need for another PR 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in ae36898

@lorenzo-cavazzi
Copy link
Member Author

lorenzo-cavazzi commented Oct 3, 2024

@leafty I implemented your second batch of suggestions; thanks for taking the time to go through the PR again. That helps in reducing the follow-up fixes/improvements :D

I noticed that IDs with spaces are accepted, but editing/deleting those services triggers errors. Any idea what could be wrong?
P.S: I added a disabled input to show the ID in the "update" modal.

Screenshot_20241003_111127

@leafty
Copy link
Member

leafty commented Oct 3, 2024

I noticed that IDs with spaces are accepted, but editing/deleting those services triggers errors. Any idea what could be wrong? P.S: I added a disabled input to show the ID in the "update" modal.

This is a bug with the backend, I will have to fix it.

Copy link
Member

@leafty leafty left a comment

Choose a reason for hiding this comment

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

LGTM Thanks

@lorenzo-cavazzi lorenzo-cavazzi merged commit 910491f into main Oct 3, 2024
18 checks passed
@lorenzo-cavazzi lorenzo-cavazzi deleted the lorenzo/git-auth-flow-admin branch October 3, 2024 09:38
@RenkuBot
Copy link
Contributor

RenkuBot commented Oct 3, 2024

Tearing down the temporary RenkuLab deplyoment for this PR.

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.

3 participants