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(18222): Show layers starting with key words at the top in mcda dropdown #756

Conversation

albaranau
Copy link
Contributor

@albaranau albaranau commented Jun 4, 2024

https://kontur.fibery.io/Tasks/Task/Show-layers-starting-with-key-words-at-the-top-in-MCDA-dropdown-18222

Summary by CodeRabbit

  • New Features

    • Enhanced sorting functionality in forms: Input items are now sorted alphabetically or by word occurrence in search results.
  • Refactor

    • Updated sorting logic in the MCDAForm component for better organization and search efficiency.
  • Tests

    • Added test cases for new sorting functions to ensure reliability and accuracy.
  • Chores

    • Updated @konturio/ui-kit version from 5.1.12 to 5.2.0.

@albaranau albaranau requested a review from a team June 4, 2024 14:34
@albaranau albaranau self-assigned this Jun 4, 2024
Copy link
Contributor

coderabbitai bot commented Jun 4, 2024

Walkthrough

The recent updates focus on enhancing the sorting logic within the MCDAForm component and introducing robust sorting utilities. The @konturio/ui-kit package version was incremented, and new sorting functions were added to improve the organization of input items and search results. Accompanying tests ensure the reliability of these functions.

Changes

Files Change Summary
package.json Updated @konturio/ui-kit version from 5.1.12 to 5.2.0.
src/.../MCDAForm/index.tsx Refactored sorting logic for input items and search results using new utility functions.
src/.../MCDAForm/utils/sorting.test.ts Added test cases for sortByAlphabet and sortByWordOccurence functions.
src/.../MCDAForm/utils/sorting.tsx Introduced sortByAlphabet and sortByWordOccurence functions for sorting SelectableItem arrays.
src/utils/common/sorting.test.ts Added tests for sorting functions operating on SelectableItem arrays.
src/utils/common/sorting.ts Added sortByAlphabet and sortByWordOccurence functions for sorting based on different criteria.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant MCDAForm
    participant SortingUtils

    User->>MCDAForm: Enter search term
    MCDAForm->>SortingUtils: Call sortByWordOccurence
    SortingUtils-->>MCDAForm: Return sorted results
    MCDAForm-->>User: Display sorted search results
Loading

Poem

🐰 In the code, a change so bright,
Sorting items left and right,
Alphabetic, word occurrence too,
Making searches feel brand new.
With each test, the code did sing,
A smoother app, a joyous thing! 🎉


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

github-actions bot commented Jun 4, 2024

Language To Recheck Fuzzy Untranslated Total
ar 3 24 101 128
de 2 24 101 127
es 3 24 101 128
id 2 24 101 127
ko 3 24 101 128
uk 0 7 8 15

Copy link

github-actions bot commented Jun 4, 2024

Bundle size diff

Old size New size Diff
4.89 MB 4.89 MB 567 B (0.01%)

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

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 972dfd9 and b717bc1.

Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml
  • src/features/mcda/components/MCDAForm/utils/__snapshots__/sorting.test.ts.snap is excluded by !**/*.snap, !**/*.snap
Files selected for processing (4)
  • package.json (1 hunks)
  • src/features/mcda/components/MCDAForm/index.tsx (4 hunks)
  • src/features/mcda/components/MCDAForm/utils/sorting.test.ts (1 hunks)
  • src/features/mcda/components/MCDAForm/utils/sorting.tsx (1 hunks)
Additional comments not posted (5)
src/features/mcda/components/MCDAForm/utils/sorting.tsx (1)

3-7: The implementation of sortByAlphabet looks correct and efficient for case-insensitive alphabetical sorting.

src/features/mcda/components/MCDAForm/utils/sorting.test.ts (2)

5-17: The test suite for sortByWordOccurence is well-constructed and effectively checks the functionality using snapshots.


19-31: The test suite for sortByAlphabet correctly verifies the alphabetical sorting functionality using snapshots.

src/features/mcda/components/MCDAForm/index.tsx (1)

16-16: The integration of sortByAlphabet and sortByWordOccurence within the MCDAForm component is correctly implemented. The sortSearchResults function effectively combines these methods based on the search input.

Also applies to: 96-122

package.json (1)

89-89: The update of @konturio/ui-kit from 5.1.12 to 5.2.0 is noted and appears appropriate as a minor version increment.

src/features/mcda/components/MCDAForm/utils/sorting.tsx Outdated Show resolved Hide resolved
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

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between b717bc1 and 19faeb9.

Files ignored due to path filters (1)
  • src/utils/common/__snapshots__/sorting.test.ts.snap is excluded by !**/*.snap, !**/*.snap
Files selected for processing (3)
  • src/features/mcda/components/MCDAForm/index.tsx (4 hunks)
  • src/utils/common/sorting.test.ts (1 hunks)
  • src/utils/common/sorting.ts (2 hunks)
Additional comments not posted (5)
src/utils/common/sorting.test.ts (2)

5-17: The test suite for sortByWordOccurence is well-structured and effectively checks the functionality of sorting based on word occurrence.


19-31: The test suite for sortByAlphabet is correctly implemented and ensures that items are sorted alphabetically, ignoring case.

src/utils/common/sorting.ts (2)

14-21: The implementation of sortByAlphabet uses localeCompare effectively for case-insensitive alphabetical sorting.


23-42: The implementation of sortByWordOccurence is robust, using regular expressions to ensure that the word occurs at a word boundary and handling cases where the word is not found.

src/features/mcda/components/MCDAForm/index.tsx (1)

Line range hint 13-107: The integration of sortByAlphabet and sortByWordOccurence functions in the MCDAForm component is done correctly. The sortDropdownItems function is well-implemented, using the sorting functions based on the context (search term presence).

@albaranau albaranau merged commit a9dbeb6 into main Jun 6, 2024
7 checks passed
amurKontur pushed a commit that referenced this pull request Jun 10, 2024
…ropdown (#756)

* feat(18222): add sorting functions for MCDAForm dropdown

* ui-kit -> v5.2.0

* feat(18222): sort Multiselect items by search value

* chore: rename sortSearchResults -> sortDropdownItems

* chore: moved sortByAlphabet and sortByWordOccurence to utils/common

* chore(18222): refactor sortByAlphabet and sortByWordOccurence to work with generic type

* fix(18222): fix alphabetic sorting
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