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

[EuiSuperDatePicker] relative tab, timestamp: Use roundUp, switch pos with "Round To" btn #1827

Merged
merged 6 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function EuiDatePopoverContent({ value, roundUp, onChange, dateFormat })
dateFormat={dateFormat}
value={value}
onChange={onChange}
roundUp={roundUp}
/>
),
'data-test-subj': 'superDatePickerRelativeTab',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class EuiRelativeTab extends Component {

render() {
const isInvalid = this.state.count < 0;
const parsedValue = dateMath.parse(this.props.value);
const parsedValue = dateMath.parse(this.props.value, { roundUp: this.props.roundUp });
const formatedValue = isInvalid || !parsedValue || !parsedValue.isValid()
? ''
: parsedValue.format(this.props.dateFormat);
Expand Down Expand Up @@ -87,9 +87,6 @@ export class EuiRelativeTab extends Component {
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFormRow>
<EuiFieldText value={formatedValue} readOnly />
</EuiFormRow>
<EuiFormRow>
<EuiSwitch
data-test-subj={`superDatePickerRelativeDateRoundSwitch`}
Expand All @@ -98,6 +95,9 @@ export class EuiRelativeTab extends Component {
onChange={this.onRoundChange}
/>
</EuiFormRow>
<EuiFormRow>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the EuiFormRow's from wrapping the readonly text and the switch? They're not providing anything but messing up some spacing. Then you can just some spacers like so:

<EuiSpacer size="s" />

<EuiSwitch ... />

<EuiSpacer size="m" />

<EuiFieldText ... />

Which should end up looking like this:

<EuiFieldText value={formatedValue} readOnly />
</EuiFormRow>
</EuiForm>
);
}
Expand All @@ -107,4 +107,5 @@ EuiRelativeTab.propTypes = {
dateFormat: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
roundUp: PropTypes.bool
};