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

Convert timepicker to EUI #22433

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6e86082
wire timepicker component together and display in kbnGlobalTimepicker
nreese Aug 17, 2018
9beb9c9
add quick select popover
nreese Aug 17, 2018
64bd7a3
implement quick select
nreese Aug 17, 2018
9b4f9be
implement commonly used quick ranges
nreese Aug 17, 2018
203ba0c
implement recently used time ranges
nreese Aug 17, 2018
fd9adae
add TimeInput component and shows time form tabs
nreese Aug 21, 2018
fa1297b
absolute form
nreese Aug 21, 2018
26fa24c
format displayed string
nreese Aug 21, 2018
65b2ed5
open correct tab for time mode
nreese Aug 23, 2018
628d73f
set time value when mode tab is switched
nreese Aug 23, 2018
134bb3e
remove spacer at end of last section
nreese Aug 23, 2018
b42a02a
relative form
nreese Aug 27, 2018
d3f40b5
fix problem with props not getting updated in tabs
nreese Aug 27, 2018
200ef5d
add toast when from is after to
nreese Aug 27, 2018
84b0c56
clean up relative form
nreese Aug 27, 2018
46d4f41
pretty duration
nreese Aug 27, 2018
bacc859
step forward and backward buttons, do not display old time picker
nreese Aug 27, 2018
b9df914
add text input to absolute form
nreese Aug 27, 2018
4ae3550
convert moment objects to strings
nreese Aug 28, 2018
bd11874
apply time changes for recent times and commonly used times
nreese Aug 29, 2018
0598d33
design cleanup part 1 (#26)
snide Sep 7, 2018
17dc375
move refresh inputs into quick form
nreese Sep 7, 2018
b6511a3
Merge branch 'master' of github.com:elastic/kibana into eui_timepicker
nreese Dec 4, 2018
6c915d3
new dateMath import
nreese Dec 4, 2018
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
19 changes: 1 addition & 18 deletions src/legacy/core_plugins/kibana/ui_setting_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function getUiSettingDefaults() {
},
'dateFormat': {
name: 'Date format',
value: 'MMMM Do YYYY, HH:mm:ss.SSS',
value: 'MMM D, YYYY @ HH:mm:ss.SSS',
description: `When displaying a pretty formatted date, use this <a href="http://momentjs.com/docs/#/displaying/format/"
target="_blank" rel="noopener noreferrer">format</a>`,
},
Expand Down Expand Up @@ -410,23 +410,6 @@ export function getUiSettingDefaults() {
{ from: 'now/w', to: 'now', display: 'Week to date', section: 0 },
{ from: 'now/M', to: 'now', display: 'Month to date', section: 0 },
{ from: 'now/y', to: 'now', display: 'Year to date', section: 0 },

{ from: 'now-15m', to: 'now', display: 'Last 15 minutes', section: 1 },
{ from: 'now-30m', to: 'now', display: 'Last 30 minutes', section: 1 },
{ from: 'now-1h', to: 'now', display: 'Last 1 hour', section: 1 },
{ from: 'now-4h', to: 'now', display: 'Last 4 hours', section: 1 },
{ from: 'now-12h', to: 'now', display: 'Last 12 hours', section: 1 },
{ from: 'now-24h', to: 'now', display: 'Last 24 hours', section: 1 },
{ from: 'now-7d', to: 'now', display: 'Last 7 days', section: 1 },

{ from: 'now-30d', to: 'now', display: 'Last 30 days', section: 2 },
{ from: 'now-60d', to: 'now', display: 'Last 60 days', section: 2 },
{ from: 'now-90d', to: 'now', display: 'Last 90 days', section: 2 },
{ from: 'now-6M', to: 'now', display: 'Last 6 months', section: 2 },
{ from: 'now-1y', to: 'now', display: 'Last 1 year', section: 2 },
{ from: 'now-2y', to: 'now', display: 'Last 2 years', section: 2 },
{ from: 'now-5y', to: 'now', display: 'Last 5 years', section: 2 },

], null, 2),
type: 'json',
description: `The list of ranges to show in the Quick section of the time picker.
Expand Down
5 changes: 5 additions & 0 deletions src/ui/public/react_components.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
KuiToolBarSearchBox,
} from '@kbn/ui-framework/components';

import { Timepicker } from 'ui/timepicker';

import {
EuiConfirmModal,
EuiIcon,
Expand All @@ -46,3 +48,6 @@ app.directive('colorPicker', reactDirective => reactDirective(EuiColorPicker));
app.directive('iconTip', reactDirective => reactDirective(EuiIconTip, ['content', 'type', 'position', 'title', 'color']));

app.directive('callOut', reactDirective => reactDirective(EuiCallOut, ['title', 'color', 'size', 'iconType', 'children']));

app.directive('newKbnTimepicker', reactDirective => reactDirective(Timepicker, [
'from', 'to', 'setTime', 'setRefresh', 'isPaused', 'refreshInterval']));
1 change: 1 addition & 0 deletions src/ui/public/timefilter/timefilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Timefilter extends SimpleEmitter {
* @property {string} time.mode (quick | relative | absolute)
*/
setTime = (time) => {
console.log(time);
// Object.assign used for partially composed updates
const newTime = Object.assign(this.getTime(), time);
if (areTimePickerValsDifferent(this.getTime(), newTime)) {
Expand Down
106 changes: 106 additions & 0 deletions src/ui/public/timepicker/components/absolute_form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import PropTypes from 'prop-types';
import React, { Component, Fragment } from 'react';

import moment from 'moment';

import dateMath from '@elastic/datemath';

import {
EuiDatePicker,
EuiFieldText,
EuiFormRow,
} from '@elastic/eui';

const INPUT_DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss.SSS';

const toMoment = (value, roundUp) => {
const valueAsMoment = dateMath.parse(value, { roundUp });
return {
value: valueAsMoment,
textInputValue: valueAsMoment.format(INPUT_DATE_FORMAT)
};
};

export class AbsoluteForm extends Component {

constructor(props) {
super(props);

this.state = {
...toMoment(this.props.value, this.props.roundUp),
isTextInvalid: false,
};
}

static getDerivedStateFromProps = (nextProps) => {
return {
...toMoment(nextProps.value, nextProps.roundUp),
isTextInvalid: false,
};
}

handleChange = (date) => {
this.props.onChange(date.toISOString());
}

handleTextChange = (evt) => {
const date = moment(evt.target.value, INPUT_DATE_FORMAT, true);
if (date.isValid()) {
this.props.onChange(date.toISOString());
}

this.setState({
textInputValue: evt.target.value,
isTextInvalid: !date.isValid()
});
}

render() {
return (
<Fragment>
<EuiFormRow
isInvalid={this.state.isTextInvalid}
error={this.state.isTextInvalid ? `Expected format ${INPUT_DATE_FORMAT}` : undefined}
>
<EuiFieldText
isInvalid={this.state.isTextInvalid}
value={this.state.textInputValue}
onChange={this.handleTextChange}
/>
</EuiFormRow>
<EuiDatePicker
selected={this.state.value}
onChange={this.handleChange}
inline
showTimeSelect
shadow={false}
/>
</Fragment>
);
}
}

AbsoluteForm.propTypes = {
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
roundUp: PropTypes.bool.isRequired,
};
Loading