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: update login error flow and fix redirect url #1117

Merged

Conversation

JustARatherRidiculouslyLongUsername
Copy link
Contributor

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername commented Dec 12, 2024

Clickup

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

Summary by CodeRabbit

  • New Features

    • Updated integration confirmation dialog to reflect Business Central instead of QuickBooks Online.
    • Enhanced error handling for Business Central integration.
  • Bug Fixes

    • Corrected navigation paths and visibility conditions related to the Business Central onboarding process.

Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Walkthrough

The changes in this pull request primarily involve renaming and updating visibility conditions in the business-central-onboarding-landing component to reflect the Business Central integration. The boolean property isIncorrectQBOConnectedDialogVisible has been renamed to isIncorrectBCConnectedDialogVisible, and this change is applied in both the HTML template and the TypeScript class. Additionally, routing paths and error handling logic have been adjusted to align with the Business Central integration, ensuring consistency in user interface and functionality.

Changes

File Change Summary
src/app/integrations/business-central/business-central-onboarding/business-central-onboarding-landing/business-central-onboarding-landing.component.html Updated visibility conditions and bindings for isIncorrectBCConnectedDialogVisible in the integration confirmation dialog.
src/app/integrations/business-central/business-central-onboarding/business-central-onboarding-landing/business-central-onboarding-landing.component.ts Renamed isIncorrectQBOConnectedDialogVisible to isIncorrectBCConnectedDialogVisible, updated routing and error handling logic accordingly.

Possibly related PRs

Suggested labels

deploy, size/S

Suggested reviewers

  • ashwin1111

Poem

In the land of Business Central bright,
A dialog change brings new delight.
From QBO to BC, we now align,
With clearer paths, our code will shine.
Hops of joy, let errors flee,
For onboarding's smooth, as smooth can be! 🐇✨


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. (Experiment)
  • @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.

Copy link
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (4)
src/app/integrations/business-central/business-central-onboarding/business-central-onboarding-landing/business-central-onboarding-landing.component.html (1)

Line range hint 9-15: Consider enhancing the error message clarity

While the error message is functional, it could be more specific about what constitutes a "different" account and what "same" means in this context.

Consider updating the context text to be more specific:

-    [contextText]="'You had previously set up the integration with a different Dynamic 365 Business Central account. Please choose the same to restore the settings'"
+    [contextText]="'This integration was previously set up with a different Dynamics 365 Business Central organization/company. Please sign in with the same organization/company account to restore your integration settings'"
src/app/integrations/business-central/business-central-onboarding/business-central-onboarding-landing/business-central-onboarding-landing.component.ts (3)

48-51: Consider using kebab-case for route paths

The route path uses underscore ('business_central') which is inconsistent with Angular's convention of using kebab-case for routes.

-      this.router.navigate([`/integrations/business_central/onboarding/landing`]);
+      this.router.navigate(['/integrations/business-central/onboarding/landing']);

Also, consider destructuring the hasAccepted property from the data parameter for better type safety:

