Skip to content

Commit

Permalink
frontend: Unify general and cluster settings
Browse files Browse the repository at this point in the history
Accessing settings in Headlamp is confusing. This change adds the cluster
settings to the sidebar along with the general and plugin settings. When
we open a cluster, clicking the Settings (gear) icon at the top will now
take us to the cluster settings page in the home context, with a cluster
selector appearing at the top of the page.

Fixes: #1927 and #2037

Signed-off-by: Evangelos Skopelitis <[email protected]>
  • Loading branch information
skoeva committed Aug 2, 2024
1 parent 69e9227 commit 7efd665
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 214 deletions.
416 changes: 214 additions & 202 deletions frontend/src/components/App/Settings/SettingsCluster.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
>
<a
class="MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-padding MuiListItem-button Mui-selected css-sayhe9-MuiButtonBase-root-MuiListItem-root"
href="/settings"
href="/settings/general"
role="button"
tabindex="0"
>
Expand Down Expand Up @@ -94,6 +94,29 @@
<ul
class="MuiList-root css-2l483y-MuiList-root"
>
<li
class="css-b4fdej"
>
<a
class="MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-padding MuiListItem-button css-sayhe9-MuiButtonBase-root-MuiListItem-root"
href="/settings/general"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root css-tlelie-MuiListItemText-root"
>
<span
class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-nqgwvn-MuiTypography-root"
>
General
</span>
</div>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</a>
</li>
<li
class="css-b4fdej"
>
Expand All @@ -117,6 +140,29 @@
/>
</a>
</li>
<li
class="css-b4fdej"
>
<a
class="MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-padding MuiListItem-button css-sayhe9-MuiButtonBase-root-MuiListItem-root"
href="/settings/cluster"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root css-tlelie-MuiListItemText-root"
>
<span
class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-nqgwvn-MuiTypography-root"
>
Cluster
</span>
</div>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</a>
</li>
</ul>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
>
<a
class="MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-padding MuiListItem-button Mui-selected css-sayhe9-MuiButtonBase-root-MuiListItem-root"
href="/settings"
href="/settings/general"
role="button"
tabindex="0"
>
Expand Down Expand Up @@ -115,6 +115,29 @@
<ul
class="MuiList-root css-2l483y-MuiList-root"
>
<li
class="css-b4fdej"
>
<a
class="MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-padding MuiListItem-button css-sayhe9-MuiButtonBase-root-MuiListItem-root"
href="/settings/general"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root css-tlelie-MuiListItemText-root"
>
<span
class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-nqgwvn-MuiTypography-root"
>
General
</span>
</div>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</a>
</li>
<li
class="css-b4fdej"
>
Expand All @@ -138,6 +161,29 @@
/>
</a>
</li>
<li
class="css-b4fdej"
>
<a
class="MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-padding MuiListItem-button css-sayhe9-MuiButtonBase-root-MuiListItem-root"
href="/settings/cluster"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root css-tlelie-MuiListItemText-root"
>
<span
class="MuiTypography-root MuiTypography-body1 MuiListItemText-primary css-nqgwvn-MuiTypography-root"
>
Cluster
</span>
</div>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</a>
</li>
</ul>
</div>
</div>
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/components/Sidebar/prepareRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,23 @@ function prepareRoutes(
name: 'settings',
icon: 'mdi:cog',
label: t('translation|Settings'),
url: '/settings',
url: '/settings/general',
subList: [
{
name: 'general',
label: t('translation|General'),
url: '/settings/general',
},
{
name: 'plugins',
label: t('translation|Plugins'),
url: '/settings/plugins',
},
{
name: 'settingsCluster',
label: t('glossary|Cluster'),
url: '/settings/cluster',
},
],
},
];
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/i18n/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
"Namespaces must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "Namespaces dürfen nur alphanumerische Kleinbuchstaben oder \"-\" enthalten und müssen mit einem alphanumerischen Zeichen beginnen und enden.",
"Cluster name must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "",
"Cluster Settings ({{ clusterName }})": "Cluster-Einstellungen ({{ clusterName }})",
"Cluster Settings": "Cluster-Einstellungen",
"The current name of cluster. You can define custom modified name.": "",
"Change name": "",
"Are you sure you want to change the name for \"{{ clusterName }}\"?": "",
"Default namespace": "Standard-Namespace",
"The default namespace for e.g. when applying resources (when not specified directly).": "Der Standard-Namespace z. B. für die Anwendung von Ressourcen (wenn nicht anders angegeben).",
"Allowed namespaces": "Erlaubte Namespaces",
"The list of namespaces you are allowed to access in this cluster.": "Liste der Namespaces, auf die Sie in diesem Cluster zugreifen dürfen.",
"Cluster {{ clusterName }} does not exist. Please select a valid cluster.": "",
"Remove Cluster": "Cluster entfernen",
"Server": "Server",
"light theme": "helles Design",
Expand Down Expand Up @@ -370,6 +370,7 @@
"Expand sidebar": "Seitenleiste erweitern",
"Main Navigation": "Hauptnavigation",
"Navigation Tabs": "Navigationstabs",
"General": "",
"Collapse Sidebar": "Seitenleiste einklappen",
"Navigation": "Navigation",
"Cluster version upgraded to {{ gitVersion }}": "Cluster-Version auf {{ gitVersion }} aktualisiert",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
"Namespaces must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "Namespaces must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.",
"Cluster name must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "Cluster name must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.",
"Cluster Settings ({{ clusterName }})": "Cluster Settings ({{ clusterName }})",
"Cluster Settings": "Cluster Settings",
"The current name of cluster. You can define custom modified name.": "The current name of cluster. You can define custom modified name.",
"Change name": "Change name",
"Are you sure you want to change the name for \"{{ clusterName }}\"?": "Are you sure you want to change the name for \"{{ clusterName }}\"?",
"Default namespace": "Default namespace",
"The default namespace for e.g. when applying resources (when not specified directly).": "The default namespace for e.g. when applying resources (when not specified directly).",
"Allowed namespaces": "Allowed namespaces",
"The list of namespaces you are allowed to access in this cluster.": "The list of namespaces you are allowed to access in this cluster.",
"Cluster {{ clusterName }} does not exist. Please select a valid cluster.": "Cluster {{ clusterName }} does not exist. Please select a valid cluster.",
"Remove Cluster": "Remove Cluster",
"Server": "Server",
"light theme": "light theme",
Expand Down Expand Up @@ -370,6 +370,7 @@
"Expand sidebar": "Expand sidebar",
"Main Navigation": "Main Navigation",
"Navigation Tabs": "Navigation Tabs",
"General": "General",
"Collapse Sidebar": "Collapse Sidebar",
"Navigation": "Navigation",
"Cluster version upgraded to {{ gitVersion }}": "Cluster version upgraded to {{ gitVersion }}",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
"Namespaces must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "Los espacios de nombre deben contener solo caracteres alfanuméricos en minúsculas o '-', y deben comenzar y terminar con un carácter alfanumérico.",
"Cluster name must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "",
"Cluster Settings ({{ clusterName }})": "Configuración del cluster ({{ clusterName }})",
"Cluster Settings": "Configuración del cluster",
"The current name of cluster. You can define custom modified name.": "",
"Change name": "",
"Are you sure you want to change the name for \"{{ clusterName }}\"?": "",
"Default namespace": "Espacio de nombre por defecto",
"The default namespace for e.g. when applying resources (when not specified directly).": "El espacio de nombre por defecto para, por ejemplo, cuando se aplican recursos (cuando no especificado directamente).",
"Allowed namespaces": "Espacios de nombre permitidos",
"The list of namespaces you are allowed to access in this cluster.": "La lista de espacios de nombre a los que tiene permiso para acceder en este cluster.",
"Cluster {{ clusterName }} does not exist. Please select a valid cluster.": "",
"Remove Cluster": "Eliminar cluster",
"Server": "Servidor",
"light theme": "tema claro",
Expand Down Expand Up @@ -371,6 +371,7 @@
"Expand sidebar": "Expandir barra lateral",
"Main Navigation": "Navegación principal",
"Navigation Tabs": "Pestañas de navegación",
"General": "",
"Collapse Sidebar": "Contraer barra lateral",
"Navigation": "Navegación",
"Cluster version upgraded to {{ gitVersion }}": "Versión del cluster actualizada a {{ gitVersion }}",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/i18n/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
"Namespaces must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "Les espaces de noms ne doivent contenir que des caractères alphanumériques minuscules ou '-', et doivent commencer et se terminer par un caractère alphanumérique.",
"Cluster name must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "",
"Cluster Settings ({{ clusterName }})": "Paramètres du cluster ({{ clusterName }})",
"Cluster Settings": "Paramètres du cluster",
"The current name of cluster. You can define custom modified name.": "",
"Change name": "",
"Are you sure you want to change the name for \"{{ clusterName }}\"?": "",
"Default namespace": "Espace de noms par défaut",
"The default namespace for e.g. when applying resources (when not specified directly).": "L'espace de noms par défaut, par exemple lors de l'application de ressources (lorsqu'il n'est pas spécifié directement).",
"Allowed namespaces": "Espaces de noms autorisés",
"The list of namespaces you are allowed to access in this cluster.": "La liste des espaces de noms que vous pouvez accéder dans ce cluster.",
"Cluster {{ clusterName }} does not exist. Please select a valid cluster.": "",
"Remove Cluster": "Supprimer le cluster",
"Server": "Serveur",
"light theme": "thème clair",
Expand Down Expand Up @@ -371,6 +371,7 @@
"Expand sidebar": "Développer la barre latérale",
"Main Navigation": "Navigation principale",
"Navigation Tabs": "Onglets de navigation",
"General": "",
"Collapse Sidebar": "Réduire la barre latérale",
"Navigation": "Navigation",
"Cluster version upgraded to {{ gitVersion }}": "Version du cluster mise à jour vers {{ gitVersion }}",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/i18n/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@
"Namespaces must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "Os namespaces devem conter apenas caracteres alfanuméricos minúsculos ou '-', e devem começar e terminar com um carácter alfanumérico.",
"Cluster name must contain only lowercase alphanumeric characters or '-', and must start and end with an alphanumeric character.": "",
"Cluster Settings ({{ clusterName }})": "Definições do cluster ({{ clusterName }})",
"Cluster Settings": "Definições do cluster",
"The current name of cluster. You can define custom modified name.": "",
"Change name": "",
"Are you sure you want to change the name for \"{{ clusterName }}\"?": "",
"Default namespace": "Namespace padrão",
"The default namespace for e.g. when applying resources (when not specified directly).": "O namespace por defeito, por exemplo, quando se aplicam recursos (quando não especificado directamente).",
"Allowed namespaces": "Namespaces permitidos",
"The list of namespaces you are allowed to access in this cluster.": "A lista de namespaces que tem permissão para aceder neste cluster.",
"Cluster {{ clusterName }} does not exist. Please select a valid cluster.": "",
"Remove Cluster": "Remover Cluster",
"Server": "Servidor",
"light theme": "tema claro",
Expand Down Expand Up @@ -371,6 +371,7 @@
"Expand sidebar": "Expandir barra lateral",
"Main Navigation": "Navegação Principal",
"Navigation Tabs": "Separadores de Navegação",
"General": "",
"Collapse Sidebar": "Encolher Barra Lateral",
"Navigation": "Navegação",
"Cluster version upgraded to {{ gitVersion }}": "Versão do cluster actualizada para {{ gitVersion }}",
Expand Down
31 changes: 27 additions & 4 deletions frontend/src/lib/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,11 @@ const defaultRoutes: {
),
},
settings: {
path: '/settings',
path: '/settings/general',
exact: true,
name: 'Settings',
sidebar: {
item: 'settings',
item: 'general',
sidebar: DefaultSidebars.HOME,
},
useClusterURL: false,
Expand All @@ -684,7 +684,6 @@ const defaultRoutes: {
</PageGrid>
),
},

settingsClusters: {
path: '/settings/clusters',
exact: true,
Expand All @@ -702,7 +701,27 @@ const defaultRoutes: {
path: '/settings',
exact: true,
name: 'Cluster Settings',
sidebar: 'settingsCluster',
sidebar: {
item: 'settingsCluster',
sidebar: DefaultSidebars.HOME,
},
useClusterURL: true,
noAuthRequired: true,
component: () => (
<PageGrid>
<SettingsCluster />
</PageGrid>
),
},
settingsClusterHomeContext: {
path: '/settings/cluster',
exact: true,
name: 'Cluster Settings',
sidebar: {
item: 'settingsCluster',
sidebar: DefaultSidebars.HOME,
},
useClusterURL: false,
noAuthRequired: true,
component: () => (
<PageGrid>
Expand Down Expand Up @@ -840,6 +859,10 @@ export function createRouteURL(routeName: string, params: RouteURLProps = {}) {
fullParams.cluster = cluster;
}

if (routeName === 'settingsCluster') {
return `/settings/cluster?c=${fullParams.cluster}`;
}

const url = getRoutePath(route);
return generatePath(url, fullParams);
}
Expand Down

0 comments on commit 7efd665

Please sign in to comment.