Skip to content

Commit 1f7ee0a

Browse files
authored
Remove auto refresh option in create acceleration flyout (#1716)
* remove auto refresh option, update tests Signed-off-by: Shenoy Pratik <[email protected]> * update error on blur Signed-off-by: Shenoy Pratik <[email protected]> --------- Signed-off-by: Shenoy Pratik <[email protected]>
1 parent a44a4ae commit 1f7ee0a

File tree

10 files changed

+649
-68
lines changed

10 files changed

+649
-68
lines changed

common/constants/data_sources.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ export const ACCELERATION_TIME_INTERVAL = [
3333
{ text: 'day(s)', value: 'day' },
3434
{ text: 'week(s)', value: 'week' },
3535
];
36+
export const ACCELERATION_REFRESH_TIME_INTERVAL = [
37+
{ text: 'minutes(s)', value: 'minute' },
38+
{ text: 'hour(s)', value: 'hour' },
39+
{ text: 'day(s)', value: 'day' },
40+
{ text: 'week(s)', value: 'week' },
41+
];
3642

3743
export const ACCELERATION_ADD_FIELDS_TEXT = '(add fields here)';
3844
export const ACCELERATION_INDEX_NAME_REGEX = /^[a-z0-9_]+$/;

common/types/data_connections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export interface FormErrorsType {
217217
watermarkDelayError: string[];
218218
}
219219

220-
export type AccelerationRefreshType = 'auto' | 'autoInterval' | 'manual' | 'manualIncrement';
220+
export type AccelerationRefreshType = 'autoInterval' | 'manual' | 'manualIncrement';
221221

222222
export interface CreateAccelerationForm {
223223
dataSource: string;

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/__tests__/__snapshots__/create_acceleration.test.tsx.snap

Lines changed: 214 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ Array [
583583
<input
584584
id="random_html_id"
585585
type="hidden"
586-
value="auto"
586+
value="autoInterval"
587587
/>
588588
<div
589589
class="euiFormControlLayout"
@@ -595,7 +595,7 @@ Array [
595595
class="euiScreenReaderOnly"
596596
id="random_html_id"
597597
>
598-
Select an option: Auto, is selected
598+
Select an option: Auto (Interval), is selected
599599
</span>
600600
<button
601601
aria-describedby="random_html_id-help-0"
@@ -604,7 +604,7 @@ Array [
604604
class="euiSuperSelectControl"
605605
type="button"
606606
>
607-
Auto
607+
Auto (Interval)
608608
</button>
609609
<div
610610
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
@@ -641,6 +641,104 @@ Array [
641641
</div>
642642
</div>
643643
</div>
644+
<div
645+
class="euiFormRow"
646+
id="random_html_id-row"
647+
>
648+
<div
649+
class="euiFormRow__labelWrapper"
650+
>
651+
<label
652+
aria-invalid="false"
653+
class="euiFormLabel euiFormRow__label"
654+
for="random_html_id"
655+
>
656+
Refresh increments
657+
</label>
658+
</div>
659+
<div
660+
class="euiFormRow__fieldWrapper"
661+
>
662+
<div
663+
class="euiFormControlLayout euiFormControlLayout--group"
664+
>
665+
<div
666+
class="euiFormControlLayout__childrenWrapper"
667+
>
668+
<input
669+
aria-describedby="random_html_id-help-0"
670+
aria-label="Refresh increments"
671+
class="euiFieldNumber euiFieldNumber--inGroup"
672+
id="random_html_id"
673+
min="1"
674+
placeholder="Refresh increments"
675+
type="number"
676+
value="15"
677+
/>
678+
</div>
679+
<div
680+
class="euiFormControlLayout"
681+
>
682+
<div
683+
class="euiFormControlLayout__childrenWrapper"
684+
>
685+
<select
686+
class="euiSelect euiFormControlLayout__append"
687+
>
688+
<option
689+
value="minute"
690+
>
691+
minutes(s)
692+
</option>
693+
<option
694+
value="hour"
695+
>
696+
hour(s)
697+
</option>
698+
<option
699+
value="day"
700+
>
701+
day(s)
702+
</option>
703+
<option
704+
value="week"
705+
>
706+
week(s)
707+
</option>
708+
</select>
709+
<div
710+
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
711+
>
712+
<span
713+
class="euiFormControlLayoutCustomIcon"
714+
>
715+
<svg
716+
aria-hidden="true"
717+
class="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon"
718+
focusable="false"
719+
height="16"
720+
role="img"
721+
viewBox="0 0 16 16"
722+
width="16"
723+
xmlns="http://www.w3.org/2000/svg"
724+
>
725+
<path
726+
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
727+
/>
728+
</svg>
729+
</span>
730+
</div>
731+
</div>
732+
</div>
733+
</div>
734+
<div
735+
class="euiFormHelpText euiFormRow__text"
736+
id="random_html_id-help-0"
737+
>
738+
Specify how frequent the index gets updated when performing the refresh job.
739+
</div>
740+
</div>
741+
</div>
644742
<div
645743
class="euiFormRow"
646744
id="random_html_id-row"
@@ -2036,7 +2134,7 @@ Array [
20362134
<input
20372135
id="random_html_id"
20382136
type="hidden"
2039-
value="auto"
2137+
value="autoInterval"
20402138
/>,
20412139
<div
20422140
className="euiFormControlLayout"
@@ -2048,7 +2146,7 @@ Array [
20482146
className="euiScreenReaderOnly"
20492147
id="random_html_id"
20502148
>
2051-
Select an option: Auto, is selected
2149+
Select an option: Auto (Interval), is selected
20522150
</span>
20532151
<button
20542152
aria-describedby="random_html_id-help-0"
@@ -2061,7 +2159,7 @@ Array [
20612159
onKeyDown={[Function]}
20622160
type="button"
20632161
>
2064-
Auto
2162+
Auto (Interval)
20652163
</button>
20662164
<div
20672165
className="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
@@ -2100,6 +2198,116 @@ Array [
21002198
</div>
21012199
</div>
21022200
</div>,
2201+
<div
2202+
className="euiFormRow"
2203+
id="random_html_id-row"
2204+
>
2205+
<div
2206+
className="euiFormRow__labelWrapper"
2207+
>
2208+
<label
2209+
aria-invalid={false}
2210+
className="euiFormLabel euiFormRow__label"
2211+
htmlFor="random_html_id"
2212+
>
2213+
Refresh increments
2214+
</label>
2215+
</div>
2216+
<div
2217+
className="euiFormRow__fieldWrapper"
2218+
>
2219+
<div
2220+
className="euiFormControlLayout euiFormControlLayout--group"
2221+
>
2222+
<div
2223+
className="euiFormControlLayout__childrenWrapper"
2224+
>
2225+
<input
2226+
aria-describedby="random_html_id-help-0"
2227+
aria-label="Refresh increments"
2228+
className="euiFieldNumber euiFieldNumber--inGroup"
2229+
id="random_html_id"
2230+
min={1}
2231+
onBlur={[Function]}
2232+
onChange={[Function]}
2233+
onFocus={[Function]}
2234+
placeholder="Refresh increments"
2235+
type="number"
2236+
value={15}
2237+
/>
2238+
</div>
2239+
<div
2240+
className="euiFormControlLayout"
2241+
>
2242+
<div
2243+
className="euiFormControlLayout__childrenWrapper"
2244+
>
2245+
<select
2246+
className="euiSelect euiFormControlLayout__append"
2247+
onBlur={[Function]}
2248+
onChange={[Function]}
2249+
onMouseUp={[Function]}
2250+
value="minute"
2251+
>
2252+
<option
2253+
key="0"
2254+
value="minute"
2255+
>
2256+
minutes(s)
2257+
</option>
2258+
<option
2259+
key="1"
2260+
value="hour"
2261+
>
2262+
hour(s)
2263+
</option>
2264+
<option
2265+
key="2"
2266+
value="day"
2267+
>
2268+
day(s)
2269+
</option>
2270+
<option
2271+
key="3"
2272+
value="week"
2273+
>
2274+
week(s)
2275+
</option>
2276+
</select>
2277+
<div
2278+
className="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
2279+
>
2280+
<span
2281+
className="euiFormControlLayoutCustomIcon"
2282+
>
2283+
<svg
2284+
aria-hidden={true}
2285+
className="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon"
2286+
focusable="false"
2287+
height={16}
2288+
role="img"
2289+
style={null}
2290+
viewBox="0 0 16 16"
2291+
width={16}
2292+
xmlns="http://www.w3.org/2000/svg"
2293+
>
2294+
<path
2295+
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
2296+
/>
2297+
</svg>
2298+
</span>
2299+
</div>
2300+
</div>
2301+
</div>
2302+
</div>
2303+
<div
2304+
className="euiFormHelpText euiFormRow__text"
2305+
id="random_html_id-help-0"
2306+
>
2307+
Specify how frequent the index gets updated when performing the refresh job.
2308+
</div>
2309+
</div>
2310+
</div>,
21032311
<div
21042312
className="euiFormRow"
21052313
id="random_html_id-row"

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/__tests__/utils.test.tsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,36 @@ describe('validateReplicaCount', () => {
109109

110110
describe('validateRefreshInterval', () => {
111111
it('should return an array with an error message when refreshType is "interval" and refreshWindow is less than 1', () => {
112-
expect(validateRefreshInterval('autoInterval', 0)).toEqual([
112+
expect(validateRefreshInterval('autoInterval', 0, 'hour')).toEqual([
113113
'refresh window should be greater than 0',
114114
]);
115-
expect(validateRefreshInterval('autoInterval', -1)).toEqual([
115+
expect(validateRefreshInterval('autoInterval', -1, 'day')).toEqual([
116116
'refresh window should be greater than 0',
117117
]);
118-
expect(validateRefreshInterval('autoInterval', -10)).toEqual([
118+
expect(validateRefreshInterval('autoInterval', -10, 'week')).toEqual([
119119
'refresh window should be greater than 0',
120120
]);
121+
expect(validateRefreshInterval('autoInterval', 14, 'minute')).toEqual([
122+
'refresh window should be greater than 15 minutes',
123+
]);
124+
expect(validateRefreshInterval('autoInterval', 10, 'minute')).toEqual([
125+
'refresh window should be greater than 15 minutes',
126+
]);
127+
expect(validateRefreshInterval('autoInterval', 0, 'minute')).toEqual([
128+
'refresh window should be greater than 15 minutes',
129+
]);
121130
});
122131

123132
it('should return an empty array when refreshType is not "interval" or when refreshWindow is greater than or equal to 1', () => {
124-
expect(validateRefreshInterval('auto', 0)).toEqual([]);
125-
expect(validateRefreshInterval('auto', 1)).toEqual([]);
126-
expect(validateRefreshInterval('autoInterval', 1)).toEqual([]);
127-
expect(validateRefreshInterval('autoInterval', 5)).toEqual([]);
128-
expect(validateRefreshInterval('manual', 0)).toEqual([]);
129-
expect(validateRefreshInterval('manualIncrement', 0)).toEqual([]);
133+
expect(validateRefreshInterval('auto', 0, 'minute')).toEqual([]);
134+
expect(validateRefreshInterval('auto', 1, 'minute')).toEqual([]);
135+
expect(validateRefreshInterval('autoInterval', 15, 'minute')).toEqual([]);
136+
expect(validateRefreshInterval('autoInterval', 20, 'minute')).toEqual([]);
137+
expect(validateRefreshInterval('manual', 0, 'minute')).toEqual([]);
138+
expect(validateRefreshInterval('manualIncrement', 0, 'minute')).toEqual([]);
139+
expect(validateRefreshInterval('autoInterval', 1, 'hour')).toEqual([]);
140+
expect(validateRefreshInterval('autoInterval', 2, 'day')).toEqual([]);
141+
expect(validateRefreshInterval('autoInterval', 3, 'week')).toEqual([]);
130142
});
131143
});
132144

public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import React, { useEffect, useState } from 'react';
1919
import {
2020
ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME,
21+
ACCELERATION_REFRESH_TIME_INTERVAL,
2122
ACCELERATION_TIME_INTERVAL,
2223
} from '../../../../../../../../common/constants/data_sources';
2324
import {
@@ -75,15 +76,15 @@ export const CreateAcceleration = ({
7576
accelerationIndexName: ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME,
7677
primaryShardsCount: 1,
7778
replicaShardsCount: 1,
78-
refreshType: 'auto',
79+
refreshType: 'autoInterval',
7980
checkpointLocation: undefined,
8081
watermarkDelay: {
8182
delayWindow: 1,
8283
delayInterval: ACCELERATION_TIME_INTERVAL[2].value, // minutes
8384
},
8485
refreshIntervalOptions: {
85-
refreshWindow: 1,
86-
refreshInterval: ACCELERATION_TIME_INTERVAL[2].value, // minutes
86+
refreshWindow: 15,
87+
refreshInterval: ACCELERATION_REFRESH_TIME_INTERVAL[0].value, // minutes
8788
},
8889
formErrors: {
8990
dataSourceError: [],

0 commit comments

Comments
 (0)