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
9 changes: 7 additions & 2 deletions apps/app/components/command-palette/command-pallette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ import issuesService from "services/issues.service";
import inboxService from "services/inbox.service";
// fetch keys
import { INBOX_LIST, ISSUE_DETAILS } from "constants/fetch-keys";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";

export const CommandPalette: React.FC = () => {
const store: any = useMobxStore();

const [isPaletteOpen, setIsPaletteOpen] = useState(false);
const [isIssueModalOpen, setIsIssueModalOpen] = useState(false);
const [isProjectModalOpen, setIsProjectModalOpen] = useState(false);
Expand Down Expand Up @@ -96,7 +100,8 @@ export const CommandPalette: React.FC = () => {
setIsIssueModalOpen(true);
} else if ((ctrlKey || metaKey) && keyPressed === "b") {
e.preventDefault();
toggleCollapsed();
// toggleCollapsed();
store.theme.setSidebarCollapsed(!store?.theme?.sidebarCollapsed);
} else if (key === "Delete") {
e.preventDefault();
setIsBulkDeleteIssuesModalOpen(true);
Expand All @@ -120,7 +125,7 @@ export const CommandPalette: React.FC = () => {
}
}
},
[toggleCollapsed, copyIssueUrlToClipboard]
[copyIssueUrlToClipboard]
);

