Skip to content

[public-api] Add Delete, Regenerate, and Update PAT UI #14936

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
Nov 25, 2022
Merged

Conversation

mustard-mh
Copy link
Contributor

@mustard-mh mustard-mh commented Nov 24, 2022

Description

Add delete, regenerate and edit UI

(edit not implemented yet)

Related Issue(s)

Fixes #14618
Fixes #14616
Relates #14612

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

Screenshot

Delete Edit
image image
Regenerate Result
image image

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-ide-public-api.1 because the annotations in the pull request description changed
(with .werft/ from main)

@roboquat roboquat added size/XL and removed size/XS labels Nov 24, 2022
@jeanp413 jeanp413 changed the title WIP: [apt] ui [public-api] Add Delete, Regenerate, and Update PAT UI Nov 24, 2022
@jeanp413 jeanp413 marked this pull request as ready for review November 24, 2022 21:14
@jeanp413 jeanp413 requested a review from a team November 24, 2022 21:14
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Nov 24, 2022
@easyCZ
Copy link
Member

easyCZ commented Nov 24, 2022

The API implementation of the Update is here

When we're editing a token, I believe we should not be able to update the Expiration. The expiration is tied to the token value and the only way to extend the expiration should be generate a new one. What do you think?

@mustard-mh
Copy link
Contributor Author

The API implementation of the Update is here

When we're editing a token, I believe we should not be able to update the Expiration. The expiration is tied to the token value and the only way to extend the expiration should be generate a new one. What do you think?

Make sense, will change it to update name and scope (not) only

case nameField:
name, err := validatePersonalAccessTokenName(tokenReq.GetName())
if err != nil {
return nil, err
}
updateOpts.Name = &name
case scopesField:
scopes, err := validateScopes(tokenReq.GetScopes())
if err != nil {
return nil, err
}
dbScopes := db.Scopes(scopes)
updateOpts.Scopes = &dbScopes
}

Co-authored-by: Huiwen <mhqnwt@gmail.com>
@mustard-mh
Copy link
Contributor Author

mustard-mh commented Nov 25, 2022

Updated:

  • Call server update method
  • Remove expirationDate field for token update
  • Add expirationDate in regenerate modal since it's removed above. cc @gtsiolis

image

Copy link
Member

@easyCZ easyCZ left a comment

Choose a reason for hiding this comment

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

LGTM

We can do follow-up in subsequent PRs also.

Comment on lines +250 to +264
<select
name="expiration"
value={value.expirationDays}
onChange={(e) => {
update({ expirationDays: Number(e.target.value) });
}}
>
<option value="30">30 Days</option>
<option value="90">90 Days</option>
<option value="180">180 Days</option>
</select>
<p className="text-gray-500 dark:text-gray-400 mt-2">
The token will expire on{" "}
{Intl.DateTimeFormat("en-US", { dateStyle: "long" }).format(value.expirationDate)}.
</p>
Copy link
Member

Choose a reason for hiding this comment

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

We've got the select duplicated in 2 views, any way to consolidate?

name: value.name,
scopes: ["function:*", "resource:default"],
},
updateMask: { paths: ["name", "scopes"] },
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to determine what's changed, to properly apply the update mask? Or do we just update all? There is a potential risk to two simultaneous requests performing an update but given these are Personal Tokens, we can probably keep it this way.

@roboquat roboquat merged commit 3e2d7dd into main Nov 25, 2022
@roboquat roboquat deleted the ide/public-api branch November 25, 2022 10:07
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Nov 25, 2022
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/XL team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement delete token UI Implement token regeneration UI
4 participants