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

feat(application-system): Remove phone input feature flag #16372

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

Toti91
Copy link
Member

@Toti91 Toti91 commented Oct 11, 2024

Remove phone input feature flag

Attach a link to issue if relevant

What

Remove the feature flag for selecting other countries than iceland
Make selecting other countries an "opt-in" feature with a new prop enableCountrySelector

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced phone input fields to support country selection with the new enableCountrySelector property.
  • Bug Fixes

    • Removed the outdated disableDropdown property to streamline phone field functionality.
  • Documentation

    • Updated interface definitions to reflect changes in phone field properties across various forms and components.

@Toti91 Toti91 requested review from a team as code owners October 11, 2024 14:35
@Toti91 Toti91 added the automerge Merge this PR as soon as all checks pass label Oct 11, 2024
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes in this pull request primarily involve the modification of the buildPhoneField function across various files in the application. The parameter disableDropdown has been replaced with enableCountrySelector, enhancing the configurability of phone fields to allow for country selection. This adjustment is reflected in the PhoneField interface and the PhoneFormField component, ensuring consistency across the application. The overall structure and logic of the affected sections remain unchanged.

Changes

File Path Change Summary
libs/application/core/src/lib/fieldBuilders.ts Updated buildPhoneField function to replace disableDropdown with enableCountrySelector.
libs/application/templates/estate/src/forms/Sections/announcerInfo.ts Updated buildPhoneField calls, replacing disableDropdown with enableCountrySelector.
libs/application/templates/estate/src/forms/Sections/representative.ts Removed disableDropdown property in buildPhoneField call.
libs/application/templates/inheritance-report/src/forms/sections/applicant.ts Updated buildPhoneField calls, replacing disableDropdown with enableCountrySelector.
libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts Updated buildPhoneField calls, replacing disableDropdown with enableCountrySelector.
libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritanceExecutor.ts Updated buildPhoneField calls, replacing disableDropdown with enableCountrySelector.
libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts Updated buildPhoneField calls, replacing disableDropdown with enableCountrySelector.
libs/application/templates/signature-collection/presidential-list-creation/src/forms/Draft.ts Updated buildPhoneField calls, replacing disableDropdown with enableCountrySelector.
libs/application/types/src/lib/Fields.ts Updated PhoneField interface to replace disableDropdown with enableCountrySelector.
libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx Updated PhoneFormField component to replace disableDropdown with enableCountrySelector.

Possibly related PRs

  • fix(estate): foreign phone numbers #15826: This PR modifies the announcerInfo section to change the buildPhoneField function call, replacing disableDropdown with enableCountrySelector, which directly relates to the changes made in the main PR.
  • fix(efs): Set up for separate feature flag #15974: This PR includes changes in the applicant section where buildTextField is replaced with buildPhoneField, indicating a shift to using the updated phone field configuration, which aligns with the main PR's modifications.
  • feat(passport-application): Þjóðskrá as fixed deliveryaddress #16272: This PR introduces a fixed delivery address in the passport application, which may involve changes to how phone fields are handled in the context of delivery information, potentially connecting to the updates in the main PR regarding phone field configuration.

Suggested labels

autoupdate

Suggested reviewers

  • rafnarnason
  • kksteini

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.

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

🧹 Outside diff range and nitpick comments (4)
libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx (3)

35-35: LGTM! Consider updating the Props interface for clarity.

The addition of enableCountrySelector with a default value of false aligns well with the PR objective of making country selection an opt-in feature. This maintains backwards compatibility while allowing for the new functionality.

Consider updating the Props interface to explicitly include enableCountrySelector as an optional boolean property. This would improve type safety and make the component's API more clear to other developers. You can add the following line to the Props interface:

enableCountrySelector?: boolean;

69-69: LGTM! Consider renaming the prop for clarity.

The replacement of the feature flag logic with disableDropdown={!enableCountrySelector} simplifies the component and aligns with the PR objectives. This change makes the component more self-contained and easier to understand.

To improve clarity, consider renaming the disableDropdown prop in the PhoneInputController component to enableDropdown. This would allow you to pass the enableCountrySelector value directly without negation:

enableDropdown={enableCountrySelector}

This change would make the code more intuitive and reduce the cognitive load of understanding the inverted logic.


Line range hint 1-82: LGTM! Consider optimizing imports for better tree-shaking.

The PhoneFormField component is well-structured, uses TypeScript effectively, and is designed for reusability across different NextJS apps. It adheres to the coding guidelines for files in the libs directory.

