From 8bde8a89420e46da2b4580b58d0ea0c9c822cf94 Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Thu, 7 May 2020 13:25:16 +0530 Subject: [PATCH 1/3] added EuiSuperDatePicker UTC offset prop --- .../date_popover/absolute_tab.tsx | 36 ++++++++++--------- .../date_popover/date_popover_button.tsx | 3 ++ .../date_popover/date_popover_content.tsx | 3 ++ .../super_date_picker/super_date_picker.tsx | 6 +++- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/components/date_picker/super_date_picker/date_popover/absolute_tab.tsx b/src/components/date_picker/super_date_picker/date_popover/absolute_tab.tsx index 3401e4e286a..57363b233aa 100644 --- a/src/components/date_picker/super_date_picker/date_popover/absolute_tab.tsx +++ b/src/components/date_picker/super_date_picker/date_popover/absolute_tab.tsx @@ -36,6 +36,7 @@ export interface EuiAbsoluteTabProps { onChange: EuiDatePopoverContentProps['onChange']; roundUp: boolean; position: 'start' | 'end'; + utcOffset?: number; } interface EuiAbsoluteTabState { @@ -106,37 +107,38 @@ export class EuiAbsoluteTab extends Component< }; render() { + const { dateFormat, timeFormat, locale, utcOffset } = this.props; + const { + valueAsMoment, + isTextInvalid, + textInputValue, + sentenceCasedPosition, + } = this.state; + return (
+ isInvalid={isTextInvalid} + error={isTextInvalid ? `Expected format ${dateFormat}` : undefined}> - {this.state.sentenceCasedPosition} date - - } + prepend={{sentenceCasedPosition} date} />
diff --git a/src/components/date_picker/super_date_picker/date_popover/date_popover_button.tsx b/src/components/date_picker/super_date_picker/date_popover/date_popover_button.tsx index e589753c278..12061f79046 100644 --- a/src/components/date_picker/super_date_picker/date_popover/date_popover_button.tsx +++ b/src/components/date_picker/super_date_picker/date_popover/date_popover_button.tsx @@ -49,6 +49,7 @@ export interface EuiDatePopoverButtonProps { roundUp?: boolean; timeFormat: string; value: string; + utcOffset?: number; } export const EuiDatePopoverButton: FunctionComponent< @@ -65,6 +66,7 @@ export const EuiDatePopoverButton: FunctionComponent< onChange, locale, dateFormat, + utcOffset, timeFormat, isOpen, onPopoverToggle, @@ -120,6 +122,7 @@ export const EuiDatePopoverButton: FunctionComponent< timeFormat={timeFormat} locale={locale} position={position} + utcOffset={utcOffset} /> ); diff --git a/src/components/date_picker/super_date_picker/date_popover/date_popover_content.tsx b/src/components/date_picker/super_date_picker/date_popover/date_popover_content.tsx index 31e8f86d5f5..008d3639765 100644 --- a/src/components/date_picker/super_date_picker/date_popover/date_popover_content.tsx +++ b/src/components/date_picker/super_date_picker/date_popover/date_popover_content.tsx @@ -45,6 +45,7 @@ export interface EuiDatePopoverContentProps { timeFormat: string; locale?: LocaleSpecifier; position: 'start' | 'end'; + utcOffset?: number; } export const EuiDatePopoverContent: FunctionComponent< @@ -57,6 +58,7 @@ export const EuiDatePopoverContent: FunctionComponent< timeFormat, locale, position, + utcOffset, }) => { const onTabClick: EuiTabbedContentProps['onTabClick'] = selectedTab => { switch (selectedTab.id) { @@ -84,6 +86,7 @@ export const EuiDatePopoverContent: FunctionComponent< onChange={onChange} roundUp={roundUp} position={position} + utcOffset={utcOffset} /> ), 'data-test-subj': 'superDatePickerAbsoluteTab', diff --git a/src/components/date_picker/super_date_picker/super_date_picker.tsx b/src/components/date_picker/super_date_picker/super_date_picker.tsx index 89553378878..877facd6ce6 100644 --- a/src/components/date_picker/super_date_picker/super_date_picker.tsx +++ b/src/components/date_picker/super_date_picker/super_date_picker.tsx @@ -102,7 +102,7 @@ export type EuiSuperDatePickerProps = CommonProps & { * Callback for when the time changes. */ onTimeChange: (props: OnTimeChangeProps) => void; - recentlyUsedRanges: DurationRange[]; + recentlyUsedRanges: Array; /** * Refresh interval in milliseconds @@ -119,6 +119,7 @@ export type EuiSuperDatePickerProps = CommonProps & { * Specifies the formatted used when displaying times */ timeFormat: string; + utcOffset?: number; }; interface EuiSuperDatePickerState { @@ -359,6 +360,7 @@ export class EuiSuperDatePicker extends Component< locale, refreshInterval, timeFormat, + utcOffset, } = this.props; if (isAutoRefreshOnly) { @@ -425,6 +427,7 @@ export class EuiSuperDatePicker extends Component< onChange={this.setStart} value={start} dateFormat={dateFormat} + utcOffset={utcOffset} timeFormat={timeFormat} locale={locale || contextLocale} isOpen={this.state.isStartDatePopoverOpen} @@ -441,6 +444,7 @@ export class EuiSuperDatePicker extends Component< onChange={this.setEnd} value={end} dateFormat={dateFormat} + utcOffset={utcOffset} timeFormat={timeFormat} locale={locale || contextLocale} roundUp From 09f19d646d413af3e88e30dceb55bd5f33e7afbb Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Thu, 7 May 2020 13:26:37 +0530 Subject: [PATCH 2/3] CL --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d8884f8f96..cb862016608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) +- Added `utcOffset` prop to `EuiSuperDatePicker` ([#3436](https://github.com/elastic/eui/pull/3436)) - Added `iconType` prop to `EuiDatePicker` ([#3383](https://github.com/elastic/eui/pull/3383)) - Applied `max-width: 100%` to `EuiPageBody` so inner flex-based items don't overflow their containers ([#3375](https://github.com/elastic/eui/pull/3375)) - Added `titleSize` prop to `EuiStep` and `EuiSteps` ([#3340](https://github.com/elastic/eui/pull/3340)) From db8cc6667913fbf5dec3650d01094829a8ead535 Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Thu, 7 May 2020 13:32:29 +0530 Subject: [PATCH 3/3] restored syntax --- .../date_picker/super_date_picker/super_date_picker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/date_picker/super_date_picker/super_date_picker.tsx b/src/components/date_picker/super_date_picker/super_date_picker.tsx index 877facd6ce6..91b8e16ab06 100644 --- a/src/components/date_picker/super_date_picker/super_date_picker.tsx +++ b/src/components/date_picker/super_date_picker/super_date_picker.tsx @@ -102,7 +102,7 @@ export type EuiSuperDatePickerProps = CommonProps & { * Callback for when the time changes. */ onTimeChange: (props: OnTimeChangeProps) => void; - recentlyUsedRanges: Array; + recentlyUsedRanges: DurationRange[]; /** * Refresh interval in milliseconds