mirror of
https://github.com/ansible/awx.git
synced 2026-05-25 01:27:45 -02:30
Move the construction of the rule object out to it's own function
This commit is contained in:
@@ -26,8 +26,7 @@ function ScheduleAdd({ i18n, createSchedule }) {
|
||||
const { pathname } = location;
|
||||
const pathRoot = pathname.substr(0, pathname.indexOf('schedules'));
|
||||
|
||||
const handleSubmit = async values => {
|
||||
try {
|
||||
const buildRuleObj = values => {
|
||||
const [startDate, startTime] = values.startDateTime.split('T');
|
||||
// Dates are formatted like "YYYY-MM-DD"
|
||||
const [startYear, startMonth, startDay] = startDate.split('-');
|
||||
@@ -112,9 +111,7 @@ function ScheduleAdd({ i18n, createSchedule }) {
|
||||
case 'onDate': {
|
||||
const [endDate, endTime] = values.endDateTime.split('T');
|
||||
const [endYear, endMonth, endDay] = endDate.split('-');
|
||||
const [endHour = 0, endMinute = 0, endSecond = 0] = endTime.split(
|
||||
':'
|
||||
);
|
||||
const [endHour = 0, endMinute = 0, endSecond = 0] = endTime.split(':');
|
||||
ruleObj.until = new Date(
|
||||
Date.UTC(
|
||||
endYear,
|
||||
@@ -131,7 +128,12 @@ function ScheduleAdd({ i18n, createSchedule }) {
|
||||
throw new Error(i18n._(t`End did not match an expected value`));
|
||||
}
|
||||
|
||||
const rule = new RRule(ruleObj);
|
||||
return ruleObj;
|
||||
};
|
||||
|
||||
const handleSubmit = async values => {
|
||||
try {
|
||||
const rule = new RRule(buildRuleObj(values));
|
||||
const {
|
||||
data: { id: scheduleId },
|
||||
} = await createSchedule({
|
||||
|
||||
Reference in New Issue
Block a user