Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Help Text with documentation link to Schedules page #12448

Merged
merged 3 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions awx/ui/src/components/Schedule/ScheduleDetail/ScheduleDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { formatDateString } from 'util/dates';
import useRequest, { useDismissableError } from 'hooks/useRequest';
import { JobTemplatesAPI, SchedulesAPI, WorkflowJobTemplatesAPI } from 'api';
import { parseVariableField, jsonToYaml } from 'util/yaml';
import { useConfig } from 'contexts/Config';
import AlertModal from '../../AlertModal';
import { CardBody, CardActionsRow } from '../../Card';
import ContentError from '../../ContentError';
Expand All @@ -24,6 +25,7 @@ import ErrorDetail from '../../ErrorDetail';
import ChipGroup from '../../ChipGroup';
import { VariablesDetail } from '../../CodeEditor';
import { VERBOSITY } from '../../VerbositySelectField';
import helpText from '../../../screens/Template/shared/JobTemplate.helptext';

const PromptDivider = styled(Divider)`
margin-top: var(--pf-global--spacer--lg);
Expand All @@ -39,7 +41,6 @@ const PromptTitle = styled(Title)`
const PromptDetailList = styled(DetailList)`
padding: 0px 20px;
`;

function ScheduleDetail({ hasDaysToKeepField, schedule, surveyConfig }) {
const {
id,
Expand Down Expand Up @@ -67,6 +68,7 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, surveyConfig }) {
const history = useHistory();
const { pathname } = useLocation();
const pathRoot = pathname.substr(0, pathname.indexOf('schedules'));
const config = useConfig();

const {
request: deleteSchedule,
Expand Down Expand Up @@ -260,7 +262,11 @@ function ScheduleDetail({ hasDaysToKeepField, schedule, surveyConfig }) {
value={formatDateString(next_run, timezone)}
/>
<Detail label={t`Last Run`} value={formatDateString(dtend, timezone)} />
<Detail label={t`Local Time Zone`} value={timezone} />
<Detail
label={t`Local Time Zone`}
value={timezone}
helpText={helpText.localTimeZone(config)}
/>
<Detail label={t`Repeat Frequency`} value={repeatFrequency} />
{hasDaysToKeepField ? (
<Detail label={t`Days of Data to Keep`} value={daysToKeep} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ describe('<ScheduleDetail />', () => {
expect(
wrapper.find('Detail[label="Local Time Zone"]').find('dd').text()
).toBe('America/New_York');
expect(
wrapper.find('Detail[label="Local Time Zone"]').prop('helpText')
).toBeDefined();
expect(wrapper.find('Detail[label="Repeat Frequency"]').length).toBe(1);
expect(wrapper.find('Detail[label="Created"]').length).toBe(1);
expect(wrapper.find('Detail[label="Last Modified"]').length).toBe(1);
Expand Down
8 changes: 7 additions & 1 deletion awx/ui/src/components/Schedule/shared/ScheduleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import {
// To be removed once UI completes complex schedules
Alert,
} from '@patternfly/react-core';
import { Config } from 'contexts/Config';
import { Config, useConfig } from 'contexts/Config';
import { SchedulesAPI } from 'api';
import { dateToInputDateTime } from 'util/dates';
import useRequest from 'hooks/useRequest';
import { required } from 'util/validators';
import { parseVariableField } from 'util/yaml';
import Popover from '../../Popover';
import AnsibleSelect from '../../AnsibleSelect';
import ContentError from '../../ContentError';
import ContentLoading from '../../ContentLoading';
Expand All @@ -33,6 +34,7 @@ import FrequencyDetailSubform from './FrequencyDetailSubform';
import SchedulePromptableFields from './SchedulePromptableFields';
import DateTimePicker from './DateTimePicker';
import buildRuleObj from './buildRuleObj';
import helpText from '../../../screens/Template/shared/JobTemplate.helptext';

const NUM_DAYS_PER_FREQUENCY = {
week: 7,
Expand Down Expand Up @@ -118,6 +120,9 @@ function ScheduleFormFields({ hasDaysToKeepField, zoneOptions, zoneLinks }) {
} else if (timezoneMessage) {
timezoneValidatedStatus = 'warning';
}

const config = useConfig();

return (
<>
<FormField
Expand Down Expand Up @@ -147,6 +152,7 @@ function ScheduleFormFields({ hasDaysToKeepField, zoneOptions, zoneLinks }) {
validated={timezoneValidatedStatus}
label={t`Local time zone`}
helperText={timezoneMessage}
labelIcon={<Popover content={helpText.localTimeZone(config)} />}
>
<AnsibleSelect
id="schedule-timezone"
Expand Down
3 changes: 3 additions & 0 deletions awx/ui/src/components/Schedule/shared/ScheduleForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ const defaultFieldsVisible = () => {
expect(wrapper.find('FormGroup[label="Description"]').length).toBe(1);
expect(wrapper.find('FormGroup[label="Start date/time"]').length).toBe(1);
expect(wrapper.find('FormGroup[label="Local time zone"]').length).toBe(1);
expect(
wrapper.find('FormGroup[label="Local time zone"]').find('HelpIcon').length
).toBe(1);
expect(wrapper.find('FormGroup[label="Run frequency"]').length).toBe(1);
};

Expand Down
4 changes: 2 additions & 2 deletions awx/ui/src/screens/Template/Survey/SurveyQuestionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ function SurveyQuestionForm({
target="_blank"
rel="noreferrer"
>
{t`documentation`}{' '}
</a>
{t`documentation`}
</a>{' '}
{t`for more information.`}
</>
}
Expand Down
14 changes: 14 additions & 0 deletions awx/ui/src/screens/Template/shared/JobTemplate.helptext.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { t } from '@lingui/macro';
import getDocsBaseUrl from 'util/getDocsBaseUrl';

const jtHelpTextStrings = {
jobType: t`For job templates, select run to execute the playbook. Select check to only check playbook syntax, test environment setup, and report problems without executing the playbook.`,
Expand Down Expand Up @@ -46,6 +47,19 @@ const jtHelpTextStrings = {
{t`Refer to the Ansible documentation for details about the configuration file.`}
</span>
),
localTimeZone: (config = '') => (
<span>
{t`Refer to the`}{' '}
<a
href={`${getDocsBaseUrl(config)}/html/userguide/scheduling.html`}
target="_blank"
rel="noreferrer"
>
{t`documentation`}
</a>{' '}
{t`for more information.`}
</span>
),
};

export default jtHelpTextStrings;