From 2353643c1b7c8b6e5f354fd5abe1d4532e5f8f0f Mon Sep 17 00:00:00 2001 From: Wroud Date: Tue, 8 Sep 2020 18:40:13 +0300 Subject: [PATCH] chore(core-connections): test connection & misc improvements CB-247 --- .../ObjectPropertyInfoForm.tsx | 14 ++++++++++ .../ConnectionForm/ConnectionForm.tsx | 8 ++++++ .../Connections/ConnectionForm/Controller.ts | 13 +++++++++ .../Options/OptionsController.ts | 28 ++++++++++++++++++- .../src/Administration/ConnectionsResource.ts | 6 ++++ .../core-connections/src/locales/en.ts | 1 + .../core-connections/src/locales/ru.ts | 1 + .../ConnectionForm/ConnectionForm.tsx | 2 +- 8 files changed, 71 insertions(+), 2 deletions(-) diff --git a/webapp/packages/core-blocks/src/ObjectPropertyInfoForm/ObjectPropertyInfoForm.tsx b/webapp/packages/core-blocks/src/ObjectPropertyInfoForm/ObjectPropertyInfoForm.tsx index fd93a59551..2ae79b682f 100644 --- a/webapp/packages/core-blocks/src/ObjectPropertyInfoForm/ObjectPropertyInfoForm.tsx +++ b/webapp/packages/core-blocks/src/ObjectPropertyInfoForm/ObjectPropertyInfoForm.tsx @@ -7,6 +7,7 @@ */ import { observer } from 'mobx-react'; +import { useCallback } from 'react'; import styled from 'reshadow'; import { InputField } from '@cloudbeaver/core-blocks'; @@ -37,6 +38,18 @@ export const ObjectPropertyInfoForm = observer(function ObjectPropertyInfoForm({ return styled(useStyles(formStyles))(
Properties empty
); } + const handleFocus = useCallback((e: React.FocusEvent) => { + if (e.target.type !== 'password') { + return; + } + + const property = properties.find(property => property.id === e.target.name); + + if (property?.value === e.target.value) { + credentials[e.target.name] = ''; + } + }, [properties, credentials]); + return styled(useStyles(formStyles))( {properties.map(property => ( @@ -45,6 +58,7 @@ export const ObjectPropertyInfoForm = observer(function ObjectPropertyInfoForm({ type={property.features.includes('password') ? 'password' : 'text'} name={property.id!} state={credentials} + onFocus={handleFocus} disabled={disabled} autoComplete={RESERVED_KEYWORDS.includes(autofillToken) ? autofillToken : `${autofillToken} ${property.id}`} mod='surface' diff --git a/webapp/packages/core-connections/src/Administration/Connections/ConnectionForm/ConnectionForm.tsx b/webapp/packages/core-connections/src/Administration/Connections/ConnectionForm/ConnectionForm.tsx index 214bb1ec5c..16f2ae03b7 100644 --- a/webapp/packages/core-connections/src/Administration/Connections/ConnectionForm/ConnectionForm.tsx +++ b/webapp/packages/core-connections/src/Administration/Connections/ConnectionForm/ConnectionForm.tsx @@ -157,6 +157,14 @@ export const ConnectionForm = observer(function ConnectionForm({ > {translate('ui_processing_cancel')} +