Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support to sidebar #2119

Merged
merged 25 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ee46ed2
Discord dark mode and fixing the link
harshsbhat Sep 17, 2024
d817f16
Requested changes
harshsbhat Sep 17, 2024
c572089
Requested changes
harshsbhat Sep 17, 2024
686e6d3
Lint
harshsbhat Sep 17, 2024
6f0adf5
Merge remote-tracking branch 'origin/main' into harshbhat/supportSidebar
harshsbhat Sep 20, 2024
ff15f94
Adding support to sidebar
harshsbhat Sep 20, 2024
4d6711b
remove unused imports
harshsbhat Sep 20, 2024
acba9f7
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 20, 2024
ba3e055
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 20, 2024
56467f6
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 21, 2024
cf43aa8
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 21, 2024
3e43bf5
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 23, 2024
0e1f40d
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 24, 2024
fa1d22b
Merge branch 'unkeyed:main' into harshbhat/supportSidebar
harshsbhat Sep 25, 2024
4564e47
change the docs icon to book and remove repeating code
harshsbhat Sep 25, 2024
2a4823a
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 25, 2024
d8f04d1
Merge branch 'main' into harshbhat/supportSidebar
chronark Sep 26, 2024
045922e
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 26, 2024
429d205
Consistent size
harshsbhat Sep 26, 2024
bfdb4c5
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 26, 2024
dc6183f
Making sure the Feedback is clickable, the feedback can be entered us…
harshsbhat Sep 27, 2024
10b591d
Revert "Making sure the Feedback is clickable, the feedback can be en…
harshsbhat Sep 27, 2024
de9bef9
pnpm-lock file
harshsbhat Sep 27, 2024
39e9046
Fix
harshsbhat Sep 27, 2024
41dffeb
Merge branch 'main' into harshbhat/supportSidebar
harshsbhat Sep 30, 2024
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
31 changes: 28 additions & 3 deletions apps/dashboard/app/(app)/desktop-sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
import { Feedback } from "@/components/dashboard/feedback-component";
import { Badge } from "@/components/ui/badge";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import type { Workspace } from "@/lib/db";
Expand All @@ -16,7 +17,6 @@ import {
MonitorDot,
Settings2,
ShieldCheck,
User,
} from "lucide-react";
import Link from "next/link";
import { useSelectedLayoutSegments } from "next/navigation";
Expand All @@ -38,7 +38,7 @@ type Props = {
type NavItem = {
disabled?: boolean;
tooltip?: string;
icon: LucideIcon;
icon: LucideIcon | React.ElementType;
href: string;
external?: boolean;
label: string;
Expand All @@ -47,6 +47,23 @@ type NavItem = {
hidden?: boolean;
};

const DiscordIcon = () => (
<svg
className="w-4 h-4 fill-current" // Increased height to 6
viewBox="0 -28.5 256 256"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
preserveAspectRatio="xMidYMid"
>
<g>
<path
d="M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z"
fillRule="nonzero"
/>
</g>
</svg>
);

const Tag: React.FC<{ label: string; className?: string }> = ({ label, className }) => (
<div
className={cn(
Expand Down Expand Up @@ -128,12 +145,17 @@ export const DesktopSidebar: React.FC<Props> = ({ workspace, className }) => {
external: true,
label: "Docs",
},
{
icon: DiscordIcon,
href: "https://www.unkey.com/discord",
external: true,
label: "Discord",
},
];

const firstOfNextMonth = new Date();
firstOfNextMonth.setUTCMonth(firstOfNextMonth.getUTCMonth() + 1);
firstOfNextMonth.setDate(1);

return (
<aside
className={cn(
Expand Down Expand Up @@ -177,6 +199,9 @@ export const DesktopSidebar: React.FC<Props> = ({ workspace, className }) => {
<NavLink item={item} />
</li>
))}
<li>
<Feedback />
</li>
</ul>
</li>
</ul>
Expand Down
158 changes: 158 additions & 0 deletions apps/dashboard/components/dashboard/feedback-component.tsx
harshsbhat marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
"use client";
import { Loading } from "@/components/dashboard/loading";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Textarea } from "@/components/ui/textarea";
import { toast } from "@/components/ui/toaster";
import { trpc } from "@/lib/trpc/client";
import { zodResolver } from "@hookform/resolvers/zod";
import { MessagesSquare } from "lucide-react";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "../ui/form";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select";

export const Feedback: React.FC = () => {
const [open, setOpen] = useState(false);
/**
* This was necessary cause otherwise the dialog would not close when you're clicking outside of it
*/

const schema = z.object({
severity: z.enum(["p0", "p1", "p2", "p3"]),
issueType: z.enum(["bug", "feature", "security", "payment", "question"]),
message: z.string(),
});

const form = useForm<z.infer<typeof schema>>({
resolver: zodResolver(schema),
defaultValues: {
severity: "p2",
issueType: "bug",
message: "",
},
});

const create = trpc.plain.createIssue.useMutation({
onSuccess: () => {
setOpen(false);
toast.success("Your issue has been created, we'll get back to you as soon as possible");
},
onError(err) {
console.error(err);
toast.error(err.message);
},
});

return (
<div className="transition-all duration-150 group flex gap-x-2 rounded-md px-2 py-1 text-sm font-normal leading-6 items-center border border-transparent hover:bg-background-subtle hover:text-content justify-between">
<button type="button" onClick={() => setOpen(true)} className="flex items-center">
<MessagesSquare className="w-4 h-4 mr-2" />
Feedback
</button>
<Dialog open={open} onOpenChange={setOpen}>
<Form {...form}>
<form>
<DialogContent>
<DialogHeader>
<DialogTitle>Report an issue</DialogTitle>
<DialogDescription>What went wrong or how can we improve?</DialogDescription>
</DialogHeader>
<div className="grid grid-cols-2 gap-4">
<FormField
control={form.control}
name="issueType"
render={({ field }) => (
<FormItem>
<FormLabel>Area</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="What area is this" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="bug">Bug</SelectItem>
<SelectItem value="feature">Feature Request</SelectItem>
<SelectItem value="security">Security</SelectItem>
<SelectItem value="payment">Payments</SelectItem>
<SelectItem value="question">General Question</SelectItem>
</SelectContent>
</Select>

<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="severity"
render={({ field }) => (
<FormItem>
<FormLabel>Severity</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Select a severity" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="p0">Urgent</SelectItem>
<SelectItem value="p1">High</SelectItem>
<SelectItem value="p2">Normal</SelectItem>
<SelectItem value="p3">Low</SelectItem>
</SelectContent>
</Select>

<FormMessage />
</FormItem>
)}
/>
</div>
<FormField
control={form.control}
name="message"
render={({ field }) => (
<FormItem>
<FormLabel>What can we do for you?</FormLabel>
<FormControl>
<Textarea
{...field}
placeholder="Please include all information relevant to your issue."
/>
</FormControl>

<FormMessage />
</FormItem>
)}
/>

<DialogFooter>
<Button variant="ghost" onClick={() => setOpen(false)}>
Cancel
</Button>
<Button
type="submit"
disabled={create.isLoading}
onClick={form.handleSubmit((data) => {
create.mutate(data);
})}
>
{create.isLoading ? <Loading /> : "Send"}
</Button>
</DialogFooter>
</DialogContent>
</form>
</Form>
</Dialog>
</div>
);
};