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 deprecations in analytics, billing & account-settings #1481

Conversation

future-pirate-king
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Oct 28, 2024

Walkthrough

This pull request introduces several changes across multiple components in the application. Key modifications include the adjustment of methods for handling personal tokens and multi-factor authentication, the addition of a new registry entry for a date picker component, and updates to subscription handling in the organization billing component. Additionally, there are changes to the template rendering of tables, affecting their styling. The overall structure and functionality of the components remain intact, with no significant alterations to exported or public entities.

Changes

File Path Change Summary
app/components/account-settings/developer-settings/personal-token-list/index.ts Modified personalTokenList getter to use slice() instead of toArray().
app/components/account-settings/security/multi-factor-auth/index.ts Replaced findBy with find in computed properties (isMFAEnabled, isEmailMFAEnabled, isAppMFAEnabled) for clarity in condition checking.
app/components/ak-date-picker/calendar-nav/index.ts Added a new export declaration for AkDatePickerCalendarNavComponent in the registry.
app/components/ak-date-picker/index.hbs Simplified instantiation of CalendarComponent and updated @navComponent property for dynamic resolution.
app/components/organization-billing/index.ts Added subscriptionList getter; updated subscription, subscriptionCount, and sortedPlans getters for better state management.
app/components/organization-billing/invoice-list/index.hbs Updated @variant attribute of AkTable from 'bordered' to 'full-bordered'.
app/components/organization-billing/subscription/index.hbs Changed @variant attribute of AkTable from 'bordered' to 'full-bordered' within a conditional block.
app/models/analytics/recent-issue.ts Updated vulnerability property to use AsyncBelongsTo type, indicating an asynchronous relationship.

Possibly related PRs

Suggested reviewers

  • Praseetha-KR
  • cosmosgenius
  • Yibaebi

Poem

🐰 In the garden of code, we hop and play,
With tokens and tables, we brighten the day.
From toArray to slice, our changes are neat,
In the world of Ember, our work is a treat!
So let’s celebrate, with a joyful cheer,
For each little change brings us closer, my dear! 🌼


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

cloudflare-workers-and-pages bot commented Oct 28, 2024

Deploying irenestaging with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7bba24d
Status: ✅  Deploy successful!
Preview URL: https://310fb04c.irenestaging.pages.dev
Branch Preview URL: https://pd-1559-fix-deprecation-anal.irenestaging.pages.dev

View logs

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: 3

🧹 Outside diff range and nitpick comments (6)
app/components/organization-billing/index.ts (1)

46-48: LGTM! Consider adding return type annotation.

The getter properly handles immutability and null cases. For better type safety, consider adding an explicit return type annotation.

