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

WIP Add Tracking #119

Merged
merged 20 commits into from
Jun 21, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 26 additions & 17 deletions src/components/side-panel/panel-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import React from 'react';
import React, {Component} from 'react';
import styled from 'styled-components';
import PropTypes from 'prop-types';
import {Tooltip} from 'components/common/styled-components';
Expand Down Expand Up @@ -204,26 +204,43 @@ const defaultActionItems = [
];

function PanelHeaderFactory() {
const PanelHeader = ({
return class PanelHeader extends Component {
static propTypes = {
appName: PropTypes.string,
version: PropTypes.string,
uiState: PropTypes.object,
uiStateActions: PropTypes.object,
logoComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
actionItems: PropTypes.arrayOf(PropTypes.any)
};

static defaultProps = {
logoComponent: KeplerGlLogo,
actionItems: defaultActionItems
};

render() {
const {
appName,
version,
actionItems = defaultActionItems,
actionItems,
onSaveMap,
onExportImage,
onExportData,
onExportConfig,
logoComponent = KeplerGlLogo,
visibleDropdown,
showExportDropdown,
hideExportDropdown
}) => (
} = this.props;

return (
<StyledPanelHeader className="side-panel__panel-header">
<StyledPanelHeaderTop className="side-panel__panel-header__top">
<logoComponent version={version}/>
<this.props.logoComponent appName={appName} version={version}/>
Copy link
Contributor

Choose a reason for hiding this comment

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

PanelHeader can't be rendered as a pure functional component, because we can only use this.props.logoComponent syntax to render the local component, otherwise, react will interpret logoComponent as a tag

<StyledPanelTopActions>
{actionItems.map(item => (
<div className="side-panel__panel-header__right"
key={item.id} style={{position: 'relative'}}>
key={item.id} style={{position: 'relative'}}>
<PanelAction
item={item}
onClick={() => {
Expand All @@ -249,16 +266,8 @@ function PanelHeaderFactory() {
</StyledPanelHeaderTop>
</StyledPanelHeader>
);

PanelHeader.propTypes = {
appName: PropTypes.string,
version: PropTypes.string,
uiState: PropTypes.object,
uiStateActions: PropTypes.object,
logoComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
actionItems: PropTypes.arrayOf(PropTypes.any)
};
return PanelHeader;
}
}
}

export default PanelHeaderFactory;