* feat ui: login flow for spot extension * spot list, store and service created * some fixing for header * start work on single spot * spot player start * header for player, comments, icons, etc * split stuff into compoennts, create player state manager * player controls, activity panel etc etc * comments, empty page, rename and stuff * interval buttons etc * access modal * pubkey support * fix tooltip * limit 10 -> 9 * hls lib instead of videojs * some warnings * fix date display for exp * change public links * display more client data * fix cleaning, init comment * map network to replay player network ev * stream support, console panel, close panels on X * fixing streaming, destroy on leave * fix autoplay * show notification on spot login * fix spot login * backup player added, fix audio issue * show thumbnail when no video, add spot roles * add poster thumbnail * some fixes to video check * fix events jump * fix play btn * try catch over pubkey * icons * spot login pinging * move spot login flow to login comp, use separate spot login path for unique jwt * invalidate spot jwt on logout * add visual data on page load event * typo fix * issue to copy change * share spot url f
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import React from 'react';
|
|
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
|
import { connect } from 'react-redux';
|
|
import { logout } from 'Duck/user';
|
|
import { client, CLIENT_DEFAULT_TAB } from 'App/routes';
|
|
import { Icon } from 'UI';
|
|
import { getInitials } from 'App/utils';
|
|
import { useStore } from "App/mstore";
|
|
|
|
const CLIENT_PATH = client(CLIENT_DEFAULT_TAB);
|
|
|
|
interface Props {
|
|
history: any;
|
|
onLogoutClick?: any;
|
|
className?: string;
|
|
account: any;
|
|
}
|
|
function UserMenu(props: RouteComponentProps<Props>) {
|
|
const { account, history, className, onLogoutClick }: any = props;
|
|
const { loginStore } = useStore();
|
|
|
|
const onAccountClick = () => {
|
|
history.push(CLIENT_PATH);
|
|
};
|
|
|
|
const onLogout = () => {
|
|
loginStore.invalidateSpotJWT()
|
|
window.postMessage({
|
|
type: "orspot:invalidate"
|
|
}, "*")
|
|
onLogoutClick();
|
|
}
|
|
return (
|
|
<div
|
|
|
|
>
|
|
<div className="flex items-start p-3 border-b border-dashed hover:bg-active-blue cursor-pointer" onClick={onAccountClick}>
|
|
<div className="w-10 h-10 bg-tealx rounded-full flex items-center justify-center mr-2 color-white shrink-0 uppercase">
|
|
{getInitials(account.name)}
|
|
</div>
|
|
<div className="overflow-hidden leading-8">
|
|
<div className="color-teal font-medium leading-none capitalize">{account.name}</div>
|
|
<div className="overflow-hidden whitespace-nowrap color-gray-medium text-ellipsis">
|
|
{account.email}
|
|
</div>
|
|
<div className="rounded-full bg-gray-light flex items-center px-2 color-gray-medium text-sm w-fit text-center">
|
|
{account.superAdmin ? 'Owner' : account.admin ? 'Admin' : 'Member'}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div className="p-2">
|
|
<div
|
|
className="rounded border border-transparent p-2 cursor-pointer flex items-center hover:bg-active-blue hover:!border-active-blue-border hover-teal"
|
|
onClick={onLogout}
|
|
>
|
|
<Icon name="door-closed" size="16" />
|
|
<button className="ml-2">{'Logout'}</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default connect(
|
|
(state: any) => ({
|
|
account: state.getIn(['user', 'account']),
|
|
}),
|
|
{ onLogoutClick: logout }
|
|
)(withRouter(UserMenu)) as React.FunctionComponent<RouteComponentProps<Props>>;
|
|
|
|
// export default UserMenu;
|