Skip to content

Web: Redo locking feature#25305

Merged
kimlisa merged 2 commits intomasterfrom
lisa/redo-lock-feature
May 1, 2023
Merged

Web: Redo locking feature#25305
kimlisa merged 2 commits intomasterfrom
lisa/redo-lock-feature

Conversation

@kimlisa
Copy link
Copy Markdown
Contributor

@kimlisa kimlisa commented Apr 28, 2023

part of #25168
enterprise PR: https://github.com/gravitational/teleport.e/pull/1237

recommend reviewing by commit (i plan to delete the old locks code after review)

it was hard to work with one size fit all data structure for the different types of resources especially when there are three types of pagination being used, so decided to re-do and have everything have its own table

design and ux is copied from access requests

in addition

  • i didn't agree with supplying a manual add input box for every resource (especially when you can now use the search bar) so it only shows up for logins
  • i copied the table display/formatting from other places, figured we can decide later what to customize if we want to
  • add access checking, will not render lock tab if user doesn't have lock.list perm and does not render new lock screen if they don't have lock.create and lock.update perm
  • add confirmation dialogue when user is deleting locks
  • ** since we create a lock per resource select (this was how it worked before and figured it was okay), there's no guarantee that all will succeed in a row, so we allow user to re-attempt the failed ones
  • supports all pagination types until we come up with another one ;;

Improvements for later:

  • writing test and stories
  • deduplicate code (shares similarities with access request)
  • some cells are not aligned perfectly to center (you can tell on smaller screen with access requests)
  • ** it looks like you can make batch lock request (as long the target keys are unique), like for example, locking one user and one device can be batched into one lock request. Locking two user has to be separate requests. Not sure if we wanted to support batching for less trip to back, but left it alone for another time.

Demo (using a smaller page size to demonstrate paginating):

Screen.Recording.2023-04-27.at.7.04.24.PM.mov

@public-teleport-github-review-bot
Copy link
Copy Markdown

@kimlisa - this PR will require admin approval to merge due to its size. Consider breaking it up into a series smaller changes.

@kimlisa kimlisa requested review from avatus and rudream and removed request for ibeckermayer and ravicious April 28, 2023 02:44
@kimlisa
Copy link
Copy Markdown
Contributor Author

kimlisa commented Apr 28, 2023

@rudream @avatus i would really appreciate it if ya'll can help me try to break this feature 🙏

@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented Apr 28, 2023

add access checking, will not render lock tab if user doesn't have lock.list perm and does not render new lock screen if they don't have lock.create and lock.update perm

We want to get away from this pattern of completely hiding parts of Teleport, because it prevents people from learning that these features exist.

For now it's fine, but we should start to prefer to always show the tabs and just indicate that the user doesn't have access.

Copy link
Copy Markdown
Contributor

@avatus avatus left a comment

Choose a reason for hiding this comment

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

Looks and feels really good to use now. I left some UI comments but more of a discussion rather than suggested changes. Feel free to push back/ignore them all.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think request is good language here but I'm not 100% sold on my suggestion. Best I could come up with.

Suggested change
+ Add to request
+ Add Target

If we use the language from the above comments like "Lock Request" then we can just keep this as is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Proceed to Lock? Proceed to Lock Request? Feel free to skip

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Text bold>Resources Added ({numAddedResources})</Text>
<Text bold>Targets Added ({numAddedResources})</Text>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Submit Request
Create Locks

I think it makes sense here to say Create Locks even if used in the button to open this dialog

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{locks.length} {pluralize(locks.length, 'Resource')} Selected
{locks.length} {pluralize(locks.length, 'Target')} Added

Again, not 100% sold here as you are selecting resources TO lock so you can skip this one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Back to Locks?

Comment on lines 42 to 44
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Listing logins are not supported. Use the input box below to manually
define a login to lock. <br />
Double check the spelling before adding.
Listing logins is not supported. Use the input box below to manually
define a login to lock. <br />
Double check the spelling before adding.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Box>New Request</Box>
<Box>New Lock Request</Box>

