add docs links to notification templates, project scm

This commit is contained in:
Keith J. Grant
2021-04-05 10:16:51 -07:00
parent 64b9d61dd4
commit 4227f7276b
2 changed files with 92 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
import 'styled-components/macro';
import React, { useEffect, useRef } from 'react';
import { Trans, withI18n } from '@lingui/react';
import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro';
import { useField, useFormikContext } from 'formik';
import { Switch, Text } from '@patternfly/react-core';
@@ -9,6 +9,8 @@ import {
SubFormLayout,
} from '../../../components/FormLayout';
import CodeEditorField from '../../../components/CodeEditor/CodeEditorField';
import { useConfig } from '../../../contexts/Config';
import getDocsBaseUrl from '../../../util/getDocsBaseUrl';
function CustomMessagesSubForm({ defaultMessages, type, i18n }) {
const [useCustomField, , useCustomHelpers] = useField('useCustomMessages');
@@ -16,6 +18,7 @@ function CustomMessagesSubForm({ defaultMessages, type, i18n }) {
const showBodies = ['email', 'pagerduty', 'webhook'].includes(type);
const { setFieldValue } = useFormikContext();
const config = useConfig();
const mountedRef = useRef(null);
useEffect(
function resetToDefaultMessages() {
@@ -69,11 +72,9 @@ function CustomMessagesSubForm({ defaultMessages, type, i18n }) {
css="margin-bottom: var(--pf-c-content--MarginBottom)"
>
<small>
<Trans>
Use custom messages to change the content of notifications sent
when a job starts, succeeds, or fails. Use curly braces to
access information about the job:{' '}
</Trans>
{i18n._(t`Use custom messages to change the content of
notifications sent when a job starts, succeeds, or fails. Use
curly braces to access information about the job:`)}{' '}
<code>
{'{{'} job_friendly_name {'}}'}
</code>
@@ -81,23 +82,22 @@ function CustomMessagesSubForm({ defaultMessages, type, i18n }) {
<code>
{'{{'} url {'}}'}
</code>
, <Trans>or attributes of the job such as</Trans>{' '}
,{' '}
<code>
{'{{'} job.status {'}}'}
</code>
.{' '}
<Trans>
You may apply a number of possible variables in the message.
Refer to the{' '}
</Trans>{' '}
{i18n._(t`You may apply a number of possible variables in the
message. For more information, refer to the`)}{' '}
<a
href="https://docs.ansible.com/ansible-tower/latest/html/userguide/notifications.html#create-custom-notifications"
target="_blank"
rel="noopener noreferrer"
href={`${getDocsBaseUrl(
config
)}/html/userguide/notifications.html#create-custom-notifications`}
>
Ansible Tower documentation
</a>{' '}
<Trans>for more details.</Trans>
{i18n._(t`Ansible Tower Documentation.`)}
</a>
</small>
</Text>
<FormFullWidthLayout>

View File

@@ -9,90 +9,97 @@ import {
ScmCredentialFormField,
ScmTypeOptions,
} from './SharedFields';
import { useConfig } from '../../../../contexts/Config';
import getDocsBaseUrl from '../../../../util/getDocsBaseUrl';
const GitSubForm = ({
i18n,
credential,
onCredentialSelection,
scmUpdateOnLaunch,
}) => (
<>
<UrlFormField
i18n={i18n}
tooltip={
<span>
{i18n._(t`Example URLs for GIT Source Control include:`)}
<ul css="margin: 10px 0 10px 20px">
<li>
<code>https://github.com/ansible/ansible.git</code>
</li>
<li>
<code>git@github.com:ansible/ansible.git</code>
</li>
<li>
<code>git://servername.example.com/ansible.git</code>
</li>
</ul>
{i18n._(t`Note: When using SSH protocol for GitHub or
}) => {
const config = useConfig();
return (
<>
<UrlFormField
i18n={i18n}
tooltip={
<span>
{i18n._(t`Example URLs for GIT Source Control include:`)}
<ul css="margin: 10px 0 10px 20px">
<li>
<code>https://github.com/ansible/ansible.git</code>
</li>
<li>
<code>git@github.com:ansible/ansible.git</code>
</li>
<li>
<code>git://servername.example.com/ansible.git</code>
</li>
</ul>
{i18n._(t`Note: When using SSH protocol for GitHub or
Bitbucket, enter an SSH key only, do not enter a username
(other than git). Additionally, GitHub and Bitbucket do
not support password authentication when using SSH. GIT
read only protocol (git://) does not use username or
password information.`)}
</span>
}
/>
<BranchFormField
i18n={i18n}
label={i18n._(t`Source Control Branch/Tag/Commit`)}
/>
<FormField
id="project-scm-refspec"
label={i18n._(t`Source Control Refspec`)}
name="scm_refspec"
type="text"
tooltipMaxWidth="400px"
tooltip={
<span>
{i18n._(t`A refspec to fetch (passed to the Ansible git
</span>
}
/>
<BranchFormField
i18n={i18n}
label={i18n._(t`Source Control Branch/Tag/Commit`)}
/>
<FormField
id="project-scm-refspec"
label={i18n._(t`Source Control Refspec`)}
name="scm_refspec"
type="text"
tooltipMaxWidth="400px"
tooltip={
<span>
{i18n._(t`A refspec to fetch (passed to the Ansible git
module). This parameter allows access to references via
the branch field not otherwise available.`)}
<br />
<br />
{i18n._(t`Note: This field assumes the remote name is "origin".`)}
<br />
<br />
{i18n._(t`Examples include:`)}
<ul css={{ margin: '10px 0 10px 20px' }}>
<li>
<code>refs/*:refs/remotes/origin/*</code>
</li>
<li>
<code>refs/pull/62/head:refs/remotes/origin/pull/62/head</code>
</li>
</ul>
{i18n._(t`The first fetches all references. The second
<br />
<br />
{i18n._(t`Note: This field assumes the remote name is "origin".`)}
<br />
<br />
{i18n._(t`Examples include:`)}
<ul css={{ margin: '10px 0 10px 20px' }}>
<li>
<code>refs/*:refs/remotes/origin/*</code>
</li>
<li>
<code>refs/pull/62/head:refs/remotes/origin/pull/62/head</code>
</li>
</ul>
{i18n._(t`The first fetches all references. The second
fetches the Github pull request number 62, in this example
the branch needs to be "pull/62/head".`)}
<br />
<br />
{i18n._(t`For more information, refer to the`)}{' '}
<a
target="_blank"
rel="noopener noreferrer"
href="https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#manage-playbooks-using-source-control"
>
{i18n._(t`Ansible Tower Documentation.`)}
</a>
</span>
}
/>
<ScmCredentialFormField
credential={credential}
onCredentialSelection={onCredentialSelection}
/>
<ScmTypeOptions scmUpdateOnLaunch={scmUpdateOnLaunch} />
</>
);
<br />
<br />
{i18n._(t`For more information, refer to the`)}{' '}
<a
target="_blank"
rel="noopener noreferrer"
href={`${getDocsBaseUrl(
config
)}/html/userguide/projects.html#manage-playbooks-using-source-control`}
>
{i18n._(t`Ansible Tower Documentation.`)}
</a>
</span>
}
/>
<ScmCredentialFormField
credential={credential}
onCredentialSelection={onCredentialSelection}
/>
<ScmTypeOptions scmUpdateOnLaunch={scmUpdateOnLaunch} />
</>
);
};
export default withI18n()(GitSubForm);