2021-08-11 05:33:11 +00:00
|
|
|
import React, { useEffect } from "react";
|
2021-03-08 08:24:12 +00:00
|
|
|
|
|
|
|
|
import { HELP_MODAL_WIDTH } from "constants/HelpConstants";
|
|
|
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
2022-04-12 10:50:01 +00:00
|
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
2021-08-11 05:33:11 +00:00
|
|
|
import { useSelector } from "react-redux";
|
2022-02-25 06:13:16 +00:00
|
|
|
import bootIntercom from "utils/bootIntercom";
|
2022-02-11 18:08:46 +00:00
|
|
|
import {
|
2023-05-19 18:37:06 +00:00
|
|
|
APPSMITH_DISPLAY_VERSION,
|
2022-02-11 18:08:46 +00:00
|
|
|
createMessage,
|
|
|
|
|
HELP_RESOURCE_TOOLTIP,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2023-05-19 18:37:06 +00:00
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
Menu,
|
|
|
|
|
MenuContent,
|
|
|
|
|
MenuItem,
|
|
|
|
|
MenuTrigger,
|
|
|
|
|
Tooltip,
|
|
|
|
|
MenuSeparator,
|
|
|
|
|
} from "design-system";
|
|
|
|
|
import { getAppsmithConfigs } from "@appsmith/configs";
|
|
|
|
|
import moment from "moment/moment";
|
|
|
|
|
import styled from "styled-components";
|
2021-03-08 08:24:12 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const { appVersion, cloudHosting, intercomAppID } = getAppsmithConfigs();
|
2021-03-08 08:24:12 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const HelpFooter = styled.div`
|
2021-03-08 08:24:12 +00:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2023-05-19 18:37:06 +00:00
|
|
|
justify-content: space-between;
|
|
|
|
|
font-size: 8px;
|
2021-03-08 08:24:12 +00:00
|
|
|
`;
|
2023-05-19 18:37:06 +00:00
|
|
|
type HelpItem = {
|
|
|
|
|
label: string;
|
|
|
|
|
link?: string;
|
|
|
|
|
id?: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const HELP_MENU_ITEMS: HelpItem[] = [
|
|
|
|
|
{
|
|
|
|
|
icon: "file-line",
|
|
|
|
|
label: "Documentation",
|
|
|
|
|
link: "https://docs.appsmith.com/",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: "bug-line",
|
|
|
|
|
label: "Report a bug",
|
|
|
|
|
link: "https://github.com/appsmithorg/appsmith/issues/new/choose",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: "discord",
|
|
|
|
|
label: "Join our discord",
|
|
|
|
|
link: "https://discord.gg/rBTTVJp",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (intercomAppID && window.Intercom) {
|
|
|
|
|
HELP_MENU_ITEMS.push({
|
|
|
|
|
icon: "chat-help",
|
|
|
|
|
label: "Chat with us",
|
|
|
|
|
id: "intercom-trigger",
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-03-08 08:24:12 +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 (
|
2023-05-19 18:37:06 +00:00
|
|
|
<Menu
|
|
|
|
|
onOpenChange={(open) => {
|
|
|
|
|
if (open) {
|
|
|
|
|
AnalyticsUtil.logEvent("OPEN_HELP", { page: "Editor" });
|
|
|
|
|
}
|
2021-03-08 08:24:12 +00:00
|
|
|
}}
|
|
|
|
|
>
|
2023-05-19 18:37:06 +00:00
|
|
|
<MenuTrigger>
|
|
|
|
|
<div>
|
|
|
|
|
<Tooltip
|
|
|
|
|
content={createMessage(HELP_RESOURCE_TOOLTIP)}
|
|
|
|
|
placement="bottomRight"
|
|
|
|
|
>
|
|
|
|
|
<Button kind="tertiary" size="md" startIcon="question-line">
|
|
|
|
|
Help
|
|
|
|
|
</Button>
|
|
|
|
|
</Tooltip>
|
2023-04-10 12:59:14 +00:00
|
|
|
</div>
|
2023-05-19 18:37:06 +00:00
|
|
|
</MenuTrigger>
|
|
|
|
|
<MenuContent collisionPadding={10} style={{ width: HELP_MODAL_WIDTH }}>
|
|
|
|
|
{HELP_MENU_ITEMS.map((item) => (
|
|
|
|
|
<MenuItem
|
|
|
|
|
key={item.label}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
if (item.link) window.open(item.link, "_blank");
|
|
|
|
|
if (item.id === "intercom-trigger") {
|
|
|
|
|
if (intercomAppID && window.Intercom) {
|
|
|
|
|
window.Intercom("show");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
startIcon={item.icon}
|
|
|
|
|
>
|
|
|
|
|
{item.label}
|
|
|
|
|
</MenuItem>
|
|
|
|
|
))}
|
|
|
|
|
{appVersion.id && (
|
|
|
|
|
<>
|
|
|
|
|
<MenuSeparator />
|
|
|
|
|
<MenuItem className="menuitem-nohover">
|
|
|
|
|
<HelpFooter>
|
|
|
|
|
<span>
|
|
|
|
|
{createMessage(
|
|
|
|
|
APPSMITH_DISPLAY_VERSION,
|
|
|
|
|
appVersion.edition,
|
|
|
|
|
appVersion.id,
|
|
|
|
|
cloudHosting,
|
|
|
|
|
)}
|
|
|
|
|
</span>
|
|
|
|
|
<span>Released {moment(appVersion.releaseDate).fromNow()}</span>
|
|
|
|
|
</HelpFooter>
|
|
|
|
|
</MenuItem>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</MenuContent>
|
|
|
|
|
</Menu>
|
2021-03-08 08:24:12 +00:00
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2021-03-08 08:24:12 +00:00
|
|
|
|
|
|
|
|
export default HelpButton;
|