State
> {
mounted = false;
+ errorListElement = React.createRef<HTMLDivElement>();
+
constructor(props: AlmBindingDefinitionFormProps) {
super(props);
if (error) {
this.setState({ validationError: error });
+ if (this.errorListElement?.current) {
+ this.errorListElement.current.scrollIntoView({ block: 'start' });
+ }
} else {
this.props.afterSubmit(formData);
}
bitbucketVariant={bitbucketVariant}
onBitbucketVariantChange={this.handleBitbucketVariantChange}
validationError={validationError}
+ errorListElementRef={this.errorListElement}
/>
);
}
</ButtonSecondary>
</div>
)}
- {showField && isTextArea && (
- <InputTextArea
- id={id}
- maxLength={maxLength || 2000}
- onChange={(e) => props.onFieldChange(propKey, e.currentTarget.value)}
- required={!optional}
- rows={5}
- size="full"
- value={value}
- isInvalid={isInvalid}
- />
- )}
- {showField && !isTextArea && (
- <InputField
- autoFocus={autoFocus}
- id={id}
- maxLength={maxLength || 100}
- name={id}
- onChange={(e) => props.onFieldChange(propKey, e.currentTarget.value)}
- type="text"
- size="full"
- value={value}
- isInvalid={isInvalid}
- />
- )}
+ {showField &&
+ (isTextArea ? (
+ <InputTextArea
+ id={id}
+ maxLength={maxLength || 2000}
+ onChange={(e) => props.onFieldChange(propKey, e.currentTarget.value)}
+ required={!optional}
+ rows={5}
+ size="full"
+ value={value}
+ isInvalid={isInvalid}
+ />
+ ) : (
+ <InputField
+ autoFocus={autoFocus}
+ id={id}
+ maxLength={maxLength || 100}
+ name={id}
+ onChange={(e) => props.onFieldChange(propKey, e.currentTarget.value)}
+ type="text"
+ size="full"
+ value={value}
+ isInvalid={isInvalid}
+ />
+ ))}
{showField && isSecret && (
<FlagMessage variant="info" className="sw-mt-2">
<span>
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { ButtonPrimary, FlagMessage, Modal, Spinner } from 'design-system';
+import { ButtonPrimary, FlagMessage, Modal, PageContentFontWrapper, Spinner } from 'design-system';
import * as React from 'react';
import { translate } from '../../../../helpers/l10n';
import {
bitbucketVariant: AlmKeys.BitbucketServer | AlmKeys.BitbucketCloud,
) => void;
validationError?: string;
+ errorListElementRef: React.RefObject<HTMLDivElement>;
}
export default class AlmBindingDefinitionFormRenderer extends React.PureComponent<Readonly<Props>> {
};
render() {
- const { isUpdate, canSubmit, submitting, validationError } = this.props;
+ const { isUpdate, canSubmit, submitting, validationError, errorListElementRef } = this.props;
const header = translate('settings.almintegration.form.header', isUpdate ? 'edit' : 'create');
const FORM_ID = `settings.almintegration.form.${isUpdate ? 'edit' : 'create'}`;
const formBody = (
<form id={FORM_ID} onSubmit={handleSubmit}>
- {this.renderForm()}
- {validationError && !canSubmit && (
- <FlagMessage variant="error" className="sw-w-full">
- <div>
- <p>{translate('settings.almintegration.configuration_invalid')}</p>
- <ul>
- <li>{validationError}</li>
- </ul>
- </div>
- </FlagMessage>
- )}
+ <PageContentFontWrapper className="sw-body-sm" ref={errorListElementRef}>
+ {validationError && !canSubmit && (
+ <FlagMessage variant="error" className="sw-w-full sw-mb-2">
+ <div>
+ <p>{translate('settings.almintegration.configuration_invalid')}</p>
+ <ul>
+ <li>{validationError}</li>
+ </ul>
+ </div>
+ </FlagMessage>
+ )}
+ {this.renderForm()}
+ </PageContentFontWrapper>
</form>
);
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
+import { Link } from 'design-system';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
-import DocLink from '../../../../components/common/DocLink';
-import Link from '../../../../components/common/Link';
import { ALM_DOCUMENTATION_PATHS } from '../../../../helpers/constants';
+import { useDocUrl } from '../../../../helpers/docs';
import { translate } from '../../../../helpers/l10n';
import { AlmKeys, AzureBindingDefinition } from '../../../../types/alm-settings';
import { AlmBindingDefinitionFormField } from './AlmBindingDefinitionFormField';
export default function AzureForm(props: AzureFormProps) {
const { formData, onFieldChange } = props;
-
+ const toStatic = useDocUrl(ALM_DOCUMENTATION_PATHS[AlmKeys.Azure]);
return (
<>
<AlmBindingDefinitionFormField
</Link>
),
permission: <strong>{'Code > Read & Write'}</strong>,
- doc_link: (
- <DocLink to={ALM_DOCUMENTATION_PATHS[AlmKeys.Azure]}>
- {translate('learn_more')}
- </DocLink>
- ),
+ doc_link: <Link to={toStatic}>{translate('learn_more')}</Link>,
}}
/>
}
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { FlagMessage, Link } from 'design-system';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
-import DocLink from '../../../../components/common/DocLink';
-import Link from '../../../../components/common/Link';
-import { Alert } from '../../../../components/ui/Alert';
import { ALM_DOCUMENTATION_PATHS } from '../../../../helpers/constants';
+import { useDocUrl } from '../../../../helpers/docs';
import { translate } from '../../../../helpers/l10n';
import { AlmKeys, BitbucketCloudBindingDefinition } from '../../../../types/alm-settings';
import { BITBUCKET_CLOUD_WORKSPACE_ID_FORMAT } from '../../constants';
formData.workspace && !BITBUCKET_CLOUD_WORKSPACE_ID_FORMAT.test(formData.workspace),
);
+ const toStatic = useDocUrl(ALM_DOCUMENTATION_PATHS[AlmKeys.BitbucketCloud]);
+
return (
<>
+ <FlagMessage variant="info" className="sw-mb-8">
+ <div>
+ <FormattedMessage
+ defaultMessage={translate(`settings.almintegration.bitbucketcloud.info`)}
+ id="settings.almintegration.bitbucketcloud.info"
+ values={{
+ oauth: (
+ <Link
+ to="https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/"
+ target="_blank"
+ >
+ {translate('settings.almintegration.bitbucketcloud.oauth')}
+ </Link>
+ ),
+ permission: <strong>Pull Requests: Read</strong>,
+ doc_link: <Link to={toStatic}>{translate('learn_more')}</Link>,
+ }}
+ />
+ </div>
+ </FlagMessage>
+
<AlmBindingDefinitionFormField
autoFocus
help={translate('settings.almintegration.form.name.bitbucketcloud.help')}
/>
<AlmBindingDefinitionFormField
help={
- <FormattedMessage
- defaultMessage={translate('settings.almintegration.form.workspace.bitbucketcloud.help')}
- id="settings.almintegration.form.workspace.bitbucketcloud.help"
- values={{
- example: (
- <>
- {'https://bitbucket.org/'}
- <strong>{'{workspace}'}</strong>
- {'/{repository}'}
- </>
- ),
- }}
- />
+ <>
+ <FormattedMessage
+ defaultMessage={translate(
+ 'settings.almintegration.form.workspace.bitbucketcloud.help',
+ )}
+ id="settings.almintegration.form.workspace.bitbucketcloud.help"
+ values={{
+ example: (
+ <>
+ {'https://bitbucket.org/'}
+ <strong>{'{workspace}'}</strong>
+ {'/{repository}'}
+ </>
+ ),
+ }}
+ />
+ <p>{translate('settings.almintegration.form.workspace.bitbucketcloud.error')}</p>
+ </>
}
id="workspace.bitbucketcloud"
isInvalid={workspaceIDIsInvalid}
propKey="workspace"
value={formData.workspace || ''}
/>
- <Alert className="big-spacer-top" variant="info">
- <FormattedMessage
- defaultMessage={translate(`settings.almintegration.bitbucketcloud.info`)}
- id="settings.almintegration.bitbucketcloud.info"
- values={{
- oauth: (
- <Link
- to="https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/"
- target="_blank"
- >
- {translate('settings.almintegration.bitbucketcloud.oauth')}
- </Link>
- ),
- permission: <strong>Pull Requests: Read</strong>,
- doc_link: (
- <DocLink to={ALM_DOCUMENTATION_PATHS[AlmKeys.BitbucketCloud]}>
- {translate('learn_more')}
- </DocLink>
- ),
- }}
- />
- </Alert>
<AlmBindingDefinitionFormField
id="client_id.bitbucketcloud"
help={translate('settings.almintegration.form.oauth_key.bitbucketcloud.help')}
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+import { FormField, ToggleButton } from 'design-system';
import * as React from 'react';
-import ButtonToggle from '../../../../components/controls/ButtonToggle';
import { translate } from '../../../../helpers/l10n';
import {
AlmKeys,
return (
<>
{!isUpdate && (
- <div className="display-flex-column">
- <strong>{translate('settings.almintegration.form.choose_bitbucket_variant')}</strong>
- <div className="little-spacer-top big-spacer-bottom">
- <ButtonToggle
+ <FormField label={translate('settings.almintegration.form.choose_bitbucket_variant')}>
+ <div>
+ <ToggleButton
label={translate('settings.almintegration.form.choose_bitbucket_variant')}
- onCheck={props.onVariantChange}
+ onChange={props.onVariantChange}
options={[
{
label: translate('alm.bitbucket.long'),
value={variant}
/>
</div>
- </div>
+ </FormField>
)}
{variant !== undefined && (
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
+import { Link } from 'design-system';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
-import DocLink from '../../../../components/common/DocLink';
-import Link from '../../../../components/common/Link';
import { ALM_DOCUMENTATION_PATHS } from '../../../../helpers/constants';
+import { useDocUrl } from '../../../../helpers/docs';
import { translate } from '../../../../helpers/l10n';
import { AlmKeys, BitbucketServerBindingDefinition } from '../../../../types/alm-settings';
import { AlmBindingDefinitionFormField } from './AlmBindingDefinitionFormField';
export default function BitbucketServerForm(props: BitbucketServerFormProps) {
const { formData } = props;
-
+ const toStatic = useDocUrl(ALM_DOCUMENTATION_PATHS[AlmKeys.BitbucketServer]);
return (
<>
<AlmBindingDefinitionFormField
</Link>
),
permission: <strong>Read</strong>,
- doc_link: (
- <DocLink to={ALM_DOCUMENTATION_PATHS[AlmKeys.BitbucketServer]}>
- {translate('learn_more')}
- </DocLink>
- ),
+ doc_link: <Link to={toStatic}>{translate('learn_more')}</Link>,
}}
/>
}
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { FlagMessage, Link, PageContentFontWrapper } from 'design-system';
+import { FlagMessage, Link } from 'design-system';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import { ALM_DOCUMENTATION_PATHS } from '../../../../helpers/constants';
const { formData, onFieldChange } = props;
const toStatic = useDocUrl(ALM_DOCUMENTATION_PATHS[AlmKeys.GitHub]);
return (
- <PageContentFontWrapper className="sw-body-sm">
+ <>
<FlagMessage variant="info" className="sw-mb-8">
<span>
<FormattedMessage
isSecret
optional
/>
- </PageContentFontWrapper>
+ </>
);
}
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
+import { Link } from 'design-system';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
-import DocLink from '../../../../components/common/DocLink';
-import Link from '../../../../components/common/Link';
import { ALM_DOCUMENTATION_PATHS } from '../../../../helpers/constants';
+import { useDocUrl } from '../../../../helpers/docs';
import { translate } from '../../../../helpers/l10n';
import { AlmKeys, GitlabBindingDefinition } from '../../../../types/alm-settings';
import { AlmBindingDefinitionFormField } from './AlmBindingDefinitionFormField';
export default function GitlabForm(props: GitlabFormProps) {
const { formData, onFieldChange } = props;
-
+ const toStatic = useDocUrl(ALM_DOCUMENTATION_PATHS[AlmKeys.GitLab]);
return (
<>
<AlmBindingDefinitionFormField
),
permission: <strong>Reporter</strong>,
scope: <strong>api</strong>,
- doc_link: (
- <DocLink to={ALM_DOCUMENTATION_PATHS[AlmKeys.GitLab]}>
- {translate('learn_more')}
- </DocLink>
- ),
+ doc_link: <Link to={toStatic}>{translate('learn_more')}</Link>,
}}
/>
}
tab: (almKey: AlmKeys) =>
byRole('tab', { name: `${almKey} settings.almintegration.tab.${almKey}` }),
bitbucketConfiguration: (almKey: AlmKeys.BitbucketCloud | AlmKeys.BitbucketServer) =>
- byRole('button', { name: `alm.${almKey}.long` }),
+ byRole('radio', { name: `alm.${almKey}.long` }),
configurationInput: (id: string) =>
byRole('textbox', { name: `settings.almintegration.form.${id} required` }),
updateSecretValueButton: (key: string) =>