Skip to content

Commit

Permalink
Merge pull request #2536 from headlamp-k8s/show-cluster-origin
Browse files Browse the repository at this point in the history
frontend: Home: Show the origin of each cluster
  • Loading branch information
illume authored Nov 7, 2024
2 parents 4e33ae7 + 6d0dc28 commit 27a9fc7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
25 changes: 25 additions & 0 deletions frontend/src/components/App/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,24 @@ function HomeComponent(props: HomeComponentProps) {
.sort();
}

/**
* Gets the origin of a cluster.
*
* @param cluster
* @returns A description of where the cluster is picked up from: dynamic, in-cluster, or from a kubeconfig file.
*/
function getOrigin(cluster: Cluster): string {
if (cluster.meta_data?.source === 'kubeconfig') {
const kubeconfigPath = process.env.KUBECONFIG ?? '~/.kube/config';
return t('translation|Kubeconfig') + ` (${kubeconfigPath})`;
} else if (cluster.meta_data?.source === 'dynamic_cluster') {
return t('translation|Dynamic cluster');
} else if (cluster.meta_data?.source === 'in_cluster') {
return t('translation|In-cluster');
}
return 'Unknown';
}

const memoizedComponent = React.useMemo(
() => (
<PageGrid>
Expand Down Expand Up @@ -267,6 +285,13 @@ function HomeComponent(props: HomeComponentProps) {
</Link>
),
},
{
label: t('Origin'),
getValue: cluster => getOrigin(cluster),
render: ({ name }) => (
<Typography variant="body2">{getOrigin(clusters[name])}</Typography>
),
},
{
label: t('Status'),
getValue: cluster => cluster.name,
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/i18n/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
"Delete Cluster": "",
"Are you sure you want to remove the cluster \"{{ clusterName }}\"?": "Sind Sie sicher, dass Sie den Cluster \"{{ clusterName }}\" entfernen möchten?",
"Active": "Aktiv",
"Kubeconfig": "",
"Dynamic cluster": "",
"In-cluster": "",
"Home": "Startseite",
"All Clusters": "Alle Cluster",
"Name": "Name",
"Origin": "",
"Status": "Status",
"Warnings": "",
"Load cluster": "Cluster laden",
Expand All @@ -40,7 +44,6 @@
"Visible": "Sichtbar",
"Plugins": "Plugins",
"Description": "Beschreibung",
"Origin": "",
"Unknown": "",
"Incompatible": "Inkompatibel",
"Enabled": "",
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
"Delete Cluster": "Delete Cluster",
"Are you sure you want to remove the cluster \"{{ clusterName }}\"?": "Are you sure you want to remove the cluster \"{{ clusterName }}\"?",
"Active": "Active",
"Kubeconfig": "Kubeconfig",
"Dynamic cluster": "Dynamic cluster",
"In-cluster": "In-cluster",
"Home": "Home",
"All Clusters": "All Clusters",
"Name": "Name",
"Origin": "Origin",
"Status": "Status",
"Warnings": "Warnings",
"Load cluster": "Load cluster",
Expand All @@ -40,7 +44,6 @@
"Visible": "Visible",
"Plugins": "Plugins",
"Description": "Description",
"Origin": "Origin",
"Unknown": "Unknown",
"Incompatible": "Incompatible",
"Enabled": "Enabled",
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
"Delete Cluster": "",
"Are you sure you want to remove the cluster \"{{ clusterName }}\"?": "¿Está seguro de que desea eliminar el cluster \"{{ clusterName }}\"?",
"Active": "Activo",
"Kubeconfig": "",
"Dynamic cluster": "",
"In-cluster": "",
"Home": "Inicio",
"All Clusters": "Todos los Clusters",
"Name": "Nombre",
"Origin": "",
"Status": "Estado",
"Warnings": "",
"Load cluster": "Cargar cluster",
Expand All @@ -40,7 +44,6 @@
"Visible": "Visible",
"Plugins": "Plugins",
"Description": "Descripción",
"Origin": "",
"Unknown": "",
"Incompatible": "Incompatible",
"Enabled": "",
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/i18n/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
"Delete Cluster": "",
"Are you sure you want to remove the cluster \"{{ clusterName }}\"?": "Voulez-vous vraiment supprimer le cluster \"{{ clusterName }}\"?",
"Active": "Actif",
"Kubeconfig": "",
"Dynamic cluster": "",
"In-cluster": "",
"Home": "Accueil",
"All Clusters": "Tous les clusters",
"Name": "Nom",
"Origin": "",
"Status": "Statut",
"Warnings": "",
"Load cluster": "Charger cluster",
Expand All @@ -40,7 +44,6 @@
"Visible": "Visible",
"Plugins": "Plugins",
"Description": "Description",
"Origin": "",
"Unknown": "",
"Incompatible": "Incompatible",
"Enabled": "",
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/i18n/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
"Delete Cluster": "",
"Are you sure you want to remove the cluster \"{{ clusterName }}\"?": "Tem a certeza que quer remover o cluster \"{{ clusterName }}\"?",
"Active": "Activo",
"Kubeconfig": "",
"Dynamic cluster": "",
"In-cluster": "",
"Home": "Início",
"All Clusters": "Todos os Clusters",
"Name": "Nome",
"Origin": "",
"Status": "Estado",
"Warnings": "",
"Load cluster": "Carregar cluster",
Expand All @@ -40,7 +44,6 @@
"Visible": "Visível",
"Plugins": "Plugins",
"Description": "Descrição",
"Origin": "",
"Unknown": "",
"Incompatible": "Incompatível",
"Enabled": "",
Expand Down

0 comments on commit 27a9fc7

Please sign in to comment.