Skip to content

Commit

Permalink
Remove auto refresh option in create acceleration flyout (#1716) (#1718)
Browse files Browse the repository at this point in the history
* remove auto refresh option, update tests



* update error on blur



---------


(cherry picked from commit 1f7ee0a)

Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 84c2a00 commit f1e2ce1
Show file tree
Hide file tree
Showing 10 changed files with 649 additions and 68 deletions.
6 changes: 6 additions & 0 deletions common/constants/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export const ACCELERATION_TIME_INTERVAL = [
{ text: 'day(s)', value: 'day' },
{ text: 'week(s)', value: 'week' },
];
export const ACCELERATION_REFRESH_TIME_INTERVAL = [
{ text: 'minutes(s)', value: 'minute' },
{ text: 'hour(s)', value: 'hour' },
{ text: 'day(s)', value: 'day' },
{ text: 'week(s)', value: 'week' },
];

export const ACCELERATION_ADD_FIELDS_TEXT = '(add fields here)';
export const ACCELERATION_INDEX_NAME_REGEX = /^[a-z0-9_]+$/;
Expand Down
2 changes: 1 addition & 1 deletion common/types/data_connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export interface FormErrorsType {
watermarkDelayError: string[];
}

export type AccelerationRefreshType = 'auto' | 'autoInterval' | 'manual' | 'manualIncrement';
export type AccelerationRefreshType = 'autoInterval' | 'manual' | 'manualIncrement';

export interface CreateAccelerationForm {
dataSource: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ Array [
<input
id="random_html_id"
type="hidden"
value="auto"
value="autoInterval"
/>
<div
class="euiFormControlLayout"
Expand All @@ -595,7 +595,7 @@ Array [
class="euiScreenReaderOnly"
id="random_html_id"
>
Select an option: Auto, is selected
Select an option: Auto (Interval), is selected
</span>
<button
aria-describedby="random_html_id-help-0"
Expand All @@ -604,7 +604,7 @@ Array [
class="euiSuperSelectControl"
type="button"
>
Auto
Auto (Interval)
</button>
<div
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
Expand Down Expand Up @@ -641,6 +641,104 @@ Array [
</div>
</div>
</div>
<div
class="euiFormRow"
id="random_html_id-row"
>
<div
class="euiFormRow__labelWrapper"
>
<label
aria-invalid="false"
class="euiFormLabel euiFormRow__label"
for="random_html_id"
>
Refresh increments
</label>
</div>
<div
class="euiFormRow__fieldWrapper"
>
<div
class="euiFormControlLayout euiFormControlLayout--group"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
aria-describedby="random_html_id-help-0"
aria-label="Refresh increments"
class="euiFieldNumber euiFieldNumber--inGroup"
id="random_html_id"
min="1"
placeholder="Refresh increments"
type="number"
value="15"
/>
</div>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<select
class="euiSelect euiFormControlLayout__append"
>
<option
value="minute"
>
minutes(s)
</option>
<option
value="hour"
>
hour(s)
</option>
<option
value="day"
>
day(s)
</option>
<option
value="week"
>
week(s)
</option>
</select>
<div
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
>
<span
class="euiFormControlLayoutCustomIcon"
>
<svg
aria-hidden="true"
class="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon"
focusable="false"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
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"
/>
</svg>
</span>
</div>
</div>
</div>
</div>
<div
class="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Specify how frequent the index gets updated when performing the refresh job.
</div>
</div>
</div>
<div
class="euiFormRow"
id="random_html_id-row"
Expand Down Expand Up @@ -2036,7 +2134,7 @@ Array [
<input
id="random_html_id"
type="hidden"
value="auto"
value="autoInterval"
/>,
<div
className="euiFormControlLayout"
Expand All @@ -2048,7 +2146,7 @@ Array [
className="euiScreenReaderOnly"
id="random_html_id"
>
Select an option: Auto, is selected
Select an option: Auto (Interval), is selected
</span>
<button
aria-describedby="random_html_id-help-0"
Expand All @@ -2061,7 +2159,7 @@ Array [
onKeyDown={[Function]}
type="button"
>
Auto
Auto (Interval)
</button>
<div
className="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
Expand Down Expand Up @@ -2100,6 +2198,116 @@ Array [
</div>
</div>
</div>,
<div
className="euiFormRow"
id="random_html_id-row"
>
<div
className="euiFormRow__labelWrapper"
>
<label
aria-invalid={false}
className="euiFormLabel euiFormRow__label"
htmlFor="random_html_id"
>
Refresh increments
</label>
</div>
<div
className="euiFormRow__fieldWrapper"
>
<div
className="euiFormControlLayout euiFormControlLayout--group"
>
<div
className="euiFormControlLayout__childrenWrapper"
>
<input
aria-describedby="random_html_id-help-0"
aria-label="Refresh increments"
className="euiFieldNumber euiFieldNumber--inGroup"
id="random_html_id"
min={1}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
placeholder="Refresh increments"
type="number"
value={15}
/>
</div>
<div
className="euiFormControlLayout"
>
<div
className="euiFormControlLayout__childrenWrapper"
>
<select
className="euiSelect euiFormControlLayout__append"
onBlur={[Function]}
onChange={[Function]}
onMouseUp={[Function]}
value="minute"
>
<option
key="0"
value="minute"
>
minutes(s)
</option>
<option
key="1"
value="hour"
>
hour(s)
</option>
<option
key="2"
value="day"
>
day(s)
</option>
<option
key="3"
value="week"
>
week(s)
</option>
</select>
<div
className="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
>
<span
className="euiFormControlLayoutCustomIcon"
>
<svg
aria-hidden={true}
className="euiIcon euiIcon--medium euiIcon-isLoading euiFormControlLayoutCustomIcon__icon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
>
<path
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"
/>
</svg>
</span>
</div>
</div>
</div>
</div>
<div
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Specify how frequent the index gets updated when performing the refresh job.
</div>
</div>
</div>,
<div
className="euiFormRow"
id="random_html_id-row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,36 @@ describe('validateReplicaCount', () => {

describe('validateRefreshInterval', () => {
it('should return an array with an error message when refreshType is "interval" and refreshWindow is less than 1', () => {
expect(validateRefreshInterval('autoInterval', 0)).toEqual([
expect(validateRefreshInterval('autoInterval', 0, 'hour')).toEqual([
'refresh window should be greater than 0',
]);
expect(validateRefreshInterval('autoInterval', -1)).toEqual([
expect(validateRefreshInterval('autoInterval', -1, 'day')).toEqual([
'refresh window should be greater than 0',
]);
expect(validateRefreshInterval('autoInterval', -10)).toEqual([
expect(validateRefreshInterval('autoInterval', -10, 'week')).toEqual([
'refresh window should be greater than 0',
]);
expect(validateRefreshInterval('autoInterval', 14, 'minute')).toEqual([
'refresh window should be greater than 15 minutes',
]);
expect(validateRefreshInterval('autoInterval', 10, 'minute')).toEqual([
'refresh window should be greater than 15 minutes',
]);
expect(validateRefreshInterval('autoInterval', 0, 'minute')).toEqual([
'refresh window should be greater than 15 minutes',
]);
});

it('should return an empty array when refreshType is not "interval" or when refreshWindow is greater than or equal to 1', () => {
expect(validateRefreshInterval('auto', 0)).toEqual([]);
expect(validateRefreshInterval('auto', 1)).toEqual([]);
expect(validateRefreshInterval('autoInterval', 1)).toEqual([]);
expect(validateRefreshInterval('autoInterval', 5)).toEqual([]);
expect(validateRefreshInterval('manual', 0)).toEqual([]);
expect(validateRefreshInterval('manualIncrement', 0)).toEqual([]);
expect(validateRefreshInterval('auto', 0, 'minute')).toEqual([]);
expect(validateRefreshInterval('auto', 1, 'minute')).toEqual([]);
expect(validateRefreshInterval('autoInterval', 15, 'minute')).toEqual([]);
expect(validateRefreshInterval('autoInterval', 20, 'minute')).toEqual([]);
expect(validateRefreshInterval('manual', 0, 'minute')).toEqual([]);
expect(validateRefreshInterval('manualIncrement', 0, 'minute')).toEqual([]);
expect(validateRefreshInterval('autoInterval', 1, 'hour')).toEqual([]);
expect(validateRefreshInterval('autoInterval', 2, 'day')).toEqual([]);
expect(validateRefreshInterval('autoInterval', 3, 'week')).toEqual([]);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import React, { useEffect, useState } from 'react';
import {
ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME,
ACCELERATION_REFRESH_TIME_INTERVAL,
ACCELERATION_TIME_INTERVAL,
} from '../../../../../../../../common/constants/data_sources';
import {
Expand Down Expand Up @@ -75,15 +76,15 @@ export const CreateAcceleration = ({
accelerationIndexName: ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME,
primaryShardsCount: 1,
replicaShardsCount: 1,
refreshType: 'auto',
refreshType: 'autoInterval',
checkpointLocation: undefined,
watermarkDelay: {
delayWindow: 1,
delayInterval: ACCELERATION_TIME_INTERVAL[2].value, // minutes
},
refreshIntervalOptions: {
refreshWindow: 1,
refreshInterval: ACCELERATION_TIME_INTERVAL[2].value, // minutes
refreshWindow: 15,
refreshInterval: ACCELERATION_REFRESH_TIME_INTERVAL[0].value, // minutes
},
formErrors: {
dataSourceError: [],
Expand Down
Loading

0 comments on commit f1e2ce1

Please sign in to comment.