Skip to content
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

Added utcOffset prop to EuiSuperDatePicker #3436

Merged
merged 7 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added `sortBy` and `sortShift` props to `euiPaletteColorBlind()` for sorting along the color wheel ([#3387](https://github.com/elastic/eui/pull/3387))
- Added `utcOffset` prop to `EuiSuperDatePicker` ([#3436](https://github.com/elastic/eui/pull/3436))
- Added `partition` key to `EuiChartThemeType` for Partition chart support ([#3387](https://github.com/elastic/eui/pull/3387))
- Updated `EuiImage`'s `caption` prop type from `string` to `ReactNode` ([#3387](https://github.com/elastic/eui/pull/3387))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface EuiAbsoluteTabProps {
onChange: EuiDatePopoverContentProps['onChange'];
roundUp: boolean;
position: 'start' | 'end';
utcOffset?: number;
}

interface EuiAbsoluteTabState {
Expand Down Expand Up @@ -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 (
<div>
<EuiDatePicker
inline
showTimeSelect
shadow={false}
selected={this.state.valueAsMoment}
selected={valueAsMoment}
onChange={this.handleChange}
dateFormat={this.props.dateFormat}
timeFormat={this.props.timeFormat}
locale={this.props.locale}
dateFormat={dateFormat}
timeFormat={timeFormat}
locale={locale}
utcOffset={utcOffset}
/>
<EuiFormRow
className="euiSuperDatePicker__absoluteDateFormRow"
isInvalid={this.state.isTextInvalid}
error={
this.state.isTextInvalid
? `Expected format ${this.props.dateFormat}`
: undefined
}>
isInvalid={isTextInvalid}
error={isTextInvalid ? `Expected format ${dateFormat}` : undefined}>
<EuiFieldText
compressed
isInvalid={this.state.isTextInvalid}
value={this.state.textInputValue}
isInvalid={isTextInvalid}
value={textInputValue}
onChange={this.handleTextChange}
data-test-subj={'superDatePickerAbsoluteDateInput'}
prepend={
<EuiFormLabel>
{this.state.sentenceCasedPosition} date
</EuiFormLabel>
}
prepend={<EuiFormLabel>{sentenceCasedPosition} date</EuiFormLabel>}
/>
</EuiFormRow>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface EuiDatePopoverButtonProps {
roundUp?: boolean;
timeFormat: string;
value: string;
utcOffset?: number;
}

export const EuiDatePopoverButton: FunctionComponent<
Expand All @@ -65,6 +66,7 @@ export const EuiDatePopoverButton: FunctionComponent<
onChange,
locale,
dateFormat,
utcOffset,
timeFormat,
isOpen,
onPopoverToggle,
Expand Down Expand Up @@ -120,6 +122,7 @@ export const EuiDatePopoverButton: FunctionComponent<
timeFormat={timeFormat}
locale={locale}
position={position}
utcOffset={utcOffset}
/>
</EuiPopover>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface EuiDatePopoverContentProps {
timeFormat: string;
locale?: LocaleSpecifier;
position: 'start' | 'end';
utcOffset?: number;
}

export const EuiDatePopoverContent: FunctionComponent<
Expand All @@ -57,6 +58,7 @@ export const EuiDatePopoverContent: FunctionComponent<
timeFormat,
locale,
position,
utcOffset,
}) => {
const onTabClick: EuiTabbedContentProps['onTabClick'] = selectedTab => {
switch (selectedTab.id) {
Expand Down Expand Up @@ -84,6 +86,7 @@ export const EuiDatePopoverContent: FunctionComponent<
onChange={onChange}
roundUp={roundUp}
position={position}
utcOffset={utcOffset}
/>
),
'data-test-subj': 'superDatePickerAbsoluteTab',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export type EuiSuperDatePickerProps = CommonProps & {
* Specifies the formatted used when displaying times
*/
timeFormat: string;
utcOffset?: number;
};

interface EuiSuperDatePickerState {
Expand Down Expand Up @@ -359,6 +360,7 @@ export class EuiSuperDatePicker extends Component<
locale,
refreshInterval,
timeFormat,
utcOffset,
} = this.props;

if (isAutoRefreshOnly) {
Expand Down Expand Up @@ -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}
Expand All @@ -441,6 +444,7 @@ export class EuiSuperDatePicker extends Component<
onChange={this.setEnd}
value={end}
dateFormat={dateFormat}
utcOffset={utcOffset}
timeFormat={timeFormat}
locale={locale || contextLocale}
roundUp
Expand Down