|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
import React, { Component } from 'react'; |
|
|
|
|
import classNames from 'classnames'; |
|
|
|
|
import { isEqual } from 'lodash'; |
|
|
|
|
|
|
|
|
|
import PanelHeaderCorner from './PanelHeaderCorner'; |
|
|
|
|
import { PanelHeaderMenu } from './PanelHeaderMenu'; |
|
|
|
|
@ -19,21 +20,45 @@ export interface Props { |
|
|
|
|
links?: []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface ClickCoordinates { |
|
|
|
|
x: number; |
|
|
|
|
y: number; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface State { |
|
|
|
|
panelMenuOpen: boolean; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export class PanelHeader extends Component<Props, State> { |
|
|
|
|
clickCoordinates: ClickCoordinates = {x: 0, y: 0}; |
|
|
|
|
state = { |
|
|
|
|
panelMenuOpen: false, |
|
|
|
|
clickCoordinates: {x: 0, y: 0} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
eventToClickCoordinates = (event: React.MouseEvent<HTMLDivElement>) => { |
|
|
|
|
return { |
|
|
|
|
x: event.clientX, |
|
|
|
|
y: event.clientY |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMouseDown = (event: React.MouseEvent<HTMLDivElement>) => { |
|
|
|
|
this.clickCoordinates = this.eventToClickCoordinates(event); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
onMenuToggle = event => { |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
isClick = (clickCoordinates: ClickCoordinates) => { |
|
|
|
|
return isEqual(clickCoordinates, this.clickCoordinates); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMenuToggle = (event: React.MouseEvent<HTMLDivElement>) => { |
|
|
|
|
if (this.isClick(this.eventToClickCoordinates(event))) { |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
|
|
|
|
|
this.setState(prevState => ({ |
|
|
|
|
panelMenuOpen: !prevState.panelMenuOpen, |
|
|
|
|
})); |
|
|
|
|
this.setState(prevState => ({ |
|
|
|
|
panelMenuOpen: !prevState.panelMenuOpen, |
|
|
|
|
})); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
closeMenu = () => { |
|
|
|
|
@ -64,7 +89,7 @@ export class PanelHeader extends Component<Props, State> { |
|
|
|
|
<i className="fa fa-spinner fa-spin" /> |
|
|
|
|
</span> |
|
|
|
|
)} |
|
|
|
|
<div className="panel-title-container" onClick={this.onMenuToggle}> |
|
|
|
|
<div className="panel-title-container" onClick={this.onMenuToggle} onMouseDown={this.onMouseDown}> |
|
|
|
|
<div className="panel-title"> |
|
|
|
|
<span className="icon-gf panel-alert-icon" /> |
|
|
|
|
<span className="panel-title-text"> |
|
|
|
|
|