-  acceptWarning(data: ConfigurationWarningOut): void {
-    this.isIncorrectBCConnectedDialogVisible = false;
-    if (data.hasAccepted) {
+  acceptWarning({ hasAccepted }: ConfigurationWarningOut): void {
+    this.isIncorrectBCConnectedDialogVisible = false;
+    if (hasAccepted) {

Line range hint 67-80: Improve error handling type safety

The error handling could benefit from more specific typing. Consider creating an interface for the error response:

interface BusinessCentralError {
  message: string;
  code?: string;
  // Add other relevant error fields
}

// Then update the error handling:
}, (error: { error: BusinessCentralError }) => {
  const errorMessage = error.error?.message ?? 'Failed to connect to Dynamic 365 Business Central. Please try again';

Consider using error constants and standardize error handling

The error message 'Please choose the correct Dynamic 365 Business Central account' is used in multiple components but isn't defined as a constant. Additionally, there are inconsistencies in error message handling across the Business Central integration:

  • business-central-onboarding-landing.component.ts: Direct string comparison
  • business-central-onboarding-connector.component.ts: Direct string comparison
  • Other components use different error message formats (e.g., "Failed to connect to Dynamic 365 Business Central...")

Create a shared error constants file for Business Central integration:

// business-central-error.constants.ts
export const BC_ERRORS = {
  INCORRECT_ACCOUNT: 'Please choose the correct Dynamic 365 Business Central account',
  CONNECTION_FAILED: 'Failed to connect to Dynamic 365 Business Central. Please try again'
};
🔗 Analysis chain

Line range hint 75-80: Consider using error codes instead of string comparison

Using hardcoded error message strings for flow control can be fragile. Consider using error codes or constants instead.

+  private readonly ERROR_INCORRECT_BC_ACCOUNT = 'Please choose the correct Dynamic 365 Business Central account';
+
   // In error handling
-      if (errorMessage === 'Please choose the correct Dynamic 365 Business Central account') {
+      if (errorMessage === this.ERROR_INCORRECT_BC_ACCOUNT) {

Let's verify the consistency of this error message across the codebase:


Let's also check the service layer where this error might originate:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for variations of the Business Central account error message
rg -i "choose.*business.*central.*account" --type ts
rg -i "correct.*business.*central.*account" --type ts

Length of output: 1102


Script:

#!/bin/bash
# Let's check if there's a shared constant or enum for this error message
ast-grep --pattern 'const ERROR_INCORRECT_BC_ACCOUNT = "Please choose the correct Dynamic 365 Business Central account"'
ast-grep --pattern 'enum $_ { $$$ }'
rg -i "business.*central.*error" --type ts

Length of output: 57392


Script:

#!/bin/bash
# Look for service files related to Business Central
fd -e ts "business-central.*service"

Length of output: 1780


Script:

#!/bin/bash
# Let's check the business central auth service for error handling
cat src/app/core/services/business-central/business-central-core/business-central-auth.service.ts

# Also check the connector service where this error might originate
cat src/app/core/services/business-central/business-central-configuration/business-central-connector.service.ts

Length of output: 3001


Script:

#!/bin/bash
# Let's check if this error message is defined as a constant anywhere in the codebase
rg -i "const.*ERROR_INCORRECT_BC_ACCOUNT" --type ts

# Also check if there are any error message constants defined in any business central related files
fd -e ts "business-central" -x cat {} | grep -i "const.*error.*="

Length of output: 403

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d45a9b5 and 6c78d53.

📒 Files selected for processing (2)
  • src/app/integrations/business-central/business-central-onboarding/business-central-onboarding-landing/business-central-onboarding-landing.component.html (1 hunks)
  • src/app/integrations/business-central/business-central-onboarding/business-central-onboarding-landing/business-central-onboarding-landing.component.ts (3 hunks)
🔇 Additional comments (3)
src/app/integrations/business-central/business-central-onboarding/business-central-onboarding-landing/business-central-onboarding-landing.component.html (2)

1-1: LGTM! Correctly renamed QBO reference to BC

The visibility condition has been properly updated to use Business Central terminology while maintaining the correct negation logic.


2-8: Verify routing paths consistency

The template contains several routing paths and integration-specific values. Let's verify their consistency across the codebase.

✅ Verification successful

Routing paths and integration assets are consistent

The verification shows that:

  • The routing path business_central/onboarding/connector is consistently used across components and services
  • The Business Central logo asset path assets/logos/BusinessCentral-logo.svg is correctly referenced
  • The navigation flow is properly maintained in the token guard, onboarding service, and component implementations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify routing paths and integration names consistency

# Check for routing path references
rg -A 2 "business_central/onboarding/connector"

# Check for Business Central related constants and configurations
rg "BusinessCentral-logo\.svg"

Length of output: 4845

src/app/integrations/business-central/business-central-onboarding/business-central-onboarding-landing/business-central-onboarding-landing.component.ts (1)

36-36: LGTM! Property rename improves code clarity

The rename from isIncorrectQBOConnectedDialogVisible to isIncorrectBCConnectedDialogVisible better reflects its usage with Business Central integration.

Copy link

Unit Test Coverage % values
Statements 34.04% ( 4200 / 12338 )
Branches 27.65% ( 1209 / 4372 )
Functions 26.68% ( 922 / 3455 )
Lines 34.2% ( 4132 / 12081 )

@JustARatherRidiculouslyLongUsername JustARatherRidiculouslyLongUsername merged commit 4973a8a into bc-beta-bugfixes Dec 12, 2024
5 checks passed
JustARatherRidiculouslyLongUsername added a commit that referenced this pull request Dec 12, 2024
* fix: initialize chart of accounts multiselect when there is no api response (#1110)

* fix: remove the posted at date option for ccc expenses grouped by report (#1105)

* fix: update login error flow and fix redirect url (#1117)

* fix: restrict JE modules to group by expense only (#1113)

* fix: restrict JE modules to group by expense only

* fix: add a default bank account field for CCC expenses (#1114)

* fix: remove validation temporarily (#1111)

* fix: add a default bank account field for CCC expenses

* fix: add missing options to bank accounts on page init

* fix: dynamic content for xero customize settings (#1112)

* fix: update sublabel key to avoid build fail (#1116)

* fix: Prod fixes of QBD direct (#1118)

* fix bugs (#1119)

* refactor: capitalization

* fix: only ccc exports not being saved (#1121)

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>

---------

Co-authored-by: Ashwin Thanaraj <[email protected]>
Co-authored-by: Nilesh Pant <[email protected]>
Co-authored-by: Dhaarani <[email protected]>
Co-authored-by: Anish Kr Singh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Extra Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants