Skip to content

[pat] Token UI polish #15015

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

Merged
merged 1 commit into from
Dec 1, 2022
Merged

[pat] Token UI polish #15015

merged 1 commit into from
Dec 1, 2022

Conversation

jeanp413
Copy link
Member

@jeanp413 jeanp413 commented Nov 28, 2022

Description

Validate PAT token name

Related Issue(s)

How to test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-jp-pat-validation.1 because the annotations in the pull request description changed
(with .werft/ from main)

@roboquat roboquat added size/S and removed size/XS labels Nov 28, 2022
@jeanp413
Copy link
Member Author

jeanp413 commented Nov 28, 2022

/werft run recreate-preview=true

👍 started the job as gitpod-build-jp-pat-validation.3
(with .werft/ from main)

@jeanp413
Copy link
Member Author

jeanp413 commented Nov 30, 2022

/werft run

👍 started the job as gitpod-build-jp-pat-validation.6
(with .werft/ from main)

@roboquat roboquat added size/XXL and removed size/S labels Nov 30, 2022
@mustard-mh
Copy link
Contributor

mustard-mh commented Nov 30, 2022

/werft run recreate-preview=true

👍 started the job as gitpod-build-jp-pat-validation.8
(with .werft/ from main)

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Thanks for tackling most of the issues in #15002, @jeanp413 & @mustard-mh!

I was in the neighborhood and left some UX comments below. 🏀

Comment on lines +9 to +13
const PillClsMap: Record<PillType, string> = {
info: "bg-blue-50 text-blue-500 dark:bg-blue-500 dark:text-blue-100",
warn: "bg-orange-100 text-orange-700 dark:bg-orange-600 dark:text-orange-100",
success: "bg-green-100 text-green-700 dark:bg-green-600 dark:text-green-100",
};
Copy link
Contributor

@gtsiolis gtsiolis Nov 30, 2022

Choose a reason for hiding this comment

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

praise: Thank you for extending this component, @jeanp413 & @mustard-mh!

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually this is @mustard-mh change 😄

Copy link
Contributor

@gtsiolis gtsiolis Nov 30, 2022

Choose a reason for hiding this comment

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

I realized this a few hours after posting the comment above.

Thanks for giving credit where credit is due, @jeanp413! 🧡

token={t}
menuEntries={[
{
title: "Edit",
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Not the best line to comment this, but when you Edit a token and add or remove permissions, the expiration date changes back to today. ❗

Copy link
Contributor

Choose a reason for hiding this comment

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

It can be reproduced.

But it's weird that from the code, we don't send expirationTime, but devTools shows we have send it (maybe a default value of protobuf Timestamp)

image

And server should not update expirationDate too.

cc @easyCZ

Copy link
Member

Choose a reason for hiding this comment

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

For the fine grained update, there's a second field which you can supply - updateMask. It's a list of of the token fields which should be updated.

It may make sense to link the update form "changes" to those fields and send them to ensure its updated. I'll investigate and can look into fixing the backend, it should never send back internal error code anyway.

Copy link
Contributor

@mustard-mh mustard-mh Nov 30, 2022

Choose a reason for hiding this comment

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

updateMask has added in dashboard code, but not worked

Test failed

image

I can fix it later @easyCZ

Copy link
Member

Choose a reason for hiding this comment

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

I've added a couple of fixes to API validation and Not Found handling in the following:

That should at least give us more info about the error.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like the original migration put the on update on the wrong column. The on-update should be on set on _lastModified

Copy link
Member

Choose a reason for hiding this comment

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

Great find! I'll add a migration tomorrow.

Copy link
Member

Choose a reason for hiding this comment

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

Migration PR: #15093

Copy link
Member

Choose a reason for hiding this comment

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

The update issue, where the expiration would be reset is now fixed in staging.

Copy link
Member

Choose a reason for hiding this comment

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

The remaining issue is that a no-update returns a Not Found from the API. Tracked here #15105

@jeanp413 jeanp413 marked this pull request as ready for review November 30, 2022 20:02
@jeanp413 jeanp413 requested a review from a team November 30, 2022 20:02
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Nov 30, 2022
@mustard-mh mustard-mh changed the title [pat] Validate name [pat] Token UI polish Nov 30, 2022
@easyCZ
Copy link
Member

easyCZ commented Dec 1, 2022

Preview is broken for me, rerunning.

/werft run with-clean-slate-deployment=true

👍 started the job as gitpod-build-jp-pat-validation.18
(with .werft/ from main)

@easyCZ
Copy link
Member

easyCZ commented Dec 1, 2022

Looking good. There's a couple of minor aspects which we can follow-up on.

Screenshot 2022-12-01 at 13 26 27

Here we should drop the `Personal` keywords, to be consistent with other places.

Screenshot 2022-12-01 at 13 26 35

here also

Screenshot 2022-12-01 at 13 28 11

The expiration icon should have a tooltip to explain why it's there

@easyCZ
Copy link
Member

easyCZ commented Dec 1, 2022

Scopes updating also works as expected

@easyCZ
Copy link
Member

easyCZ commented Dec 1, 2022

I'm going to approve the PR, and I'll track/put up PRs for the small bits from this PR. Thanks a lot for the improvements, this is awesome to see materialize.

@roboquat roboquat merged commit 77c68c7 into main Dec 1, 2022
@roboquat roboquat deleted the jp/pat-validation branch December 1, 2022 12:35
@easyCZ
Copy link
Member

easyCZ commented Dec 1, 2022

The follow-up to improve the expiration time UX (tooltip) is tracked here #15103

@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Dec 2, 2022
@laushinka
Copy link
Contributor

laushinka commented Dec 5, 2022

Hi @jeanp413, sorry for the late question, but was there a reason why TokenEntry.tsx was moved into PersonalAccessTokens.tsx? Asking because the component now has quite a lot to navigate reading through, and I think we can benefit from extracting things out for readability's sake.

@gtsiolis
Copy link
Contributor

gtsiolis commented Dec 5, 2022

@laushinka I had a similar thought back in #15015 (comment).

@jeanp413
Copy link
Member Author

jeanp413 commented Dec 5, 2022

@laushinka sorry, I had it in my mind to ask you about it here in the review but then forgot about it 🤦, I moved because I created another small component only for tokens in PersonalAccessTokens.tsx that I needed to reuse in the TokenEntry.tsx too and wanted to avoid cyclic dependencies, I saw other files that coupled all related components in one file so I just followed that.

If it's preferred to have split components, I can do a follow up PR today 👍 , and if that's the case would it makes sense to group multiple files related to PAT inside a subfolder or is it Ok to add them all in settings folder?

@laushinka
Copy link
Contributor

laushinka commented Dec 5, 2022

@laushinka sorry, I had it in my mind to ask you about it here in the review but then forgot about it 🤦

@jeanp413 All good! I just did this PR. Hope that looks reasonable to you too :)

would it makes sense to group multiple files related to PAT inside a subfolder or is it Ok to add them all in settings folder?

I thought about it too, and I think it would make sense to group them all inside a subfolder as you suggest 👍🏼 I didn't do that in the PR above, but I can do a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/XXL team: webapp Issue belongs to the WebApp team
Projects
None yet
6 participants