mirror of
https://github.com/ansible/awx.git
synced 2026-05-21 07:47:44 -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 { pathname } = location;
|
||||||
const pathRoot = pathname.substr(0, pathname.indexOf('schedules'));
|
const pathRoot = pathname.substr(0, pathname.indexOf('schedules'));
|
||||||
|
|
||||||
const handleSubmit = async values => {
|
const buildRuleObj = values => {
|
||||||
try {
|
|
||||||
const [startDate, startTime] = values.startDateTime.split('T');
|
const [startDate, startTime] = values.startDateTime.split('T');
|
||||||
// Dates are formatted like "YYYY-MM-DD"
|
// Dates are formatted like "YYYY-MM-DD"
|
||||||
const [startYear, startMonth, startDay] = startDate.split('-');
|
const [startYear, startMonth, startDay] = startDate.split('-');
|
||||||
@@ -112,9 +111,7 @@ function ScheduleAdd({ i18n, createSchedule }) {
|
|||||||
case 'onDate': {
|
case 'onDate': {
|
||||||
const [endDate, endTime] = values.endDateTime.split('T');
|
const [endDate, endTime] = values.endDateTime.split('T');
|
||||||
const [endYear, endMonth, endDay] = endDate.split('-');
|
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(
|
ruleObj.until = new Date(
|
||||||
Date.UTC(
|
Date.UTC(
|
||||||
endYear,
|
endYear,
|
||||||
@@ -131,7 +128,12 @@ function ScheduleAdd({ i18n, createSchedule }) {
|
|||||||
throw new Error(i18n._(t`End did not match an expected value`));
|
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 {
|
const {
|
||||||
data: { id: scheduleId },
|
data: { id: scheduleId },
|
||||||
} = await createSchedule({
|
} = await createSchedule({
|
||||||
|
|||||||
Reference in New Issue
Block a user