Comment thread lib/web/ui/lock.go Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this just call MakeLock in a loop rather than repeating the same code?

Comment thread lib/web/ui/usercontext.go Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Lock access `json:"lock"`
Locks access `json:"lock"`

Most of these fields are plural.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Missing license on a lot of these new files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// to define the type of lock to be locked.
// to define the type of resource to be locked.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This bit us in the past, right? It's not always a name.

Also, I'm fine with this as-is for simplicity, but note that the data model for the frontend doesn't match the backend now. On the backend, a lock target can have multiple different resources (so long as they are different types).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This bit us in the past, right? It's not always a name.

i think this only applies to mapping backend with frontend fields, which isn't the case here. this type is only for frontend use. in the api response we get a mapping of targets, it wasn't very useful in its map form so I converted it into a list of LockTarget and added it as an extra field to the frontend model. i did it in this layer so we don't have to always process it when we use it in components.

we have a lot of frontend models that don't match the backend b/c we customize it further to suit our needs. i thought it was okay to do but maybe it shouldn't be done in the service layer. @ryanclark thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return json.map(lock => makeLock(lock));
return json.map(makeLock);

@kimlisa
Copy link
Copy Markdown
Contributor Author

kimlisa commented Apr 28, 2023

add access checking, will not render lock tab if user doesn't have lock.list perm and does not render new lock screen if they don't have lock.create and lock.update perm

We want to get away from this pattern of completely hiding parts of Teleport, because it prevents people from learning that these features exist.

For now it's fine, but we should start to prefer to always show the tabs and just indicate that the user doesn't have access.

is this something recently decided? i'll double check with xin in our upcoming monday meeting, but i thought we wanted it to be possible to turn off features? There are cases where we don't want to hide things, and thought those only applied when the user at least met the minimum criteria eg. most features look for at least a list access

(i'll leave it as is for now though)

@kimlisa kimlisa requested review from avatus and zmb3 April 28, 2023 20:14
@kimlisa kimlisa force-pushed the lisa/redo-lock-feature branch 2 times, most recently from 5105601 to 43eade2 Compare April 28, 2023 20:21
Copy link
Copy Markdown
Contributor

@avatus avatus left a comment

Choose a reason for hiding this comment

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

Tested about everything I could think of.
We can update some of the test plan points later but I plan on making a few large changes to that soon anyway.

I'd love to have @rudream comb over this as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we update locks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you can

// UpsertLock upserts a lock.
(but no exposed api for the web to use atm), it's an upsert action that requires user to have both the create and update rule

Copy link
Copy Markdown
Collaborator

@zmb3 zmb3 left a comment

Choose a reason for hiding this comment

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

I was not able to break it. Thanks so much for this.

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from rudream April 28, 2023 22:37
Also reverts body `overflow: hidden`
Fixes #24885
@kimlisa kimlisa force-pushed the lisa/redo-lock-feature branch from 2981d85 to adcbf98 Compare May 1, 2023 18:29
@kimlisa kimlisa enabled auto-merge May 1, 2023 18:32
@kimlisa kimlisa added this pull request to the merge queue May 1, 2023
Merged via the queue into master with commit a0773f9 May 1, 2023
@kimlisa kimlisa deleted the lisa/redo-lock-feature branch May 1, 2023 19:03
@public-teleport-github-review-bot
Copy link
Copy Markdown

@kimlisa See the table below for backport results.

Branch Result
branch/v13 Failed

kimlisa added a commit that referenced this pull request May 1, 2023
Also reverts body `overflow: hidden`
Fixes #24885
kimlisa added a commit that referenced this pull request May 1, 2023
Also reverts body `overflow: hidden`
Fixes #24885
@r0mant r0mant mentioned this pull request Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants