Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cluster-admin] Highlighted list items for better UX #120

Merged
merged 9 commits into from
Apr 12, 2024
4 changes: 2 additions & 2 deletions ui/cluster-admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ui/cluster-admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "greenhouse-cluster-admin",
"version": "1.6.4",
"version": "1.6.5",
"author": "Services-Team",
"contributors": [
"Uwe Mayer"
Expand Down Expand Up @@ -95,4 +95,4 @@
"appDependencies": {
"auth": "latest"
}
}
}
2 changes: 1 addition & 1 deletion ui/cluster-admin/src/components/ClusterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface ClusterListProps {
const ClusterList: React.FC<ClusterListProps> = (props: ClusterListProps) => {
return (
<>
<DataGrid columns={5}>
<DataGrid columns={5} minContentColumns={[0]} className="clusters">
<DataGridRow>
<DataGridHeadCell>
<Icon icon="monitorHeart" />
Expand Down
21 changes: 19 additions & 2 deletions ui/cluster-admin/src/components/ClusterListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ const ClusterListItem: React.FC<ClusterListItemProps> = (
props: ClusterListItemProps
) => {
const setClusterDetails = useStore((state) => state.setClusterDetails)
const clusterDetails = useStore((state) => state.clusterDetails)

const setClusterDetailPlugins = useStore(
(state) => state.setClusterDetailPlugins
)
const setShowOnBoardCluster = useStore((state) => state.setShowOnBoardCluster)
const { getPluginsforCluster: getPluginsforCluster } = useGetPlugins()

const setShowClusterDetails = useStore((state) => state.setShowClusterDetails)
const showClusterDetails = useStore((state) => state.showClusterDetails)

let clusterStatus = getResourceStatusFromKubernetesConditions(
props.cluster.status?.statusConditions?.conditions ?? []
Expand All @@ -35,7 +38,13 @@ const ClusterListItem: React.FC<ClusterListItemProps> = (

const openDetails = () => {
setClusterDetails(props.cluster)
setShowClusterDetails(true)

// set showClusterDetails to false if the same cluster is clicked again.
clusterDetails?.cluster?.metadata?.name ===
props?.cluster?.metadata?.name && showClusterDetails
? setShowClusterDetails(false)
: setShowClusterDetails(true)

setShowOnBoardCluster(false)

// only get plugin configs on click
Expand All @@ -46,7 +55,15 @@ const ClusterListItem: React.FC<ClusterListItemProps> = (
}

return (
<DataGridRow style={{ cursor: "pointer" }} onClick={() => openDetails()}>
<DataGridRow
className={`cursor-pointer ${
clusterDetails?.cluster?.metadata?.name ===
props?.cluster?.metadata?.name && showClusterDetails
TilmanHaupt marked this conversation as resolved.
Show resolved Hide resolved
? "active"
: ""
}`}
onClick={() => openDetails()}
>
<DataGridCell>
<ResourceStatusIcon status={clusterStatus} />
</DataGridCell>
Expand Down
12 changes: 12 additions & 0 deletions ui/cluster-admin/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@

/* If necessary, app styles can be added below */

.clusters {
.juno-datagrid-row:hover {
.juno-datagrid-cell {
@apply bg-theme-background-lvl-1;
}
}

.juno-datagrid-row.active {
.juno-datagrid-cell {
@apply bg-theme-background-lvl-2;
}
}
}
Loading