-
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
Teleterm: Define access request fields necessary for selecting time options #39050
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 |
@gzdunek @ravicious , just FYI, this PR adds more fields than just |
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.
Submitted some nits, looks good overall.
@ravicious @gzdunek can i get a sanity check for this commit and this follow up enterprise PR |
maxDuration: params.maxDuration, | ||
requestTtl: params.requestTtl, | ||
assumeStartTime: params.assumeStartTime, | ||
resourceIds: params.resourceIds, |
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.
req
can be dropped completely and we can pass params
directly:
diff --git a/web/packages/teleterm/src/services/tshd/createClient.ts b/web/packages/teleterm/src/services/tshd/createClient.ts
index 6aa17d551b..c99a1b67b6 100644
--- a/web/packages/teleterm/src/services/tshd/createClient.ts
+++ b/web/packages/teleterm/src/services/tshd/createClient.ts
@@ -295,19 +295,8 @@ export function createTshdClient(
},
async createAccessRequest(params: types.CreateAccessRequestParams) {
- const req = api.CreateAccessRequestRequest.create({
- rootClusterUri: params.rootClusterUri,
- suggestedReviewers: params.suggestedReviewers,
- roles: params.roles,
- reason: params.reason,
- dryRun: params.dryRun,
- maxDuration: params.maxDuration,
- requestTtl: params.requestTtl,
- assumeStartTime: params.assumeStartTime,
- resourceIds: params.resourceIds,
- });
return new Promise<AccessRequest>((resolve, reject) => {
- tshd.createAccessRequest(req, (err, response) => {
+ tshd.createAccessRequest(params, (err, response) => {
if (err) {
reject(err);
} else {
AssumeStartTime: getProtoTimestamp(req.GetAssumeStartTime()), | ||
MaxDuration: timestamppb.New(req.GetMaxDuration()), | ||
RequestTtl: timestamppb.New(req.Expiry()), | ||
SessionTtl: timestamppb.New(req.GetSessionTLL()), |
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.
The changes from this PR seem okay and they typecheck. I'm able to successfully submit an access request, but when I then go to list all requests in Connect, I see "Invalid time value".
I added a console.error
to see the exact error:
diff --git a/web/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx b/web/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx
index 216dae57..d03f6e36 100644
--- a/web/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx
+++ b/web/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx
@@ -57,6 +57,7 @@ export default function useAccessRequests(doc: types.DocumentAccessRequests) {
);
setAccessRequests(requests);
} catch (err) {
+ console.log(err);
setAttempt({
status: 'failed',
statusText: err.message,
And the error is:
RangeError: Invalid time value
at formatDistanceStrict (date-fns.js?v=1abd8bfc:2759:11)
at getDurationText (makeAccessRequest.ts:87:20)
at makeAccessRequest (makeAccessRequest.ts:24:22)
at makeUiAccessRequest (useAccessRequests.tsx:98:10)
at useAccessRequests.tsx:56:17
at Array.map (<anonymous>)
at getRequests (useAccessRequests.tsx:55:33)
It looks like makeAccessRequest
from e/web/teleport/src/services/workflow/makeAccessRequest.ts
expects dates to be Date
instances. The argument to it doesn't have a type, so we didn't get type errors for that.
Perhaps makeUiAccessRequest
from e/web/teleterm/src/ui/DocumentAccessRequests/useAccessRequests.tsx
needs to be updated?
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.
thanks so much for catching these, i updated the types here and added a test to hopefully catch them easier in future. probably the best way to prevent is to type the response value right? but i think that's going to create more refactoring
i also ran teleterm to test these changes out
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.
Yeah, in teleterm we shouldn't use makeAccessRequest
from web as it converts the fully typed response to any
:(
But this is out of scope for this PR.
ff803d9
to
96bc3b6
Compare
61527b8
to
b91e349
Compare
part of #35436
I also sneaked in an export
RadioGroup.tsx
required in an enterprise work