-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1111 from sgratch/fix-npe-with-cacert-clipboard-copy
🐞 Handle undefined cacert credentials field when copying the field value to clipboard
- Loading branch information
Showing
7 changed files
with
53 additions
and
74 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...ules/Providers/views/details/components/CredentialsSection/ShowFieldWithClipboardCopy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { useForkliftTranslation } from 'src/utils/i18n'; | ||
|
||
import { ClipboardCopy, ClipboardCopyVariant, TextInput } from '@patternfly/react-core'; | ||
|
||
export interface ShowFieldWithClipboardCopyProps { | ||
value: string; | ||
} | ||
|
||
/** | ||
* Show a readable field value. | ||
* If value is an empty string, show a field read ony text with a proper text message. | ||
* If value is a non empty string, show a read only field with a copy clipboard button | ||
* | ||
* @property value - field value | ||
*/ | ||
export const ShowFieldWithClipboardCopy: React.FC<ShowFieldWithClipboardCopyProps> = ({ | ||
value, | ||
}) => { | ||
const { t } = useForkliftTranslation(); | ||
|
||
return value ? ( | ||
<ClipboardCopy | ||
isReadOnly | ||
hoverTip={t('Copy')} | ||
clickTip={t('Copied')} | ||
isCode | ||
variant={value && value.length > 128 ? ClipboardCopyVariant.expansion : undefined} | ||
> | ||
{value} | ||
</ClipboardCopy> | ||
) : ( | ||
<TextInput value={'< No value >'} type="text" isDisabled /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters