-
Notifications
You must be signed in to change notification settings - Fork 0
[Ready for Review] Add Report Issue dialog UI and wire it to Settings menu with Bugsink configured #164
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
Merged
Merged
[Ready for Review] Add Report Issue dialog UI and wire it to Settings menu with Bugsink configured #164
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
160d1ec
Create new dialog component for Report Issue and wire to existing Rep…
eddie-wq07 9fd09fa
fix: jobService seperator not accepted; test issues
theosiemensrhodes d0028dc
Configure tRPC mutation for Bugsink configuration
eddie-wq07 3ed78e7
Merge branch 'main' into report-issue-dialog
theosiemensrhodes d1bbaf8
fix: minor fixes/code review
theosiemensrhodes 30819f7
fix: remove flush; probably fine
theosiemensrhodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| openssl rand -base64 24 | tr '+/' '-_' | ||
| #!/bin/sh | ||
| LENGTH="${1:-32}" | ||
| BYTES=$(( (LENGTH * 3 + 3) / 4 )) | ||
| openssl rand -base64 "$BYTES" | tr -d '\n' | tr '+/' '-_' | head -c "$LENGTH" | ||
| echo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| "use client"; | ||
|
|
||
| import { FormInputField } from "@/components/form/FormInput"; | ||
| import { FormTextareaField } from "@/components/form/FormTextarea"; | ||
| import { Button } from "@/components/ui/button"; | ||
| import { | ||
| Dialog, | ||
| DialogClose, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogFooter, | ||
| DialogHeader, | ||
| DialogTitle, | ||
| } from "@/components/ui/dialog"; | ||
| import { FieldGroup } from "@/components/ui/field"; | ||
| import { SubmitBugReportInput } from "@/models/api/bug-report"; | ||
| import { clientApi } from "@/trpc/client"; | ||
| import NiceModal, { useModal } from "@ebay/nice-modal-react"; | ||
| import { zodResolver } from "@hookform/resolvers/zod"; | ||
| import { useForm } from "react-hook-form"; | ||
| import { toast } from "sonner"; | ||
| import type { z } from "zod"; | ||
|
|
||
| type ReportIssueSchemaType = z.infer<typeof SubmitBugReportInput>; | ||
|
|
||
| export const ReportIssueDialog = NiceModal.create(() => { | ||
| const modal = useModal(); | ||
|
|
||
| const form = useForm<ReportIssueSchemaType>({ | ||
| resolver: zodResolver(SubmitBugReportInput), | ||
| defaultValues: { | ||
| title: "", | ||
| description: "", | ||
| email: "", | ||
| }, | ||
| mode: "onSubmit", | ||
| reValidateMode: "onChange", | ||
| }); | ||
|
|
||
| const submitBugReport = clientApi.bugReport.submit.useMutation({ | ||
| onSuccess: () => { | ||
| toast.success("Issue reported successfully. Thank you!"); | ||
| modal.hide(); | ||
| form.reset(); | ||
| }, | ||
| onError: (error) => { | ||
| toast.error(`Failed to report issue: ${error.message}`); | ||
| }, | ||
| }); | ||
|
|
||
| const onSubmit = (data: ReportIssueSchemaType) => { | ||
| submitBugReport.mutate(data); | ||
| }; | ||
|
|
||
| return ( | ||
| <Dialog | ||
| open={modal.visible} | ||
| onOpenChange={(open) => (open ? modal.show() : modal.hide())} | ||
| > | ||
| <DialogContent> | ||
| <DialogHeader> | ||
| <DialogTitle>Report Issue</DialogTitle> | ||
| <DialogDescription> | ||
| Let us know about any issues you're experiencing. | ||
| </DialogDescription> | ||
| </DialogHeader> | ||
|
|
||
| <form | ||
| className="flex flex-col gap-6" | ||
| onSubmit={form.handleSubmit(onSubmit)} | ||
| > | ||
| <FieldGroup> | ||
| <FormInputField | ||
| control={form.control} | ||
| name="title" | ||
| label="Title" | ||
| placeholder="Brief description of the issue" | ||
| maxLength={200} | ||
| required | ||
| /> | ||
|
|
||
| <FormTextareaField | ||
| control={form.control} | ||
| name="description" | ||
| label="What happened?" | ||
| placeholder="Describe the issue in detail..." | ||
| rows={5} | ||
| required | ||
| /> | ||
|
|
||
| <FormInputField | ||
| control={form.control} | ||
| name="email" | ||
| label="Contact Email" | ||
| placeholder="your.email@example.com" | ||
| type="email" | ||
| /> | ||
| </FieldGroup> | ||
|
|
||
| <DialogFooter> | ||
| <DialogClose asChild> | ||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| disabled={submitBugReport.isPending} | ||
| > | ||
| Cancel | ||
| </Button> | ||
| </DialogClose> | ||
| <Button | ||
| type="submit" | ||
| size="sm" | ||
| disabled={submitBugReport.isPending} | ||
| > | ||
| {submitBugReport.isPending ? "Submitting..." : "Submit"} | ||
| </Button> | ||
| </DialogFooter> | ||
| </form> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import { | |
| import { forceLogout } from "@/lib/auth/logout"; | ||
| import { useAuth } from "@/providers/client-auth-provider"; | ||
| import NiceModal from "@ebay/nice-modal-react"; | ||
| import { ReportIssueDialog } from "../report-issue-dialog"; | ||
| import { SettingsDialog } from "./settings-dialog"; | ||
|
|
||
| export function SettingsDropdown({ | ||
|
|
@@ -46,11 +47,9 @@ export function SettingsDropdown({ | |
| </DropdownMenuGroup> | ||
| <DropdownMenuSeparator /> | ||
| <DropdownMenuGroup> | ||
| <DropdownMenuItem disabled> | ||
| <DropdownMenuItem onSelect={() => NiceModal.show(ReportIssueDialog)}> | ||
| <Flag /> | ||
| <span> | ||
| Report a Bug <i>(Coming soon)</i> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should do "Report an Issue" maybe, otherwise great work on the frontend |
||
| </span> | ||
| <span>Report Issue</span> | ||
| </DropdownMenuItem> | ||
| <DropdownMenuItem onSelect={handleLogout}> | ||
| <LogOut /> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,14 @@ | ||
| import { env } from "@/env"; | ||
| import { migrate } from "@/server/db/migrate"; | ||
| import * as Sentry from "@sentry/nextjs"; | ||
|
|
||
| /** | ||
| * Next.js instrumentation hook. Called exactly once when the server process | ||
| * starts (both in development and production). This is the right place to run | ||
| * one-time startup work like database migrations. | ||
| * | ||
| * @see https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation | ||
| */ | ||
| export async function register() { | ||
| if (process.env.NEXT_RUNTIME === "nodejs") { | ||
| Sentry.init({ | ||
| dsn: env.SENTRY_DSN, | ||
| tracesSampleRate: 1.0, | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| environment: env.NODE_ENV, | ||
| }); | ||
| } | ||
| await migrate(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { z } from "zod"; | ||
|
|
||
| export const SubmitBugReportInput = z.object({ | ||
| title: z.string().min(1, "Title is required").max(200), | ||
| description: z.string().min(1, "Description is required").max(5000), | ||
| email: z.string().email("Invalid email").optional().or(z.literal("")), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import * as Sentry from "@sentry/nextjs"; | ||
| import { SubmitBugReportInput } from "@/models/api/bug-report"; | ||
| import { authorizedProcedure } from "@/server/api/procedures"; | ||
| import { createTRPCRouter } from "@/server/api/trpc"; | ||
|
|
||
| export const bugReportRouter = createTRPCRouter({ | ||
| submit: authorizedProcedure() | ||
| .input(SubmitBugReportInput) | ||
| .mutation(async ({ input }) => { | ||
| Sentry.captureMessage(input.title, { | ||
| level: "info", | ||
| tags: { | ||
| type: "user_bug_report", | ||
| }, | ||
| extra: { | ||
| description: input.description, | ||
| email: input.email || "not provided", | ||
| }, | ||
| }); | ||
| }), | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.