To further improve tree-shaking and bundling, consider updating the import from '@island.is/island-ui/core' to only import the specific component you need:

import { Box } from '@island.is/island-ui/core/Box'

This change can help reduce the bundle size by ensuring only the necessary components are imported.

libs/application/templates/estate/src/forms/Sections/announcerInfo.ts (1)

71-71: LGTM! Consider adding a comment for clarity.

The change from disableDropdown: false to enableCountrySelector: true aligns with the PR objective of making country selection an "opt-in" feature. This modification enhances the configurability of the phone field component.

Consider adding a brief comment explaining the purpose of enableCountrySelector: true to improve code readability:

 buildPhoneField({
   id: 'applicant.phone',
   title: m.phone,
   width: 'half',
   required: true,
+  // Enable country selection for phone input
   enableCountrySelector: true,
   defaultValue: (application: Application) => {
     // ... (rest of the code)
   },
 }),
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c369d03 and 7268b31.

📒 Files selected for processing (10)
  • libs/application/core/src/lib/fieldBuilders.ts (2 hunks)
  • libs/application/templates/estate/src/forms/Sections/announcerInfo.ts (1 hunks)
  • libs/application/templates/estate/src/forms/Sections/representative.ts (0 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/applicant.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts (1 hunks)
  • libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritanceExecutor.ts (1 hunks)
  • libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts (0 hunks)
  • libs/application/templates/signature-collection/presidential-list-creation/src/forms/Draft.ts (0 hunks)
  • libs/application/types/src/lib/Fields.ts (1 hunks)
  • libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx (2 hunks)
💤 Files with no reviewable changes (3)
  • libs/application/templates/estate/src/forms/Sections/representative.ts
  • libs/application/templates/signature-collection/parliamentary-list-creation/src/forms/Draft.ts
  • libs/application/templates/signature-collection/presidential-list-creation/src/forms/Draft.ts
🧰 Additional context used
📓 Path-based instructions (7)
libs/application/core/src/lib/fieldBuilders.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/estate/src/forms/Sections/announcerInfo.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/inheritance-report/src/forms/sections/applicant.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritanceExecutor.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/types/src/lib/Fields.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (4)
libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/applicant.ts (1)

32-32: Change aligns with PR objectives, but consider potential impacts

The modification from disableDropdown: false to enableCountrySelector: true aligns with the PR objective of making country selection an "opt-in" feature. This change effectively removes the feature flag and enables the country selector by default.

However, please consider the following points:

  1. This change might affect existing implementations that relied on the default behavior. Ensure that all consumers of this component are aware of and prepared for this change.
  2. The new property name enableCountrySelector is more descriptive and better reflects the functionality, which is a good improvement.

To ensure this change doesn't introduce unexpected behavior in other parts of the application, please run the following verification:

✅ Verification successful

Verification Successful: No issues found

The change from disableDropdown: false to enableCountrySelector: true in applicant.ts aligns with the PR objective of making country selection an "opt-in" feature. The shell script results confirm that other usages of buildPhoneField are compatible with this change and do not require additional updates.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of buildPhoneField to ensure they are updated or compatible with the new property
rg --type typescript 'buildPhoneField\(' -A 5 -g '!**/applicant.ts'

Length of output: 104


Script:

#!/bin/bash
# Search for other usages of buildPhoneField to ensure they are updated or compatible with the new property
rg 'buildPhoneField\(' -A 5 -g '*.ts' -g '*.tsx' --iglob '!**/applicant.ts'

Length of output: 26595

libs/application/templates/inheritance-report/src/forms/sections/prepaidInheritance/inheritanceExecutor.ts (2)

Line range hint 1-89: Adherence to coding guidelines confirmed

This file adheres to the coding guidelines for libs/**/*:

  1. The inheritanceExecutor section is reusable across different NextJS apps.
  2. TypeScript is used effectively for defining props and types.
  3. The code structure supports efficient tree-shaking and bundling.

44-44: LGTM: Change aligns with PR objectives

The modification from disableDropdown: true to enableCountrySelector: true in the buildPhoneField function call aligns with the PR objectives. This change implements the new "opt-in" feature for selecting countries other than Iceland for phone input, as described in the PR summary.

To ensure consistency across the codebase, let's verify if this change has been applied to all relevant buildPhoneField calls:

libs/application/core/src/lib/fieldBuilders.ts (1)

319-319: LGTM! Verify usage across the codebase.

The change from disableDropdown to enableCountrySelector improves the API's clarity and aligns with the PR objective of making the country selector an "opt-in" feature. This is a positive change in terms of naming convention and usability.

To ensure this change doesn't break existing implementations, please run the following script to check for any occurrences of disableDropdown in phone field usage:

If any results are found, they will need to be updated to use enableCountrySelector instead.

Also applies to: 329-329

✅ Verification successful

Verification Successful: No occurrences of 'disableDropdown' found in phone field usage.

This confirms that the change from disableDropdown to enableCountrySelector does not impact other parts of the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of 'disableDropdown' in phone fields
rg --type typescript --type javascript 'buildPhoneField.*disableDropdown'

Length of output: 110


Script:

#!/bin/bash
# Search for usage of 'disableDropdown' in phone fields within TypeScript and JavaScript files
rg --type ts --type js 'buildPhoneField.*disableDropdown'

Length of output: 59

Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 36.72%. Comparing base (d907f83) to head (b7f7191).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...i-fields/src/lib/PhoneFormField/PhoneFormField.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16372      +/-   ##
==========================================
- Coverage   36.75%   36.72%   -0.03%     
==========================================
  Files        6804     6804              
  Lines      140909   140857      -52     
  Branches    40137    40111      -26     
==========================================
- Hits        51785    51736      -49     
+ Misses      89124    89121       -3     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
application-api-files 57.97% <ø> (ø)
application-core 71.83% <ø> (+0.32%) ⬆️
application-system-api 41.43% <ø> (-0.02%) ⬇️
application-template-api-modules 27.97% <ø> (+0.01%) ⬆️
application-templates-accident-notification 29.29% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.35% <ø> (ø)
application-templates-driving-license 18.29% <ø> (ø)
application-templates-estate 12.31% <ø> (ø)
application-templates-example-payment 25.14% <ø> (ø)
application-templates-financial-aid 14.27% <ø> (ø)
application-templates-general-petition 23.43% <ø> (ø)
application-templates-health-insurance 26.41% <ø> (ø)
application-templates-inheritance-report 6.43% <ø> (ø)
application-templates-marriage-conditions 15.09% <ø> (ø)
application-templates-mortgage-certificate 43.75% <ø> (ø)
application-templates-parental-leave 29.97% <ø> (ø)
application-types 6.71% <ø> (ø)
application-ui-components 1.28% <ø> (ø)
application-ui-shell 21.35% <0.00%> (+0.07%) ⬆️
clients-charge-fjs-v2 24.11% <ø> (ø)
web 1.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
libs/application/core/src/lib/fieldBuilders.ts 37.98% <ø> (ø)
...mplates/estate/src/forms/Sections/announcerInfo.ts 0.00% <ø> (ø)
...plates/estate/src/forms/Sections/representative.ts 0.00% <ø> (ø)
...inheritance-report/src/forms/sections/applicant.ts 0.00% <ø> (ø)
...src/forms/sections/prepaidInheritance/applicant.ts 0.00% <ø> (ø)
...sections/prepaidInheritance/inheritanceExecutor.ts 0.00% <ø> (ø)
libs/application/types/src/lib/Fields.ts 100.00% <ø> (ø)
...i-fields/src/lib/PhoneFormField/PhoneFormField.tsx 5.88% <0.00%> (+0.32%) ⬆️

... and 16 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eaccf23...b7f7191. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 11, 2024

Datadog Report

All test runs b3a050f 🔗

21 Total Test Services: 0 Failed, 21 Passed
⬆️ Test Sessions change in coverage: 2 increased, 88 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 8.98s 1 no change Link
api 0 0 0 4 0 2.68s 1 no change Link
application-api-files 0 0 0 12 0 5.89s 1 no change Link
application-core 0 0 0 92 0 18.54s 1 increased (+0.2%) Link
application-system-api 0 0 0 120 2 3m 32.31s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 23.61s 1 no change Link
application-templates-accident-notification 0 0 0 148 0 18.78s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 10.4s 1 no change Link
application-templates-driving-license 0 0 0 13 0 15.49s 1 no change Link
application-templates-example-payment 0 0 0 2 0 11.18s 1 no change Link

Copy link
Member

@jonnigs jonnigs left a comment

Choose a reason for hiding this comment

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

LGTM

@kodiakhq kodiakhq bot merged commit 0d3f6b6 into main Oct 14, 2024
84 checks passed
@kodiakhq kodiakhq bot deleted the feat/opt-in-phone-country branch October 14, 2024 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants