-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Web: implement requesting for kube namespace selector #47345
Conversation
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
768b594
to
3140a5c
Compare
Haven't looked at all the code yet. In general, its SUPER slick and nice. a couple comments of UX and couple questions.
dad8591a20128f4aba5409885d630d8a.mp4
is this because of the flicker or is this one of the wonky things you're talking about in the react-select? |
3140a5c
to
a7f49c2
Compare
namespaces are resources and is behaving the same as if you were to add/remove resources to the checklist.
good catch, this is currently not supported when kube resources are present, and should be handled in another PR
i might be misunderstanding, but the flicker has always been there? (it's the dry run + get resource role attempt per added resource change) i think it's fine to reload again, if the user for some reason wants to change the namespace again. before the adhoc method, it was calling this api unnecessarily few times per selector on renders (and the user may not even want to select a namespace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leaving a small comment about excludeKubeClusterWithNamespaces
that I had when reviewing #47347.
web/packages/shared/components/AccessRequests/NewRequest/kube.ts
Outdated
Show resolved
Hide resolved
web/packages/shared/components/AccessRequests/NewRequest/RequestCheckout/RequestCheckout.tsx
Outdated
Show resolved
Hide resolved
web/packages/shared/components/AccessRequests/NewRequest/RequestCheckout/RequestCheckout.tsx
Outdated
Show resolved
Hide resolved
web/packages/shared/components/AccessRequests/NewRequest/RequestCheckout/RequestCheckout.tsx
Outdated
Show resolved
Hide resolved
web/packages/shared/components/AccessRequests/NewRequest/RequestCheckout/RequestCheckout.tsx
Outdated
Show resolved
Hide resolved
{hasUnsupportedKubeRequestModes && ( | ||
<Alert kind="danger"> | ||
You can only request Kubernetes resource kind{' '} | ||
{unsupportedKubeRequestModes} for cluster{' '} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to get rid of those square brackets around resource kinds? How is the message going to look like if unsupportedKubeRequestModes
includes multiple kinds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'll look like this [secret pod namespace]
, opting not to change anything, since it follows error messaging in tsh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine for now, but long term I think we should strive to not leak too many CLI-specific conventions leak to GUIs. I had a similar discussion with Grzegorz recently. #47652 (comment)
I'm not sure why tsh shows the resource kinds in square brackets in the first place, but in the UI it looks kind of weird IMHO – we have much more freedom there with regards to styling when it comes showing data like this. TBH I think just a regular string would be fine here, e.g. "You can only request Kubernetes resource kinds pod and secret", where "resource kinds" gets pluralized depending on the count and the array with allowed kinds uses something like Array#to_sentence
from Ruby on Rails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I keep forgetting that there's now an equivalent of Array#to_sentence
in JS. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat
const vehicles = ['Motorcycle', 'Bus', 'Car'];
const formatter = new Intl.ListFormat('en', {
style: 'long',
type: 'conjunction',
});
console.log(formatter.format(vehicles));
// Expected output: "Motorcycle, Bus, and Car"
Though I'm not sure if this is something we could use without a polyfill. caniuse.com says that it's not available at all in Safari on Macs that are not running Big Sur or better. https://caniuse.com/mdn-javascript_builtins_intl_listformat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
web/packages/shared/components/AccessRequests/NewRequest/RequestCheckout/RequestCheckout.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm submitting some misc issues I found while reviewing the teleterm PR, but I don't plan on reviewing this PR in its entirety. @rudream could you take a look at it?
...ckages/shared/components/AccessRequests/NewRequest/RequestCheckout/KubeNamespaceSelector.tsx
Outdated
Show resolved
Hide resolved
...ckages/shared/components/AccessRequests/NewRequest/RequestCheckout/KubeNamespaceSelector.tsx
Show resolved
Hide resolved
638a391
to
1a979b2
Compare
1a979b2
to
d10cd23
Compare
…ces during access requests (#48413) * Web: add support for requesting for kube namespaces (#47345) * Teleterm: add support for access requesting kube namespaces (#47347) * WebShared: Update how request checkout handles kube resource related errors (#48168) * WebShared: Update how request checkout handles kube resource related errors * Fix bug where after create/cancel, specifiable fields were retained * Remove single toggler for kube resources * Address CR * Update snaps * Backport fixes - teleport version v16 and less uses react select version 3 which required to add manual support for initially fetching namespaces on select dropdown - hover tooltip design diffs - field select design diffs
part of #46742
requires:
role.allow.request
field calledkubernetes_resources
#47173this is ready for review, i'm still trying to figure out how to make the updated react select less wonky (it works but wonky)
if you want to test, i have a staging cluster with all the UI changes, let me know and i'll invite
when request.allow.kubernetes_resources requires namespace
when request.kubernetes_resources is a kind that web UI doesn't support, it disables the checkout regardless of other resources (it is enabled once user removes the kubernetes):
demo (when no config is specified, allows requesting for a
kube_cluster
or a kube_clustersnamespace
):Screen.Recording.2024-11-04.at.6.14.54.PM.mov