Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 17, 2023
1 parent 0851395 commit 71b68a7
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"react-dom": "18.2.0",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.49.2",
"react-hotkeys-hook": "^4.4.1",
"react-pin-field": "^3.1.4",
"recharts": "^2.10.3",
"sharp": "^0.33.0",
Expand Down
93 changes: 81 additions & 12 deletions apps/dashboard/src/components/command-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import { signOutAction } from "@/actions/sign-out-action";
import { Button } from "@midday/ui/button";
import {
CommandDialog,
Expand All @@ -14,8 +15,9 @@ import { Icons } from "@midday/ui/icons";
import { DialogProps } from "@radix-ui/react-alert-dialog";
import { MoonIcon, SunIcon } from "@radix-ui/react-icons";
import { useTheme } from "next-themes";
import { useRouter } from "next/navigation";
import { useCallback, useEffect, useState } from "react";
import { usePathname, useRouter } from "next/navigation";
import { useCallback, useState } from "react";
import { useHotkeys } from "react-hotkeys-hook";

const navigation = [
{
Expand All @@ -28,6 +30,21 @@ const navigation = [
path: "/transactions",
icon: () => <Icons.Transactions size={20} />,
},
{
name: "Vault",
path: "/vault",
icon: Icons.Files,
},
{
name: "Inbox",
path: "/vault/inbox",
icon: Icons.FolderSpecial,
},
{
name: "Exports",
path: "/vault/exports",
icon: Icons.DriveFileMove,
},
{
name: "Apps",
path: "/apps",
Expand All @@ -51,6 +68,11 @@ const settings = [
path: "/settings",
icon: Icons.Peolple,
},
{
name: "Security",
path: "/settings/security",
icon: Icons.Security,
},
{
name: "Notifications",
path: "/settings/notifications",
Expand All @@ -65,20 +87,67 @@ const settings = [

export function CommandMenu({ ...props }: DialogProps) {
const router = useRouter();
const pathname = usePathname();
const { setTheme } = useTheme();
const [open, setOpen] = useState(false);

useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
setOpen((open) => !open);
}
};
const handleSignOut = async () => {
signOutAction();
router.refresh();
};

document.addEventListener("keydown", down);
return () => document.removeEventListener("keydown", down);
}, []);
useHotkeys("ctrl+k", () => setOpen((open) => !open));
useHotkeys("meta+k", () => setOpen((open) => !open));

useHotkeys("meta+o", (evt) => {
evt.preventDefault();
router.push("/onboarding");
});

useHotkeys("ctrl+o", (evt) => {
evt.preventDefault();
router.push("/onboarding");
});

useHotkeys("meta+s", (evt) => {
evt.preventDefault();
router.push("/settings");
});

useHotkeys("ctrl+s", (evt) => {
evt.preventDefault();
router.push("/settings");
});

useHotkeys("ctrl+meta+p", (evt) => {
evt.preventDefault();
router.push("/profile");
});

useHotkeys("shift+meta+p", (evt) => {
evt.preventDefault();
router.push("/profile");
});

useHotkeys("ctrl+meta+q", (evt) => {
evt.preventDefault();
handleSignOut();
});

useHotkeys("shift+meta+q", (evt) => {
evt.preventDefault();
handleSignOut();
});

useHotkeys("ctrl+f", (evt) => {
evt.preventDefault();
router.push(`${pathname}?feedback`);
});

useHotkeys("meta+f", (evt) => {
evt.preventDefault();
router.push(`${pathname}?feedback`);
});

const runCommand = useCallback((command: () => unknown) => {
setOpen(false);
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/components/tables/vault/data-table-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,15 @@ export function DataTableRow({ data, teamId }) {
<a
href={`/api/download/zip?path=${filepath}/${data.name}&filename=${data.name}`}
download
className="truncate"
className="truncate w-full"
>
Download
</a>
) : (
<a
href={`/api/download/file?path=${folderPath}/${data.name}&filename=${data.name}`}
download
className="truncate"
className="truncate w-full"
>
Download
</a>
Expand Down
4 changes: 3 additions & 1 deletion apps/dashboard/src/components/user-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export async function UserMenu() {
</Link>

<DropdownMenuItem>
<Link href="?feedback">Feedback</Link>
<Link href="?feedback" className="w-full">
Feedback
</Link>
<DropdownMenuShortcut>⌘F</DropdownMenuShortcut>
</DropdownMenuItem>

Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions packages/ui/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
MdRefresh,
MdSave,
MdSearch,
MdSecurity,
MdSensors,
MdTopic,
MdTrendingDown,
Expand Down Expand Up @@ -419,4 +420,5 @@ export const Icons = {
OpenInFull: MdOutlineOpenInFull,
FileDownload: MdOutlineFileDownload,
Image: MdOutlineInsertPhoto,
Security: MdSecurity,
};

0 comments on commit 71b68a7

Please sign in to comment.