-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiSuperDatePicker] add showRefreshOnly prop #1412
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
008a5a8
[EuiSuperDatePicker] add showRefreshOnly prop
nreese 80cda42
showRefreshOnly design updates (#4)
cchaos 72a209d
rename showRefreshOnly to isAutoRefreshOnly, add description for prop
nreese 849ab4e
Merge branch 'master' of github.com:elastic/eui into showRefreshOnly
nreese adfe619
changelog
nreese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/components/date_picker/super_date_picker/pretty_interval.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
const MS_IN_SECOND = 1000; | ||
const MS_IN_MINUTE = 60 * MS_IN_SECOND; | ||
const MS_IN_HOUR = 60 * MS_IN_MINUTE; | ||
const MS_IN_DAY = 24 * MS_IN_HOUR; | ||
|
||
export function prettyInterval(isPaused, intervalInMs) { | ||
if (isPaused || intervalInMs === 0) { | ||
return 'Off'; | ||
} else if (intervalInMs < MS_IN_MINUTE) { | ||
const intervalInSeconds = Math.round(intervalInMs / MS_IN_SECOND); | ||
const units = intervalInSeconds > 1 ? 'seconds' : 'second'; | ||
return `${intervalInSeconds} ${units}`; | ||
} else if (intervalInMs < MS_IN_HOUR) { | ||
const intervalInMinutes = Math.round(intervalInMs / MS_IN_MINUTE); | ||
const units = intervalInMinutes > 1 ? 'minutes' : 'minute'; | ||
return `${intervalInMinutes} ${units}`; | ||
} else if (intervalInMs < MS_IN_DAY) { | ||
const intervalInHours = Math.round(intervalInMs / MS_IN_HOUR); | ||
const units = intervalInHours > 1 ? 'hours' : 'hour'; | ||
return `${intervalInHours} ${units}`; | ||
} | ||
|
||
const intervalInDays = Math.round(intervalInMs / MS_IN_DAY); | ||
const units = intervalInDays > 1 ? 'days' : 'day'; | ||
return `${intervalInDays} ${units}`; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/components/date_picker/super_date_picker/pretty_interval.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
import { prettyInterval } from './pretty_interval'; | ||
|
||
const IS_NOT_PAUSED = false; | ||
const IS_PAUSED = true; | ||
|
||
test('Off', () => { | ||
expect(prettyInterval(IS_NOT_PAUSED, 0)).toBe('Off'); | ||
expect(prettyInterval(IS_PAUSED, 1000)).toBe('Off'); | ||
}); | ||
|
||
test('seconds', () => { | ||
expect(prettyInterval(IS_NOT_PAUSED, 1000)).toBe('1 second'); | ||
expect(prettyInterval(IS_NOT_PAUSED, 15000)).toBe('15 seconds'); | ||
}); | ||
|
||
test('minutes', () => { | ||
expect(prettyInterval(IS_NOT_PAUSED, 60000)).toBe('1 minute'); | ||
expect(prettyInterval(IS_NOT_PAUSED, 1800000)).toBe('30 minutes'); | ||
}); | ||
|
||
test('hours', () => { | ||
expect(prettyInterval(IS_NOT_PAUSED, 3600000)).toBe('1 hour'); | ||
expect(prettyInterval(IS_NOT_PAUSED, 43200000)).toBe('12 hours'); | ||
}); | ||
|
||
test('days', () => { | ||
expect(prettyInterval(IS_NOT_PAUSED, 86400000)).toBe('1 day'); | ||
expect(prettyInterval(IS_NOT_PAUSED, 86400000 * 2)).toBe('2 days'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
...er/super_date_picker/quick_select_popover/__snapshots__/quick_select_popover.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiQuickSelectPopover is rendered 1`] = ` | ||
<EuiPopover | ||
anchorPosition="downLeft" | ||
button={ | ||
<EuiButtonEmpty | ||
aria-label="Date quick select" | ||
className="euiFormControlLayout__prepend" | ||
color="primary" | ||
data-test-subj="superDatePickerToggleQuickMenuButton" | ||
iconSide="right" | ||
iconType="arrowDown" | ||
onClick={[Function]} | ||
size="xs" | ||
textProps={ | ||
Object { | ||
"className": "euiQuickSelectPopover__buttonText", | ||
} | ||
} | ||
type="button" | ||
> | ||
<EuiIcon | ||
size="m" | ||
type="calendar" | ||
/> | ||
</EuiButtonEmpty> | ||
} | ||
closePopover={[Function]} | ||
hasArrow={true} | ||
id="QuickSelectPopover" | ||
isOpen={false} | ||
ownFocus={true} | ||
panelPaddingSize="m" | ||
> | ||
<div | ||
className="euiQuickSelectPopover__content" | ||
data-test-subj="superDatePickerQuickMenu" | ||
> | ||
<React.Fragment> | ||
<EuiQuickSelect | ||
applyTime={[Function]} | ||
end="now" | ||
prevQuickSelect={Object {}} | ||
start="now-15m" | ||
/> | ||
<EuiCommonlyUsedTimeRanges | ||
applyTime={[Function]} | ||
commonlyUsedRanges={ | ||
Array [ | ||
Object { | ||
"end": "now/d", | ||
"label": "Today", | ||
"start": "now/d", | ||
}, | ||
] | ||
} | ||
/> | ||
<EuiRecentlyUsed | ||
applyTime={[Function]} | ||
commonlyUsedRanges={ | ||
Array [ | ||
Object { | ||
"end": "now/d", | ||
"label": "Today", | ||
"start": "now/d", | ||
}, | ||
] | ||
} | ||
dateFormat="MMM D, YYYY @ HH:mm:ss.SSS" | ||
recentlyUsedRanges={ | ||
Array [ | ||
Object { | ||
"end": "now/d", | ||
"label": "Today", | ||
"start": "now/d", | ||
}, | ||
] | ||
} | ||
/> | ||
</React.Fragment> | ||
<EuiRefreshInterval | ||
applyRefreshInterval={[Function]} | ||
isPaused={true} | ||
refreshInterval={0} | ||
/> | ||
</div> | ||
</EuiPopover> | ||
`; | ||
|
||
exports[`EuiQuickSelectPopover showRefreshOnly 1`] = ` | ||
<EuiPopover | ||
anchorPosition="downLeft" | ||
button={ | ||
<EuiButtonEmpty | ||
aria-label="Date quick select" | ||
className="euiFormControlLayout__prepend" | ||
color="primary" | ||
data-test-subj="superDatePickerToggleQuickMenuButton" | ||
iconSide="right" | ||
iconType="arrowDown" | ||
onClick={[Function]} | ||
size="xs" | ||
textProps={ | ||
Object { | ||
"className": "euiQuickSelectPopover__buttonText", | ||
} | ||
} | ||
type="button" | ||
> | ||
<EuiIcon | ||
size="m" | ||
type="calendar" | ||
/> | ||
</EuiButtonEmpty> | ||
} | ||
closePopover={[Function]} | ||
hasArrow={true} | ||
id="QuickSelectPopover" | ||
isOpen={false} | ||
ownFocus={true} | ||
panelPaddingSize="m" | ||
> | ||
<div | ||
className="euiQuickSelectPopover__content" | ||
data-test-subj="superDatePickerQuickMenu" | ||
> | ||
<EuiRefreshInterval | ||
applyRefreshInterval={[Function]} | ||
isPaused={true} | ||
refreshInterval={0} | ||
/> | ||
</div> | ||
</EuiPopover> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prop name is confusing because I think that's it's referring to the Update/Refresh button. Can you rename to
isAutoRefreshOnly
?