Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* trying new EuiWrappingPopover * allow button press to close popover * fix button styling * start options panel with darkTheme option * add other options * remove old options html * get dashboar state functional test working
- Loading branch information
Showing
9 changed files
with
211 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
src/core_plugins/kibana/public/dashboard/top_nav/options.html
This file was deleted.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
src/core_plugins/kibana/public/dashboard/top_nav/options.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* 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 React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { | ||
EuiForm, | ||
EuiFormRow, | ||
EuiSwitch, | ||
} from '@elastic/eui'; | ||
|
||
export class OptionsMenu extends Component { | ||
|
||
state = { | ||
darkTheme: this.props.darkTheme, | ||
useMargins: this.props.useMargins, | ||
hidePanelTitles: this.props.hidePanelTitles, | ||
} | ||
|
||
handleDarkThemeChange = (evt) => { | ||
const isChecked = evt.target.checked; | ||
this.props.onDarkThemeChange(isChecked); | ||
this.setState({ darkTheme: isChecked }); | ||
} | ||
|
||
handleUseMarginsChange = (evt) => { | ||
const isChecked = evt.target.checked; | ||
this.props.onUseMarginsChange(isChecked); | ||
this.setState({ useMargins: isChecked }); | ||
} | ||
|
||
handleHidePanelTitlesChange = (evt) => { | ||
const isChecked = evt.target.checked; | ||
this.props.onHidePanelTitlesChange(isChecked); | ||
this.setState({ hidePanelTitles: isChecked }); | ||
} | ||
|
||
render() { | ||
return ( | ||
<EuiForm | ||
data-test-subj="dashboardOptionsMenu" | ||
> | ||
|
||
<EuiFormRow> | ||
<EuiSwitch | ||
label="Use dark theme" | ||
checked={this.state.darkTheme} | ||
onChange={this.handleDarkThemeChange} | ||
data-test-subj="dashboardDarkThemeCheckbox" | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow> | ||
<EuiSwitch | ||
label="Use margins between panels" | ||
checked={this.state.useMargins} | ||
onChange={this.handleUseMarginsChange} | ||
data-test-subj="dashboardMarginsCheckbox" | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow> | ||
<EuiSwitch | ||
label="Hide all panel titles" | ||
checked={this.state.hidePanelTitles} | ||
onChange={this.handleHidePanelTitlesChange} | ||
data-test-subj="dashboardPanelTitlesCheckbox" | ||
/> | ||
</EuiFormRow> | ||
|
||
</EuiForm> | ||
); | ||
} | ||
} | ||
|
||
OptionsMenu.propTypes = { | ||
darkTheme: PropTypes.bool.isRequired, | ||
onDarkThemeChange: PropTypes.func.isRequired, | ||
useMargins: PropTypes.bool.isRequired, | ||
onUseMarginsChange: PropTypes.func.isRequired, | ||
hidePanelTitles: PropTypes.bool.isRequired, | ||
onHidePanelTitlesChange: PropTypes.func.isRequired, | ||
}; |
7 changes: 7 additions & 0 deletions
7
src/core_plugins/kibana/public/dashboard/top_nav/options_popover.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.dashOptionsPopover { | ||
height: 100%; | ||
|
||
.euiPopover__anchor { | ||
height: 100%; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/core_plugins/kibana/public/dashboard/top_nav/show_options_popover.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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 './options_popover.less'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import { OptionsMenu } from './options'; | ||
|
||
import { | ||
EuiWrappingPopover, | ||
} from '@elastic/eui'; | ||
|
||
let isOpen = false; | ||
|
||
const container = document.createElement('div'); | ||
|
||
const onClose = () => { | ||
ReactDOM.unmountComponentAtNode(container); | ||
isOpen = false; | ||
}; | ||
|
||
export function showOptionsPopover({ | ||
anchorElement, | ||
darkTheme, | ||
onDarkThemeChange, | ||
useMargins, | ||
onUseMarginsChange, | ||
hidePanelTitles, | ||
onHidePanelTitlesChange, | ||
}) { | ||
if (isOpen) { | ||
onClose(); | ||
return; | ||
} | ||
|
||
isOpen = true; | ||
|
||
document.body.appendChild(container); | ||
const element = ( | ||
<EuiWrappingPopover | ||
className="dashOptionsPopover" | ||
id="popover" | ||
button={anchorElement} | ||
isOpen={true} | ||
closePopover={onClose} | ||
> | ||
<OptionsMenu | ||
darkTheme={darkTheme} | ||
onDarkThemeChange={onDarkThemeChange} | ||
useMargins={useMargins} | ||
onUseMarginsChange={onUseMarginsChange} | ||
hidePanelTitles={hidePanelTitles} | ||
onHidePanelTitlesChange={onHidePanelTitlesChange} | ||
/> | ||
</EuiWrappingPopover> | ||
); | ||
ReactDOM.render(element, container); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters