From 16d235022a4711857cde9d0953be3a864b1bfb83 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Mon, 4 Jan 2021 11:42:25 +0100 Subject: SONAR-12840 Toggle private field visibility on update --- .../AlmBindingDefinitionFormField.tsx | 29 ++++++++++++++++++---- .../components/almIntegration/AzureForm.tsx | 1 + .../components/almIntegration/BitbucketForm.tsx | 1 + .../components/almIntegration/GithubForm.tsx | 2 ++ .../components/almIntegration/GitlabForm.tsx | 1 + .../AlmBindingDefinitionFormField-test.tsx | 13 ++++++++++ .../AlmBindingDefinitionFormField-test.tsx.snap | 28 +++++++++++++++++++++ .../__snapshots__/AzureForm-test.tsx.snap | 2 ++ .../__snapshots__/BitbucketForm-test.tsx.snap | 2 ++ .../__snapshots__/GithubForm-test.tsx.snap | 4 +++ .../__snapshots__/GitlabForm-test.tsx.snap | 2 ++ .../main/resources/org/sonar/l10n/core.properties | 2 ++ 12 files changed, 82 insertions(+), 5 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormField.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormField.tsx index 33e6912b5ed..b86c8209f8f 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormField.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmBindingDefinitionFormField.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; +import { ButtonLink } from 'sonar-ui-common/components/controls/buttons'; import HelpTooltip from 'sonar-ui-common/components/controls/HelpTooltip'; import { translate } from 'sonar-ui-common/helpers/l10n'; import { AlmBindingDefinition } from '../../../../types/alm-settings'; @@ -30,6 +31,7 @@ export interface AlmBindingDefinitionFormFieldProps void; optional?: boolean; + overwriteOnly?: boolean; propKey: keyof B; readOnly?: boolean; value: string; @@ -44,12 +46,13 @@ export function AlmBindingDefinitionFormField( id, isTextArea, maxLength, - onFieldChange, optional, + overwriteOnly = false, propKey, readOnly = false, value } = props; + const [showField, setShowField] = React.useState(!overwriteOnly); return (
@@ -58,18 +61,34 @@ export function AlmBindingDefinitionFormField( {!optional && *} {help && } - {isTextArea ? ( + + {!showField && overwriteOnly && ( +
+

{translate('settings.almintegration.form.secret_field')}

+ { + props.onFieldChange(propKey, ''); + setShowField(true); + }}> + {translate('settings.almintegration.form.update_secret_field')} + +
+ )} + + {showField && isTextArea && (