Skip to content

Commit

Permalink
Merge pull request #10291 from AlexSCorey/10152-AddsPFDatePicker-v2
Browse files Browse the repository at this point in the history
Resolves issue where FireFox users could not schedule a job template

SUMMARY
This addresses #10152 and #6214
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

UI

ADDITIONAL INFORMATION

Reviewed-by: Michael Abashian <None>
Reviewed-by: Tiago Góes <tiago.goes2009@gmail.com>
  • Loading branch information
2 parents 3cb3819 + 16c6e2d commit e4f21ec
Show file tree
Hide file tree
Showing 15 changed files with 323 additions and 136 deletions.
4 changes: 3 additions & 1 deletion awx/ui_next/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
{
"markupOnly": true,
"ignoreAttribute": [
"dateFieldName",
"timeFieldName",
"to",
"streamType",
"path",
Expand Down Expand Up @@ -85,7 +87,7 @@
"data-cy",
"fieldName"
],
"ignore": ["Ansible", "Tower", "JSON", "YAML", "lg"],
"ignore": ["Ansible", "Tower", "JSON", "YAML", "lg", "hh:mm AM/PM"],
"ignoreComponent": [
"AboutModal",
"code",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ function ScheduleAdd({
end,
frequency,
interval,
startDateTime,
timezone,
occurrences,
runOn,
runOnTheDay,
runOnTheMonth,
runOnDayMonth,
runOnDayNumber,
endDateTime,
runOnTheOccurrence,
credentials,
daysOfWeek,
Expand Down Expand Up @@ -100,6 +98,10 @@ function ScheduleAdd({
});
}
}
delete requestData.startDate;
delete requestData.startTime;
delete requestData.endDate;
delete requestData.endTime;

const {
data: { id: scheduleId },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ describe('<ScheduleAdd />', () => {
frequency: 'none',
interval: 1,
name: 'Run once schedule',
startDateTime: '2020-03-25T10:00:00',
startDate: '2020-03-25',
startTime: '10:00:00',
timezone: 'America/New_York',
});
});
Expand All @@ -103,7 +104,8 @@ describe('<ScheduleAdd />', () => {
interval: 10,
name: 'Run every 10 minutes 10 times',
occurrences: 10,
startDateTime: '2020-03-25T10:30:00',
startDate: '2020-03-25',
startTime: '10:30:00',
timezone: 'America/New_York',
});
});
Expand All @@ -120,11 +122,13 @@ describe('<ScheduleAdd />', () => {
wrapper.find('Formik').invoke('onSubmit')({
description: 'test description',
end: 'onDate',
endDateTime: '2020-03-26T10:45:00',
endDate: '2020-03-26',
endTime: '10:45:00',
frequency: 'hour',
interval: 1,
name: 'Run every hour until date',
startDateTime: '2020-03-25T10:45:00',
startDate: '2020-03-25',
startTime: '10:45:00',
timezone: 'America/New_York',
});
});
Expand All @@ -144,7 +148,8 @@ describe('<ScheduleAdd />', () => {
frequency: 'day',
interval: 1,
name: 'Run daily',
startDateTime: '2020-03-25T10:45:00',
startDate: '2020-03-25',
startTime: '10:45:00',
timezone: 'America/New_York',
});
});
Expand All @@ -166,7 +171,8 @@ describe('<ScheduleAdd />', () => {
interval: 1,
name: 'Run weekly on mon/wed/fri',
occurrences: 1,
startDateTime: '2020-03-25T10:45:00',
startDate: '2020-03-25',
startTime: '10:45:00',
timezone: 'America/New_York',
});
});
Expand All @@ -188,7 +194,8 @@ describe('<ScheduleAdd />', () => {
occurrences: 1,
runOn: 'day',
runOnDayNumber: 1,
startDateTime: '2020-04-01T10:45',
startTime: '10:45',
startDate: '2020-04-01',
timezone: 'America/New_York',
});
});
Expand All @@ -205,15 +212,17 @@ describe('<ScheduleAdd />', () => {
wrapper.find('Formik').invoke('onSubmit')({
description: 'test description',
end: 'never',
endDateTime: '2020-03-26T11:00:00',
endDate: '2020-03-26',
endTime: '11:00:00',
frequency: 'month',
interval: 1,
name: 'Run monthly on the last Tuesday',
occurrences: 1,
runOn: 'the',
runOnTheDay: 'tuesday',
runOnTheOccurrence: -1,
startDateTime: '2020-03-31T11:00',
startDate: '2020-03-31',
startTime: '11:00',
timezone: 'America/New_York',
});
});
Expand All @@ -237,7 +246,8 @@ describe('<ScheduleAdd />', () => {
runOn: 'day',
runOnDayMonth: 3,
runOnDayNumber: 1,
startDateTime: '2020-03-01T00:00',
startDate: '2020-03-01',
startTime: '00:00',
timezone: 'America/New_York',
});
});
Expand All @@ -262,7 +272,8 @@ describe('<ScheduleAdd />', () => {
runOnTheOccurrence: 2,
runOnTheDay: 'friday',
runOnTheMonth: 4,
startDateTime: '2020-04-10T11:15',
startDate: '2020-04-10',
startTime: '11:15',
timezone: 'America/New_York',
});
});
Expand All @@ -287,7 +298,8 @@ describe('<ScheduleAdd />', () => {
runOnTheOccurrence: 1,
runOnTheDay: 'weekday',
runOnTheMonth: 10,
startDateTime: '2020-04-10T11:15',
startDate: '2020-04-10',
startTime: '11:15',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -371,7 +383,8 @@ describe('<ScheduleAdd />', () => {
wrapper.find('Formik').invoke('onSubmit')({
name: 'Schedule',
end: 'never',
endDateTime: '2021-01-29T14:15:00',
endDate: '2021-01-29',
endTime: '14:15:00',
frequency: 'none',
occurrences: 1,
runOn: 'day',
Expand All @@ -386,7 +399,8 @@ describe('<ScheduleAdd />', () => {
{ name: 'cred 1', id: 10 },
{ name: 'cred 2', id: 20 },
],
startDateTime: '2021-01-28T14:15:00',
startDate: '2021-01-28',
startTime: '14:15:00',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -457,7 +471,8 @@ describe('<ScheduleAdd />', () => {
frequency: 'none',
interval: 1,
name: 'Run once schedule',
startDateTime: '2020-03-25T10:00:00',
startDate: '2020-03-25',
startTime: '10:00:00',
timezone: 'America/New_York',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ function ScheduleEdit({
end,
frequency,
interval,
startDateTime,
timezone,
occurences,
runOn,
runOnTheDay,
runOnTheMonth,
runOnDayMonth,
runOnDayNumber,
endDateTime,
runOnTheOccurence,
daysOfWeek,
...submitValues
Expand Down Expand Up @@ -98,6 +96,10 @@ function ScheduleEdit({
...submitValues,
rrule: rule.toString().replace(/\n/g, ' '),
};
delete requestData.startDate;
delete requestData.startTime;
delete requestData.endDate;
delete requestData.endTime;

if (Object.keys(values).includes('daysToKeep')) {
if (!requestData.extra_data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import ScheduleEdit from './ScheduleEdit';
jest.mock('../../../api');

let wrapper;

const now = new Date();
const closestQuarterHour = new Date(Math.ceil(now.getTime() / 900000) * 900000);
const tomorrow = new Date(closestQuarterHour);
tomorrow.setDate(tomorrow.getDate() + 1);
const mockSchedule = {
rrule:
'DTSTART;TZID=America/New_York:20200402T144500 RRULE:INTERVAL=1;COUNT=1;FREQ=MINUTELY',
Expand Down Expand Up @@ -202,7 +205,8 @@ describe('<ScheduleEdit />', () => {
frequency: 'none',
interval: 1,
name: 'Run once schedule',
startDateTime: '2020-03-25T10:00:00',
startDate: '2020-03-25',
startTime: '10:00:00',
timezone: 'America/New_York',
});
});
Expand All @@ -223,7 +227,8 @@ describe('<ScheduleEdit />', () => {
interval: 10,
name: 'Run every 10 minutes 10 times',
occurrences: 10,
startDateTime: '2020-03-25T10:30:00',
startDate: '2020-03-25',
startTime: '10:30:00',
timezone: 'America/New_York',
});
});
Expand All @@ -241,11 +246,13 @@ describe('<ScheduleEdit />', () => {
wrapper.find('Formik').invoke('onSubmit')({
description: 'test description',
end: 'onDate',
endDateTime: '2020-03-26T10:45:00',
endDate: '2020-03-26',
endTime: '10:45:00',
frequency: 'hour',
interval: 1,
name: 'Run every hour until date',
startDateTime: '2020-03-25T10:45:00',
startDate: '2020-03-25',
startTime: '10:45:00',
timezone: 'America/New_York',
});
});
Expand All @@ -265,7 +272,8 @@ describe('<ScheduleEdit />', () => {
frequency: 'day',
interval: 1,
name: 'Run daily',
startDateTime: '2020-03-25T10:45:00',
startDate: '2020-03-25',
startTime: '10:45:00',
timezone: 'America/New_York',
});
});
Expand All @@ -287,7 +295,8 @@ describe('<ScheduleEdit />', () => {
interval: 1,
name: 'Run weekly on mon/wed/fri',
occurrences: 1,
startDateTime: '2020-03-25T10:45:00',
startDate: '2020-03-25',
startTime: '10:45:00',
timezone: 'America/New_York',
});
});
Expand All @@ -310,7 +319,8 @@ describe('<ScheduleEdit />', () => {
occurrences: 1,
runOn: 'day',
runOnDayNumber: 1,
startDateTime: '2020-04-01T10:45',
startDate: '2020-04-01',
startTime: '10:45',
timezone: 'America/New_York',
});
});
Expand All @@ -336,12 +346,14 @@ describe('<ScheduleEdit />', () => {
runOn: 'the',
runOnTheDay: 'tuesday',
runOnTheOccurrence: -1,
startDateTime: '2020-03-31T11:00',
startDate: '2020-03-31',
startTime: '11:00',
timezone: 'America/New_York',
});
});
expect(SchedulesAPI.update).toHaveBeenCalledWith(27, {
description: 'test description',
endDateTime: '2020-03-26T11:00:00',
name: 'Run monthly on the last Tuesday',
extra_data: {},
occurrences: 1,
Expand All @@ -362,7 +374,8 @@ describe('<ScheduleEdit />', () => {
runOn: 'day',
runOnDayMonth: 3,
runOnDayNumber: 1,
startDateTime: '2020-03-01T00:00',
startTime: '00:00',
startDate: '2020-03-01',
timezone: 'America/New_York',
});
});
Expand All @@ -388,7 +401,8 @@ describe('<ScheduleEdit />', () => {
runOnTheOccurrence: 2,
runOnTheDay: 'friday',
runOnTheMonth: 4,
startDateTime: '2020-04-10T11:15',
startTime: '11:15',
startDate: '2020-04-10',
timezone: 'America/New_York',
});
});
Expand All @@ -415,7 +429,8 @@ describe('<ScheduleEdit />', () => {
runOnTheOccurrence: 1,
runOnTheDay: 'weekday',
runOnTheMonth: 10,
startDateTime: '2020-04-10T11:15',
startTime: '11:15',
startDate: '2020-04-10',
timezone: 'America/New_York',
});
});
Expand Down Expand Up @@ -526,7 +541,8 @@ describe('<ScheduleEdit />', () => {
wrapper.find('Formik').invoke('onSubmit')({
name: mockSchedule.name,
end: 'never',
endDateTime: '2021-01-29T14:15:00',
endDate: '2021-01-29',
endTime: '14:15:00',
frequency: 'none',
occurrences: 1,
runOn: 'day',
Expand All @@ -536,7 +552,8 @@ describe('<ScheduleEdit />', () => {
runOnTheMonth: 1,
runOnTheOccurrence: 1,
skip_tags: '',
startDateTime: '2021-01-28T14:15:00',
startDate: '2021-01-28',
startTime: '14:15:00',
timezone: 'America/New_York',
credentials: [
{ id: 3, name: 'Credential 3', kind: 'ssh', url: '' },
Expand Down Expand Up @@ -622,15 +639,18 @@ describe('<ScheduleEdit />', () => {
await act(async () =>
wrapper.find('Button[aria-label="Save"]').prop('onClick')()
);

expect(SchedulesAPI.update).toBeCalledWith(27, {
endDateTime: undefined,
startDateTime: undefined,
description: '',
extra_data: {},
occurrences: 1,
runOnTheOccurrence: 1,
name: 'foo',
inventory: 702,
rrule:
'DTSTART;TZID=America/New_York:20200402T144500 RRULE:INTERVAL=1;COUNT=1;FREQ=MINUTELY',
'DTSTART;TZID=America/New_York:20200402T184500 RRULE:INTERVAL=1;COUNT=1;FREQ=MINUTELY',
});
});
test('should submit survey with default values properly, without opening prompt wizard', async () => {
Expand Down Expand Up @@ -728,7 +748,8 @@ describe('<ScheduleEdit />', () => {
frequency: 'none',
interval: 1,
name: 'Run once schedule',
startDateTime: '2020-03-25T10:00:00',
startDate: '2020-03-25',
startTime: '10:00:00',
timezone: 'America/New_York',
});
});
Expand Down
Loading

0 comments on commit e4f21ec

Please sign in to comment.