Skip to content

Commit

Permalink
Front: Display Intercom connections as coming soon
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph committed Nov 16, 2023
1 parent cdadd53 commit b2546ea
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 9 deletions.
11 changes: 11 additions & 0 deletions front/components/poke/plans/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DropdownMenu,
GithubLogo,
Input,
IntercomLogo,
NotionLogo,
SlackLogo,
} from "@dust-tt/sparkle";
Expand All @@ -21,6 +22,7 @@ export type EditingPlanType = {
isNotionAllowed: boolean;
isGoogleDriveAllowed: boolean;
isGithubAllowed: boolean;
isIntercomAllowed: boolean;
maxMessages: string | number;
dataSourcesCount: string | number;
dataSourcesDocumentsCount: string | number;
Expand All @@ -40,6 +42,7 @@ export const fromPlanType = (plan: PlanType): EditingPlanType => {
isNotionAllowed: plan.limits.connections.isNotionAllowed,
isGoogleDriveAllowed: plan.limits.connections.isGoogleDriveAllowed,
isGithubAllowed: plan.limits.connections.isGithubAllowed,
isIntercomAllowed: plan.limits.connections.isIntercomAllowed,
maxMessages: plan.limits.assistant.maxMessages,
dataSourcesCount: plan.limits.dataSources.count,
dataSourcesDocumentsCount: plan.limits.dataSources.documents.count,
Expand All @@ -64,6 +67,7 @@ export const toPlanType = (editingPlan: EditingPlanType): PlanType => {
isNotionAllowed: editingPlan.isNotionAllowed,
isGoogleDriveAllowed: editingPlan.isGoogleDriveAllowed,
isGithubAllowed: editingPlan.isGithubAllowed,
isIntercomAllowed: editingPlan.isIntercomAllowed,
},
dataSources: {
count: parseInt(editingPlan.dataSourcesCount.toString(), 10),
Expand Down Expand Up @@ -92,6 +96,7 @@ const getEmptyPlan = (): EditingPlanType => ({
isNotionAllowed: false,
isGoogleDriveAllowed: false,
isGithubAllowed: false,
isIntercomAllowed: false,
maxMessages: "",
dataSourcesCount: "",
dataSourcesDocumentsCount: "",
Expand Down Expand Up @@ -199,6 +204,12 @@ export const PLAN_FIELDS = {
title: "Github",
IconComponent: () => <GithubLogo className="h-4 w-4" />,
},
isIntercomAllowed: {
type: "boolean",
width: "tiny",
title: "Intercom",
IconComponent: () => <IntercomLogo className="h-4 w-4" />,
},
maxMessages: {
type: "number",
width: "medium",
Expand Down
21 changes: 19 additions & 2 deletions front/lib/connector_providers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { DriveLogo, GithubLogo, NotionLogo, SlackLogo } from "@dust-tt/sparkle";
import {
DriveLogo,
GithubLogo,
IntercomLogo,
NotionLogo,
SlackLogo,
} from "@dust-tt/sparkle";

import { ConnectorProvider } from "@app/lib/connectors_api";
import { isDevelopment } from "@app/lib/development";

export const CONNECTOR_CONFIGURATIONS: Record<
ConnectorProvider,
Expand Down Expand Up @@ -47,11 +54,21 @@ export const CONNECTOR_CONFIGURATIONS: Record<
github: {
name: "GitHub",
connectorProvider: "github",
isBuilt: true,
isBuilt: isDevelopment(), // TODO @daph Activate Intercom connector
logoPath: "/static/github_black_32x32.png",
description:
"Authorize access to your company's GitHub on a repository-by-repository basis. Dust can access Issues, Discussions, and Pull Request threads. We're working on adding support for code indexing.",
logoComponent: GithubLogo,
isNested: false,
},
intercom: {
name: "Intercom",
connectorProvider: "intercom",
isBuilt: true,
logoPath: "/static/intercom_32x32.png",
description:
"Authorize access to your company's Intercom. Dust can access your Intercom Knowledge Base. Dust does not access Intercom conversations.",
logoComponent: IntercomLogo,
isNested: false,
},
};
2 changes: 2 additions & 0 deletions front/lib/connectors_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ const CONNECTOR_PROVIDERS = [
"notion",
"github",
"google_drive",
"intercom",
] as const;
export type ConnectorProvider = (typeof CONNECTOR_PROVIDERS)[number];
export const CONNECTOR_PROVIDERS_USING_NANGO = [
"slack",
"notion",
"google_drive",
"intercom",
] as const;
type ConnectorProviderUsingNango =
(typeof CONNECTOR_PROVIDERS_USING_NANGO)[number];
Expand Down
5 changes: 5 additions & 0 deletions front/lib/models/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class Plan extends Model<
declare isManagedNotionAllowed: boolean;
declare isManagedGoogleDriveAllowed: boolean;
declare isManagedGithubAllowed: boolean;
declare isManagedIntercomAllowed: boolean;
declare maxDataSourcesCount: number;
declare maxDataSourcesDocumentsCount: number;
declare maxDataSourcesDocumentsSizeMb: number;
Expand Down Expand Up @@ -110,6 +111,10 @@ Plan.init(
type: DataTypes.BOOLEAN,
defaultValue: false,
},
isManagedIntercomAllowed: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
maxDataSourcesCount: {
type: DataTypes.INTEGER,
allowNull: false,
Expand Down
1 change: 1 addition & 0 deletions front/lib/plans/enterprise_plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const ENT_PLAN_FAKE_DATA: PlanAttributes = {
isManagedNotionAllowed: true,
isManagedGoogleDriveAllowed: true,
isManagedGithubAllowed: true,
isManagedIntercomAllowed: true,
maxDataSourcesCount: -1,
maxDataSourcesDocumentsCount: -1,
maxDataSourcesDocumentsSizeMb: 2,
Expand Down
2 changes: 2 additions & 0 deletions front/lib/plans/free_plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const FREE_TEST_PLAN_DATA: PlanAttributes = {
isManagedNotionAllowed: false,
isManagedGoogleDriveAllowed: false,
isManagedGithubAllowed: false,
isManagedIntercomAllowed: false,
maxDataSourcesCount: 5,
maxDataSourcesDocumentsCount: 10,
maxDataSourcesDocumentsSizeMb: 2,
Expand All @@ -58,6 +59,7 @@ const FREE_PLANS_DATA: PlanAttributes[] = [
isManagedNotionAllowed: true,
isManagedGoogleDriveAllowed: true,
isManagedGithubAllowed: true,
isManagedIntercomAllowed: true,
maxDataSourcesCount: -1,
maxDataSourcesDocumentsCount: -1,
maxDataSourcesDocumentsSizeMb: 2,
Expand Down
1 change: 1 addition & 0 deletions front/lib/plans/pro_plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if (isDevelopment()) {
isManagedNotionAllowed: true,
isManagedGoogleDriveAllowed: true,
isManagedGithubAllowed: true,
isManagedIntercomAllowed: true,
maxDataSourcesCount: -1,
maxDataSourcesDocumentsCount: -1,
maxDataSourcesDocumentsSizeMb: 2,
Expand Down
9 changes: 4 additions & 5 deletions front/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"initdb": "env $(cat .env.local) npx tsx admin/db.ts"
},
"dependencies": {
"@dust-tt/sparkle": "^0.2.41",
"@dust-tt/sparkle": "^0.2.43",
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@headlessui/react": "^1.7.7",
Expand Down
5 changes: 4 additions & 1 deletion front/pages/api/w/[wId]/data_sources/managed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function handler(

if (
!req.body.provider ||
!["slack", "notion", "github", "google_drive"].includes(
!["slack", "notion", "github", "google_drive", "intercom"].includes(
req.body.provider
)
) {
Expand Down Expand Up @@ -133,6 +133,9 @@ async function handler(
isDataSourceAllowedInPlan =
plan.limits.connections.isGoogleDriveAllowed;
break;
case "intercom":
isDataSourceAllowedInPlan = plan.limits.connections.isIntercomAllowed;
break;
default:
isDataSourceAllowedInPlan = false; // default to false if provider is not recognized
}
Expand Down
9 changes: 9 additions & 0 deletions front/pages/w/[wId]/builder/data-sources/[name]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const {
NANGO_SLACK_CONNECTOR_ID = "",
NANGO_NOTION_CONNECTOR_ID = "",
NANGO_GOOGLE_DRIVE_CONNECTOR_ID = "",
NANGO_INTERCOM_CONNECTOR_ID = "",
NANGO_PUBLIC_KEY = "",
GITHUB_APP_URL = "",
} = process.env;
Expand All @@ -67,6 +68,7 @@ export const getServerSideProps: GetServerSideProps<{
slackConnectorId: string;
notionConnectorId: string;
googleDriveConnectorId: string;
intercomConnectorId: string;
};
githubAppUrl: string;
gaTrackingId: string;
Expand Down Expand Up @@ -125,6 +127,7 @@ export const getServerSideProps: GetServerSideProps<{
slackConnectorId: NANGO_SLACK_CONNECTOR_ID,
notionConnectorId: NANGO_NOTION_CONNECTOR_ID,
googleDriveConnectorId: NANGO_GOOGLE_DRIVE_CONNECTOR_ID,
intercomConnectorId: NANGO_INTERCOM_CONNECTOR_ID,
},
githubAppUrl: GITHUB_APP_URL,
gaTrackingId: GA_TRACKING_ID,
Expand Down Expand Up @@ -434,6 +437,7 @@ const CONNECTOR_TYPE_TO_HELPER_TEXT: Record<ConnectorProvider, string> = {
google_drive: "Google Drive folders and files Dust has access to.",
slack: "Slack channels synchronized with Dust:",
github: "GitHub repositories Dust has access to.",
intercom: "Intercom Help Centers synchronized with Dust:",
};

const CONNECTOR_TYPE_TO_MISMATCH_ERROR: Record<ConnectorProvider, string> = {
Expand All @@ -444,6 +448,8 @@ const CONNECTOR_TYPE_TO_MISMATCH_ERROR: Record<ConnectorProvider, string> = {
"You cannot select another Github Organization.\nPlease contact us at team@dust.tt if you initially selected a wrong Organization.",
google_drive:
"You cannot select another Google Drive Domain.\nPlease contact us at team@dust.tt if you initially selected a wrong shared Drive.",
intercom:
"You cannot select another Intercom Workspace.\nPlease contact us at team@dust.tt if you initially selected a wrong Workspace.",
};

function ManagedDataSourceView({
Expand All @@ -466,6 +472,7 @@ function ManagedDataSourceView({
slackConnectorId: string;
notionConnectorId: string;
googleDriveConnectorId: string;
intercomConnectorId: string;
};
githubAppUrl: string;
plan: PlanType;
Expand Down Expand Up @@ -518,6 +525,7 @@ function ManagedDataSourceView({
slack: nangoConfig.slackConnectorId,
notion: nangoConfig.notionConnectorId,
google_drive: nangoConfig.googleDriveConnectorId,
intercom: nangoConfig.intercomConnectorId,
}[provider];

const nango = new Nango({ publicKey: nangoConfig.publicKey });
Expand Down Expand Up @@ -670,6 +678,7 @@ function ManagedDataSourceView({
);
case "notion":
case "github":
case "intercom":
return (
<Button
label="Add / Remove data, manage permissions"
Expand Down
8 changes: 8 additions & 0 deletions front/pages/w/[wId]/builder/data-sources/managed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const {
NANGO_SLACK_CONNECTOR_ID = "",
NANGO_NOTION_CONNECTOR_ID = "",
NANGO_GOOGLE_DRIVE_CONNECTOR_ID = "",
NANGO_INTERCOM_CONNECTOR_ID = "",
NANGO_PUBLIC_KEY = "",
GITHUB_APP_URL = "",
} = process.env;
Expand Down Expand Up @@ -70,6 +71,7 @@ export const getServerSideProps: GetServerSideProps<{
slackConnectorId: string;
notionConnectorId: string;
googleDriveConnectorId: string;
intercomConnectorId: string;
};
githubAppUrl: string;
}> = async (context) => {
Expand Down Expand Up @@ -221,6 +223,7 @@ export const getServerSideProps: GetServerSideProps<{
slackConnectorId: NANGO_SLACK_CONNECTOR_ID,
notionConnectorId: NANGO_NOTION_CONNECTOR_ID,
googleDriveConnectorId: NANGO_GOOGLE_DRIVE_CONNECTOR_ID,
intercomConnectorId: NANGO_INTERCOM_CONNECTOR_ID,
},
githubAppUrl: GITHUB_APP_URL,
},
Expand Down Expand Up @@ -258,6 +261,7 @@ export default function DataSourcesView({
slack: nangoConfig.slackConnectorId,
notion: nangoConfig.notionConnectorId,
google_drive: nangoConfig.googleDriveConnectorId,
intercom: nangoConfig.intercomConnectorId,
}[provider];
const nango = new Nango({ publicKey: nangoConfig.publicKey });
const newConnectionId = buildConnectionId(owner.sId, provider);
Expand Down Expand Up @@ -404,6 +408,10 @@ export default function DataSourcesView({
isDataSourceAllowedInPlan =
planConnectionsLimits.isGoogleDriveAllowed;
break;
case "intercom":
isDataSourceAllowedInPlan =
planConnectionsLimits.isIntercomAllowed;
break;
default:
((p: never) => {
throw new Error(
Expand Down
1 change: 1 addition & 0 deletions front/types/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type ManageDataSourcesLimitsType = {
isNotionAllowed: boolean;
isGoogleDriveAllowed: boolean;
isGithubAllowed: boolean;
isIntercomAllowed: boolean;
};
export type LimitsType = {
assistant: {
Expand Down

0 comments on commit b2546ea

Please sign in to comment.