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

fix: Sentry issue loader issue for submit report page #3420

Merged
merged 3 commits into from
Jan 15, 2025
Merged

Conversation

arjunaj5
Copy link
Contributor

@arjunaj5 arjunaj5 commented Jan 13, 2025

Clickup

https://app.clickup.com/t/86cxndjxh

Code Coverage

Please add code coverage here

UI Preview

Please add screenshots for UI changes

Summary by CodeRabbit

  • New Features

    • Enhanced report submission process with loading indicators
    • Added conditional rendering for "Submit Report" button
    • Improved user feedback during report submission and resubmission
  • Bug Fixes

    • Prevented multiple report submissions by disabling buttons during loading state

Copy link

coderabbitai bot commented Jan 13, 2025

Walkthrough

In a superstar style, I'll break down these changes faster than a bullet! 🚀 The pull request enhances the report submission experience in the Fyle application. By adding loading states and conditional rendering for submit buttons, the code now provides smoother user interactions. The modifications ensure that users get clear visual feedback during report submissions, preventing multiple unnecessary clicks and improving overall interface responsiveness.

Changes

File Change Summary
src/app/fyle/my-view-report/my-view-report.page.html - Added [disabled] and loading attributes to submit buttons
- Implemented conditional rendering for "Submit Report" button
src/app/fyle/my-view-report/my-view-report.page.ts - Introduced submitReportLoader boolean property
- Updated resubmitReport and submitReport methods with loading state management

Suggested Reviewers

  • Chethan-Fyle
  • arjunaj5
  • Dimple16

Suggested Labels

size/XS

Possibly Related PRs

Poem

Buttons that dance with loading grace, 🕺
Submission flows at Rajini's pace! 💥
No more clicks that go astray,
UI magic rules the day! 🌟
Fyle's interface, stylishly neat,
User experience now complete! 👊

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 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.

@github-actions github-actions bot added the size/M Medium PR label Jan 13, 2025
[disabled]="submitReportLoader"
appFormButtonValidation
[loadingText]="'Resubmitting'"
[loading]="submitReportLoader"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call was going twice/thrice due to button not being disabled.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 09a3422 and a128350.

📒 Files selected for processing (2)
  • src/app/fyle/my-view-report/my-view-report.page.html (1 hunks)
  • src/app/fyle/my-view-report/my-view-report.page.ts (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/fyle/my-view-report/my-view-report.page.ts

[error] 441-441: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 457-457: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (4)
src/app/fyle/my-view-report/my-view-report.page.ts (2)

116-116: Mind it! The loading state property looks perfect!

The submitReportLoader boolean property is well-placed to handle loading states during report submission operations.


453-477: Kabali style implementation of submitReport!

The implementation is solid with:

  • Proper loading state management
  • Comprehensive error handling with Sentry
  • Clean success message handling
🧰 Tools
🪛 Biome (1.9.4)

[error] 457-457: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

src/app/fyle/my-view-report/my-view-report.page.html (2)

331-334: Style-ah implementation of the resubmit button!

The button implementation is complete with:

  • Loading state management
  • Form validation
  • User feedback through loading text

342-345: Thalaiva approves this submit button implementation!

The button implementation is perfect with:

  • Loading state management
  • Form validation
  • User feedback through loading text

Comment on lines +438 to +451
this.submitReportLoader = true;
this.spenderReportsService
.resubmit(this.reportId)
.pipe(finalize(() => (this.submitReportLoader = false)))
.subscribe(() => {
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report submitted successfully.`;
const message = `Report resubmitted successfully.`;
this.matSnackBar.openFromComponent(ToastMessageComponent, {
...this.snackbarProperties.setSnackbarProperties('success', { message }),
panelClass: ['msb-success-with-camera-icon'],
});
this.trackingService.showToastMessage({ ToastContent: message });
},
error: (error) => {
// Capture error with additional details in Sentry
Sentry.captureException(error, {
extra: {
reportId: this.reportId,
errorResponse: error,
},
});
},
});
});
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Superstar implementation of resubmitReport, but let's make it even better!

The loading state management is implemented well with proper cleanup. However, we should handle potential errors to prevent silent failures.

Add error handling like this:

 resubmitReport(): void {
   this.submitReportLoader = true;
   this.spenderReportsService
     .resubmit(this.reportId)
     .pipe(finalize(() => (this.submitReportLoader = false)))
-    .subscribe(() => {
+    .subscribe({
+      next: () => {
         this.router.navigate(['/', 'enterprise', 'my_reports']);
         const message = `Report resubmitted successfully.`;
         this.matSnackBar.openFromComponent(ToastMessageComponent, {
           ...this.snackbarProperties.setSnackbarProperties('success', { message }),
           panelClass: ['msb-success-with-camera-icon'],
         });
         this.trackingService.showToastMessage({ ToastContent: message });
+      },
+      error: (error) => {
+        Sentry.captureException(error, {
+          extra: {
+            reportId: this.reportId,
+            errorResponse: error,
+          },
+        });
+      },
+    });
 }

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Biome (1.9.4)

[error] 441-441: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 09a3422 and a128350.

📒 Files selected for processing (2)
  • src/app/fyle/my-view-report/my-view-report.page.html (1 hunks)
  • src/app/fyle/my-view-report/my-view-report.page.ts (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/app/fyle/my-view-report/my-view-report.page.ts

[error] 441-441: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 457-457: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (3)
src/app/fyle/my-view-report/my-view-report.page.ts (1)

116-116: Mind it! This is a superstar addition!

The submitReportLoader property is a powerful addition that prevents multiple report submissions, just like how I prevent villains from causing trouble!

src/app/fyle/my-view-report/my-view-report.page.html (2)

331-334: Marana Mass! These button enhancements are perfect!

The combination of disabled state and loading indicator will prevent multiple submissions like a boss!


342-345: Mind it! The consistency in button behavior is outstanding!

Both submit and resubmit buttons now follow the same powerful pattern. This is how we maintain style consistency!

Comment on lines +438 to +451
this.submitReportLoader = true;
this.spenderReportsService
.resubmit(this.reportId)
.pipe(finalize(() => (this.submitReportLoader = false)))
.subscribe(() => {
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report submitted successfully.`;
const message = `Report resubmitted successfully.`;
this.matSnackBar.openFromComponent(ToastMessageComponent, {
...this.snackbarProperties.setSnackbarProperties('success', { message }),
panelClass: ['msb-success-with-camera-icon'],
});
this.trackingService.showToastMessage({ ToastContent: message });
},
error: (error) => {
// Capture error with additional details in Sentry
Sentry.captureException(error, {
extra: {
reportId: this.reportId,
errorResponse: error,
},
});
},
});
});
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Style! The loading state management is stylish, but needs a small fix!

The implementation is solid, but there's a style issue with the finalize operator. Let me show you the Rajini way to fix it!

-      .pipe(finalize(() => (this.submitReportLoader = false)))
+      .pipe(
+        finalize(() => {
+          this.submitReportLoader = false;
+        })
+      )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.submitReportLoader = true;
this.spenderReportsService
.resubmit(this.reportId)
.pipe(finalize(() => (this.submitReportLoader = false)))
.subscribe(() => {
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report submitted successfully.`;
const message = `Report resubmitted successfully.`;
this.matSnackBar.openFromComponent(ToastMessageComponent, {
...this.snackbarProperties.setSnackbarProperties('success', { message }),
panelClass: ['msb-success-with-camera-icon'],
});
this.trackingService.showToastMessage({ ToastContent: message });
},
error: (error) => {
// Capture error with additional details in Sentry
Sentry.captureException(error, {
extra: {
reportId: this.reportId,
errorResponse: error,
},
});
},
});
});
}
this.submitReportLoader = true;
this.spenderReportsService
.resubmit(this.reportId)
.pipe(
finalize(() => {
this.submitReportLoader = false;
})
)
.subscribe(() => {
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report resubmitted successfully.`;
this.matSnackBar.openFromComponent(ToastMessageComponent, {
...this.snackbarProperties.setSnackbarProperties('success', { message }),
panelClass: ['msb-success-with-camera-icon'],
});
this.trackingService.showToastMessage({ ToastContent: message });
});
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 441-441: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Comment on lines +453 to +477
submitReport(): void {
this.submitReportLoader = true;
this.spenderReportsService
.submit(this.reportId)
.pipe(finalize(() => (this.submitReportLoader = false)))
.subscribe({
next: () => {
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report submitted successfully.`;
this.matSnackBar.openFromComponent(ToastMessageComponent, {
...this.snackbarProperties.setSnackbarProperties('success', { message }),
panelClass: ['msb-success-with-camera-icon'],
});
this.trackingService.showToastMessage({ ToastContent: message });
},
error: (error) => {
// Capture error with additional details in Sentry
Sentry.captureException(error, {
extra: {
reportId: this.reportId,
errorResponse: error,
},
});
},
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Thalaiva approves this implementation with a small style suggestion!

The error handling with Sentry is top-notch, like my action sequences! But let's fix the finalize operator style.

-      .pipe(finalize(() => (this.submitReportLoader = false)))
+      .pipe(
+        finalize(() => {
+          this.submitReportLoader = false;
+        })
+      )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
submitReport(): void {
this.submitReportLoader = true;
this.spenderReportsService
.submit(this.reportId)
.pipe(finalize(() => (this.submitReportLoader = false)))
.subscribe({
next: () => {
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report submitted successfully.`;
this.matSnackBar.openFromComponent(ToastMessageComponent, {
...this.snackbarProperties.setSnackbarProperties('success', { message }),
panelClass: ['msb-success-with-camera-icon'],
});
this.trackingService.showToastMessage({ ToastContent: message });
},
error: (error) => {
// Capture error with additional details in Sentry
Sentry.captureException(error, {
extra: {
reportId: this.reportId,
errorResponse: error,
},
});
},
});
submitReport(): void {
this.submitReportLoader = true;
this.spenderReportsService
.submit(this.reportId)
.pipe(
finalize(() => {
this.submitReportLoader = false;
})
)
.subscribe({
next: () => {
this.router.navigate(['/', 'enterprise', 'my_reports']);
const message = `Report submitted successfully.`;
this.matSnackBar.openFromComponent(ToastMessageComponent, {
...this.snackbarProperties.setSnackbarProperties('success', { message }),
panelClass: ['msb-success-with-camera-icon'],
});
this.trackingService.showToastMessage({ ToastContent: message });
},
error: (error) => {
// Capture error with additional details in Sentry
Sentry.captureException(error, {
extra: {
reportId: this.reportId,
errorResponse: error,
},
});
},
});
🧰 Tools
🪛 Biome (1.9.4)

[error] 457-457: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

Copy link

Unit Test Coverage % values
Statements 95.96% ( 19300 / 20111 )
Branches 91.11% ( 10660 / 11700 )
Functions 94.25% ( 5737 / 6087 )
Lines 96% ( 18426 / 19193 )

@arjunaj5 arjunaj5 merged commit d3fdf9e into master Jan 15, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Medium PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants