diff --git a/public/components/arg_add_popover/arg_add_popover.js b/public/components/arg_add_popover/arg_add_popover.js
index 35ce239b4db01..3d123ed69921b 100644
--- a/public/components/arg_add_popover/arg_add_popover.js
+++ b/public/components/arg_add_popover/arg_add_popover.js
@@ -1,38 +1,31 @@
import React from 'react';
import { PropTypes } from 'prop-types';
-import { Popover, OverlayTrigger } from 'react-bootstrap';
-import { get } from 'lodash';
+import { EuiButtonIcon } from '@elastic/eui';
+import { Popover } from '../popover';
import { ArgAdd } from '../arg_add';
import './arg_add_popover.less';
export const ArgAddPopover = ({ options }) => {
- let close;
- const linkRef = refNode => {
- // TODO: handleHide is a private method, there must be a supported way to do this, I just don't know
- // what it is.
- close = get(refNode, 'handleHide');
- };
-
- const picker = (
-
- {options.map(opt => (
- {
- opt.onValueAdd();
- close();
- }}
- />
- ))}
-
+ const button = handleClick => (
+
);
return (
-
-
-
+
+ {({ closePopover }) =>
+ options.map(opt => (
+ {
+ opt.onValueAdd();
+ closePopover();
+ }}
+ />
+ ))
+ }
+
);
};
diff --git a/public/components/arg_add_popover/arg_add_popover.less b/public/components/arg_add_popover/arg_add_popover.less
index db8b18ee3485c..77abbe4a9feb8 100644
--- a/public/components/arg_add_popover/arg_add_popover.less
+++ b/public/components/arg_add_popover/arg_add_popover.less
@@ -1,13 +1,10 @@
-@import (reference) "../../style/main";
+@import (reference) '../../style/main';
-.canvas__add-arg-popover .popover-content {
- padding: 0px;
+.canvas__add-arg-popover {
width: 200px;
font-size: @textXSmall;
-}
-.canvas__add-arg-button.fa {
- color: @mediumGrey;
- margin-left: @spacingXS;
- font-size: @textSmall;
+ .popover-content {
+ padding: 0;
+ }
}
diff --git a/public/components/arg_form/arg_form.less b/public/components/arg_form/arg_form.less
index fc82da320514e..8ad3ce81af24f 100644
--- a/public/components/arg_form/arg_form.less
+++ b/public/components/arg_form/arg_form.less
@@ -31,7 +31,7 @@
}
.canvas__arg--controls {
- padding: 0 @spacingS @spacingS @spacingS;
+ padding: @spacingS;
.canvas__arg--controls--submit {
text-align: right;
diff --git a/public/components/popover/index.js b/public/components/popover/index.js
new file mode 100644
index 0000000000000..b0f083d9c1449
--- /dev/null
+++ b/public/components/popover/index.js
@@ -0,0 +1 @@
+export { Popover } from './popover';
diff --git a/public/components/popover/popover.js b/public/components/popover/popover.js
new file mode 100644
index 0000000000000..c2bb8f14eb968
--- /dev/null
+++ b/public/components/popover/popover.js
@@ -0,0 +1,87 @@
+import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { Popover as BootstrapPopover, Overlay } from 'react-bootstrap';
+
+// mapping for EUI popover positions to bootstrap placements
+const anchorPositions = {
+ upCenter: 'top',
+ upLeft: 'top',
+ upRight: 'top',
+ downCenter: 'bottom',
+ downLeft: 'bottom',
+ downRight: 'bottom',
+ leftCenter: 'left',
+ leftUp: 'left',
+ leftDown: 'left',
+ rightCenter: 'right',
+ rightUp: 'right',
+ rightDown: 'right',
+};
+
+export class Popover extends PureComponent {
+ static propTypes = {
+ id: PropTypes.string,
+ panelClassName: PropTypes.string,
+ button: PropTypes.func.isRequired,
+ children: PropTypes.func.isRequired,
+ title: PropTypes.string,
+ anchorPosition: PropTypes.string,
+ style: PropTypes.object,
+ };
+
+ static defaultProps = {
+ ownFocus: false,
+ anchorPosition: 'downCenter',
+ panelPaddingSize: 'm',
+ };
+
+ state = {
+ isPopoverOpen: false,
+ };
+
+ handleClick = () => {
+ this.setState({
+ isPopoverOpen: !this.state.isPopoverOpen,
+ });
+ };
+
+ closePopover = () => {
+ this.setState({
+ isPopoverOpen: false,
+ });
+ };
+
+ render() {
+ const { id, button, children, panelClassName, title, anchorPosition, style } = this.props;
+
+ const position = anchorPositions[anchorPosition] ? anchorPosition : 'downCenter';
+
+ // TODO: replace bootstrap popover with EuiPopover https://github.com/elastic/kibana-canvas/issues/612
+ // Pending https://github.com/elastic/eui/issues/873
+ const popover = (
+
+ {children({ closePopover: this.closePopover })}
+
+ );
+
+ return (
+
{
+ this.target = button;
+ }}
+ style={style}
+ >
+ {button(this.handleClick)}
+ this.setState({ isPopoverOpen: false })}
+ rootClose
+ placement={anchorPositions[position]}
+ target={this.target}
+ >
+ {popover}
+
+
+ );
+ }
+}
diff --git a/public/components/refresh_control/auto_refresh_controls.js b/public/components/refresh_control/auto_refresh_controls.js
index 82eb42c85c45b..f11b29468d5bb 100644
--- a/public/components/refresh_control/auto_refresh_controls.js
+++ b/public/components/refresh_control/auto_refresh_controls.js
@@ -7,7 +7,6 @@ import {
EuiButton,
EuiLink,
EuiFieldText,
- EuiTitle,
EuiSpacer,
} from '@elastic/eui';
import { timeDurationString } from '../../lib/time_duration';
@@ -18,22 +17,16 @@ export const AutoRefreshControls = ({ refreshInterval, setRefresh, disableInterv
return (
{refreshInterval > 0 ? (
-
+
-
- Interval: {timeDurationString(refreshInterval)}
-
+ Interval: {timeDurationString(refreshInterval)}
-
- Disable
-
+ Disable
) : (
-
- Interval: disabled
-
+ Interval: disabled
)}
diff --git a/public/components/refresh_control/refresh_control.js b/public/components/refresh_control/refresh_control.js
index f1af39fcd1cbc..c94e33515c864 100644
--- a/public/components/refresh_control/refresh_control.js
+++ b/public/components/refresh_control/refresh_control.js
@@ -1,6 +1,7 @@
-import React, { PureComponent } from 'react';
+import React from 'react';
import PropTypes from 'prop-types';
-import { EuiIcon, EuiButtonIcon, EuiPopover, EuiPopoverTitle } from '@elastic/eui';
+import { EuiIcon, EuiButtonIcon } from '@elastic/eui';
+import { Popover } from '../popover';
import { AutoRefreshControls } from './auto_refresh_controls';
import './refresh_control.less';
@@ -38,69 +39,51 @@ const getRefreshInterval = (val = '') => {
}
};
-export class RefreshControl extends PureComponent {
- state = {
- isPopoverOpen: false,
- };
+export const RefreshControl = ({ inFlight, doRefresh, setRefreshInterval, refreshInterval }) => {
+ const setRefresh = val => setRefreshInterval(getRefreshInterval(val));
- handleClick = () => {
- this.setState({
- isPopoverOpen: !this.state.isPopoverOpen,
- });
- };
+ const popoverButton = handleClick => (
+
+ );
- closePopover = () => {
- this.setState({
- isPopoverOpen: false,
- });
- };
-
- render() {
- const { inFlight, doRefresh, setRefreshInterval, refreshInterval } = this.props;
- const setRefresh = val => setRefreshInterval(getRefreshInterval(val));
-
- const popoverButton = (
-
- );
-
- const autoRefreshControls = (
-
- Workpad Auto Refresh
+ const autoRefreshControls = (
+
+ {({ closePopover }) => (
setRefresh(0)}
+ disableInterval={() => {
+ setRefresh(0);
+ closePopover();
+ }}
/>
-
- );
+ )}
+
+ );
- return (
-
-
- {autoRefreshControls}
-
- );
- }
-}
+ return (
+
+
+ {autoRefreshControls}
+
+ );
+};
RefreshControl.propTypes = {
inFlight: PropTypes.bool.isRequired,
diff --git a/public/components/refresh_control/refresh_control.less b/public/components/refresh_control/refresh_control.less
index 39297c5b3308d..4ffd0100302c5 100644
--- a/public/components/refresh_control/refresh_control.less
+++ b/public/components/refresh_control/refresh_control.less
@@ -1,9 +1,8 @@
@import (reference) '../../style/main';
.canvas__refresh_control {
- .canvas__refresh_control--popover {
- min-width: 250px;
- }
+ display: flex;
+ align-items: center;
.canvas__auto_refresh {
color: #93c83d;
@@ -13,16 +12,13 @@
-webkit-animation: refreshInFlight 3s 0s linear infinite;
animation: refreshInFlight 3s linear 0s infinite;
}
+}
+.canvas__refresh_control--popover {
+ width: 250px;
.canvas__refresh_control--auto-refresh--submit {
min-width: @spacingXXXL;
}
-
- .canvas__refresh_control--auto-refresh--preset-intervals {
- .items > * {
- width: 100%;
- }
- }
}
@-webkit-keyframes refreshInFlight {
diff --git a/public/components/sidebar/sidebar.less b/public/components/sidebar/sidebar.less
index bc471869b1aef..3e92de8b9986b 100644
--- a/public/components/sidebar/sidebar.less
+++ b/public/components/sidebar/sidebar.less
@@ -1,4 +1,4 @@
-@import (reference) "../../style/main";
+@import (reference) '../../style/main';
.canvas__sidebar {
padding: @spacingS;
@@ -7,6 +7,8 @@
.canvas__sidebar-section-title {
font-size: @textMedium;
font-weight: 200;
+ display: flex;
+ align-items: center;
}
.canvas__sidebar-section-tip {