Skip to content

Commit 064ac63

Browse files
committed
fix: code-review
1 parent 8078842 commit 064ac63

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

src/containers/Tenant/Schema/CreateDirectoryDialog/CreateDirectoryDialog.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
&__description {
99
color: var(--g-color-text-secondary);
1010
}
11-
&__error-wrapper {
12-
min-height: var(--g-text-body-1-line-height);
11+
&__input-wrapper {
12+
min-height: 48px;
1313
}
1414
}

src/containers/Tenant/Schema/CreateDirectoryDialog/CreateDirectoryDialog.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import './CreateDirectoryDialog.scss';
1111

1212
const b = cn('ydb-schema-create-directory-dialog');
1313

14-
const relativePathInputName = 'relativePath';
14+
const relativePathInputId = 'relativePath';
1515

1616
interface SchemaTreeProps {
1717
open: boolean;
@@ -28,14 +28,13 @@ function validateRelativePath(value: string) {
2828
}
2929

3030
export function CreateDirectoryDialog({open, onClose, parentPath, onSuccess}: SchemaTreeProps) {
31-
const [showResponseError, setShowResponseError] = React.useState(false);
3231
const [validationError, setValidationError] = React.useState('');
3332
const [relativePath, setRelativePath] = React.useState('');
3433
const [create, response] = schemaApi.useCreateDirectoryMutation();
3534

3635
const resetErrors = () => {
3736
setValidationError('');
38-
setShowResponseError(false);
37+
response.reset();
3938
};
4039

4140
const handleUpdate = (updated: string) => {
@@ -50,7 +49,6 @@ export function CreateDirectoryDialog({open, onClose, parentPath, onSuccess}: Sc
5049
};
5150

5251
const handleSubmit = () => {
53-
setShowResponseError(true);
5452
const path = `${parentPath}/${relativePath}`;
5553
create({
5654
database: parentPath,
@@ -63,8 +61,6 @@ export function CreateDirectoryDialog({open, onClose, parentPath, onSuccess}: Sc
6361
});
6462
};
6563

66-
const hasValidationError = Boolean(validationError);
67-
6864
return (
6965
<Dialog open={open} onClose={handleClose} size="s">
7066
<Dialog.Header caption={i18n('schema.tree.dialog.header')} />
@@ -79,27 +75,27 @@ export function CreateDirectoryDialog({open, onClose, parentPath, onSuccess}: Sc
7975
}}
8076
>
8177
<Dialog.Body>
82-
<label htmlFor={relativePathInputName} className={b('label')}>
78+
<label htmlFor={relativePathInputId} className={b('label')}>
8379
<span className={b('description')}>
8480
{i18n('schema.tree.dialog.description')}
8581
</span>
8682
{`${parentPath}/`}
8783
</label>
88-
<TextInput
89-
placeholder={i18n('schema.tree.dialog.placeholder')}
90-
value={relativePath}
91-
onUpdate={handleUpdate}
92-
autoFocus
93-
hasClear
94-
autoComplete={false}
95-
disabled={response.isLoading}
96-
validationState={validationError ? 'invalid' : undefined}
97-
name={relativePathInputName}
98-
/>
99-
<div className={b('error-wrapper')}>
100-
{hasValidationError && <ResponseError error={validationError} />}
84+
<div className={b('input-wrapper')}>
85+
<TextInput
86+
placeholder={i18n('schema.tree.dialog.placeholder')}
87+
value={relativePath}
88+
onUpdate={handleUpdate}
89+
autoFocus
90+
hasClear
91+
autoComplete={false}
92+
disabled={response.isLoading}
93+
validationState={validationError ? 'invalid' : undefined}
94+
id={relativePathInputId}
95+
errorMessage={validationError}
96+
/>
10197
</div>
102-
{showResponseError && response.isError && (
98+
{response.isError && (
10399
<ResponseError
104100
error={response.error}
105101
defaultMessage={i18n('schema.tree.dialog.invalid')}

0 commit comments

Comments
 (0)