2021-08-11 05:33:11 +00:00
|
|
|
import React, { useEffect } from "react";
|
2021-03-13 18:01:47 +00:00
|
|
|
import styled, { createGlobalStyle, withTheme } from "styled-components";
|
2021-03-08 08:24:12 +00:00
|
|
|
import { Popover, Position } from "@blueprintjs/core";
|
|
|
|
|
|
2021-08-16 11:03:27 +00:00
|
|
|
import DocumentationSearch from "components/designSystems/appsmith/help/DocumentationSearch";
|
2021-03-08 08:24:12 +00:00
|
|
|
import Icon, { IconSize } from "components/ads/Icon";
|
|
|
|
|
|
|
|
|
|
import { HELP_MODAL_WIDTH } from "constants/HelpConstants";
|
|
|
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
2021-03-13 18:01:47 +00:00
|
|
|
import { Theme } from "constants/DefaultTheme";
|
2021-08-11 05:33:11 +00:00
|
|
|
import { getCurrentUser } from "../../selectors/usersSelectors";
|
|
|
|
|
import { useSelector } from "react-redux";
|
2021-08-16 11:03:27 +00:00
|
|
|
import { bootIntercom } from "utils/helpers";
|
2021-10-05 06:33:58 +00:00
|
|
|
import { Colors } from "constants/Colors";
|
2021-03-08 08:24:12 +00:00
|
|
|
|
|
|
|
|
const HelpPopoverStyle = createGlobalStyle`
|
|
|
|
|
.bp3-popover.bp3-minimal.navbar-help-popover {
|
|
|
|
|
margin-top: 0 !important;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledTrigger = styled.div`
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
width: 25px;
|
|
|
|
|
height: 25px;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
2021-04-26 16:45:03 +00:00
|
|
|
margin: 0 ${(props) => props.theme.spaces[4]}px;
|
2021-03-08 08:24:12 +00:00
|
|
|
background: ${(props) =>
|
|
|
|
|
props.theme.colors.globalSearch.helpButtonBackground};
|
2021-10-05 06:33:58 +00:00
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
border: 1.5px solid ${Colors.GREY_10};
|
|
|
|
|
}
|
2021-03-08 08:24:12 +00:00
|
|
|
`;
|
|
|
|
|
|
2021-03-13 18:01:47 +00:00
|
|
|
const Trigger = withTheme(({ theme }: { theme: Theme }) => (
|
2021-03-08 08:24:12 +00:00
|
|
|
<StyledTrigger>
|
2021-03-13 18:01:47 +00:00
|
|
|
<Icon
|
2021-04-28 10:28:39 +00:00
|
|
|
fillColor={theme.colors.globalSearch.helpIcon}
|
2021-03-13 18:01:47 +00:00
|
|
|
name="help"
|
2021-10-04 15:34:37 +00:00
|
|
|
size={IconSize.LARGE}
|
2021-03-13 18:01:47 +00:00
|
|
|
/>
|
2021-03-08 08:24:12 +00:00
|
|
|
</StyledTrigger>
|
2021-03-13 18:01:47 +00:00
|
|
|
));
|
2021-03-08 08:24:12 +00:00
|
|
|
|
|
|
|
|
const onOpened = () => {
|
|
|
|
|
AnalyticsUtil.logEvent("OPEN_HELP", { page: "Editor" });
|
|
|
|
|
};
|
2021-08-11 05:33:11 +00:00
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
function HelpButton() {
|
2021-08-11 05:33:11 +00:00
|
|
|
const user = useSelector(getCurrentUser);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2021-08-16 11:03:27 +00:00
|
|
|
bootIntercom(user);
|
2021-08-11 05:33:11 +00:00
|
|
|
}, [user?.email]);
|
|
|
|
|
|
2021-03-08 08:24:12 +00:00
|
|
|
return (
|
|
|
|
|
<Popover
|
2021-04-28 10:28:39 +00:00
|
|
|
minimal
|
2021-03-08 08:24:12 +00:00
|
|
|
modifiers={{
|
|
|
|
|
offset: {
|
|
|
|
|
enabled: true,
|
|
|
|
|
offset: "0, 6",
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
onOpened={onOpened}
|
|
|
|
|
popoverClassName="navbar-help-popover"
|
2021-04-28 10:28:39 +00:00
|
|
|
position={Position.BOTTOM_RIGHT}
|
2021-03-08 08:24:12 +00:00
|
|
|
>
|
|
|
|
|
<>
|
|
|
|
|
<HelpPopoverStyle />
|
|
|
|
|
<Trigger />
|
|
|
|
|
</>
|
|
|
|
|
<div style={{ width: HELP_MODAL_WIDTH }}>
|
2021-04-28 10:28:39 +00:00
|
|
|
<DocumentationSearch hideMinimizeBtn hideSearch hitsPerPage={4} />
|
2021-03-08 08:24:12 +00:00
|
|
|
</div>
|
|
|
|
|
</Popover>
|
|
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2021-03-08 08:24:12 +00:00
|
|
|
|
|
|
|
|
export default HelpButton;
|