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

View File

@@ -9,13 +9,17 @@ import {
ScmCredentialFormField, ScmCredentialFormField,
ScmTypeOptions, ScmTypeOptions,
} from './SharedFields'; } from './SharedFields';
import { useConfig } from '../../../../contexts/Config';
import getDocsBaseUrl from '../../../../util/getDocsBaseUrl';
const GitSubForm = ({ const GitSubForm = ({
i18n, i18n,
credential, credential,
onCredentialSelection, onCredentialSelection,
scmUpdateOnLaunch, scmUpdateOnLaunch,
}) => ( }) => {
const config = useConfig();
return (
<> <>
<UrlFormField <UrlFormField
i18n={i18n} i18n={i18n}
@@ -80,7 +84,9 @@ const GitSubForm = ({
<a <a
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
href="https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#manage-playbooks-using-source-control" href={`${getDocsBaseUrl(
config
)}/html/userguide/projects.html#manage-playbooks-using-source-control`}
> >
{i18n._(t`Ansible Tower Documentation.`)} {i18n._(t`Ansible Tower Documentation.`)}
</a> </a>
@@ -93,6 +99,7 @@ const GitSubForm = ({
/> />
<ScmTypeOptions scmUpdateOnLaunch={scmUpdateOnLaunch} /> <ScmTypeOptions scmUpdateOnLaunch={scmUpdateOnLaunch} />
</> </>
); );
};
export default withI18n()(GitSubForm); export default withI18n()(GitSubForm);