3 * Copyright (C) 2009-2021 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 import * as React from 'react';
21 import { ResetButtonLink, SubmitButton } from 'sonar-ui-common/components/controls/buttons';
22 import SimpleModal from 'sonar-ui-common/components/controls/SimpleModal';
23 import { Alert } from 'sonar-ui-common/components/ui/Alert';
24 import DeferredSpinner from 'sonar-ui-common/components/ui/DeferredSpinner';
25 import { translate } from 'sonar-ui-common/helpers/l10n';
27 export interface AlmBindingDefinitionFormModalProps {
28 action: 'edit' | 'create';
29 canSubmit: () => boolean;
30 children: React.ReactNode;
31 help?: React.ReactNode;
32 isSecondInstance: boolean;
37 export default function AlmBindingDefinitionFormModalRenderer(
38 props: AlmBindingDefinitionFormModalProps
40 const { action, children, help, isSecondInstance } = props;
41 const header = translate('settings.almintegration.form.header', action);
44 <SimpleModal header={header} onClose={props.onCancel} onSubmit={props.onSubmit} size="medium">
45 {({ onCloseClick, onFormSubmit, submitting }) => (
46 <form className="views-form" onSubmit={onFormSubmit}>
47 <div className="modal-head">
51 <div className="modal-body modal-container">
52 {isSecondInstance && action === 'create' && (
53 <Alert className="big-spacer-bottom" variant="warning">
54 {translate('settings.almintegration.form.second_instance_warning')}
58 <div className="display-flex-start">
59 <div className="flex-1">{children}</div>
62 <Alert className="huge-spacer-left flex-1" variant="info">
69 <div className="modal-foot">
70 <DeferredSpinner className="spacer-right" loading={submitting} />
71 <SubmitButton disabled={submitting || !props.canSubmit()}>
72 {translate('settings.almintegration.form.save')}
74 <ResetButtonLink onClick={onCloseClick}>{translate('cancel')}</ResetButtonLink>