2020-08-03 11:10:58 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
2020-08-04 03:35:27 +03:00
|
|
|
import * as OldSVG from "~/components/system/svg";
|
2020-08-03 11:10:58 +03:00
|
|
|
|
2020-08-24 09:32:26 +03:00
|
|
|
import { TooltipWrapper, dispatchCustomEvent, PopoverNavigation } from "~/components/system";
|
2020-08-03 11:10:58 +03:00
|
|
|
import { css } from "@emotion/react";
|
|
|
|
|
|
|
|
import Dismissible from "~/components/core/Dismissible";
|
2020-08-09 11:08:46 +03:00
|
|
|
import CircleButtonLight from "~/components/core/CircleButtonLight";
|
2020-08-03 11:10:58 +03:00
|
|
|
|
2020-08-04 03:35:27 +03:00
|
|
|
const STYLES_ANCHOR = css`
|
|
|
|
position: relative;
|
|
|
|
`;
|
|
|
|
|
2020-08-14 11:29:29 +03:00
|
|
|
const APPLICATION_CONTROL_MENU_ID = "application-control-menu";
|
|
|
|
|
2020-08-03 11:10:58 +03:00
|
|
|
export default class ApplicationControlMenu extends React.Component {
|
2020-08-14 11:29:29 +03:00
|
|
|
state = { visible: false };
|
2020-08-03 11:10:58 +03:00
|
|
|
|
|
|
|
_handleClick = (e) => {
|
2020-08-14 11:29:29 +03:00
|
|
|
this.setState({ visible: !this.state.visible });
|
2020-08-03 11:10:58 +03:00
|
|
|
|
2020-08-14 11:29:29 +03:00
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "show-tooltip",
|
|
|
|
detail: {
|
|
|
|
id: APPLICATION_CONTROL_MENU_ID,
|
|
|
|
},
|
|
|
|
});
|
2020-08-03 11:10:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
_handleHide = () => {
|
|
|
|
this.setState({ visible: false });
|
2020-08-14 11:29:29 +03:00
|
|
|
return dispatchCustomEvent({
|
|
|
|
name: "hide-tooltip",
|
|
|
|
detail: {
|
|
|
|
id: APPLICATION_CONTROL_MENU_ID,
|
|
|
|
},
|
|
|
|
});
|
2020-08-03 11:10:58 +03:00
|
|
|
};
|
|
|
|
|
2020-08-14 11:29:29 +03:00
|
|
|
_handleNavigateTo = (data) => {
|
|
|
|
this._handleHide();
|
|
|
|
return this.props.onNavigateTo(data);
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleAction = (data) => {
|
|
|
|
this._handleHide();
|
|
|
|
return this.props.onAction(data);
|
|
|
|
};
|
2020-08-04 03:35:27 +03:00
|
|
|
|
2020-08-14 11:29:29 +03:00
|
|
|
_handleSignOut = (data) => {
|
|
|
|
this._handleHide();
|
|
|
|
return this.props.onSignOut(data);
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2020-08-03 11:10:58 +03:00
|
|
|
return (
|
2020-08-14 11:29:29 +03:00
|
|
|
<TooltipWrapper
|
|
|
|
id={APPLICATION_CONTROL_MENU_ID}
|
|
|
|
type="navigation"
|
|
|
|
horizontal="right"
|
|
|
|
vertical="below"
|
|
|
|
content={
|
|
|
|
<Dismissible
|
|
|
|
css={STYLES_ANCHOR}
|
|
|
|
captureResize={true}
|
|
|
|
captureScroll={false}
|
|
|
|
enabled
|
|
|
|
onOutsideRectEvent={this._handleHide}
|
2020-08-24 09:32:26 +03:00
|
|
|
style={this.props.style}>
|
2020-08-14 11:29:29 +03:00
|
|
|
<PopoverNavigation
|
|
|
|
style={{
|
|
|
|
left: 0,
|
|
|
|
top: "24px",
|
|
|
|
cursor: "pointer",
|
|
|
|
}}
|
|
|
|
onNavigateTo={this._handleNavigateTo}
|
|
|
|
onAction={this._handleAction}
|
|
|
|
onSignOut={this._handleSignOut}
|
|
|
|
navigation={[
|
2020-08-18 22:28:33 +03:00
|
|
|
{
|
|
|
|
text: "Profile & account settings",
|
|
|
|
value: "V1_NAVIGATION_PROFILE",
|
|
|
|
},
|
2020-08-24 09:32:26 +03:00
|
|
|
/*
|
2020-08-18 22:28:33 +03:00
|
|
|
{
|
|
|
|
text: "Filecoin settings",
|
|
|
|
value: "V1_NAVIGATION_FILECOIN_SETTINGS",
|
|
|
|
},
|
2020-08-24 09:32:26 +03:00
|
|
|
*/
|
2020-08-18 22:28:33 +03:00
|
|
|
{ text: "Sign out", value: null, action: "SIGN_OUT" },
|
2020-08-14 11:29:29 +03:00
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</Dismissible>
|
2020-08-24 09:32:26 +03:00
|
|
|
}>
|
2020-08-09 11:08:46 +03:00
|
|
|
<CircleButtonLight
|
2020-08-08 23:44:27 +03:00
|
|
|
onClick={this._handleClick}
|
|
|
|
style={{
|
2020-08-25 05:31:42 +03:00
|
|
|
backgroundColor: this.state.visible ? Constants.system.brand : Constants.system.white,
|
2020-08-08 23:44:27 +03:00
|
|
|
color: this.state.visible ? Constants.system.white : null,
|
2020-08-24 09:32:26 +03:00
|
|
|
}}>
|
2020-08-08 23:44:27 +03:00
|
|
|
<OldSVG.ChevronDown height="20px" />
|
2020-08-09 11:08:46 +03:00
|
|
|
</CircleButtonLight>
|
2020-08-25 05:31:42 +03:00
|
|
|
</TooltipWrapper>
|
2020-08-03 11:10:58 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|