@datarobot/design-system 29.7.7 → 29.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/scheduler/utils.d.ts +2 -2
- package/cjs/scheduler/utils.js +80 -78
- package/cjs/scheduler/utils.test.js +3 -3
- package/esm/scheduler/utils.d.ts +2 -2
- package/esm/scheduler/utils.js +80 -78
- package/esm/scheduler/utils.test.js +3 -3
- package/js/bundle/bundle.js +78 -76
- package/js/bundle/bundle.min.js +1 -1
- package/js/bundle/index.d.ts +2 -2
- package/package.json +1 -1
package/cjs/scheduler/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Frequency, Schedule, ScheduleValidity } from './constants';
|
|
2
2
|
export declare const stringToArrayOfNumbersOrAll: (value?: string | number) => (number | "*")[];
|
|
3
3
|
export declare function useArrayOfRangedNumbersOrAllValidator(): ({ min, max, values, allowAll, }: ScheduleValidity) => ScheduleValidity | undefined;
|
|
4
|
-
export declare function useGetScheduleString(schedule: Schedule, stringOptions?: {
|
|
4
|
+
export declare function useGetScheduleString(): (schedule: Schedule, stringOptions?: {
|
|
5
5
|
complexScheduleString?: string | null;
|
|
6
6
|
timeStandardString?: string | null;
|
|
7
|
-
})
|
|
7
|
+
}) => string | null;
|
|
8
8
|
export declare function getFrequency({ minute, hour, month, dayOfMonth, dayOfWeek, }: Schedule): Frequency | undefined;
|
package/cjs/scheduler/utils.js
CHANGED
|
@@ -63,91 +63,93 @@ function useArrayOfRangedNumbersOrAllValidator() {
|
|
|
63
63
|
return validity;
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
function useGetScheduleString(
|
|
66
|
+
function useGetScheduleString() {
|
|
67
67
|
const {
|
|
68
68
|
t
|
|
69
69
|
} = (0, _useTranslation.useTranslation)();
|
|
70
|
-
const {
|
|
71
|
-
complexScheduleString = t('Complex schedule'),
|
|
72
|
-
timeStandardString = t('(UTC)')
|
|
73
|
-
} = stringOptions;
|
|
74
|
-
const scheduleStringTimeStandard = timeStandardString ? ` ${timeStandardString}` : '';
|
|
75
70
|
const months = (0, _constants.useMonths)();
|
|
76
71
|
const daysOfWeek = (0, _constants.useDaysOfWeek)();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
case _constants.FREQUENCIES.WEEKLY:
|
|
90
|
-
{
|
|
91
|
-
const options = {
|
|
92
|
-
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
93
|
-
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
94
|
-
day: daysOfWeek.find(d => d.index === schedule?.dayOfWeek?.[0])?.label
|
|
95
|
-
};
|
|
96
|
-
const weeklyString = schedule?.dayOfWeek?.length === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', {
|
|
97
|
-
...options
|
|
98
|
-
}) : t('Weekly on multiple days at {{hour}}:{{minutes}}', {
|
|
99
|
-
...options
|
|
72
|
+
return (schedule, stringOptions = {}) => {
|
|
73
|
+
const {
|
|
74
|
+
complexScheduleString = t('Complex schedule'),
|
|
75
|
+
timeStandardString = t('(UTC)')
|
|
76
|
+
} = stringOptions;
|
|
77
|
+
const scheduleStringTimeStandard = timeStandardString ? ` ${timeStandardString}` : '';
|
|
78
|
+
switch (getFrequency(schedule)) {
|
|
79
|
+
case _constants.FREQUENCIES.HOURLY:
|
|
80
|
+
return schedule?.minute?.[0] === 1 ? t('Hourly at {{minutes}} minute past the hour', {
|
|
81
|
+
minutes: schedule.minute[0].toString()
|
|
82
|
+
}) : t('Hourly at {{minutes}} minutes past the hour', {
|
|
83
|
+
minutes: schedule?.minute?.[0].toString()
|
|
100
84
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
case _constants.FREQUENCIES.MONTHLY:
|
|
104
|
-
{
|
|
105
|
-
const options = {
|
|
85
|
+
case _constants.FREQUENCIES.DAILY:
|
|
86
|
+
return `${t('Daily at {{hour}}:{{minutes}}', {
|
|
106
87
|
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
107
|
-
minutes: schedule?.minute?.[0].toString().padStart(2, '0')
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
88
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0')
|
|
89
|
+
})}${scheduleStringTimeStandard}`;
|
|
90
|
+
case _constants.FREQUENCIES.WEEKLY:
|
|
91
|
+
{
|
|
92
|
+
const options = {
|
|
93
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
94
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
95
|
+
day: daysOfWeek.find(d => d.index === schedule?.dayOfWeek?.[0])?.label
|
|
96
|
+
};
|
|
97
|
+
const weeklyString = schedule?.dayOfWeek?.length === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', {
|
|
98
|
+
...options
|
|
99
|
+
}) : t('Weekly on multiple days at {{hour}}:{{minutes}}', {
|
|
100
|
+
...options
|
|
101
|
+
});
|
|
102
|
+
return `${weeklyString}${scheduleStringTimeStandard}`;
|
|
103
|
+
}
|
|
104
|
+
case _constants.FREQUENCIES.MONTHLY:
|
|
105
|
+
{
|
|
106
|
+
const options = {
|
|
107
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
108
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
109
|
+
day: schedule?.dayOfMonth?.[0],
|
|
110
|
+
days: schedule?.dayOfMonth?.join(', ') // day 1, 2, 3
|
|
111
|
+
};
|
|
112
|
+
const monthlyString = schedule?.dayOfMonth?.length === 1 ? t('Monthly on day {{day}} at {{hour}}:{{minutes}}', {
|
|
113
|
+
...options
|
|
114
|
+
}) : t('Monthly on days {{days}} at {{hour}}:{{minutes}}', {
|
|
115
|
+
...options
|
|
116
|
+
});
|
|
117
|
+
return `${monthlyString}${scheduleStringTimeStandard}`;
|
|
118
|
+
}
|
|
119
|
+
case _constants.FREQUENCIES.QUARTERLY:
|
|
120
|
+
{
|
|
121
|
+
const options = {
|
|
122
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
123
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
124
|
+
day: schedule?.dayOfMonth?.[0],
|
|
125
|
+
days: schedule?.dayOfMonth?.join(', ') // day 1, 2, 3
|
|
126
|
+
};
|
|
127
|
+
const quarterlyString = schedule?.dayOfMonth?.length === 1 ? t('Quarterly on day {{day}} at {{hour}}:{{minutes}}', {
|
|
128
|
+
...options
|
|
129
|
+
}) : t('Quarterly on days {{days}} at {{hour}}:{{minutes}}', {
|
|
130
|
+
...options
|
|
131
|
+
});
|
|
132
|
+
return `${quarterlyString}${scheduleStringTimeStandard}`;
|
|
133
|
+
}
|
|
134
|
+
case _constants.FREQUENCIES.YEARLY:
|
|
135
|
+
{
|
|
136
|
+
const options = {
|
|
137
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
138
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
139
|
+
day: schedule?.dayOfMonth?.[0],
|
|
140
|
+
month: Object.values(months).find(m => m.index === schedule?.month?.[0])?.label
|
|
141
|
+
};
|
|
142
|
+
const yearlyString = Math.max(schedule?.month?.length ?? 0, schedule?.dayOfMonth?.length ?? 0) ? t('Yearly on {{month}} {{day}} at {{hour}}:{{minutes}}', {
|
|
143
|
+
...options
|
|
144
|
+
}) : t('Yearly on multiple dates at {{hour}}:{{minutes}}', {
|
|
145
|
+
...options
|
|
146
|
+
});
|
|
147
|
+
return `${yearlyString}${scheduleStringTimeStandard}`;
|
|
148
|
+
}
|
|
149
|
+
default:
|
|
150
|
+
return complexScheduleString;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
151
153
|
}
|
|
152
154
|
function hasSameItems(arr1, arr2) {
|
|
153
155
|
return arr1.length === arr2?.length && arr1.every(item1 => {
|
|
@@ -108,7 +108,7 @@ describe('useGetScheduleString', function () {
|
|
|
108
108
|
it(`should generate "${expectedString}"`, function () {
|
|
109
109
|
const {
|
|
110
110
|
result
|
|
111
|
-
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)(schedule));
|
|
111
|
+
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)()(schedule));
|
|
112
112
|
expect(result.current).toBe(`${expectedString}`);
|
|
113
113
|
});
|
|
114
114
|
});
|
|
@@ -123,7 +123,7 @@ describe('useGetScheduleString', function () {
|
|
|
123
123
|
it(`should generate "${expectedString}"`, function () {
|
|
124
124
|
const {
|
|
125
125
|
result
|
|
126
|
-
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)(schedule, {
|
|
126
|
+
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)()(schedule, {
|
|
127
127
|
timeStandardString: '(EST)'
|
|
128
128
|
}));
|
|
129
129
|
expect(result.current).toBe(`${expectedString}`);
|
|
@@ -138,7 +138,7 @@ describe('useGetScheduleString', function () {
|
|
|
138
138
|
it(`should generate "${expectedScheduleString}"`, function () {
|
|
139
139
|
const {
|
|
140
140
|
result
|
|
141
|
-
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)(schedule, {
|
|
141
|
+
} = (0, _react.renderHook)(() => (0, _utils.useGetScheduleString)()(schedule, {
|
|
142
142
|
timeStandardString: null
|
|
143
143
|
}));
|
|
144
144
|
expect(result.current).toBe(expectedScheduleString);
|
package/esm/scheduler/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Frequency, Schedule, ScheduleValidity } from './constants';
|
|
2
2
|
export declare const stringToArrayOfNumbersOrAll: (value?: string | number) => (number | "*")[];
|
|
3
3
|
export declare function useArrayOfRangedNumbersOrAllValidator(): ({ min, max, values, allowAll, }: ScheduleValidity) => ScheduleValidity | undefined;
|
|
4
|
-
export declare function useGetScheduleString(schedule: Schedule, stringOptions?: {
|
|
4
|
+
export declare function useGetScheduleString(): (schedule: Schedule, stringOptions?: {
|
|
5
5
|
complexScheduleString?: string | null;
|
|
6
6
|
timeStandardString?: string | null;
|
|
7
|
-
})
|
|
7
|
+
}) => string | null;
|
|
8
8
|
export declare function getFrequency({ minute, hour, month, dayOfMonth, dayOfWeek, }: Schedule): Frequency | undefined;
|
package/esm/scheduler/utils.js
CHANGED
|
@@ -53,91 +53,93 @@ export function useArrayOfRangedNumbersOrAllValidator() {
|
|
|
53
53
|
return validity;
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
export function useGetScheduleString(
|
|
56
|
+
export function useGetScheduleString() {
|
|
57
57
|
const {
|
|
58
58
|
t
|
|
59
59
|
} = useTranslation();
|
|
60
|
-
const {
|
|
61
|
-
complexScheduleString = t('Complex schedule'),
|
|
62
|
-
timeStandardString = t('(UTC)')
|
|
63
|
-
} = stringOptions;
|
|
64
|
-
const scheduleStringTimeStandard = timeStandardString ? ` ${timeStandardString}` : '';
|
|
65
60
|
const months = useMonths();
|
|
66
61
|
const daysOfWeek = useDaysOfWeek();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
case FREQUENCIES.WEEKLY:
|
|
80
|
-
{
|
|
81
|
-
const options = {
|
|
82
|
-
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
83
|
-
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
84
|
-
day: daysOfWeek.find(d => d.index === schedule?.dayOfWeek?.[0])?.label
|
|
85
|
-
};
|
|
86
|
-
const weeklyString = schedule?.dayOfWeek?.length === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', {
|
|
87
|
-
...options
|
|
88
|
-
}) : t('Weekly on multiple days at {{hour}}:{{minutes}}', {
|
|
89
|
-
...options
|
|
62
|
+
return (schedule, stringOptions = {}) => {
|
|
63
|
+
const {
|
|
64
|
+
complexScheduleString = t('Complex schedule'),
|
|
65
|
+
timeStandardString = t('(UTC)')
|
|
66
|
+
} = stringOptions;
|
|
67
|
+
const scheduleStringTimeStandard = timeStandardString ? ` ${timeStandardString}` : '';
|
|
68
|
+
switch (getFrequency(schedule)) {
|
|
69
|
+
case FREQUENCIES.HOURLY:
|
|
70
|
+
return schedule?.minute?.[0] === 1 ? t('Hourly at {{minutes}} minute past the hour', {
|
|
71
|
+
minutes: schedule.minute[0].toString()
|
|
72
|
+
}) : t('Hourly at {{minutes}} minutes past the hour', {
|
|
73
|
+
minutes: schedule?.minute?.[0].toString()
|
|
90
74
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
case FREQUENCIES.MONTHLY:
|
|
94
|
-
{
|
|
95
|
-
const options = {
|
|
75
|
+
case FREQUENCIES.DAILY:
|
|
76
|
+
return `${t('Daily at {{hour}}:{{minutes}}', {
|
|
96
77
|
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
97
|
-
minutes: schedule?.minute?.[0].toString().padStart(2, '0')
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
78
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0')
|
|
79
|
+
})}${scheduleStringTimeStandard}`;
|
|
80
|
+
case FREQUENCIES.WEEKLY:
|
|
81
|
+
{
|
|
82
|
+
const options = {
|
|
83
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
84
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
85
|
+
day: daysOfWeek.find(d => d.index === schedule?.dayOfWeek?.[0])?.label
|
|
86
|
+
};
|
|
87
|
+
const weeklyString = schedule?.dayOfWeek?.length === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', {
|
|
88
|
+
...options
|
|
89
|
+
}) : t('Weekly on multiple days at {{hour}}:{{minutes}}', {
|
|
90
|
+
...options
|
|
91
|
+
});
|
|
92
|
+
return `${weeklyString}${scheduleStringTimeStandard}`;
|
|
93
|
+
}
|
|
94
|
+
case FREQUENCIES.MONTHLY:
|
|
95
|
+
{
|
|
96
|
+
const options = {
|
|
97
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
98
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
99
|
+
day: schedule?.dayOfMonth?.[0],
|
|
100
|
+
days: schedule?.dayOfMonth?.join(', ') // day 1, 2, 3
|
|
101
|
+
};
|
|
102
|
+
const monthlyString = schedule?.dayOfMonth?.length === 1 ? t('Monthly on day {{day}} at {{hour}}:{{minutes}}', {
|
|
103
|
+
...options
|
|
104
|
+
}) : t('Monthly on days {{days}} at {{hour}}:{{minutes}}', {
|
|
105
|
+
...options
|
|
106
|
+
});
|
|
107
|
+
return `${monthlyString}${scheduleStringTimeStandard}`;
|
|
108
|
+
}
|
|
109
|
+
case FREQUENCIES.QUARTERLY:
|
|
110
|
+
{
|
|
111
|
+
const options = {
|
|
112
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
113
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
114
|
+
day: schedule?.dayOfMonth?.[0],
|
|
115
|
+
days: schedule?.dayOfMonth?.join(', ') // day 1, 2, 3
|
|
116
|
+
};
|
|
117
|
+
const quarterlyString = schedule?.dayOfMonth?.length === 1 ? t('Quarterly on day {{day}} at {{hour}}:{{minutes}}', {
|
|
118
|
+
...options
|
|
119
|
+
}) : t('Quarterly on days {{days}} at {{hour}}:{{minutes}}', {
|
|
120
|
+
...options
|
|
121
|
+
});
|
|
122
|
+
return `${quarterlyString}${scheduleStringTimeStandard}`;
|
|
123
|
+
}
|
|
124
|
+
case FREQUENCIES.YEARLY:
|
|
125
|
+
{
|
|
126
|
+
const options = {
|
|
127
|
+
hour: schedule?.hour?.[0].toString().padStart(2, '0'),
|
|
128
|
+
minutes: schedule?.minute?.[0].toString().padStart(2, '0'),
|
|
129
|
+
day: schedule?.dayOfMonth?.[0],
|
|
130
|
+
month: Object.values(months).find(m => m.index === schedule?.month?.[0])?.label
|
|
131
|
+
};
|
|
132
|
+
const yearlyString = Math.max(schedule?.month?.length ?? 0, schedule?.dayOfMonth?.length ?? 0) ? t('Yearly on {{month}} {{day}} at {{hour}}:{{minutes}}', {
|
|
133
|
+
...options
|
|
134
|
+
}) : t('Yearly on multiple dates at {{hour}}:{{minutes}}', {
|
|
135
|
+
...options
|
|
136
|
+
});
|
|
137
|
+
return `${yearlyString}${scheduleStringTimeStandard}`;
|
|
138
|
+
}
|
|
139
|
+
default:
|
|
140
|
+
return complexScheduleString;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
141
143
|
}
|
|
142
144
|
function hasSameItems(arr1, arr2) {
|
|
143
145
|
return arr1.length === arr2?.length && arr1.every(item1 => {
|
|
@@ -106,7 +106,7 @@ describe('useGetScheduleString', function () {
|
|
|
106
106
|
it(`should generate "${expectedString}"`, function () {
|
|
107
107
|
const {
|
|
108
108
|
result
|
|
109
|
-
} = renderHook(() => useGetScheduleString(schedule));
|
|
109
|
+
} = renderHook(() => useGetScheduleString()(schedule));
|
|
110
110
|
expect(result.current).toBe(`${expectedString}`);
|
|
111
111
|
});
|
|
112
112
|
});
|
|
@@ -121,7 +121,7 @@ describe('useGetScheduleString', function () {
|
|
|
121
121
|
it(`should generate "${expectedString}"`, function () {
|
|
122
122
|
const {
|
|
123
123
|
result
|
|
124
|
-
} = renderHook(() => useGetScheduleString(schedule, {
|
|
124
|
+
} = renderHook(() => useGetScheduleString()(schedule, {
|
|
125
125
|
timeStandardString: '(EST)'
|
|
126
126
|
}));
|
|
127
127
|
expect(result.current).toBe(`${expectedString}`);
|
|
@@ -136,7 +136,7 @@ describe('useGetScheduleString', function () {
|
|
|
136
136
|
it(`should generate "${expectedScheduleString}"`, function () {
|
|
137
137
|
const {
|
|
138
138
|
result
|
|
139
|
-
} = renderHook(() => useGetScheduleString(schedule, {
|
|
139
|
+
} = renderHook(() => useGetScheduleString()(schedule, {
|
|
140
140
|
timeStandardString: null
|
|
141
141
|
}));
|
|
142
142
|
expect(result.current).toBe(expectedScheduleString);
|
package/js/bundle/bundle.js
CHANGED
|
@@ -74125,86 +74125,88 @@ function useArrayOfRangedNumbersOrAllValidator() {
|
|
|
74125
74125
|
return validity;
|
|
74126
74126
|
};
|
|
74127
74127
|
}
|
|
74128
|
-
function useGetScheduleString(
|
|
74129
|
-
var _schedule$minute, _schedule$minute2, _schedule$hour, _schedule$minute3;
|
|
74130
|
-
var stringOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
74128
|
+
function useGetScheduleString() {
|
|
74131
74129
|
var _useTranslation2 = (0,_hooks_use_translation__WEBPACK_IMPORTED_MODULE_1__.useTranslation)(),
|
|
74132
74130
|
t = _useTranslation2.t;
|
|
74133
|
-
var _stringOptions$comple = stringOptions.complexScheduleString,
|
|
74134
|
-
complexScheduleString = _stringOptions$comple === void 0 ? t('Complex schedule') : _stringOptions$comple,
|
|
74135
|
-
_stringOptions$timeSt = stringOptions.timeStandardString,
|
|
74136
|
-
timeStandardString = _stringOptions$timeSt === void 0 ? t('(UTC)') : _stringOptions$timeSt;
|
|
74137
|
-
var scheduleStringTimeStandard = timeStandardString ? " ".concat(timeStandardString) : '';
|
|
74138
74131
|
var months = (0,_constants__WEBPACK_IMPORTED_MODULE_2__.useMonths)();
|
|
74139
74132
|
var daysOfWeek = (0,_constants__WEBPACK_IMPORTED_MODULE_2__.useDaysOfWeek)();
|
|
74140
|
-
|
|
74141
|
-
|
|
74142
|
-
|
|
74143
|
-
|
|
74144
|
-
|
|
74145
|
-
|
|
74146
|
-
|
|
74147
|
-
|
|
74148
|
-
|
|
74149
|
-
|
|
74150
|
-
|
|
74151
|
-
|
|
74152
|
-
|
|
74153
|
-
|
|
74154
|
-
|
|
74155
|
-
|
|
74156
|
-
|
|
74157
|
-
|
|
74158
|
-
|
|
74159
|
-
|
|
74160
|
-
|
|
74161
|
-
|
|
74162
|
-
|
|
74163
|
-
|
|
74164
|
-
|
|
74165
|
-
|
|
74166
|
-
|
|
74167
|
-
|
|
74168
|
-
|
|
74169
|
-
|
|
74170
|
-
|
|
74171
|
-
|
|
74172
|
-
|
|
74173
|
-
|
|
74174
|
-
|
|
74175
|
-
|
|
74176
|
-
|
|
74177
|
-
|
|
74178
|
-
|
|
74179
|
-
|
|
74180
|
-
|
|
74181
|
-
|
|
74182
|
-
|
|
74183
|
-
|
|
74184
|
-
|
|
74185
|
-
|
|
74186
|
-
|
|
74187
|
-
|
|
74188
|
-
|
|
74189
|
-
|
|
74190
|
-
|
|
74191
|
-
|
|
74192
|
-
|
|
74193
|
-
|
|
74194
|
-
|
|
74195
|
-
|
|
74196
|
-
|
|
74197
|
-
|
|
74198
|
-
|
|
74199
|
-
|
|
74200
|
-
|
|
74201
|
-
|
|
74202
|
-
|
|
74203
|
-
|
|
74204
|
-
|
|
74205
|
-
|
|
74206
|
-
|
|
74207
|
-
|
|
74133
|
+
return function (schedule) {
|
|
74134
|
+
var _schedule$minute, _schedule$minute2, _schedule$hour, _schedule$minute3;
|
|
74135
|
+
var stringOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
74136
|
+
var _stringOptions$comple = stringOptions.complexScheduleString,
|
|
74137
|
+
complexScheduleString = _stringOptions$comple === void 0 ? t('Complex schedule') : _stringOptions$comple,
|
|
74138
|
+
_stringOptions$timeSt = stringOptions.timeStandardString,
|
|
74139
|
+
timeStandardString = _stringOptions$timeSt === void 0 ? t('(UTC)') : _stringOptions$timeSt;
|
|
74140
|
+
var scheduleStringTimeStandard = timeStandardString ? " ".concat(timeStandardString) : '';
|
|
74141
|
+
switch (getFrequency(schedule)) {
|
|
74142
|
+
case _constants__WEBPACK_IMPORTED_MODULE_2__.FREQUENCIES.HOURLY:
|
|
74143
|
+
return (schedule === null || schedule === void 0 || (_schedule$minute = schedule.minute) === null || _schedule$minute === void 0 ? void 0 : _schedule$minute[0]) === 1 ? t('Hourly at {{minutes}} minute past the hour', {
|
|
74144
|
+
minutes: schedule.minute[0].toString()
|
|
74145
|
+
}) : t('Hourly at {{minutes}} minutes past the hour', {
|
|
74146
|
+
minutes: schedule === null || schedule === void 0 || (_schedule$minute2 = schedule.minute) === null || _schedule$minute2 === void 0 ? void 0 : _schedule$minute2[0].toString()
|
|
74147
|
+
});
|
|
74148
|
+
case _constants__WEBPACK_IMPORTED_MODULE_2__.FREQUENCIES.DAILY:
|
|
74149
|
+
return "".concat(t('Daily at {{hour}}:{{minutes}}', {
|
|
74150
|
+
hour: schedule === null || schedule === void 0 || (_schedule$hour = schedule.hour) === null || _schedule$hour === void 0 ? void 0 : _schedule$hour[0].toString().padStart(2, '0'),
|
|
74151
|
+
minutes: schedule === null || schedule === void 0 || (_schedule$minute3 = schedule.minute) === null || _schedule$minute3 === void 0 ? void 0 : _schedule$minute3[0].toString().padStart(2, '0')
|
|
74152
|
+
})).concat(scheduleStringTimeStandard);
|
|
74153
|
+
case _constants__WEBPACK_IMPORTED_MODULE_2__.FREQUENCIES.WEEKLY:
|
|
74154
|
+
{
|
|
74155
|
+
var _schedule$hour2, _schedule$minute4, _daysOfWeek$find, _schedule$dayOfWeek2;
|
|
74156
|
+
var options = {
|
|
74157
|
+
hour: schedule === null || schedule === void 0 || (_schedule$hour2 = schedule.hour) === null || _schedule$hour2 === void 0 ? void 0 : _schedule$hour2[0].toString().padStart(2, '0'),
|
|
74158
|
+
minutes: schedule === null || schedule === void 0 || (_schedule$minute4 = schedule.minute) === null || _schedule$minute4 === void 0 ? void 0 : _schedule$minute4[0].toString().padStart(2, '0'),
|
|
74159
|
+
day: (_daysOfWeek$find = daysOfWeek.find(function (d) {
|
|
74160
|
+
var _schedule$dayOfWeek;
|
|
74161
|
+
return d.index === (schedule === null || schedule === void 0 || (_schedule$dayOfWeek = schedule.dayOfWeek) === null || _schedule$dayOfWeek === void 0 ? void 0 : _schedule$dayOfWeek[0]);
|
|
74162
|
+
})) === null || _daysOfWeek$find === void 0 ? void 0 : _daysOfWeek$find.label
|
|
74163
|
+
};
|
|
74164
|
+
var weeklyString = (schedule === null || schedule === void 0 || (_schedule$dayOfWeek2 = schedule.dayOfWeek) === null || _schedule$dayOfWeek2 === void 0 ? void 0 : _schedule$dayOfWeek2.length) === 1 ? t('Weekly on {{day}} at {{hour}}:{{minutes}}', _objectSpread({}, options)) : t('Weekly on multiple days at {{hour}}:{{minutes}}', _objectSpread({}, options));
|
|
74165
|
+
return "".concat(weeklyString).concat(scheduleStringTimeStandard);
|
|
74166
|
+
}
|
|
74167
|
+
case _constants__WEBPACK_IMPORTED_MODULE_2__.FREQUENCIES.MONTHLY:
|
|
74168
|
+
{
|
|
74169
|
+
var _schedule$hour3, _schedule$minute5, _schedule$dayOfMonth, _schedule$dayOfMonth2, _schedule$dayOfMonth3;
|
|
74170
|
+
var _options = {
|
|
74171
|
+
hour: schedule === null || schedule === void 0 || (_schedule$hour3 = schedule.hour) === null || _schedule$hour3 === void 0 ? void 0 : _schedule$hour3[0].toString().padStart(2, '0'),
|
|
74172
|
+
minutes: schedule === null || schedule === void 0 || (_schedule$minute5 = schedule.minute) === null || _schedule$minute5 === void 0 ? void 0 : _schedule$minute5[0].toString().padStart(2, '0'),
|
|
74173
|
+
day: schedule === null || schedule === void 0 || (_schedule$dayOfMonth = schedule.dayOfMonth) === null || _schedule$dayOfMonth === void 0 ? void 0 : _schedule$dayOfMonth[0],
|
|
74174
|
+
days: schedule === null || schedule === void 0 || (_schedule$dayOfMonth2 = schedule.dayOfMonth) === null || _schedule$dayOfMonth2 === void 0 ? void 0 : _schedule$dayOfMonth2.join(', ') // day 1, 2, 3
|
|
74175
|
+
};
|
|
74176
|
+
var monthlyString = (schedule === null || schedule === void 0 || (_schedule$dayOfMonth3 = schedule.dayOfMonth) === null || _schedule$dayOfMonth3 === void 0 ? void 0 : _schedule$dayOfMonth3.length) === 1 ? t('Monthly on day {{day}} at {{hour}}:{{minutes}}', _objectSpread({}, _options)) : t('Monthly on days {{days}} at {{hour}}:{{minutes}}', _objectSpread({}, _options));
|
|
74177
|
+
return "".concat(monthlyString).concat(scheduleStringTimeStandard);
|
|
74178
|
+
}
|
|
74179
|
+
case _constants__WEBPACK_IMPORTED_MODULE_2__.FREQUENCIES.QUARTERLY:
|
|
74180
|
+
{
|
|
74181
|
+
var _schedule$hour4, _schedule$minute6, _schedule$dayOfMonth4, _schedule$dayOfMonth5, _schedule$dayOfMonth6;
|
|
74182
|
+
var _options2 = {
|
|
74183
|
+
hour: schedule === null || schedule === void 0 || (_schedule$hour4 = schedule.hour) === null || _schedule$hour4 === void 0 ? void 0 : _schedule$hour4[0].toString().padStart(2, '0'),
|
|
74184
|
+
minutes: schedule === null || schedule === void 0 || (_schedule$minute6 = schedule.minute) === null || _schedule$minute6 === void 0 ? void 0 : _schedule$minute6[0].toString().padStart(2, '0'),
|
|
74185
|
+
day: schedule === null || schedule === void 0 || (_schedule$dayOfMonth4 = schedule.dayOfMonth) === null || _schedule$dayOfMonth4 === void 0 ? void 0 : _schedule$dayOfMonth4[0],
|
|
74186
|
+
days: schedule === null || schedule === void 0 || (_schedule$dayOfMonth5 = schedule.dayOfMonth) === null || _schedule$dayOfMonth5 === void 0 ? void 0 : _schedule$dayOfMonth5.join(', ') // day 1, 2, 3
|
|
74187
|
+
};
|
|
74188
|
+
var quarterlyString = (schedule === null || schedule === void 0 || (_schedule$dayOfMonth6 = schedule.dayOfMonth) === null || _schedule$dayOfMonth6 === void 0 ? void 0 : _schedule$dayOfMonth6.length) === 1 ? t('Quarterly on day {{day}} at {{hour}}:{{minutes}}', _objectSpread({}, _options2)) : t('Quarterly on days {{days}} at {{hour}}:{{minutes}}', _objectSpread({}, _options2));
|
|
74189
|
+
return "".concat(quarterlyString).concat(scheduleStringTimeStandard);
|
|
74190
|
+
}
|
|
74191
|
+
case _constants__WEBPACK_IMPORTED_MODULE_2__.FREQUENCIES.YEARLY:
|
|
74192
|
+
{
|
|
74193
|
+
var _schedule$hour5, _schedule$minute7, _schedule$dayOfMonth7, _Object$values$find, _schedule$month$lengt, _schedule$month2, _schedule$dayOfMonth$, _schedule$dayOfMonth8;
|
|
74194
|
+
var _options3 = {
|
|
74195
|
+
hour: schedule === null || schedule === void 0 || (_schedule$hour5 = schedule.hour) === null || _schedule$hour5 === void 0 ? void 0 : _schedule$hour5[0].toString().padStart(2, '0'),
|
|
74196
|
+
minutes: schedule === null || schedule === void 0 || (_schedule$minute7 = schedule.minute) === null || _schedule$minute7 === void 0 ? void 0 : _schedule$minute7[0].toString().padStart(2, '0'),
|
|
74197
|
+
day: schedule === null || schedule === void 0 || (_schedule$dayOfMonth7 = schedule.dayOfMonth) === null || _schedule$dayOfMonth7 === void 0 ? void 0 : _schedule$dayOfMonth7[0],
|
|
74198
|
+
month: (_Object$values$find = Object.values(months).find(function (m) {
|
|
74199
|
+
var _schedule$month;
|
|
74200
|
+
return m.index === (schedule === null || schedule === void 0 || (_schedule$month = schedule.month) === null || _schedule$month === void 0 ? void 0 : _schedule$month[0]);
|
|
74201
|
+
})) === null || _Object$values$find === void 0 ? void 0 : _Object$values$find.label
|
|
74202
|
+
};
|
|
74203
|
+
var yearlyString = Math.max((_schedule$month$lengt = schedule === null || schedule === void 0 || (_schedule$month2 = schedule.month) === null || _schedule$month2 === void 0 ? void 0 : _schedule$month2.length) !== null && _schedule$month$lengt !== void 0 ? _schedule$month$lengt : 0, (_schedule$dayOfMonth$ = schedule === null || schedule === void 0 || (_schedule$dayOfMonth8 = schedule.dayOfMonth) === null || _schedule$dayOfMonth8 === void 0 ? void 0 : _schedule$dayOfMonth8.length) !== null && _schedule$dayOfMonth$ !== void 0 ? _schedule$dayOfMonth$ : 0) ? t('Yearly on {{month}} {{day}} at {{hour}}:{{minutes}}', _objectSpread({}, _options3)) : t('Yearly on multiple dates at {{hour}}:{{minutes}}', _objectSpread({}, _options3));
|
|
74204
|
+
return "".concat(yearlyString).concat(scheduleStringTimeStandard);
|
|
74205
|
+
}
|
|
74206
|
+
default:
|
|
74207
|
+
return complexScheduleString;
|
|
74208
|
+
}
|
|
74209
|
+
};
|
|
74208
74210
|
}
|
|
74209
74211
|
function hasSameItems(arr1, arr2) {
|
|
74210
74212
|
return arr1.length === (arr2 === null || arr2 === void 0 ? void 0 : arr2.length) && arr1.every(function (item1) {
|