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 use action if possible #2054

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
16 changes: 7 additions & 9 deletions frontend/src/components/App/Settings/AllowedNamespaces.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { InlineIcon } from '@iconify/react';
import { Box, Chip, IconButton, TextField, useTheme } from '@mui/material';
import { Box, Chip, TextField, useTheme } from '@mui/material';
import { Dispatch, SetStateAction, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ClusterSettings } from '../../../helpers';
import { ActionButton } from '../../common';
import { isValidNamespaceFormat } from './DefaultNamespace';

interface AllowedNamespacesProps {
Expand Down Expand Up @@ -55,16 +55,14 @@ export default function AllowedNamespaces(props: AllowedNamespacesProps) {
}}
InputProps={{
endAdornment: (
<IconButton
<ActionButton
description={t('translation|Add namespace')}
onClick={() => {
storeNewAllowedNamespace(newAllowedNamespace);
}}
disabled={!newAllowedNamespace}
size="medium"
aria-label={t('translation|Add namespace')}
>
<InlineIcon icon="mdi:plus-circle" />
</IconButton>
icon="mdi:plus-circle"
iconButtonProps={{ size: 'medium', disabled: !newAllowedNamespace }}
/>
),
onKeyPress: event => {
if (event.key === 'Enter') {
Expand Down
25 changes: 11 additions & 14 deletions frontend/src/components/App/Settings/NumRowsInput.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Icon } from '@iconify/react';
import {
Box,
Button,
FormControl,
IconButton,
ListItemSecondaryAction,
ListItemText,
MenuItem,
Expand All @@ -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']);
Expand Down Expand Up @@ -119,16 +118,15 @@ export default function NumRowsInput(props: { defaultValue: number[] }) {
>
{t('translation|Apply')}
</Button>
<IconButton
aria-label={t('translation|Delete')}
<ActionButton
description={t('translation|Delete')}
onClick={() => {
setOptions(defaultTableRowsPerPageOptions);
setSelectedValue(defaultTableRowsPerPageOptions[0]);
}}
size="medium"
>
<Icon icon="mdi:delete" />
</IconButton>
icon="mdi:delete"
iconButtonProps={{ size: 'medium' }}
/>
</Box>
</Box>
) : (
Expand All @@ -149,17 +147,16 @@ export default function NumRowsInput(props: { defaultValue: number[] }) {
<ListItemText primary={option} />
{isCustom && (
<ListItemSecondaryAction>
<IconButton
size="small"
aria-label={t('translation|Delete')}
<ActionButton
description={t('translation|Delete')}
onClick={() => {
setOptions(defaultTableRowsPerPageOptions);
setSelectedValue(defaultTableRowsPerPageOptions[0]);
setIsSelectOpen(false);
}}
>
<Icon icon="mdi:delete" />
</IconButton>
icon="mdi:delete"
iconButtonProps={{ size: 'small' }}
/>
</ListItemSecondaryAction>
)}
</MenuItem>
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/components/cluster/Chooser.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Icon, InlineIcon } from '@iconify/react';
import { DialogActions, IconButton } from '@mui/material';
import { Icon } from '@iconify/react';
import { DialogActions } from '@mui/material';
import Autocomplete from '@mui/material/Autocomplete';
import Box from '@mui/material/Box';
import ButtonBase from '@mui/material/ButtonBase';
Expand Down Expand Up @@ -300,16 +300,15 @@ export function ClusterDialog(props: ClusterDialogProps) {
}}
buttons={[
showInfoButton && (
<IconButton
aria-label={t('Show build information')}
<ActionButton
description={t('Show build information')}
onClick={() => {
handleClose();
dispatch(setVersionDialogOpen(true));
}}
size="small"
>
<InlineIcon icon={'mdi:information-outline'} />
</IconButton>
icon={'mdi:information-outline'}
iconButtonProps={{ size: 'small' }}
/>
),
]}
>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/common/ActionMenuItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './ActionButton';
import ActionButton from './ActionButton';
export default ActionButton;
16 changes: 6 additions & 10 deletions frontend/src/components/common/Resource/Resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { InputLabel } from '@mui/material';
import Box from '@mui/material/Box';
import Divider from '@mui/material/Divider';
import Grid, { GridProps, GridSize } from '@mui/material/Grid';
import IconButton from '@mui/material/IconButton';
import Input, { InputProps } from '@mui/material/Input';
import Paper from '@mui/material/Paper';
import { BaseTextFieldProps } from '@mui/material/TextField';
Expand Down Expand Up @@ -38,7 +37,7 @@ import {
DetailsViewSection,
} from '../../DetailsViewSection/detailsViewSectionSlice';
import { PodListProps, PodListRenderer } from '../../pod/List';
import { LightTooltip, Loader, ObjectEventList } from '..';
import { ActionButton, LightTooltip, Loader, ObjectEventList } from '..';
import BackLink from '../BackLink';
import Empty from '../EmptyContent';
import ErrorBoundary from '../ErrorBoundary';
Expand Down Expand Up @@ -473,15 +472,12 @@ export function SecretField(props: InputProps) {
return (
<Grid container alignItems="stretch" spacing={2}>
<Grid item>
<IconButton
edge="end"
aria-label={t('toggle field visibility')}
<ActionButton
description={t('toggle field visibility')}
onClick={handleClickShowPassword}
onMouseDown={event => event.preventDefault()}
size="medium"
>
<Icon icon={showPassword ? 'mdi:eye-off' : 'mdi:eye'} />
</IconButton>
icon={showPassword ? 'mdi:eye-off' : 'mdi:eye'}
iconButtonProps={{ size: 'medium' }}
/>
</Grid>
<Grid item xs>
<Input
Expand Down
17 changes: 8 additions & 9 deletions frontend/src/components/portforward/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -261,13 +261,12 @@ export default function PortForwardingList() {
});
return (
<>
<IconButton
aria-label={t('translation|More')}
<ActionButton
description={t('translation|More')}
onClick={e => handleClick(e, portforward)}
size="medium"
>
<Icon icon={'mdi:dots-vertical'} />
</IconButton>
icon="mdi:dots-vertical"
iconButtonProps={{ size: 'medium' }}
/>
<Menu anchorEl={anchorEl} open={Boolean(anchorEl)} onClose={handleClose}>
{filteredOptions.map(option => (
<MenuItem onClick={() => handleClose(option)}>
Expand Down
Loading