From 0095d4e8047648999c9987236e83aae345a3a357 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 19 Oct 2022 06:33:20 -0700 Subject: [PATCH] WPCOM SSH: Use `-` consistently in UI (#69220) --- .../me/security-ssh-key/manage-ssh-keys.tsx | 23 ++++++++++++++++--- .../me/security-ssh-key/security-ssh-key.tsx | 7 ++++-- .../hosting/sftp-card/ssh-key-card.tsx | 4 +++- .../my-sites/hosting/sftp-card/ssh-keys.tsx | 2 +- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/client/me/security-ssh-key/manage-ssh-keys.tsx b/client/me/security-ssh-key/manage-ssh-keys.tsx index 8b194d2957eb1..25dfb4bb09820 100644 --- a/client/me/security-ssh-key/manage-ssh-keys.tsx +++ b/client/me/security-ssh-key/manage-ssh-keys.tsx @@ -8,7 +8,7 @@ import { SSHKeyData } from './use-ssh-key-query'; type SSHKeyProps = { sshKey: SSHKeyData } & Pick< ManageSSHKeyProps, - 'onDelete' | 'keyBeingDeleted' + 'userLogin' | 'onDelete' | 'keyBeingDeleted' >; const SSHKeyItemCard = styled( CompactCard )( { @@ -16,6 +16,13 @@ const SSHKeyItemCard = styled( CompactCard )( { alignItems: 'center', } ); +const SSHKeyName = styled.span( { + display: 'block', + fontWeight: 'bold', + overflow: 'hidden', + textOverflow: 'ellipsis', +} ); + const SSHPublicKey = styled.code( { flex: 1, position: 'relative', @@ -31,7 +38,7 @@ const SSHKeyAddedDate = styled.span( { color: 'var( --color-text-subtle )', } ); -const SSHKey = ( { sshKey, onDelete, keyBeingDeleted }: SSHKeyProps ) => { +const SSHKey = ( { userLogin, sshKey, onDelete, keyBeingDeleted }: SSHKeyProps ) => { const { __ } = useI18n(); const handleDeleteClick = () => { accept( @@ -49,6 +56,9 @@ const SSHKey = ( { sshKey, onDelete, keyBeingDeleted }: SSHKeyProps ) => { return (
+ + { userLogin }-{ sshKey.name } + { sshKey.sha256 } { sprintf( @@ -80,14 +90,21 @@ interface ManageSSHKeyProps { sshKeys: SSHKeyData[]; onDelete( name: string ): void; keyBeingDeleted: string | null; + userLogin: string; } -export const ManageSSHKeys = ( { sshKeys, onDelete, keyBeingDeleted }: ManageSSHKeyProps ) => { +export const ManageSSHKeys = ( { + userLogin, + sshKeys, + onDelete, + keyBeingDeleted, +}: ManageSSHKeyProps ) => { return ( <> { sshKeys.map( ( sshKey ) => ( { const { data, isLoading } = useSSHKeyQuery(); const dispatch = useDispatch(); + const currentUser = useSelector( getCurrentUser ); const { __ } = useI18n(); const { addSSHKey, isLoading: isAdding } = useAddSSHKeyMutation( { @@ -153,8 +155,9 @@ export const SecuritySSHKey = () => { /> ) : null } - { hasKeys && ( + { hasKeys && currentUser?.username && ( deleteSSHKey( { sshKeyName } ) } keyBeingDeleted={ keyBeingDeleted } diff --git a/client/my-sites/hosting/sftp-card/ssh-key-card.tsx b/client/my-sites/hosting/sftp-card/ssh-key-card.tsx index 66e5f9a4c9d96..92998e470ff39 100644 --- a/client/my-sites/hosting/sftp-card/ssh-key-card.tsx +++ b/client/my-sites/hosting/sftp-card/ssh-key-card.tsx @@ -18,7 +18,9 @@ function SshKeyCard( { deleteText, siteId, sshKey }: SshKeyCardProps ) { return (
- { user_login } + + { user_login }-{ name } + { sha256 } { sprintf( diff --git a/client/my-sites/hosting/sftp-card/ssh-keys.tsx b/client/my-sites/hosting/sftp-card/ssh-keys.tsx index 92aceb84e7fe9..31cc933fd5b29 100644 --- a/client/my-sites/hosting/sftp-card/ssh-keys.tsx +++ b/client/my-sites/hosting/sftp-card/ssh-keys.tsx @@ -70,7 +70,7 @@ function SshKeys( { siteId, username, disabled }: SshKeysProps ) { > { userKeys?.map( ( key ) => ( ) ) }