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

frontend: Home: Show the origin of each cluster #2536

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -236,6 +236,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})`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to translate Kubeconfig. And the value here should be: kubeconfig:PATH_TO_FILE
Can you make another PR to fix this, since this one is merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change as well as the other one mentioned are done here: #2543

} else if (cluster.meta_data?.source === 'dynamic_cluster') {
return t('translation|Dynamic cluster');
skoeva marked this conversation as resolved.
Show resolved Hide resolved
} else if (cluster.meta_data?.source === 'in_cluster') {
return t('translation|In-cluster');
}
return 'Unknown';
}

const memoizedComponent = React.useMemo(
() => (
<PageGrid>
Expand Down Expand Up @@ -264,6 +282,13 @@ function HomeComponent(props: HomeComponentProps) {
</Link>
),
},
{
label: t('Origin'),
getValue: cluster => getOrigin(cluster),
render: ({ name }) => (
<Typography variant="body2">{getOrigin(clusters[name])}</Typography>
illume marked this conversation as resolved.
Show resolved Hide resolved
),
},
{
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
Loading