forked from makeplane/plane
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WEB-2103]: chore: Intercom integration (makeplane#5295)
* fix: intecom sdk integration * dev: integrated intercom in god-mode * dev: intercom default value true * dev: updated intercom keys in intercom provider * chore: added restriction values --------- Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
- Loading branch information
1 parent
34820ee
commit 0619f1b
Showing
18 changed files
with
221 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
"use client"; | ||
|
||
import { FC, FormEvent, useEffect, useState } from "react"; | ||
import { observer } from "mobx-react"; | ||
import { MessageSquare } from "lucide-react"; | ||
import useSWR from "swr"; | ||
import { IFormattedInstanceConfiguration } from "@plane/types"; | ||
import { Button, Input, ToggleSwitch } from "@plane/ui"; | ||
// hooks | ||
import { useInstance } from "@/hooks/store"; | ||
|
||
type TIntercomConfig = { | ||
isTelemetryEnabled: boolean; | ||
}; | ||
|
||
export const IntercomConfig: FC<TIntercomConfig> = observer((props) => { | ||
const { isTelemetryEnabled } = props; | ||
// hooks | ||
const { instanceConfigurations, instance, updateInstanceConfigurations, fetchInstanceConfigurations } = useInstance(); | ||
// states | ||
const [isSubmitting, setIsSubmitting] = useState<boolean>(false); | ||
|
||
// derived values | ||
const isIntercomEnabled = isTelemetryEnabled | ||
? instanceConfigurations | ||
? instanceConfigurations?.find((config) => config.key === "IS_INTERCOM_ENABLED")?.value === "1" | ||
? true | ||
: false | ||
: undefined | ||
: false; | ||
|
||
const { isLoading } = useSWR(isTelemetryEnabled ? "INSTANCE_CONFIGURATIONS" : null, () => | ||
isTelemetryEnabled ? fetchInstanceConfigurations() : null | ||
); | ||
|
||
const initialLoader = isLoading && isIntercomEnabled === undefined; | ||
|
||
const submitInstanceConfigurations = async (payload: Partial<IFormattedInstanceConfiguration>) => { | ||
try { | ||
await updateInstanceConfigurations(payload); | ||
} catch (error) { | ||
console.error(error); | ||
} finally { | ||
setIsSubmitting(false); | ||
} | ||
}; | ||
|
||
const enableIntercomConfig = () => { | ||
submitInstanceConfigurations({ IS_INTERCOM_ENABLED: isIntercomEnabled ? "0" : "1" }); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className="flex items-center gap-14 px-4 py-3 border border-custom-border-200 rounded"> | ||
<div className="grow flex items-center gap-4"> | ||
<div className="shrink-0"> | ||
<div className="flex items-center justify-center w-10 h-10 bg-custom-background-80 rounded-full"> | ||
<MessageSquare className="w-6 h-6 text-custom-text-300/80 p-0.5" /> | ||
</div> | ||
</div> | ||
|
||
<div className="grow"> | ||
<div className="text-sm font-medium text-custom-text-100 leading-5">Talk to Plane</div> | ||
<div className="text-xs font-normal text-custom-text-300 leading-5"> | ||
Let your members chat with us via Intercom or another service. Toggling Telemetry off turns this off | ||
automatically. | ||
</div> | ||
</div> | ||
|
||
<div className="ml-auto"> | ||
<ToggleSwitch | ||
value={isIntercomEnabled ? true : false} | ||
onChange={enableIntercomConfig} | ||
size="sm" | ||
disabled={!isTelemetryEnabled || isSubmitting || initialLoader} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,9 @@ | |
"channels", | ||
"upgrade", | ||
"billing", | ||
"sign-in", | ||
"sign-up", | ||
"signin", | ||
"signup", | ||
"config", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,32 @@ | ||
export * from "./estimates"; | ||
export * from "./notifications"; | ||
export * from "./pages"; | ||
export * from "./use-app-theme"; | ||
export * from "./use-calendar-view"; | ||
export * from "./use-cycle-filter"; | ||
export * from "./use-command-palette"; | ||
export * from "./use-cycle"; | ||
export * from "./use-event-tracker"; | ||
export * from "./use-cycle-filter"; | ||
export * from "./use-dashboard"; | ||
export * from "./use-event-tracker"; | ||
export * from "./use-global-view"; | ||
export * from "./use-inbox-issues"; | ||
export * from "./use-instance"; | ||
export * from "./use-issue-detail"; | ||
export * from "./use-issues"; | ||
export * from "./use-kanban-view"; | ||
export * from "./use-label"; | ||
export * from "./use-member"; | ||
export * from "./use-mention"; | ||
export * from "./use-module"; | ||
export * from "./use-multiple-select-store"; | ||
|
||
export * from "./pages/use-project-page"; | ||
export * from "./pages/use-page"; | ||
|
||
export * from "./use-module-filter"; | ||
export * from "./use-multiple-select-store"; | ||
export * from "./use-project"; | ||
export * from "./use-project-filter"; | ||
export * from "./use-project-inbox"; | ||
export * from "./use-project-publish"; | ||
export * from "./use-project-state"; | ||
export * from "./use-project-view"; | ||
export * from "./use-project"; | ||
export * from "./use-router-params"; | ||
export * from "./use-webhook"; | ||
export * from "./use-workspace"; | ||
export * from "./use-issues"; | ||
export * from "./use-kanban-view"; | ||
export * from "./use-issue-detail"; | ||
// project inbox | ||
export * from "./use-project-inbox"; | ||
export * from "./use-inbox-issues"; | ||
export * from "./user"; | ||
export * from "./use-instance"; | ||
export * from "./use-app-theme"; | ||
export * from "./use-command-palette"; | ||
export * from "./use-router-params"; | ||
export * from "./estimates"; | ||
export * from "./notifications"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./use-page"; | ||
export * from "./use-project-page"; |
Oops, something went wrong.