Skip to content

Commit 9831845

Browse files
authored
add zendesk (#2156)
* MVP zendesk provider * hide zendesk on mobile * hide zendesk chat bubble on mobile too * made mobile selector more robust * made user menu full width * removed zendesk react and instead use Nextjs Script * updated NEXT_PUBLIC_ZENDESK_KEY env in example
1 parent 04cd821 commit 9831845

11 files changed

+1145
-107
lines changed

apps/api

Submodule api updated from 63e0ca3 to 378cbf8

apps/web/.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,6 @@ CALENDSO_ENCRYPTION_KEY=
9999

100100
# Intercom Config
101101
NEXT_PUBLIC_INTERCOM_APP_ID=
102+
103+
# Zendesk Config
104+
NEXT_PUBLIC_ZENDESK_KEY=

apps/web/components/Shell.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { Toaster } from "react-hot-toast";
1919

2020
import LicenseBanner from "@ee/components/LicenseBanner";
2121
import TrialBanner from "@ee/components/TrialBanner";
22-
import HelpMenuItemDynamic from "@ee/lib/intercom/HelpMenuItemDynamic";
22+
import IntercomMenuItem from "@ee/lib/intercom/IntercomMenuItem";
23+
import ZendeskMenuItem from "@ee/lib/zendesk/ZendeskMenuItem";
2324

2425
import classNames from "@lib/classNames";
2526
import { NEXT_PUBLIC_BASE_URL } from "@lib/config/constants";
@@ -459,7 +460,7 @@ function UserDropdown({ small }: { small?: boolean }) {
459460
viewBox="0 0 2447.6 2452.5"
460461
className={classNames(
461462
"text-gray-500 group-hover:text-gray-700",
462-
"mt-0.5 h-4 w-4 flex-shrink-0 ltr:mr-2 rtl:ml-2"
463+
"mt-0.5 h-4 w-4 flex-shrink-0 ltr:mr-4 rtl:ml-4"
463464
)}
464465
xmlns="http://www.w3.org/2000/svg">
465466
<g clipRule="evenodd" fillRule="evenodd">
@@ -489,7 +490,8 @@ function UserDropdown({ small }: { small?: boolean }) {
489490
<MapIcon className="h-5 w-5 text-gray-500 ltr:mr-3 rtl:ml-3" /> {t("visit_roadmap")}
490491
</a>
491492
</DropdownMenuItem>
492-
<HelpMenuItemDynamic />
493+
<IntercomMenuItem />
494+
<ZendeskMenuItem />
493495
<DropdownMenuSeparator className="h-px bg-gray-200" />
494496
<DropdownMenuItem>
495497
<a

apps/web/components/ui/Dropdown.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const DropdownMenuContent = forwardRef<HTMLDivElement, DropdownMenuConten
2929
{...props}
3030
className={`${
3131
props.portalled ? `` : `md:-ml-[55px]`
32-
} z-10 mt-1 -ml-0 w-48 origin-top-right rounded-sm bg-white text-sm shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none`}
32+
} z-10 mt-1 -ml-0 w-full origin-top-right rounded-sm bg-white text-sm shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none`}
3333
ref={forwardedRef}>
3434
{children}
3535
</DropdownMenuPrimitive.Content>

apps/web/ee/lib/intercom/HelpMenuItem.tsx

-33
This file was deleted.

apps/web/ee/lib/intercom/HelpMenuItemDynamic.tsx

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { ChatAltIcon } from "@heroicons/react/solid";
2+
import { useIntercom } from "react-use-intercom";
3+
4+
import classNames from "@lib/classNames";
5+
import { useLocale } from "@lib/hooks/useLocale";
6+
7+
import { DropdownMenuItem } from "@components/ui/Dropdown";
8+
9+
export default function IntercomMenuItem() {
10+
const { t } = useLocale();
11+
const { boot, show } = useIntercom();
12+
if (!process.env.NEXT_PUBLIC_INTERCOM_APP_ID) return null;
13+
else
14+
return (
15+
<DropdownMenuItem>
16+
<button
17+
onClick={() => {
18+
boot();
19+
show();
20+
}}
21+
className="flex w-full px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-gray-100 hover:text-gray-900">
22+
<ChatAltIcon
23+
className={classNames(
24+
"text-neutral-400 group-hover:text-neutral-500",
25+
"h-5 w-5 flex-shrink-0 ltr:mr-2"
26+
)}
27+
aria-hidden="true"
28+
/>
29+
{t("help")}
30+
</button>
31+
</DropdownMenuItem>
32+
);
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { ChatAltIcon } from "@heroicons/react/solid";
2+
import Script from "next/script";
3+
import { useState } from "react";
4+
5+
import classNames from "@lib/classNames";
6+
import { useLocale } from "@lib/hooks/useLocale";
7+
8+
import { DropdownMenuItem } from "@components/ui/Dropdown";
9+
10+
const ZENDESK_KEY = process.env.NEXT_PUBLIC_ZENDESK_KEY;
11+
12+
export default function ZendeskMenuItem() {
13+
const [active, setActive] = useState(false);
14+
const { t } = useLocale();
15+
16+
if (!process.env.NEXT_PUBLIC_ZENDESK_KEY) return null;
17+
else
18+
return (
19+
<>
20+
<DropdownMenuItem>
21+
<button
22+
onClick={() => setActive(true)}
23+
className="flex w-full px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-gray-100 hover:text-gray-900">
24+
<ChatAltIcon
25+
className={classNames(
26+
"text-neutral-400 group-hover:text-neutral-500",
27+
"h-5 w-5 flex-shrink-0 ltr:mr-2"
28+
)}
29+
aria-hidden="true"
30+
/>
31+
{t("help")}
32+
</button>
33+
</DropdownMenuItem>
34+
{active && (
35+
<Script id="ze-snippet" src={"https://static.zdassets.com/ekr/snippet.js?key=" + ZENDESK_KEY} />
36+
)}
37+
</>
38+
);
39+
}

apps/web/styles/globals.css

+5-9
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@
155155
}
156156
}
157157

158-
/* hide intercom chat bubble on mobile */
158+
/* hide chat bubble on mobile */
159159
@media only screen and (max-width: 768px) {
160-
.intercom-launcher-frame {
160+
#launcher {
161+
display: none !important;
162+
}
163+
div[role="presentation"] > iframe {
161164
display: none !important;
162165
}
163166
}
@@ -169,13 +172,6 @@
169172
}
170173
}
171174

172-
/* hide intercom chat bubble on mobile */
173-
@media only screen and (max-width: 768px) {
174-
.intercom-launcher-frame {
175-
display: none !important;
176-
}
177-
}
178-
179175
.react-multi-email > [type="text"] {
180176
@apply focus:border-brand block w-full rounded-md border-gray-300 shadow-sm focus:ring-black dark:border-gray-900 dark:bg-gray-700 dark:text-white sm:text-sm;
181177
}

apps/website

0 commit comments

Comments
 (0)