Add ssh public keys on user-profile page#5223
Conversation
| @@ -0,0 +1,159 @@ | |||
| // Copyright (c) Microsoft Corporation | |||
There was a problem hiding this comment.
Please use this header:
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.There was a problem hiding this comment.
Will modifiy it. And looks like that still have many files write that.
There was a problem hiding this comment.
Yes, they are the old headers. We haven't modified them. This one is the new header.
| </Hint> | ||
| <Stack horizontal gap='l1'> | ||
| <TextField | ||
| Lable='Add additional ssh public key' |
| <Stack horizontal gap='l1'> | ||
| <TextField | ||
| Lable='Add additional ssh public key' | ||
| placeholder='Additional ssh public key' |
| > | ||
| <TokenList tokens={tokens} onRevoke={onRevokeToken} /> | ||
| </UserProfileCard> | ||
| <UserProfileCard |
There was a problem hiding this comment.
Please move this UserProfileCard of SSH Public Keys before the UserProfileCard of Tokens.
SSH is supposed to be used more frequently than tokens.
| }} | ||
| minWidth={400} | ||
| > | ||
| <div>Are you sure you want to delete this ssh key?</div> |
| if (title.trim() === '') { | ||
| setInputTitleError('Please input title'); | ||
| } else if (value.trim() === '') { | ||
| setInputValueError('Please input ssk value'); |
| setInputTitleError('Please input title'); | ||
| } else if (value.trim() === '') { | ||
| setInputValueError('Please input ssk value'); | ||
| } else { |
There was a problem hiding this comment.
Please validate the value matches SSH key's format.
You can use this regex: /^ssh-rsa AAAA[0-9A-Za-z+/]+[=]{0,3}.*$/
| // click `add public ssh keys button` -> open dialog | ||
| const onAddPublicKeys = useCallback(async sshPublicKeys => { | ||
| setSSHProcessing(true); | ||
| let updatedSSHPublickeys = []; |
There was a problem hiding this comment.
Please validate here: the user cannot add ssh keys with duplicate titles. (Title should be unique for one user)
| } | ||
| updatedSSHPublickeys = updatedSSHPublickeys.filter( | ||
| item => | ||
| item.title !== sshPublicKeys.title && |
There was a problem hiding this comment.
Please only filter with item.title !== sshPublicKeys.title.
Title should be unique and delete means delete an ssh key with a certain title.
| <div> | ||
| <div className={t.mt1}> | ||
| <TextField | ||
| label='title' |
There was a problem hiding this comment.
Better to give the user some hints.
title -> Title (Please give the SSH key a name):
| </div> | ||
| <div className={t.mt1}> | ||
| <TextField | ||
| label='value' |
There was a problem hiding this comment.
Better to give the user some hints.
value -> Value (SSH Public key, starts with ssh-rsa):
| data: { | ||
| username: username, | ||
| extension: { | ||
| sshKeys: sskMessage, |
| }); | ||
| }; | ||
|
|
||
| export const updateUserRequest = async (username, sskMessage) => { |
| } | ||
| } | ||
|
|
||
| // if (title.trim() === '') { |
TODO:
improve SSH layout: