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

Fix dialogs style errors #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/component/AddClusterRoleBindingDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const AddClusterRoleBindingDialog = ({ open, onClose, onSubmit }: AddClusterRole
<TextField
label="Name"
placeholder="name"
margin="dense"
variant="outlined"
required
error={!name}
Expand Down
3 changes: 2 additions & 1 deletion src/component/AddClusterRoleDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const AddClusterRoleDialog = ({ open, onClose, onSubmit }: AddClusterRoleDialogP
<DialogContent>
<Box sx={{ marginBottom: '16px' }}>
<TextField
margin="dense"
label="Name"
placeholder="name"
fullWidth
Expand Down Expand Up @@ -260,7 +261,7 @@ const AddClusterRoleDialog = ({ open, onClose, onSubmit }: AddClusterRoleDialogP
</Box>
</DialogContent>
<DialogActions>
<Button onClick={handleClose} variant="outlined">Cancel</Button>
<Button onClick={handleClose}>Cancel</Button>
<Button onClick={handleSubmit} variant="contained">Submit</Button>
</DialogActions>
</Dialog>
Expand Down
4 changes: 2 additions & 2 deletions src/component/AddConfigmapDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ const AddConfigmapDialog = ({ open, onClose, onSubmit }: AddConfigmapDialogProps
<Dialog open={!!open} onClose={handleClose}>
<DialogTitle>Add Configmap</DialogTitle>
<DialogContent>
<Box sx={{ width: '500px' }}>
<FormControl fullWidth sx={{ marginBottom: '16px' }}>
<Box sx={{ width: '500px', gap: '16px' }}>
<FormControl fullWidth margin="dense">
<InputLabel id="namespace-label">Namespace</InputLabel>
<Select
labelId="namespace-label"
Expand Down
3 changes: 2 additions & 1 deletion src/component/AddDeviceDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const AddDeviceDialog = ({ open, onClose, onSubmit }: AddDeviceDialogProps) => {
render={({ field }) => (
<TextField
{...field}
margin="dense"
label="Name"
placeholder="name"
variant="outlined"
Expand Down Expand Up @@ -278,7 +279,7 @@ const AddDeviceDialog = ({ open, onClose, onSubmit }: AddDeviceDialogProps) => {
</TableContainer>
</Box>
<DialogActions>
<Button onClick={handleClose} variant="outlined">
<Button onClick={handleClose}>
Cancel
</Button>
<Button type="submit" variant="contained">
Expand Down
2 changes: 2 additions & 0 deletions src/component/AddDeviceModelDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const AddDeviceModelDialog = ({ open, onClose, onSubmit }: AddDeviceModelDialogP
<DialogContent>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
<TextField
margin="dense"
label="Name"
variant="outlined"
value={name}
Expand Down Expand Up @@ -167,6 +168,7 @@ const AddDeviceModelDialog = ({ open, onClose, onSubmit }: AddDeviceModelDialogP
<FormControl fullWidth>
<InputLabel>Attribute Type</InputLabel>
<Select
label="Attribute Type"
value={attributeType}
onChange={(e) => setAttributeType(e.target.value)}
displayEmpty
Expand Down
3 changes: 3 additions & 0 deletions src/component/AddEdgeApplicationDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const TargetNodeGroupField = ({ index, onRemove, nodeGroups, value, onChange }:
fullWidth
select
placeholder="name"
label="Name"
margin="dense"
value={value?.name}
onChange={(event) => onChange(index, 'name', event.target.value)}
sx={{ marginBottom: '8px' }}
Expand Down Expand Up @@ -162,6 +164,7 @@ const AddEdgeApplicationDialog = ({ open, onClose, onSubmit }: AddEdgeApplicatio
fullWidth
select
label="Namespace"
margin="dense"
value={namespace}
onChange={(e) => setNamespace(e.target.value)}
required
Expand Down
8 changes: 7 additions & 1 deletion src/component/AddNodeDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const AddNodeDialog = ({ open, onClose }: AddNodeDialogProps) => {
error={!!formErrors.cloudMasterIP}
helperText={formErrors.cloudMasterIP}
placeholder="192.168.30.300:3000"
margin="dense"
required
fullWidth
/>
Expand All @@ -82,15 +83,18 @@ const AddNodeDialog = ({ open, onClose }: AddNodeDialogProps) => {
error={!!formErrors.kubeedgeVersion}
helperText={formErrors.kubeedgeVersion}
placeholder="1.12.1"
margin="dense"
required
fullWidth
/>
<FormControl error={!!formErrors.runtimeType} fullWidth required>
<InputLabel>Runtime type</InputLabel>
<InputLabel id="runtime-type-select-label">Runtime type</InputLabel>
<Select
labelId="runtime-type-select-label"
name="runtimeType"
value={formValues.runtimeType}
onChange={handleInputChange}
label="Runtime type"
placeholder="Please select a runtime type"
>
<MenuItem value="docker">Docker</MenuItem>
Expand All @@ -106,6 +110,7 @@ const AddNodeDialog = ({ open, onClose }: AddNodeDialogProps) => {
error={!!formErrors.token}
helperText={formErrors.token}
placeholder="Please enter Token"
margin="dense"
required
fullWidth
/>
Expand All @@ -117,6 +122,7 @@ const AddNodeDialog = ({ open, onClose }: AddNodeDialogProps) => {
multiline
rows={4}
placeholder="Please enter command"
margin="dense"
/>
</Box>
</DialogContent>
Expand Down
43 changes: 25 additions & 18 deletions src/component/AddNodeGroupDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Dialog, DialogTitle, DialogContent, TextField, MenuItem, Button, IconButton, Box, Typography } from '@mui/material';
import { Dialog, DialogTitle, DialogContent, TextField, MenuItem, Button, IconButton, Box, Typography, FormControl, InputLabel } from '@mui/material';
import AddIcon from '@mui/icons-material/Add';
import RemoveIcon from '@mui/icons-material/Remove';
import { Select } from '@mui/material';
Expand Down Expand Up @@ -82,24 +82,29 @@ const AddNodeGroupDialog = ({ open, onClose, onSubmit }: AddNodeGroupDialogProps
value={name}
onChange={handleNameChange}
required
margin="dense"
helperText={!name && 'Miss name'}
/>
<Select
multiple
value={nodes}
onChange={handleNodesChange}
renderValue={(selected) => selected.join(', ')}
displayEmpty
required
placeholder="nodes"
sx={{ minWidth: 300 }}
>
{data?.items?.map((node) => (
<MenuItem key={node?.metadata?.uid} value={node?.metadata?.name || ''}>
{node?.metadata?.name || ''}
</MenuItem>
))}
</Select>
<FormControl fullWidth>
<InputLabel id="nodes-select-label">Nodes</InputLabel>
<Select
multiple
labelId="nodes-select-label"
value={nodes}
onChange={handleNodesChange}
renderValue={(selected) => selected.join(', ')}
required
label="Nodes"
placeholder="nodes"
sx={{ minWidth: 300 }}
>
{data?.items?.map((node) => (
<MenuItem key={node?.metadata?.uid} value={node?.metadata?.name || ''}>
{node?.metadata?.name || ''}
</MenuItem>
))}
</Select>
</FormControl>
<Box>
<Typography variant="subtitle1" sx={{ marginBottom: '8px' }}>MatchLabels</Typography>
{matchLabels.map((matchLabel, index) => (
Expand All @@ -108,6 +113,7 @@ const AddNodeGroupDialog = ({ open, onClose, onSubmit }: AddNodeGroupDialogProps
label="Key"
placeholder="Please input key"
variant="outlined"
margin="dense"
value={matchLabel.key}
onChange={(e) => handleMatchLabelChange(index, 'key', e.target.value)}
sx={{ flex: 1 }}
Expand All @@ -118,6 +124,7 @@ const AddNodeGroupDialog = ({ open, onClose, onSubmit }: AddNodeGroupDialogProps
label="Value"
placeholder="Please input value"
variant="outlined"
margin="dense"
value={matchLabel.value}
onChange={(e) => handleMatchLabelChange(index, 'value', e.target.value)}
sx={{ flex: 1 }}
Expand All @@ -141,7 +148,7 @@ const AddNodeGroupDialog = ({ open, onClose, onSubmit }: AddNodeGroupDialogProps
</Button>
</Box>
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: '16px' }}>
<Button variant="outlined" onClick={handleClose}>Cancel</Button>
<Button onClick={handleClose}>Cancel</Button>
<Button variant="contained" onClick={handleSubmit}>Submit</Button>
</Box>
</Box>
Expand Down
35 changes: 19 additions & 16 deletions src/component/AddRoleBindingDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Dialog, DialogTitle, DialogContent, TextField, Button, Box, Typography, IconButton, MenuItem, Select } from '@mui/material';
import { Dialog, DialogTitle, DialogContent, TextField, Button, Box, Typography, IconButton, MenuItem, Select, FormControl, InputLabel } from '@mui/material';
import AddIcon from '@mui/icons-material/Add';
import RemoveIcon from '@mui/icons-material/Remove';
import { RoleBinding, RoleRef, Subject } from '@/types/roleBinding';
Expand Down Expand Up @@ -73,20 +73,23 @@ const AddRoleBindingDialog = ({ open, onClose, onSubmit }: AddRoleBindingDialogP
<DialogTitle>Add RoleBinding</DialogTitle>
<DialogContent>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
<Select
label="Namespace"
value={namespace}
onChange={(event) => setNamespace(event.target.value)}
sx={{ marginBottom: '16px' }}
required
placeholder="Namespace"
>
{data?.items?.map((item) => (
<MenuItem key={item.metadata?.uid} value={item?.metadata?.name}>
{item?.metadata?.name}
</MenuItem>
))}
</Select>
<FormControl fullWidth margin="dense">
<InputLabel>Namespace</InputLabel>
<Select
label="Namespace"
value={namespace}
onChange={(event) => setNamespace(event.target.value)}
sx={{ marginBottom: '16px' }}
required
placeholder="Namespace"
>
{data?.items?.map((item) => (
<MenuItem key={item.metadata?.uid} value={item?.metadata?.name}>
{item?.metadata?.name}
</MenuItem>
))}
</Select>
</FormControl>
<TextField
label="Name"
variant="outlined"
Expand Down Expand Up @@ -172,7 +175,7 @@ const AddRoleBindingDialog = ({ open, onClose, onSubmit }: AddRoleBindingDialogP
</Button>
</Box>
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: '16px' }}>
<Button variant="outlined" onClick={handleClose}>Cancel</Button>
<Button onClick={handleClose}>Cancel</Button>
<Button variant="contained" color="primary" onClick={handleSubmit}>Submit</Button>
</Box>
</Box>
Expand Down
3 changes: 2 additions & 1 deletion src/component/AddRoleDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const AddRoleDialog = ({ open, onClose, onSubmit }: AddRoleDialogProps) => {
<DialogContent>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
<TextField
margin="dense"
label="Namespace"
placeholder="Please select namespace"
variant="outlined"
Expand Down Expand Up @@ -156,7 +157,7 @@ const AddRoleDialog = ({ open, onClose, onSubmit }: AddRoleDialogProps) => {
</Button>
</Box>
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: '16px', marginTop: '16px' }}>
<Button variant="outlined" onClick={handleClose}>Cancel</Button>
<Button onClick={handleClose}>Cancel</Button>
<Button variant="contained" color="primary" onClick={handleSubmit}>Submit</Button>
</Box>
</Box>
Expand Down
6 changes: 4 additions & 2 deletions src/component/AddRuleDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ const AddRuleDialog = ({ open, onClose, onSubmit }: AddRuleDialogProps) => {
<DialogTitle>Add Rule</DialogTitle>
<DialogContent>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
<FormControl fullWidth>
<FormControl fullWidth margin="dense">
<InputLabel>Namespace</InputLabel>
<Select
label="Namespace"
value={namespace}
onChange={(e) => setNamespace(e.target.value)}
displayEmpty
>
{namespaceData?.items?.map(item => (
<MenuItem key={item?.metadata?.uid} value={item?.metadata?.name}>
Expand All @@ -133,6 +133,7 @@ const AddRuleDialog = ({ open, onClose, onSubmit }: AddRuleDialogProps) => {
<FormControl fullWidth>
<InputLabel>Source</InputLabel>
<Select
label="Source"
value={source}
onChange={(e) => setSource(e.target.value)}
displayEmpty
Expand Down Expand Up @@ -160,6 +161,7 @@ const AddRuleDialog = ({ open, onClose, onSubmit }: AddRuleDialogProps) => {
<FormControl fullWidth>
<InputLabel>Target</InputLabel>
<Select
label="Target"
value={target}
onChange={(e) => setTarget(e.target.value)}
displayEmpty
Expand Down
2 changes: 2 additions & 0 deletions src/component/AddRuleEndpointDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const AddRuleEndpointDialog = ({ open, onClose, onSubmit }: AddRuleEndpointDialo
<FormControl fullWidth margin="normal" error={!!errors.newNamespace}>
<InputLabel required>Namespace</InputLabel>
<Select
label="Namespace"
value={namespace}
onChange={(e) => setNamespace(e.target.value)}
placeholder="Namespace"
Expand Down Expand Up @@ -102,6 +103,7 @@ const AddRuleEndpointDialog = ({ open, onClose, onSubmit }: AddRuleEndpointDialo
<FormControl fullWidth margin="normal" error={!!errors.ruleEndpointType}>
<InputLabel required>RuleEndpointType</InputLabel>
<Select
label="RuleEndpointType"
value={endpointType}
onChange={(event) => setEndpointType(event.target.value)}
placeholder="RuleEndpointType"
Expand Down
3 changes: 2 additions & 1 deletion src/component/AddSecretDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const AddSecretDialog = ({ open, onClose, onSubmit }: AddSecretDialogProps) => {
<Box component="form" sx={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
<TextField
select
margin="dense"
label="Namespace"
value={namespace}
onChange={handleNamespaceChange}
Expand Down Expand Up @@ -217,7 +218,7 @@ const AddSecretDialog = ({ open, onClose, onSubmit }: AddSecretDialogProps) => {
)}

<Box sx={{ display: 'flex', justifyContent: 'flex-end', marginTop: '16px' }}>
<Button onClick={handleClose} color="secondary" variant="outlined">
<Button onClick={handleClose}>
Cancel
</Button>
<Button onClick={handleSave} color="primary" variant="contained" sx={{ marginLeft: '16px' }}>
Expand Down
8 changes: 4 additions & 4 deletions src/component/AddServiceAccountDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface AddServiceAccountDialogProps {
const AddServiceAccountDialog = ({ open, onClose, onSubmit }: AddServiceAccountDialogProps) => {
const [namespace, setNamespace] = React.useState('');
const [name, setName] = React.useState('');
const [secrets, setSecrets] = React.useState([]);
const [secrets, setSecrets] = React.useState<string[]>([]);
const [formErrors, setFormErrors] = React.useState<any>({});
const namespaceData = useListNamespaces()?.data;
const { data, mutate } = useListSecrets(namespace);
Expand Down Expand Up @@ -67,6 +67,7 @@ const AddServiceAccountDialog = ({ open, onClose, onSubmit }: AddServiceAccountD
<FormControl fullWidth margin="normal" error={Boolean(formErrors.namespace)}>
<InputLabel required>Namespace</InputLabel>
<Select
label="Namespace"
value={namespace}
onChange={(event) => setNamespace(event.target.value)}
placeholder="Namespace"
Expand Down Expand Up @@ -98,11 +99,10 @@ const AddServiceAccountDialog = ({ open, onClose, onSubmit }: AddServiceAccountD
<FormControl fullWidth margin="normal" error={Boolean(formErrors.secrets)}>
<InputLabel required>Secrets</InputLabel>
<Select<string[]>
label="Secrets"
multiple
value={secrets}
// TODO: remove it
// @ts-ignore
onChange={(event) => setSecrets(event.target.value)}
onChange={(event) => setSecrets(typeof event.target.value === 'string' ? [event.target.value] : event.target.value)}
placeholder="Secrets"
>
{data?.items?.map((secret) => (
Expand Down
Loading