-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update how the cluster name is truncated
- Loading branch information
Showing
5 changed files
with
30 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
import React from 'react'; | ||
|
||
import { Link } from 'react-router-dom'; | ||
import classNames from 'classnames'; | ||
|
||
const truncatedLength = 14; // Using 14 as it cuts the uuid format after the 2nd - | ||
export const getClusterName = (cluster) => { | ||
return cluster?.name || cluster?.id.slice(0, truncatedLength) + '...'; | ||
return cluster?.name || cluster?.id; | ||
}; | ||
|
||
const ClusterLink = ({ cluster }) => { | ||
const clusterName = getClusterName(cluster); | ||
const truncatedClasses = classNames( | ||
'truncate w-32 inline-block align-middle' | ||
); | ||
|
||
if (cluster?.type == 'hana_scale_up' || cluster?.type == 'hana_scale_out') { | ||
return ( | ||
<Link | ||
className="text-jungle-green-500 hover:opacity-75" | ||
to={`/clusters/${cluster.id}`} | ||
> | ||
{clusterName} | ||
<span className={truncatedClasses}>{clusterName}</span> | ||
</Link> | ||
); | ||
} | ||
|
||
return <span>{clusterName}</span>; | ||
return <span className={truncatedClasses}>{clusterName}</span>; | ||
}; | ||
|
||
export default ClusterLink; |
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