Skip to content

Commit

Permalink
Support enter for dialog (#149)
Browse files Browse the repository at this point in the history
* support pressing 'enter' for deleting dialog

* support pressing enter for dialogs
  • Loading branch information
shanghaikid authored Dec 15, 2022
1 parent 5526375 commit 4c1f05d
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 121 deletions.
6 changes: 3 additions & 3 deletions client/src/components/customDialog/CustomDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const CustomDialog: FC<CustomDialogType> = props => {
onClose={handleCancel}
>
{type === 'notice' ? (
<>
<form onSubmit={handleConfirm}>
<CustomDialogTitle
classes={{ root: classes.title }}
onClose={handleCancel}
Expand All @@ -121,15 +121,15 @@ const CustomDialog: FC<CustomDialogType> = props => {
{cancelLabel}
</CustomButton>
<CustomButton
onClick={() => handleConfirm()}
type="submit"
color="primary"
variant="contained"
className={confirmClass}
>
{confirmLabel}
</CustomButton>
</DialogActions>
</>
</form>
) : (
CustomComponent
)}
Expand Down
99 changes: 52 additions & 47 deletions client/src/components/customDialog/DeleteDialogTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,55 +66,60 @@ const DeleteTemplate: FC<DeleteDialogContentType> = props => {

return (
<div className={classes.root}>
<CustomDialogTitle classes={{ root: classes.mb }} onClose={onCancelClick}>
{title}
</CustomDialogTitle>
<form onSubmit={onDeleteClick}>
<CustomDialogTitle
classes={{ root: classes.mb }}
onClose={onCancelClick}
>
{title}
</CustomDialogTitle>

<DialogContent>
<Typography variant="body1">{text}</Typography>
<Typography variant="body1" className={classes.mb}>
{dialogTrans('deleteTipAction')}
<strong
className={classes.btnLabel}
>{` ${label.toLowerCase()} `}</strong>
{dialogTrans('deleteTipPurpose')}
</Typography>
<TextField
value={value}
onChange={onChange}
InputLabelProps={{
classes: {
root: classes.label,
},
}}
InputProps={{
classes: {
input: classes.input,
},
}}
variant="filled"
fullWidth={true}
/>
</DialogContent>
<DialogContent>
<Typography variant="body1">{text}</Typography>
<Typography variant="body1" className={classes.mb}>
{dialogTrans('deleteTipAction')}
<strong
className={classes.btnLabel}
>{` ${label.toLowerCase()} `}</strong>
{dialogTrans('deleteTipPurpose')}
</Typography>
<TextField
value={value}
onChange={onChange}
InputLabelProps={{
classes: {
root: classes.label,
},
}}
InputProps={{
classes: {
input: classes.input,
},
}}
variant="filled"
fullWidth={true}
/>
</DialogContent>

<DialogActions className={classes.btnWrapper}>
<CustomButton
name="cancel"
onClick={onCancelClick}
className={classes.cancelBtn}
>
{btnTrans('cancel')}
</CustomButton>
<CustomButton
variant="contained"
onClick={onDeleteClick}
color="secondary"
disabled={!deleteReady}
name="delete"
>
{label}
</CustomButton>
</DialogActions>
<DialogActions className={classes.btnWrapper}>
<CustomButton
name="cancel"
onClick={onCancelClick}
className={classes.cancelBtn}
>
{btnTrans('cancel')}
</CustomButton>
<CustomButton
type="submit"
variant="contained"
color="secondary"
disabled={!deleteReady}
name="delete"
>
{label}
</CustomButton>
</DialogActions>
</form>
</div>
);
};
Expand Down
85 changes: 47 additions & 38 deletions client/src/components/customDialog/DialogTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,46 +78,55 @@ const DialogTemplate: FC<DialogContainerProps> = ({

return (
<section className={classes.wrapper}>
<div
ref={dialogRef}
className={`${classes.dialog} ${classes.block} ${dialogClass}`}
>
<CustomDialogTitle onClose={handleClose} showCloseIcon={showCloseIcon}>
{title}
</CustomDialogTitle>
<DialogContent>{children}</DialogContent>
{showActions && (
<DialogActions className={classes.actions}>
<div>{leftActions}</div>
<div>
{showCancel && (
<CustomButton onClick={onCancel} color="default" name="cancel">
{cancel}
<form onSubmit={handleConfirm}>
<div
ref={dialogRef}
className={`${classes.dialog} ${classes.block} ${dialogClass}`}
>
<CustomDialogTitle
onClose={handleClose}
showCloseIcon={showCloseIcon}
>
{title}
</CustomDialogTitle>
<DialogContent>{children}</DialogContent>
{showActions && (
<DialogActions className={classes.actions}>
<div>{leftActions}</div>
<div>
{showCancel && (
<CustomButton
onClick={onCancel}
color="default"
name="cancel"
>
{cancel}
</CustomButton>
)}
<CustomButton
type="submit"
variant="contained"
color="primary"
disabled={confirmDisabled}
name="confirm"
>
{confirm}
</CustomButton>
)}
<CustomButton
variant="contained"
onClick={handleConfirm}
color="primary"
disabled={confirmDisabled}
name="confirm"
>
{confirm}
</CustomButton>
</div>
</DialogActions>
)}
</div>
</div>
</DialogActions>
)}
</div>

<div className={`${classes.block} ${classes.codeWrapper}`}>
{showCode && (
<CodeView
height={dialogHeight}
wrapperClass={classes.code}
data={codeBlocksData}
/>
)}
</div>
<div className={`${classes.block} ${classes.codeWrapper}`}>
{showCode && (
<CodeView
height={dialogHeight}
wrapperClass={classes.code}
data={codeBlocksData}
/>
)}
</div>
</form>
</section>
);
};
Expand Down
1 change: 0 additions & 1 deletion client/src/i18n/cn/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const commonTrans = {
username: 'Username',
password: 'Password',
optional: '(optional)',

ssl: 'SSL',
},
status: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/i18n/cn/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const dialogTrans = {
loadContent: `You are trying to load a {{type}} with data. Only loaded {{type}} can be searched.`,
releaseContent: `You are trying to release a {{type}} with data. Please be aware that the data will no longer be available for search.`,

createTitle: `Create {{type}} in "{{name}}"`,
createTitle: `Create {{type}} on "{{name}}"`,
};

export default dialogTrans;
10 changes: 5 additions & 5 deletions client/src/i18n/cn/search.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const searchTrans = {
firstTip: '1. Enter search vector {{dimensionTip}}',
secondTip: '2. Choose collection and field',
firstTip: '2. Enter search vector {{dimensionTip}}',
secondTip: '1. Choose collection and field',
thirdTip: '3. Set search parameters',
vectorPlaceholder: 'Please input your vector value here, e.g. [1, 2, 3, 4]',
collection: 'Choose Loaded Collection',
noCollection: 'No collection',
field: 'Choose Field',
collection: 'Choose loaded collection',
noCollection: 'No loaded collection',
field: 'Choose vector field',
startTip: 'Start your vector search',
empty: 'No result',
result: 'Search Results',
Expand Down
6 changes: 3 additions & 3 deletions client/src/i18n/cn/success.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const successTrans = {
connect: 'Connection to milvus successful',
create: `{{name}} has been created.`,
load: `{{name}} is loading.`,
delete: `{{name}} successfully dropped,`,
release: `{{name}} has been released,`,
update: `{{name}} has been updated,`,
delete: `{{name}} successfully dropped.`,
release: `{{name}} has been released.`,
update: `{{name}} has been updated.`,
};

export default successTrans;
4 changes: 2 additions & 2 deletions client/src/i18n/cn/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const userTrans = {
createTitle: 'Create User',
updateTitle: 'Update User',
user: 'User',
deleteWarning: 'You are trying to delete user. This action cannot be undone.',
deleteWarning: 'You are trying to drop user. This action cannot be undone.',
oldPassword: 'Current Password',
newPassword: 'New Password',
confirmPassword: 'Confirm Password',
update: 'Update password',
isNotSame: 'Not same as new password',
deleteTip:
'Please select at least one item to delete and root can not be deleted.',
'Please select at least one item to drop and root can not be dropped.',
};

export default userTrans;
2 changes: 1 addition & 1 deletion client/src/i18n/en/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const dialogTrans = {
loadContent: `You are trying to load a {{type}} with data. Only loaded {{type}} can be searched.`,
releaseContent: `You are trying to release a {{type}} with data. Please be aware that the data will no longer be available for search.`,

createTitle: `Create {{type}} in "{{name}}"`,
createTitle: `Create {{type}} on "{{name}}"`,
};

export default dialogTrans;
6 changes: 3 additions & 3 deletions client/src/i18n/en/success.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const successTrans = {
connect: 'Connection to milvus successful',
create: `{{name}} has been created.`,
load: `{{name}} is loading.`,
delete: `{{name}} successfully dropped,`,
release: `{{name}} has been released,`,
update: `{{name}} has been updated,`,
delete: `{{name}} successfully dropped.`,
release: `{{name}} has been released.`,
update: `{{name}} has been updated.`,
};

export default successTrans;
4 changes: 2 additions & 2 deletions client/src/i18n/en/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const userTrans = {
createTitle: 'Create User',
updateTitle: 'Update User',
user: 'User',
deleteWarning: 'You are trying to delete user. This action cannot be undone.',
deleteWarning: 'You are trying to drop user. This action cannot be undone.',
oldPassword: 'Current Password',
newPassword: 'New Password',
confirmPassword: 'Confirm Password',
update: 'Update password',
isNotSame: 'Not same as new password',
deleteTip:
'Please select at least one item to delete and root can not be deleted.',
'Please select at least one item to drop and root can not be dropped.',
};

export default userTrans;
4 changes: 2 additions & 2 deletions client/src/pages/collections/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const CreateCollection: FC<CollectionCreateProps> = ({ handleCreate }) => {
confirmDisabled={disabled || !allFieldsValid}
dialogClass={classes.dialog}
>
<form>
<>
<fieldset className={classes.fieldset}>
<legend>{collectionTrans('general')}</legend>
{generalInfoConfigs.map(config => (
Expand Down Expand Up @@ -251,7 +251,7 @@ const CreateCollection: FC<CollectionCreateProps> = ({ handleCreate }) => {
variant="filled"
/>
</fieldset>
</form>
</>
</DialogTemplate>
);
};
Expand Down
14 changes: 6 additions & 8 deletions client/src/pages/partitions/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@ const CreatePartition: FC<PartitionCreateProps> = ({
handleConfirm={handleCreatePartition}
confirmDisabled={disabled}
>
<form>
<CustomInput
type="text"
textConfig={nameInputConfig}
checkValid={checkIsValid}
validInfo={validation}
/>
</form>
<CustomInput
type="text"
textConfig={nameInputConfig}
checkValid={checkIsValid}
validInfo={validation}
/>
</DialogTemplate>
);
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/user/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const CreateUser: FC<CreateUserProps> = ({ handleCreate, handleClose }) => {
handleConfirm={handleCreateUser}
confirmDisabled={disabled}
>
<form>
<>
{createConfigs.map(v => (
<CustomInput
type="text"
Expand All @@ -98,7 +98,7 @@ const CreateUser: FC<CreateUserProps> = ({ handleCreate, handleClose }) => {
key={v.label}
/>
))}
</form>
</>
</DialogTemplate>
);
};
Expand Down
Loading

0 comments on commit 4c1f05d

Please sign in to comment.