aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2018-02-02 11:34:03 +0100
committerGuillaume Jambet <guillaume.jambet@gmail.com>2018-03-01 15:21:05 +0100
commit827381f0e4e80b69ba67cd0128f47166eda916be (patch)
tree53068fededf21e19aa6684dd2e258f0f4f233e35 /server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx
parent85f7f977c021ea177d3f2442efa114997e313aa2 (diff)
downloadsonarqube-827381f0e4e80b69ba67cd0128f47166eda916be.tar.gz
sonarqube-827381f0e4e80b69ba67cd0128f47166eda916be.zip
SONAR-10345 Add webhooks management actions
* SONAR-10345 Add the webhooks create/update form * SONAR-10345 Add the webhooks delete action * SONAR-10345 Add fields validation on webhook create page
Diffstat (limited to 'server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx')
-rw-r--r--server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx49
1 files changed, 49 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx b/server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx
new file mode 100644
index 00000000000..503b58952e3
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/controls/ModalValidationField.tsx
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import * as React from 'react';
+import * as classNames from 'classnames';
+import AlertErrorIcon from '../icons-components/AlertErrorIcon';
+import AlertSuccessIcon from '../icons-components/AlertSuccessIcon';
+
+interface Props {
+ children: (props: { className?: string }) => React.ReactNode;
+ description?: string;
+ dirty: boolean;
+ error: string | undefined;
+ label?: React.ReactNode;
+ touched: boolean;
+}
+
+export default function ModalValidationField(props: Props) {
+ const { description, dirty, error } = props;
+
+ const isValid = dirty && props.touched && error === undefined;
+ const showError = dirty && props.touched && error !== undefined;
+ return (
+ <div className="modal-validation-field">
+ {props.label}
+ {props.children({ className: classNames({ 'has-error': showError, 'is-valid': isValid }) })}
+ {showError && <AlertErrorIcon className="little-spacer-top" />}
+ {isValid && <AlertSuccessIcon className="little-spacer-top" />}
+ {showError && <p className="text-danger">{error}</p>}
+ {description && <div className="modal-field-description">{description}</div>}
+ </div>
+ );
+}