-  get subscriptionList() {
+  get subscriptionList(): SubscriptionModel[] {
     return this.subscriptions?.slice() || [];
   }
app/components/account-settings/security/multi-factor-auth/index.ts (5)

75-75: Consider a more concise implementation.

The double negation could be replaced with Boolean conversion for better readability.

-    return !!this.mfas.records?.find((it) => it.enabled === true);
+    return Boolean(this.mfas.records?.find((it) => it.enabled === true));

Line range hint 1-1000: Consider breaking down this large component.

This component is handling multiple responsibilities (email MFA, app MFA, switching between methods, disabling MFA) and has grown quite large. Consider splitting it into smaller, focused sub-components:

  • EmailMFAHandler
  • AppMFAHandler
  • MFASwitcher
  • MFADisabler

This would improve maintainability and testability.


Line range hint 32-45: Consider using an enum for modal states.

The component uses multiple boolean flags to track modal states, which could lead to inconsistent states. Consider using an enum to represent the modal state:

enum ModalState {
  None,
  EmailEnable,
  EmailSendConfirm,
  EmailOTPEnter,
  AppEnable,
  SwitchToEmail,
  SwitchToEmailConfirm,
  SwitchToEmailAppVerify,
  SwitchToEmailEmailVerify
  // ... other states
}

export default class AccountSettingsSecurityMultiFactorAuthComponent extends Component.extend(Evented) {
  @tracked modalState: ModalState = ModalState.None;
  // ...
}

Line range hint 149-149: Remove debug statements from production code.

Debug statements should be removed or wrapped in development-only conditions.

-    debug('noMFAEnableEmail: In side otp loop');
+    // Use appropriate logging service or remove in production

Also applies to: 186-186, 428-428, 471-471, 651-651


Line range hint 167-184: Standardize error handling.

Error handling patterns vary across different methods. Consider creating a shared error handling utility:

private handleMFAError(error: AdapterError, defaultMessage: string = this.tsomethingWentWrong): void {
  const errorObj = error.payload || {};
  const otpMsg = errorObj.otp?.[0];
  
  if (otpMsg) {
    this.notify.error(this.tInvalidOTP);
  } else {
    this.notify.error(defaultMessage);
  }
}

Also applies to: 297-314, 520-537, 744-761

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 87fc4bb and c4a5004.

📒 Files selected for processing (8)
  • app/components/account-settings/developer-settings/personal-token-list/index.ts (1 hunks)
  • app/components/account-settings/security/multi-factor-auth/index.ts (1 hunks)
  • app/components/ak-date-picker/calendar-nav/index.ts (1 hunks)
  • app/components/ak-date-picker/index.hbs (2 hunks)
  • app/components/organization-billing/index.ts (2 hunks)
  • app/components/organization-billing/invoice-list/index.hbs (1 hunks)
  • app/components/organization-billing/subscription/index.hbs (1 hunks)
  • app/models/analytics/recent-issue.ts (1 hunks)
🔇 Additional comments (9)
app/models/analytics/recent-issue.ts (1)

1-2: LGTM! Import changes follow TypeScript best practices.

The changes properly separate runtime and type-level imports, which is the recommended approach for TypeScript projects.

app/components/organization-billing/invoice-list/index.hbs (1)

9-9: LGTM! Verify deprecation documentation.

The change from 'bordered' to 'full-bordered' variant appears to be addressing a deprecation in the AkTable component.

Let's verify if this change is part of documented deprecations:

app/components/ak-date-picker/calendar-nav/index.ts (1)

38-38: LGTM! Consider documenting deprecation timeline.

The addition of the kebab-case path format (ak-date-picker/calendar-nav) alongside the existing double-colon format (AkDatePicker::CalendarNav) is a good practice for deprecation handling. This allows for a gradual migration while maintaining backward compatibility.

Consider adding a comment indicating when the :: syntax will be deprecated, helping other developers plan their migrations.

Let's verify the component usage in templates:

✅ Verification successful

Component registration is correct and follows migration pattern

The verification confirms that:

  • The new kebab-case path (ak-date-picker/calendar-nav) is correctly referenced in the main component's navComponent getter
  • The component is properly registered in Glint for both syntaxes
  • All current template usage is using the AkDatePicker syntax, indicating this is a forward-compatible change for future migrations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check current usage patterns of the calendar nav component
# This helps ensure we know which syntax is currently in use

# Search for both old and new component invocation syntaxes
echo "Checking component usage patterns..."
rg -g '*.hbs' -A 2 'AkDatePicker::CalendarNav|ak-date-picker/calendar-nav'

Length of output: 159


Script:

#!/bin/bash
# Let's try a broader search to understand the component usage patterns
# First, search for any ak-date-picker related imports or registrations
echo "Checking component registrations and imports..."
rg -g '*.{ts,js}' "AkDatePickerCalendarNav|ak-date-picker/calendar-nav"

# Also search for potential template usage with more variations
echo -e "\nChecking template usage with broader patterns..."
rg -g '*.hbs' "AkDatePicker|ak-date-picker"

# Look for any Glint registry entries related to date picker
echo -e "\nChecking Glint registry entries..."
rg -g '*.{ts,js}' "'ak-date-picker|AkDatePicker" -A 2 -B 2

Length of output: 11260

app/components/organization-billing/subscription/index.hbs (1)

3-3: LGTM! Verify similar components for consistency.

The update from 'bordered' to 'full-bordered' appears to address the deprecation correctly.

Let's verify if other table components need similar updates:

✅ Verification successful

No other tables using deprecated 'bordered' variant found

The search results confirm that no other tables in the codebase are using the deprecated 'bordered' variant. The AkTable components found use either 'full-bordered' or 'semi-bordered' variants. The change from 'bordered' to 'full-bordered' in this file is consistent with the variants used throughout the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for other tables that might need the variant update
# Test: Look for AkTable components still using the deprecated 'bordered' variant
rg -g '*.hbs' "AkTable.*@variant='bordered'"

Length of output: 52


Script:

#!/bin/bash
# Let's try a broader search to find all AkTable variant usages
rg -g '*.hbs' "@variant=['\"].*['\"]" -A 1 -B 1

Length of output: 206500


Script:

#!/bin/bash
# Also search for any AkTable components to ensure we're not missing any patterns
rg -g '*.hbs' "<AkTable" -A 2 -B 1

Length of output: 15286

app/components/organization-billing/index.ts (3)

54-56: LGTM! Good simplification.

The change improves readability and efficiency by leveraging the subscriptionList getter instead of duplicating the slice logic.


66-68: Verify the type safety of sortBy method.

While the change correctly ensures immutability by copying before sorting, let's verify the type safety of the sortBy method which appears to be an Ember extension.

#!/bin/bash
# Description: Check the origin and type definitions of sortBy

# Test 1: Look for sortBy type definitions
rg -t ts "sortBy" types/

# Test 2: Check for other usages of sortBy in the codebase
ast-grep --pattern 'sortBy($$$)'

50-52: Verify handling of undefined subscription.

The change from firstObject to array indexing is good, but ensure that consumers of this getter properly handle the undefined case when there are no subscriptions.

✅ Verification successful

No issues with undefined subscription handling

The code properly handles the case when there is no subscription:

  • The parent component uses hasSubscription guard before rendering the subscription component
  • The subscription component is designed to handle undefined subscription through optional chaining
  • The getter hasSubscription checks subscriptionCount > 0 before using the subscription
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how the undefined subscription case is handled in the codebase

# Test: Search for direct usage of the subscription getter
rg -t ts -t hbs "subscription\s*[^L]" app/components/organization-billing/

Length of output: 59


Script:

#!/bin/bash
# Let's try a more comprehensive search to find usages of the subscription getter

# Search for subscription getter usage in TypeScript files
rg -t ts "\.subscription\b" app/components/organization-billing/

# Search in template files
rg -t hbs "subscription" app/components/organization-billing/

# Also check the component's template directly
fd "organization-billing.hbs" app/components/ --exec cat {}

Length of output: 1150


Script:

#!/bin/bash
# Let's check how the subscription component handles undefined values

# Check the subscription component's TypeScript implementation
cat app/components/organization-billing/subscription/index.ts

# Check if there are any conditional checks before using the subscription in the parent component
cat app/components/organization-billing/index.hbs

Length of output: 4102


Script:

#!/bin/bash
# Let's check the implementation of hasSubscription and hasNoSubscription getters

cat app/components/organization-billing/index.ts

Length of output: 2927

app/components/ak-date-picker/index.hbs (2)

1-1: LGTM! Modern approach to component instantiation.

The direct usage of the component helper is cleaner and follows current Ember.js best practices.


29-29: LGTM! Enhanced component resolution.

Using the component helper for @navComponent improves flexibility by supporting both string names and component definitions.

Copy link

cypress bot commented Oct 28, 2024

Irene    Run #513

Run Properties:  status check failed Failed #513  •  git commit 11c7dc21f6 ℹ️: Merge c4a50044b833bc972bff15214244496839042596 into 87fc4bb38f54580b73a226ccf1ae...
Project Irene
Branch Review PD-1559-fix-deprecation-analytics-billing-ac-settings
Run status status check failed Failed #513
Run duration 13m 32s
Commit git commit 11c7dc21f6 ℹ️: Merge c4a50044b833bc972bff15214244496839042596 into 87fc4bb38f54580b73a226ccf1ae...
Committer Sam David
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 31
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

Tests for review

@future-pirate-king future-pirate-king force-pushed the PD-1559-fix-deprecation-analytics-billing-ac-settings branch from c4a5004 to 7bba24d Compare November 7, 2024 05:33
Copy link

sonarqubecloud bot commented Nov 7, 2024

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.

2 participants