useEffect(() => {
Expand Down
22 changes: 10 additions & 12 deletions apps/app/components/core/theme/custom-theme-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import userService from "services/user.service";
import { applyTheme } from "helpers/theme.helper";
// types
import { ICustomTheme } from "types";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";

type Props = {
preLoadedData?: Partial<ICustomTheme> | null;
Expand All @@ -32,6 +34,8 @@ const defaultValues: ICustomTheme = {
};

export const CustomThemeSelector: React.FC<Props> = ({ preLoadedData }) => {
const store: any = useMobxStore();

const [darkPalette, setDarkPalette] = useState(false);

const {
Expand Down Expand Up @@ -60,21 +64,15 @@ export const CustomThemeSelector: React.FC<Props> = ({ preLoadedData }) => {
theme: "custom",
};

await userService
.updateUser({
theme: payload,
})
.then((res) => {
mutateUser((prevData) => {
if (!prevData) return prevData;

return { ...prevData, ...res };
}, false);

store.user
.updateCurrentUserSettings({ theme: payload })
.then((response: any) => {
setTheme("custom");
applyTheme(payload.palette, darkPalette);
})
.catch((err) => console.log(err));
.catch((error: any) => {
console.log("error", error);
});
};

const handleUpdateTheme = async (formData: any) => {
Expand Down
10 changes: 7 additions & 3 deletions apps/app/components/notifications/notification-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ import { NotificationsOutlined } from "@mui/icons-material";
import emptyNotification from "public/empty-state/notification.svg";
// helpers
import { getNumberCount } from "helpers/string.helper";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";

export const NotificationPopover = () => {
const store: any = useMobxStore();

const {
notifications,
archived,
Expand Down Expand Up @@ -77,17 +81,17 @@ export const NotificationPopover = () => {
tooltipContent="Notifications"
position="right"
className="ml-2"
disabled={!sidebarCollapse}
disabled={!store?.theme?.sidebarCollapsed}
>
<Popover.Button
className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium outline-none ${
isActive
? "bg-custom-primary-100/10 text-custom-primary-100"
: "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"
} ${sidebarCollapse ? "justify-center" : ""}`}
} ${store?.theme?.sidebarCollapsed ? "justify-center" : ""}`}
>
<NotificationsOutlined fontSize="small" />
{sidebarCollapse ? null : <span>Notifications</span>}
{store?.theme?.sidebarCollapsed ? null : <span>Notifications</span>}
{totalNotificationCount && totalNotificationCount > 0 ? (
<span className="ml-auto bg-custom-primary-300 rounded-full text-xs text-white px-1.5">
{getNumberCount(totalNotificationCount)}
Expand Down
18 changes: 11 additions & 7 deletions apps/app/components/project/sidebar-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ import { orderArrayBy } from "helpers/array.helper";
import { IProject } from "types";
// fetch-keys
import { PROJECTS_LIST } from "constants/fetch-keys";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";

export const ProjectSidebarList: FC = () => {
const store: any = useMobxStore();

const [deleteProjectModal, setDeleteProjectModal] = useState(false);
const [projectToDelete, setProjectToDelete] = useState<IProject | null>(null);

Expand Down Expand Up @@ -139,7 +143,7 @@ export const ProjectSidebarList: FC = () => {
<Disclosure as="div" className="flex flex-col space-y-2" defaultOpen={true}>
{({ open }) => (
<>
{!sidebarCollapse && (
{!store?.theme?.sidebarCollapsed && (
<Disclosure.Button
as="button"
type="button"
Expand All @@ -165,7 +169,7 @@ export const ProjectSidebarList: FC = () => {
<SingleSidebarProject
key={project.id}
project={project}
sidebarCollapse={sidebarCollapse}
sidebarCollapse={store?.theme?.sidebarCollapsed}
provided={provided}
snapshot={snapshot}
handleDeleteProject={() => handleDeleteProject(project)}
Expand Down Expand Up @@ -194,7 +198,7 @@ export const ProjectSidebarList: FC = () => {
<Disclosure as="div" className="flex flex-col space-y-2" defaultOpen={true}>
{({ open }) => (
<>
{!sidebarCollapse && (
{!store?.theme?.sidebarCollapsed && (
<Disclosure.Button
as="button"
type="button"
Expand All @@ -215,7 +219,7 @@ export const ProjectSidebarList: FC = () => {
<SingleSidebarProject
key={project.id}
project={project}
sidebarCollapse={sidebarCollapse}
sidebarCollapse={store?.theme?.sidebarCollapsed}
provided={provided}
snapshot={snapshot}
handleDeleteProject={() => handleDeleteProject(project)}
Expand Down Expand Up @@ -243,7 +247,7 @@ export const ProjectSidebarList: FC = () => {
>
{({ open }) => (
<>
{!sidebarCollapse && (
{!store?.theme?.sidebarCollapsed && (
<Disclosure.Button
as="button"
type="button"
Expand All @@ -261,7 +265,7 @@ export const ProjectSidebarList: FC = () => {
<SingleSidebarProject
key={project.id}
project={project}
sidebarCollapse={sidebarCollapse}
sidebarCollapse={store?.theme?.sidebarCollapsed}
handleDeleteProject={() => handleDeleteProject(project)}
handleCopyText={() => handleCopyText(project.id)}
shortContextMenu
Expand All @@ -284,7 +288,7 @@ export const ProjectSidebarList: FC = () => {
}}
>
<PlusIcon className="h-5 w-5" />
{!sidebarCollapse && "Add Project"}
{!store?.theme?.sidebarCollapsed && "Add Project"}
</button>
)}
</div>
Expand Down
22 changes: 13 additions & 9 deletions apps/app/components/workspace/help-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import useOutsideClickDetector from "hooks/use-outside-click-detector";
import { Bolt, HelpOutlineOutlined, WestOutlined } from "@mui/icons-material";
import { ChatBubbleOvalLeftEllipsisIcon } from "@heroicons/react/24/outline";
import { DocumentIcon, DiscordIcon, GithubIcon } from "components/icons";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";

const helpOptions = [
{
Expand Down Expand Up @@ -41,6 +43,8 @@ export interface WorkspaceHelpSectionProps {
}

export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = ({ setSidebarActive }) => {
const store: any = useMobxStore();

const [isNeedHelpOpen, setIsNeedHelpOpen] = useState(false);

const helpOptionsRef = useRef<HTMLDivElement | null>(null);
Expand All @@ -53,23 +57,23 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = ({ setS
<>
<div
className={`flex w-full items-center justify-between gap-1 self-baseline border-t border-custom-border-200 bg-custom-sidebar-background-100 py-2 px-4 ${
sidebarCollapse ? "flex-col" : ""
store?.theme?.sidebarCollapsed ? "flex-col" : ""
}`}
>
{!sidebarCollapse && (
{!store?.theme?.sidebarCollapsed && (
<div className="w-1/2 text-center cursor-default rounded-md px-2.5 py-1.5 font-medium outline-none text-sm bg-green-500/10 text-green-500">
Free Plan
</div>
)}
<div
className={`flex items-center gap-1 ${
sidebarCollapse ? "flex-col justify-center" : "justify-evenly w-1/2"
store?.theme?.sidebarCollapsed ? "flex-col justify-center" : "justify-evenly w-1/2"
}`}
>
<button
type="button"
className={`grid place-items-center rounded-md p-1.5 text-custom-text-200 hover:text-custom-text-100 hover:bg-custom-background-90 outline-none ${
sidebarCollapse ? "w-full" : ""
store?.theme?.sidebarCollapsed ? "w-full" : ""
}`}
onClick={() => {
const e = new KeyboardEvent("keydown", {
Expand All @@ -83,7 +87,7 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = ({ setS
<button
type="button"
className={`grid place-items-center rounded-md p-1.5 text-custom-text-200 hover:text-custom-text-100 hover:bg-custom-background-90 outline-none ${
sidebarCollapse ? "w-full" : ""
store?.theme?.sidebarCollapsed ? "w-full" : ""
}`}
onClick={() => setIsNeedHelpOpen((prev) => !prev)}
>
Expand All @@ -99,13 +103,13 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = ({ setS
<button
type="button"
className={`hidden md:grid place-items-center rounded-md p-1.5 text-custom-text-200 hover:text-custom-text-100 hover:bg-custom-background-90 outline-none ${
sidebarCollapse ? "w-full" : ""
store?.theme?.sidebarCollapsed ? "w-full" : ""
}`}
onClick={() => toggleCollapsed()}
onClick={() => store.theme.setSidebarCollapsed(!store?.theme?.sidebarCollapsed)}
>
<WestOutlined
fontSize="small"
className={`duration-300 ${sidebarCollapse ? "rotate-180" : ""}`}
className={`duration-300 ${store?.theme?.sidebarCollapsed ? "rotate-180" : ""}`}
/>
</button>
</div>
Expand All @@ -122,7 +126,7 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = ({ setS
>
<div
className={`absolute bottom-2 ${
sidebarCollapse ? "left-full" : "left-[-75px]"
store?.theme?.sidebarCollapsed ? "left-full" : "left-[-75px]"
} space-y-2 rounded-sm bg-custom-background-80 p-1 shadow-md`}
ref={helpOptionsRef}
>
Expand Down
10 changes: 7 additions & 3 deletions apps/app/components/workspace/sidebar-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { CheckIcon, PlusIcon } from "@heroicons/react/24/outline";
import { truncateText } from "helpers/string.helper";
// types
import { IWorkspace } from "types";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";

// Static Data
const userLinks = (workspaceSlug: string, userId: string) => [
Expand Down Expand Up @@ -54,6 +56,8 @@ const profileLinks = (workspaceSlug: string, userId: string) => [
];

export const WorkspaceSidebarDropdown = () => {
const store: any = useMobxStore();

const router = useRouter();
const { workspaceSlug } = router.query;

Expand Down Expand Up @@ -108,7 +112,7 @@ export const WorkspaceSidebarDropdown = () => {
<Menu.Button className="text-custom-sidebar-text-200 flex w-full items-center rounded-sm text-sm font-medium focus:outline-none">
<div
className={`flex w-full items-center gap-x-2 rounded-sm bg-custom-sidebar-background-80 p-1 ${
sidebarCollapse ? "justify-center" : ""
store?.theme?.sidebarCollapsed ? "justify-center" : ""
}`}
>
<div className="relative grid h-6 w-6 place-items-center rounded bg-gray-700 uppercase text-white">
Expand All @@ -123,7 +127,7 @@ export const WorkspaceSidebarDropdown = () => {
)}
</div>

{!sidebarCollapse && (
{!store?.theme?.sidebarCollapsed && (
<h4 className="text-custom-text-100">
{activeWorkspace?.name ? truncateText(activeWorkspace.name, 14) : "Loading..."}
</h4>
Expand Down Expand Up @@ -243,7 +247,7 @@ export const WorkspaceSidebarDropdown = () => {
</Transition>
</Menu>

{!sidebarCollapse && (
{!store?.theme?.sidebarCollapsed && (
<Menu as="div" className="relative flex-shrink-0">
<Menu.Button className="grid place-items-center outline-none">
<Avatar user={user} height="28px" width="28px" fontSize="14px" />
Expand Down
10 changes: 7 additions & 3 deletions apps/app/components/workspace/sidebar-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
TaskAltOutlined,
WorkOutlineOutlined,
} from "@mui/icons-material";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";

const workspaceLinks = (workspaceSlug: string) => [
{
Expand All @@ -41,6 +43,8 @@ const workspaceLinks = (workspaceSlug: string) => [
];

export const WorkspaceSidebarMenu = () => {
const store: any = useMobxStore();

const router = useRouter();
const { workspaceSlug } = router.query;

Expand All @@ -61,17 +65,17 @@ export const WorkspaceSidebarMenu = () => {
tooltipContent={link.name}
position="right"
className="ml-2"
disabled={!sidebarCollapse}
disabled={!store?.theme?.sidebarCollapsed}
>
<div
className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium outline-none ${
isActive
? "bg-custom-primary-100/10 text-custom-primary-100"
: "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80"
} ${sidebarCollapse ? "justify-center" : ""}`}
} ${store?.theme?.sidebarCollapsed ? "justify-center" : ""}`}
>
{<link.Icon fontSize="small" />}
{!sidebarCollapse && link.name}
{!store?.theme?.sidebarCollapsed && link.name}
</div>
</Tooltip>
</a>
Expand Down
11 changes: 8 additions & 3 deletions apps/app/layouts/app-layout/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ import {
WorkspaceSidebarMenu,
} from "components/workspace";
import { ProjectSidebarList } from "components/project";
// mobx react lite
import { observer } from "mobx-react-lite";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";

export interface SidebarProps {
toggleSidebar: boolean;
setToggleSidebar: React.Dispatch<React.SetStateAction<boolean>>;
}

const Sidebar: React.FC<SidebarProps> = ({ toggleSidebar, setToggleSidebar }) => {
const Sidebar: React.FC<SidebarProps> = observer(({ toggleSidebar, setToggleSidebar }) => {
const store: any = useMobxStore();
// theme
const { collapsed: sidebarCollapse } = useTheme();

return (
<div
className={`fixed md:relative inset-y-0 flex flex-col bg-custom-sidebar-background-100 h-full flex-shrink-0 flex-grow-0 border-r border-custom-sidebar-border-200 z-20 duration-300 ${
sidebarCollapse ? "" : "md:w-[280px]"
store?.theme?.sidebarCollapsed ? "" : "md:w-[280px]"
} ${toggleSidebar ? "left-0" : "-left-full md:left-0"}`}
>
<div className="flex h-full w-full flex-1 flex-col">
Expand All @@ -31,6 +36,6 @@ const Sidebar: React.FC<SidebarProps> = ({ toggleSidebar, setToggleSidebar }) =>
</div>
</div>
);
};
});

export default Sidebar;
Loading