From be965c31cdc1e1192e6070ea5ef545aa461f4b12 Mon Sep 17 00:00:00 2001 From: farodin91 Date: Tue, 18 Jun 2024 21:16:49 +0200 Subject: [PATCH] frontend use action if possible Signed-off-by: farodin91 --- .../components/App/Notifications/index.tsx | 16 +++++-------- .../components/App/Settings/NumRowsInput.tsx | 23 ++++++++----------- .../common/Resource/RestartButton.tsx | 20 +++++++--------- .../common/Resource/ScaleButton.tsx | 20 +++++++--------- frontend/src/components/portforward/index.tsx | 16 ++++++------- frontend/src/i18n/locales/de/translation.json | 2 -- frontend/src/i18n/locales/en/translation.json | 2 -- frontend/src/i18n/locales/es/translation.json | 2 -- frontend/src/i18n/locales/fr/translation.json | 2 -- frontend/src/i18n/locales/pt/translation.json | 2 -- 10 files changed, 38 insertions(+), 67 deletions(-) diff --git a/frontend/src/components/App/Notifications/index.tsx b/frontend/src/components/App/Notifications/index.tsx index 98797c5cfcb..e5e3265b703 100644 --- a/frontend/src/components/App/Notifications/index.tsx +++ b/frontend/src/components/App/Notifications/index.tsx @@ -21,7 +21,7 @@ import { useClustersConf } from '../../../lib/k8s'; import Event from '../../../lib/k8s/event'; import { createRouteURL } from '../../../lib/router'; import { useTypedSelector } from '../../../redux/reducers/reducers'; -import { DateLabel } from '../../common'; +import { ActionButton, DateLabel } from '../../common'; import Empty from '../../common/EmptyContent'; import { defaultMaxNotificationsStored, @@ -93,15 +93,11 @@ function NotificationsList(props: { {!notification.seen && ( - - notificationSeenUnseenHandler(e, notification)} - aria-label={t('translation|Mark as read')} - size="medium" - > - - - + notificationSeenUnseenHandler(e, notification)} + icon="mdi:circle" + /> )} diff --git a/frontend/src/components/App/Settings/NumRowsInput.tsx b/frontend/src/components/App/Settings/NumRowsInput.tsx index 6094968a8c6..ea8a60ca4eb 100644 --- a/frontend/src/components/App/Settings/NumRowsInput.tsx +++ b/frontend/src/components/App/Settings/NumRowsInput.tsx @@ -1,9 +1,7 @@ -import { Icon } from '@iconify/react'; import { Box, Button, FormControl, - IconButton, ListItemSecondaryAction, ListItemText, MenuItem, @@ -16,6 +14,7 @@ import { useTranslation } from 'react-i18next'; import { useDispatch } from 'react-redux'; import helpers from '../../../helpers'; import { defaultTableRowsPerPageOptions, setAppSettings } from '../../../redux/configSlice'; +import { ActionButton } from '../../common'; export default function NumRowsInput(props: { defaultValue: number[] }) { const { t } = useTranslation(['frequent', 'settings']); @@ -119,16 +118,14 @@ export default function NumRowsInput(props: { defaultValue: number[] }) { > {t('translation|Apply')} - { setOptions(defaultTableRowsPerPageOptions); setSelectedValue(defaultTableRowsPerPageOptions[0]); }} - size="medium" - > - - + icon="mdi:delete" + /> ) : ( @@ -149,17 +146,15 @@ export default function NumRowsInput(props: { defaultValue: number[] }) { {isCustom && ( - { setOptions(defaultTableRowsPerPageOptions); setSelectedValue(defaultTableRowsPerPageOptions[0]); setIsSelectOpen(false); }} - > - - + icon="mdi:delete" + /> )} diff --git a/frontend/src/components/common/Resource/RestartButton.tsx b/frontend/src/components/common/Resource/RestartButton.tsx index 1b163ba1005..030208e76be 100644 --- a/frontend/src/components/common/Resource/RestartButton.tsx +++ b/frontend/src/components/common/Resource/RestartButton.tsx @@ -1,4 +1,3 @@ -import { Icon } from '@iconify/react'; import { Button, Dialog, @@ -6,8 +5,6 @@ import { DialogContent, DialogContentText, DialogTitle, - IconButton, - Tooltip, } from '@mui/material'; import _ from 'lodash'; import { useState } from 'react'; @@ -21,6 +18,7 @@ import { HeadlampEventType, useEventCallback, } from '../../../redux/headlampEventSlice'; +import ActionButton from '../ActionButton'; import AuthVisible from './AuthVisible'; interface RestartButtonProps { @@ -81,15 +79,13 @@ export function RestartButton(props: RestartButtonProps) { console.error(`Error while getting authorization for restart button in ${item}:`, err); }} > - - setOpenDialog(true)} - size="medium" - > - - - + { + setOpenDialog(true); + }} + icon="mdi:restart" + /> ); diff --git a/frontend/src/components/common/Resource/ScaleButton.tsx b/frontend/src/components/common/Resource/ScaleButton.tsx index 4105e9f98b0..ea097609b7d 100644 --- a/frontend/src/components/common/Resource/ScaleButton.tsx +++ b/frontend/src/components/common/Resource/ScaleButton.tsx @@ -7,10 +7,8 @@ import DialogContent from '@mui/material/DialogContent'; import DialogTitle from '@mui/material/DialogTitle'; import Fab from '@mui/material/Fab'; import Grid from '@mui/material/Grid'; -import IconButton from '@mui/material/IconButton'; import MuiInput from '@mui/material/Input'; import { styled, useTheme } from '@mui/material/styles'; -import Tooltip from '@mui/material/Tooltip'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { useDispatch } from 'react-redux'; @@ -22,6 +20,7 @@ import { HeadlampEventType, useEventCallback, } from '../../../redux/headlampEventSlice'; +import ActionButton from '../ActionButton'; import { LightTooltip } from '../Tooltip'; import AuthVisible from './AuthVisible'; @@ -83,16 +82,13 @@ export default function ScaleButton(props: ScaleButtonProps) { console.error(`Error while getting authorization for scaling button in ${item}:`, err); }} > - - { - setOpenDialog(true); - }} - > - - - + { + setOpenDialog(true); + }} + icon="mdi:content-copy" + /> ); diff --git a/frontend/src/components/portforward/index.tsx b/frontend/src/components/portforward/index.tsx index 4d4c696a326..49558953de2 100644 --- a/frontend/src/components/portforward/index.tsx +++ b/frontend/src/components/portforward/index.tsx @@ -1,5 +1,5 @@ -import { Icon, InlineIcon } from '@iconify/react'; -import { Box, IconButton, Menu, MenuItem } from '@mui/material'; +import { InlineIcon } from '@iconify/react'; +import { Box, Menu, MenuItem } from '@mui/material'; import MuiLink from '@mui/material/Link'; import { useTheme } from '@mui/system'; import { useSnackbar } from 'notistack'; @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next'; import helpers from '../../helpers'; import { listPortForward, startPortForward, stopOrDeletePortForward } from '../../lib/k8s/apiProxy'; import { getCluster } from '../../lib/util'; -import { Link, Loader, SectionBox, SimpleTable, StatusLabel } from '../common'; +import { ActionButton, Link, Loader, SectionBox, SimpleTable, StatusLabel } from '../common'; import { PORT_FORWARD_RUNNING_STATUS, PORT_FORWARD_STOP_STATUS, @@ -261,13 +261,11 @@ export default function PortForwardingList() { }); return ( <> - handleClick(e, portforward)} - size="medium" - > - - + icon="mdi:dots-vertical" + /> {filteredOptions.map(option => ( handleClose(option)}> diff --git a/frontend/src/i18n/locales/de/translation.json b/frontend/src/i18n/locales/de/translation.json index 1f6392adcbf..1d99d825c70 100644 --- a/frontend/src/i18n/locales/de/translation.json +++ b/frontend/src/i18n/locales/de/translation.json @@ -224,14 +224,12 @@ "Restarted {{ itemName }}.": "{{ itemName }} neu gestartet.", "Failed to restart {{ itemName }}.": "Neustart von {{ itemName }} fehlgeschlagen.", "Restart": "Neu starten", - "restart": "Neustart", "Are you sure you want to restart {{ name }}?": "Sind Sie sicher, dass Sie {{ name }} neu starten wollen?", "Scaling {{ itemName }}…": "Skaliere {{ itemName }}…", "Cancelled scaling {{ itemName }}.": "Skalierung von {{ itemName }} abgebrochen.", "Scaled {{ itemName }}.": "{{ itemName }} skaliert .", "Failed to scale {{ itemName }}.": "Skalierung von {{ itemName }} fehlgeschlagen.", "Scale": "Skalieren", - "scale": "Skala", "Scale Replicas": "Scale-Replikas", "Current number of replicas: {{ numReplicas }}": "Aktuelle Anzahl der Replikas: {{ numReplicas }}", "Desired number of replicas:": "Gewünschte Anzahl von Replikas:", diff --git a/frontend/src/i18n/locales/en/translation.json b/frontend/src/i18n/locales/en/translation.json index 6f941488d53..25eead1f80a 100644 --- a/frontend/src/i18n/locales/en/translation.json +++ b/frontend/src/i18n/locales/en/translation.json @@ -224,14 +224,12 @@ "Restarted {{ itemName }}.": "Restarted {{ itemName }}.", "Failed to restart {{ itemName }}.": "Failed to restart {{ itemName }}.", "Restart": "Restart", - "restart": "restart", "Are you sure you want to restart {{ name }}?": "Are you sure you want to restart {{ name }}?", "Scaling {{ itemName }}…": "Scaling {{ itemName }}…", "Cancelled scaling {{ itemName }}.": "Cancelled scaling {{ itemName }}.", "Scaled {{ itemName }}.": "Scaled {{ itemName }}.", "Failed to scale {{ itemName }}.": "Failed to scale {{ itemName }}.", "Scale": "Scale", - "scale": "scale", "Scale Replicas": "Scale Replicas", "Current number of replicas: {{ numReplicas }}": "Current number of replicas: {{ numReplicas }}", "Desired number of replicas:": "Desired number of replicas:", diff --git a/frontend/src/i18n/locales/es/translation.json b/frontend/src/i18n/locales/es/translation.json index e4dd5ddd3bf..70f1caf8db3 100644 --- a/frontend/src/i18n/locales/es/translation.json +++ b/frontend/src/i18n/locales/es/translation.json @@ -225,14 +225,12 @@ "Restarted {{ itemName }}.": "Se ha reiniciado {{ itemName }}.", "Failed to restart {{ itemName }}.": "Fallo al reiniciar {{ itemName }}.", "Restart": "Reiniciar", - "restart": "reiniciar", "Are you sure you want to restart {{ name }}?": "¿Está seguro de que quiere reiniciar {{ name }}?", "Scaling {{ itemName }}…": "Escalando {{ itemName }}…", "Cancelled scaling {{ itemName }}.": "Se ha cancelado la escalada de {{ itemName }}.", "Scaled {{ itemName }}.": "Se ha escalado {{ itemName }}.", "Failed to scale {{ itemName }}.": "Fallo al escalar {{ itemName }}.", "Scale": "Escalar", - "scale": "escalar", "Scale Replicas": "Escalar Replicas", "Current number of replicas: {{ numReplicas }}": "Número actual de replicas: {{ numReplicas }}", "Desired number of replicas:": "Número deseado de replicas:", diff --git a/frontend/src/i18n/locales/fr/translation.json b/frontend/src/i18n/locales/fr/translation.json index 008e183741a..214213f2538 100644 --- a/frontend/src/i18n/locales/fr/translation.json +++ b/frontend/src/i18n/locales/fr/translation.json @@ -225,14 +225,12 @@ "Restarted {{ itemName }}.": "{{ itemName }} redémarré.", "Failed to restart {{ itemName }}.": "Échec du redémarrage de {{ itemName }}.", "Restart": "Redémarrer", - "restart": "redémarrer", "Are you sure you want to restart {{ name }}?": "Êtes-vous sûr de vouloir redémarrer {{ name }} ?", "Scaling {{ itemName }}…": "Mise à l'échelle {{ itemName }}…", "Cancelled scaling {{ itemName }}.": "Annulation de la graduation {{ itemName }}.", "Scaled {{ itemName }}.": "Mise à l'échelle {{ itemName }}.", "Failed to scale {{ itemName }}.": "Échec de la mise à l'échelle de {{ itemName }}.", "Scale": "Mettre à l'échelle", - "scale": "échelle", "Scale Replicas": "Répliques à l'échelle", "Current number of replicas: {{ numReplicas }}": "Nombre actuel de réplique(s) : {{ numReplicas }}", "Desired number of replicas:": "Nombre souhaité de réplique(s) :", diff --git a/frontend/src/i18n/locales/pt/translation.json b/frontend/src/i18n/locales/pt/translation.json index c715f4af8c4..31a13f0990c 100644 --- a/frontend/src/i18n/locales/pt/translation.json +++ b/frontend/src/i18n/locales/pt/translation.json @@ -225,14 +225,12 @@ "Restarted {{ itemName }}.": "{{ itemName }} foi reiniciado.", "Failed to restart {{ itemName }}.": "Falha ao reiniciar {{ itemName }}.", "Restart": "Reiniciar", - "restart": "reiniciar", "Are you sure you want to restart {{ name }}?": "Tem a certeza que quer reiniciar {{ name }}?", "Scaling {{ itemName }}…": "A escalar {{ itemName }}…", "Cancelled scaling {{ itemName }}.": "Cancelada a escala de {{ itemName }}.", "Scaled {{ itemName }}.": "{{ itemName }} foi escalado.", "Failed to scale {{ itemName }}.": "Falha ao escalar {{ itemName }}.", "Scale": "Escalar", - "scale": "escalar", "Scale Replicas": "Escalar Replicas", "Current number of replicas: {{ numReplicas }}": "Número atual de replicas: {{ numReplicas }}", "Desired number of replicas:": "Número desejado de replicas:",