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

Add signatures #611

Merged
merged 1 commit into from
Feb 12, 2025
Merged

Add signatures #611

merged 1 commit into from
Feb 12, 2025

Conversation

nevo-david
Copy link
Contributor

@nevo-david nevo-david commented Feb 12, 2025

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive signature management allowing users to create, view, edit, and delete signatures.
    • Enhanced the editor with quick signature insertion and updated the calendar to prefill default signature content.
    • Revamped the settings interface with a dedicated tab for signature configurations.
  • Bug Fixes

    • Improved error notifications during post submissions to provide clearer user feedback on failures.

Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitroom 🔄 Building (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 2:37pm
postiz 🔄 Building (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 2:37pm

Copy link

coderabbitai bot commented Feb 12, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request implements extensive signature management features. On the backend, it adds a SignatureController to the authenticated controllers in the API module to handle endpoints for retrieving, creating, and updating signatures. The NestJS libraries are extended with a new Prisma model, repository, service, and DTO to support signature persistence and validation. On the frontend, several components are modified and enhanced to integrate signature fetching, modal management, and a dedicated settings tab, bringing signature functionality into the editing and settings workflows without altering existing functionalities.

Changes

File(s) Change Summary
apps/backend/src/api/api.module.ts
apps/backend/src/api/routes/signature.controller.ts
Added SignatureController to the authenticated controllers and created signature-related endpoints (GET, POST, PUT) for handling signatures.
apps/frontend/src/components/launches/calendar.tsx
apps/frontend/src/components/launches/editor.tsx
apps/frontend/src/components/layout/settings.component.tsx
apps/frontend/src/components/settings/signatures.component.ts
apps/frontend/src/components/signature.tsx
Integrated signature fetching in the calendar modal; added SignatureBox in the editor; introduced a new tabbed interface in settings with a dedicated Signatures tab and a new SignaturesComponent; and provided UI components (SignatureBox and SignatureModal) for modal-based signature management.
libraries/nestjs-libraries/src/database/prisma/database.module.ts
libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts
libraries/nestjs-libraries/src/database/prisma/schema.prisma
libraries/nestjs-libraries/src/database/prisma/signatures/signature.repository.ts
libraries/nestjs-libraries/src/database/prisma/signatures/signature.service.ts
libraries/nestjs-libraries/src/dtos/signature/signature.dto.ts
Introduced a new Prisma model (Signatures) with related schema updates; added SignatureRepository and SignatureService for managing signature operations; enhanced error handling in posts service; and created a new SignatureDto for request validation.

Sequence Diagram(s)

sequenceDiagram
    participant FE as Frontend (Signature UI)
    participant Modal as SignatureModal
    participant API as SignatureController
    participant Svc as SignatureService
    participant Repo as SignatureRepository
    participant DB as Database

    FE->>API: Request default signature (GET /signatures/default)
    API->>Svc: getDefaultSignature(orgId)
    Svc->>Repo: getDefaultSignature(orgId)
    Repo-->>Svc: Return default signature
    Svc-->>API: Return default signature
    API-->>FE: Send default signature

    Modal->>API: Submit new/updated signature (POST/PUT)
    API->>Svc: createOrUpdateSignature(orgId, signatureDto)
    Svc->>Repo: createOrUpdateSignature(orgId, signatureDto)
    Repo->>DB: Upsert signature, update autoAdd state
    DB-->>Repo: Confirmation
    Repo-->>Svc: Return signature data
    Svc-->>API: Return result
    API-->>Modal: Respond with success
Loading

Possibly related PRs

  • Webhook #591: Adds a WebhookController to the authenticated controllers; similar in nature to the inclusion of SignatureController, as both expand API capabilities through new controllers.

Poem

Oh, I'm just a bouncy little rabbit,
Hopping through code with a signature habit.
New controllers and modals make my heart sing,
In the backend and frontend, the features now ring.
With lines of code that dance like spring 🌸,
I celebrate these changes with a joyful fling!
Happy coding, from your furry friend on the run!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed93eab and 46d3943.

📒 Files selected for processing (13)
  • apps/backend/src/api/api.module.ts (2 hunks)
  • apps/backend/src/api/routes/signature.controller.ts (1 hunks)
  • apps/frontend/src/components/launches/calendar.tsx (2 hunks)
  • apps/frontend/src/components/launches/editor.tsx (2 hunks)
  • apps/frontend/src/components/layout/settings.component.tsx (3 hunks)
  • apps/frontend/src/components/settings/signatures.component.tsx (1 hunks)
  • apps/frontend/src/components/signature.tsx (1 hunks)
  • libraries/nestjs-libraries/src/database/prisma/database.module.ts (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/schema.prisma (2 hunks)
  • libraries/nestjs-libraries/src/database/prisma/signatures/signature.repository.ts (1 hunks)
  • libraries/nestjs-libraries/src/database/prisma/signatures/signature.service.ts (1 hunks)
  • libraries/nestjs-libraries/src/dtos/signature/signature.dto.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@@ -61,6 +62,7 @@
return (
<>
<div className="flex gap-[5px] justify-end -mt-[30px]">
<SignatureBox editor={newRef?.current?.editor!} />

Check warning

Code scanning / ESLint

Disallow non-null assertions using the `!` postfix operator Warning

Forbidden non-null assertion.

Copilot Autofix AI 8 days ago

To fix the problem, we should avoid using the non-null assertion operator ! and instead handle the potential null or undefined values more gracefully. One way to do this is by using optional chaining and providing a fallback value or handling the case where the value is null or undefined.

In this specific case, we can check if newRef?.current?.editor is defined before using it. If it is not defined, we can either return early or provide a fallback behavior.

Suggested changeset 1
apps/frontend/src/components/launches/editor.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/frontend/src/components/launches/editor.tsx b/apps/frontend/src/components/launches/editor.tsx
--- a/apps/frontend/src/components/launches/editor.tsx
+++ b/apps/frontend/src/components/launches/editor.tsx
@@ -54,4 +54,6 @@
         setTimeout(() => {
-          // @ts-ignore
-          Transforms.insertText(newRef?.current?.editor!, emoji);
+          const editor = newRef?.current?.editor;
+          if (editor) {
+            Transforms.insertText(editor, emoji);
+          }
         }, 10);
@@ -64,10 +66,17 @@
         <div className="flex gap-[5px] justify-end -mt-[30px]">
-          <SignatureBox editor={newRef?.current?.editor!} />
-          <UText
-            editor={newRef?.current?.editor!}
-            currentValue={props.value!}
-          />
-          <BoldText
-            editor={newRef?.current?.editor!}
-            currentValue={props.value!}
+          {newRef?.current?.editor && (
+            <SignatureBox editor={newRef.current.editor} />
+          )}
+          {newRef?.current?.editor && (
+            <UText
+              editor={newRef.current.editor}
+              currentValue={props.value ?? ''}
+            />
+          )}
+          {newRef?.current?.editor && (
+            <BoldText
+              editor={newRef.current.editor}
+              currentValue={props.value ?? ''}
+            />
+          )}
           />
EOF
@@ -54,4 +54,6 @@
setTimeout(() => {
// @ts-ignore
Transforms.insertText(newRef?.current?.editor!, emoji);
const editor = newRef?.current?.editor;
if (editor) {
Transforms.insertText(editor, emoji);
}
}, 10);
@@ -64,10 +66,17 @@
<div className="flex gap-[5px] justify-end -mt-[30px]">
<SignatureBox editor={newRef?.current?.editor!} />
<UText
editor={newRef?.current?.editor!}
currentValue={props.value!}
/>
<BoldText
editor={newRef?.current?.editor!}
currentValue={props.value!}
{newRef?.current?.editor && (
<SignatureBox editor={newRef.current.editor} />
)}
{newRef?.current?.editor && (
<UText
editor={newRef.current.editor}
currentValue={props.value ?? ''}
/>
)}
{newRef?.current?.editor && (
<BoldText
editor={newRef.current.editor}
currentValue={props.value ?? ''}
/>
)}
/>
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
import clsx from 'clsx';
import { useModals } from '@mantine/modals';
import { TopTitle } from '@gitroom/frontend/components/launches/helpers/top.title.component';
import { array, boolean, object, string } from 'yup';

Check warning

Code scanning / ESLint

Disallow unused variables Warning

'array' is defined but never used.

Copilot Autofix AI 8 days ago

The best way to fix the problem is to remove the unused array import from the yup library. This will clean up the code and adhere to the ESLint rule that disallows unused variables. The change should be made in the file apps/frontend/src/components/settings/signatures.component.tsx on line 8.

Suggested changeset 1
apps/frontend/src/components/settings/signatures.component.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/frontend/src/components/settings/signatures.component.tsx b/apps/frontend/src/components/settings/signatures.component.tsx
--- a/apps/frontend/src/components/settings/signatures.component.tsx
+++ b/apps/frontend/src/components/settings/signatures.component.tsx
@@ -7,3 +7,3 @@
 import { TopTitle } from '@gitroom/frontend/components/launches/helpers/top.title.component';
-import { array, boolean, object, string } from 'yup';
+import { boolean, object, string } from 'yup';
 import { FormProvider, useForm } from 'react-hook-form';
EOF
@@ -7,3 +7,3 @@
import { TopTitle } from '@gitroom/frontend/components/launches/helpers/top.title.component';
import { array, boolean, object, string } from 'yup';
import { boolean, object, string } from 'yup';
import { FormProvider, useForm } from 'react-hook-form';
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
const modal = useModals();
const load = useCallback(async () => {
return (await fetch('/signatures')).json();
}, []);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has a missing dependency: 'fetch'. Either include it or remove the dependency array.
children: <AddOrRemoveSignature data={data} reload={mutate} />,
});
},
[mutate]

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has a missing dependency: 'modal'. Either include it or remove the dependency array.
modal.closeModal(modal.modals[modal.modals.length - 1].id);
reload();
},
[data, modal]

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has missing dependencies: 'fetch', 'reload', and 'toast'. Either include them or remove the dependency array.
const [showModal, setShowModal] = useState<any>(false);
const addSignature = useCallback(() => {
setShowModal(true);
}, [showModal]);

Check warning

Code scanning / ESLint

verifies the list of dependencies for Hooks like useEffect and similar Warning

React Hook useCallback has an unnecessary dependency: 'showModal'. Either exclude it or remove the dependency array.
@nevo-david nevo-david merged commit b4a8a13 into main Feb 12, 2025
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant