-
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
Connect: fix access request searching logic #43159
Conversation
should i include a changelog? no one complained for a year |
|
||
if (propName === 'resources') { | ||
return targetValue.some((r: any) => | ||
Object.keys(r).some(k => r[k].toUpperCase().includes(searchValue)) |
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.
this was the issue
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.
should i include a changelog? no one complained for a year
I think we should still include it.
Thanks for the fix, in general we should switch this screen to the server-side filtering, but I don't require you to do it here :)
|
||
import { AccessRequest, Resource } from 'shared/services/accessRequests'; | ||
|
||
export function requestMatcher( |
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.
This is used only in teleterm, so I don't think we should keep this function in shared
- we can fix the one we have in DocumentAccessRequests/RequestList/RequestList.tsx
.
I would also add TODO about replacing it with server-side filtering.
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.
added TODO comment (keeping file in shared because of comment)
export function requestMatcher( | ||
targetValue: any, | ||
searchValue: string, | ||
propName: keyof AccessRequest & string |
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.
& string
is not needed.
|
||
import { AccessRequest, Resource } from 'shared/services/accessRequests'; | ||
|
||
export function requestMatcher( |
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 tried to rewrite it to make it more safe, but I ultimately couldn't find a good solution. It'd have been trivial if requestMatcher
received the whole AccessRequest
object rather than the value of propName
:
export function requestMatcher(
accessRequest: AccessRequest,
searchValue: string,
propName: keyof AccessRequest
) {
if (propName === 'roles') {
return accessRequest[propName].some(role =>
role.toUpperCase().includes(searchValue)
);
}
if (propName === 'resources') {
return accessRequest[propName].some(r =>
Object.values(r.id)
.concat(Object.values(r.details.hostname || {}))
.concat(Object.values(r.details.friendlyName || {}))
.some(v => v.toUpperCase().includes(searchValue))
);
}
}
13b6f35
to
3066dca
Compare
using the search bar in the list of access requests wasn't working and threw errors about accessing invalid fields.
the same web UI's matcher was updated about a year ago but of course teleterm got missed (😅 ). moved it into a shared file.
moved from here: https://github.com/gravitational/teleport.e/pull/4429
changelog: Fix input searching logic for Connect's access request listing view