1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Copy whole drawer title if no colon exists

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-10-22 13:58:48 -04:00
parent 169f443c3b
commit 8b30c5258a

View File

@ -135,11 +135,10 @@ export class Drawer extends React.Component<DrawerProps> {
if (open) onClose(); if (open) onClose();
}; };
copyK8sObjName = () => { copyTitle = (title: string) => {
const { title } = this.props; const k8sObjName = title.split(":")[1] || title; // copy whole if no :
const k8sObjName = title.toString().split(": ")[1];
clipboard.writeText(k8sObjName); clipboard.writeText(k8sObjName.trim());
this.setState({isCopied: true}); this.setState({isCopied: true});
setTimeout(() => { setTimeout(() => {
this.setState({isCopied: false}); this.setState({isCopied: false});
@ -163,8 +162,8 @@ export class Drawer extends React.Component<DrawerProps> {
<div className="drawer-title flex align-center"> <div className="drawer-title flex align-center">
<div className="drawer-title-text flex gaps align-center"> <div className="drawer-title-text flex gaps align-center">
{title} {title}
{typeof title == "string" && ( {title && typeof title == "string" && (
<Icon material={copyIcon} tooltip={copyTooltip} onClick={this.copyK8sObjName}/> <Icon material={copyIcon} tooltip={copyTooltip} onClick={() => this.copyTitle(title)}/>
)} )}
</div> </div>
{toolbar} {toolbar}