Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/core/components/admin-sidebar/help-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const HelpSection: FC = observer(() => {
leaveTo="transform opacity-0 scale-95"
>
<div
className={`absolute bottom-2 min-w-[10rem] ${
className={`absolute bottom-2 min-w-[10rem] z-[15] ${
isSidebarCollapsed ? "left-full" : "-left-[75px]"
} divide-y divide-custom-border-200 whitespace-nowrap rounded bg-custom-background-100 p-1 shadow-custom-shadow-xs`}
ref={helpOptionsRef}
Expand Down
12 changes: 8 additions & 4 deletions web/app/[workspaceSlug]/(projects)/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ export const AppSidebar: FC<IAppSidebar> = observer(() => {
<div
ref={ref}
className={cn("size-full flex flex-col flex-1 pt-4 pb-0", {
"p-2": sidebarCollapsed,
"p-2 pt-4": sidebarCollapsed,
})}
>
<div className="px-4">
<div
className={cn("px-2", {
"px-4": !sidebarCollapsed,
})}
>
<SidebarDropdown />
<div className="flex-shrink-0 h-4" />
<SidebarAppSwitcher />
Expand All @@ -69,8 +73,8 @@ export const AppSidebar: FC<IAppSidebar> = observer(() => {
})}
/>
<div
className={cn("overflow-x-hidden scrollbar-sm h-full w-full overflow-y-auto px-4", {
"vertical-scrollbar": !sidebarCollapsed,
className={cn("overflow-x-hidden scrollbar-sm h-full w-full overflow-y-auto px-2", {
"vertical-scrollbar px-4": !sidebarCollapsed,
})}
>
<SidebarUserMenu />
Expand Down
12 changes: 6 additions & 6 deletions web/core/components/command-palette/actions/help-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
"use client";
import { Command } from "cmdk";
import { observer } from "mobx-react";
import { FileText, GithubIcon, MessageSquare, Rocket } from "lucide-react";
// ui
import { DiscordIcon } from "@plane/ui";
// hooks
import { useCommandPalette } from "@/hooks/store";
import { useCommandPalette, useTransient } from "@/hooks/store";

type Props = {
closePalette: () => void;
};

export const CommandPaletteHelpActions: React.FC<Props> = (props) => {
export const CommandPaletteHelpActions: React.FC<Props> = observer((props) => {
const { closePalette } = props;
// hooks
const { toggleShortcutModal } = useCommandPalette();
const { toggleIntercom } = useTransient();

return (
<Command.Group heading="Help">
Expand Down Expand Up @@ -68,9 +70,7 @@ export const CommandPaletteHelpActions: React.FC<Props> = (props) => {
<Command.Item
onSelect={() => {
closePalette();
if (window) {
window.$crisp.push(["do", "chat:show"]);
}
toggleIntercom(true);
}}
className="focus:outline-none"
>
Expand All @@ -81,4 +81,4 @@ export const CommandPaletteHelpActions: React.FC<Props> = (props) => {
</Command.Item>
</Command.Group>
);
};
});
9 changes: 4 additions & 5 deletions web/core/components/workspace/sidebar/help-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DiscordIcon, GithubIcon, Tooltip } from "@plane/ui";
// helpers
import { cn } from "@/helpers/common.helper";
// hooks
import { useAppTheme, useCommandPalette, useInstance } from "@/hooks/store";
import { useAppTheme, useCommandPalette, useInstance, useTransient } from "@/hooks/store";
import useOutsideClickDetector from "@/hooks/use-outside-click-detector";
import { usePlatformOS } from "@/hooks/use-platform-os";
// components
Expand Down Expand Up @@ -45,15 +45,14 @@ export const SidebarHelpSection: React.FC<WorkspaceHelpSectionProps> = observer(
const { toggleShortcutModal } = useCommandPalette();
const { isMobile } = usePlatformOS();
const { config } = useInstance();
const { isIntercomToggle, toggleIntercom } = useTransient();
// states
const [isNeedHelpOpen, setIsNeedHelpOpen] = useState(false);
// refs
const helpOptionsRef = useRef<HTMLDivElement | null>(null);

const handleCrispWindowShow = () => {
if (window) {
window.$crisp.push(["do", "chat:show"]);
}
toggleIntercom(!isIntercomToggle);
};

useOutsideClickDetector(helpOptionsRef, () => setIsNeedHelpOpen(false));
Expand Down Expand Up @@ -133,7 +132,7 @@ export const SidebarHelpSection: React.FC<WorkspaceHelpSectionProps> = observer(
leaveTo="transform opacity-0 scale-95"
>
<div
className={`absolute bottom-2 min-w-[10rem] ${
className={`absolute bottom-2 min-w-[10rem] z-[15] ${
isCollapsed ? "left-full" : "-left-[75px]"
} divide-y divide-custom-border-200 whitespace-nowrap rounded bg-custom-background-100 p-1 shadow-custom-shadow-xs`}
ref={helpOptionsRef}
Expand Down
1 change: 1 addition & 0 deletions web/core/hooks/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ export * from "./use-router-params";
export * from "./use-webhook";
export * from "./use-workspace";
export * from "./user";
export * from "./use-transient";
11 changes: 11 additions & 0 deletions web/core/hooks/store/use-transient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useContext } from "react";
// mobx store
import { StoreContext } from "@/lib/store-context";
// types
import { ITransientStore } from "@/store/transient.store";

export const useTransient = (): ITransientStore => {
const context = useContext(StoreContext);
if (context === undefined) throw new Error("useTransient must be used within StoreProvider");
return context.transient;
};
17 changes: 14 additions & 3 deletions web/core/lib/intercom-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use client";

import React, { FC, useEffect } from "react";
import Intercom from "@intercom/messenger-js-sdk";
import { Intercom, show, hide, onHide } from "@intercom/messenger-js-sdk";
import { observer } from "mobx-react";
// store hooks
import { useUser, useInstance } from "@/hooks/store";
import { useUser, useInstance, useTransient } from "@/hooks/store";

export type IntercomProviderProps = {
children: React.ReactNode;
Expand All @@ -15,6 +15,16 @@ const IntercomProvider: FC<IntercomProviderProps> = observer((props) => {
// hooks
const { data: user } = useUser();
const { config } = useInstance();
const { isIntercomToggle, toggleIntercom } = useTransient();

useEffect(() => {
if (isIntercomToggle) show();
else hide();
}, [isIntercomToggle]);

onHide(() => {
toggleIntercom(false);
});

useEffect(() => {
if (user && config?.is_intercom_enabled && config.intercom_app_id) {
Expand All @@ -23,9 +33,10 @@ const IntercomProvider: FC<IntercomProviderProps> = observer((props) => {
user_id: user.id,
name: `${user.first_name} ${user.last_name}`,
email: user.email,
hide_default_launcher: true,
});
}
}, [user, config]);
}, [user, config, toggleIntercom]);

return <>{children}</>;
});
Expand Down
5 changes: 5 additions & 0 deletions web/core/store/root.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { IProjectViewStore, ProjectViewStore } from "./project-view.store";
import { RouterStore, IRouterStore } from "./router.store";
import { IStateStore, StateStore } from "./state.store";
import { ThemeStore, IThemeStore } from "./theme.store";
import { ITransientStore, TransientStore } from "./transient.store";
import { IUserStore, UserStore } from "./user";
import { IWorkspaceRootStore, WorkspaceRootStore } from "./workspace";

Expand Down Expand Up @@ -54,6 +55,7 @@ export class CoreRootStore {
multipleSelect: IMultipleSelectStore;
workspaceNotification: IWorkspaceNotificationStore;
favorite: IFavoriteStore;
transient: ITransientStore;

constructor() {
this.router = new RouterStore();
Expand Down Expand Up @@ -81,6 +83,7 @@ export class CoreRootStore {
this.projectEstimate = new ProjectEstimateStore(this);
this.workspaceNotification = new WorkspaceNotificationStore(this);
this.favorite = new FavoriteStore(this);
this.transient = new TransientStore();
}

resetOnSignOut() {
Expand Down Expand Up @@ -110,5 +113,7 @@ export class CoreRootStore {
this.multipleSelect = new MultipleSelectStore();
this.projectEstimate = new ProjectEstimateStore(this);
this.workspaceNotification = new WorkspaceNotificationStore(this);
this.favorite = new FavoriteStore(this);
this.transient = new TransientStore();
}
}
28 changes: 28 additions & 0 deletions web/core/store/transient.store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { action, observable, makeObservable } from "mobx";

export interface ITransientStore {
// observables
isIntercomToggle: boolean;
// actions
toggleIntercom: (intercomToggle: boolean) => void;
}

export class TransientStore implements ITransientStore {
// observables
isIntercomToggle: boolean = false;

constructor() {
makeObservable(this, {
// observable
isIntercomToggle: observable.ref,
// action
toggleIntercom: action,
});
}

/**
* @description Toggle the intercom collapsed state
* @param { boolean } intercomToggle
*/
toggleIntercom = (intercomToggle: boolean) => (this.isIntercomToggle = intercomToggle);
}