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: support code lists search in library #14319

Merged
merged 14 commits into from
Jan 16, 2025

Conversation

standeren
Copy link
Contributor

@standeren standeren commented Dec 19, 2024

Description

Add functionality to search for code lists in library. The filter method iterates over the verbose codeList object (which also contains the actual code lists) due to enable automatic update of the search result if changing the id of a code list. This is also the reason for needing to keep the search pattern in a state; to be able to use the original search pattern on the new code lists object.

The search is case-insensitive

Skjermbilde 2024-12-19 kl  15 34 31

Skjermopptak.2024-12-19.kl.15.31.26.mov

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

  • New Features

    • Added search functionality to code lists.
    • Implemented ability to filter code lists by search term.
    • Added clear search button with localized label.
  • Documentation

    • Updated Norwegian translations for search-related UI elements.
  • Tests

    • Enhanced test coverage for code list search functionality.
    • Added new test cases for search filtering and interaction.

@github-actions github-actions bot added solution/studio/designer Issues related to the Altinn Studio Designer solution. frontend labels Dec 19, 2024
@standeren standeren added skip-releasenotes Issues that do not make sense to list in our release notes area/content-library Area: Related to library for shared resources team/studio-domain1 skip-documentation Issues where updating documentation is not relevant and removed team/studio-domain1 labels Dec 19, 2024
@standeren standeren marked this pull request as draft December 19, 2024 14:02
@standeren standeren force-pushed the support-code-lists-seacrh-in-library branch from a136a1d to 94eabc8 Compare December 19, 2024 14:28
@standeren standeren marked this pull request as ready for review December 19, 2024 14:35
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.66%. Comparing base (9f902c6) to head (c194cbd).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14319   +/-   ##
=======================================
  Coverage   95.66%   95.66%           
=======================================
  Files        1887     1886    -1     
  Lines       24537    24549   +12     
  Branches     2818     2818           
=======================================
+ Hits        23473    23485   +12     
  Misses        804      804           
  Partials      260      260           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@standeren standeren force-pushed the support-code-lists-seacrh-in-library branch from 34d248a to ea39100 Compare January 1, 2025 16:05
@TomasEng TomasEng self-assigned this Jan 2, 2025
Copy link
Contributor

@TomasEng TomasEng left a comment

Choose a reason for hiding this comment

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

Fin og konsentrert PR, men jeg har noen spørsmål til valgene du har tatt i koden, spesielt rundt bruken av regulære uttrykk.

Videre lurer jeg på om du har vurdert å gradere resultatene etter hvor godt de matcher søkeordet, i stedet for å bare filtrere ut alt som ikke matcher eksakt? Som bruker ville jeg i hvert fall opplevd det som en feil dersom jeg søkte etter "biler motorsykler" og listen med navnet "biler_og_motorsykler" ikke dukket opp. Samtidig, hvis jeg søkte etter bare "motorsykler", ville jeg forventet at listen med navnet "motorsykler" kom foran "biler_og_motorsykler" i resultatlisten. Jeg sier ikke at dette er ting vi må løse i denne PR-en, men det er i hvert fall noe vi bør tenke på når vi starter å implementere søk.

En komplett søkefunksjon kan altså bli ganske omfattende, men det finnes eksterne biblioteker vi kan bruke for å spare oss for arbeid. (Jeg har faktisk laget et selv, men det er ikke akkurat etablert eller mye brukt, så det strider mot våre egne prinsipper å ta det i bruk.)

@TomasEng TomasEng assigned standeren and unassigned TomasEng Jan 2, 2025
@standeren
Copy link
Contributor Author

Fin og konsentrert PR, men jeg har noen spørsmål til valgene du har tatt i koden, spesielt rundt bruken av regulære uttrykk.

Videre lurer jeg på om du har vurdert å gradere resultatene etter hvor godt de matcher søkeordet, i stedet for å bare filtrere ut alt som ikke matcher eksakt? Som bruker ville jeg i hvert fall opplevd det som en feil dersom jeg søkte etter "biler motorsykler" og listen med navnet "biler_og_motorsykler" ikke dukket opp. Samtidig, hvis jeg søkte etter bare "motorsykler", ville jeg forventet at listen med navnet "motorsykler" kom foran "biler_og_motorsykler" i resultatlisten. Jeg sier ikke at dette er ting vi må løse i denne PR-en, men det er i hvert fall noe vi bør tenke på når vi starter å implementere søk.

En komplett søkefunksjon kan altså bli ganske omfattende, men det finnes eksterne biblioteker vi kan bruke for å spare oss for arbeid. (Jeg har faktisk laget et selv, men det er ikke akkurat etablert eller mye brukt, så det strider mot våre egne prinsipper å ta det i bruk.)

Veldig gode poenger. Har ikke tenkt på at det. Men samtidig vet jeg ikke om jeg hadde forventet det av et søkefelt i en applikasjon som ikke er en søkemotor, men hadde absolutt blitt glad om det funket. Tenker jo kanskje uansett at det er fordelaktig for de som har et par kodelister, at det er mulig å gjøre enkle søk fremfor ingen søk 🤷
Her har kanskje @Annikenkbrathen noen tanker også

@standeren standeren assigned TomasEng and unassigned standeren Jan 3, 2025
@TomasEng
Copy link
Contributor

TomasEng commented Jan 3, 2025

Tenker jo kanskje uansett at det er fordelaktig for de som har et par kodelister, at det er mulig å gjøre enkle søk fremfor ingen søk

Hvis man bare har et par kodelister, er det vel ikke nødvendig å søke? Dette er vel funksjonalitet som først og fremst er aktuell for brukere med mange kodelister?

@standeren
Copy link
Contributor Author

Tenker jo kanskje uansett at det er fordelaktig for de som har et par kodelister, at det er mulig å gjøre enkle søk fremfor ingen søk

Hvis man bare har et par kodelister, er det vel ikke nødvendig å søke? Dette er vel funksjonalitet som først og fremst er aktuell for brukere med mange kodelister?

Ja, det var dårlig ordlegging av meg, mente ikke "et par" som et faktisk par, men mange.

@TomasEng TomasEng assigned standeren and unassigned TomasEng Jan 3, 2025
@Annikenkbrathen
Copy link

Veldig gode poenger. Har ikke tenkt på at det. Men samtidig vet jeg ikke om jeg hadde forventet det av et søkefelt i en applikasjon som ikke er en søkemotor, men hadde absolutt blitt glad om det funket. Tenker jo kanskje uansett at det er fordelaktig for de som har et par kodelister, at det er mulig å gjøre enkle søk fremfor ingen søk 🤷 Her har kanskje @Annikenkbrathen noen tanker også

Enig med dere her! dette blir jo som sagt mest relevant om man har mange kodelister, og da vil nok et enkelt søk hjelpe masse i første omgang!

@standeren standeren force-pushed the support-code-lists-seacrh-in-library branch from ea39100 to b72641b Compare January 6, 2025 14:10
@standeren standeren assigned TomasEng and unassigned standeren Jan 6, 2025
Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Warning

Rate limit exceeded

@standeren has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 7 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f486da7 and c194cbd.

📒 Files selected for processing (4)
  • frontend/language/src/nb.json (1 hunks)
  • frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeListPage.test.tsx (4 hunks)
  • frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeListPage.tsx (4 hunks)
  • frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeLists/CodeLists.tsx (1 hunks)
📝 Walkthrough

Walkthrough

This pull request introduces a new search functionality for the CodeListPage component, enhancing user interaction by allowing dynamic filtering of code lists based on user input. Changes include the addition of a search state variable, a filtering utility function, and corresponding tests to validate the new functionality. Additionally, a new entry is added to the Norwegian language translation file for the clear search button label. The modifications span multiple files, ensuring that both the component logic and user interface are updated accordingly.

Changes

File Change Summary
frontend/language/src/nb.json Added Norwegian translation for clear search button label.
frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeListPage.tsx Added search string state and filtering logic for code lists.
frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeListsActionsBar/CodeListsActionsBar.tsx Added onSetSearchString prop and search functionality.
frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/utils/codeListPageUtils.ts Implemented filterCodeLists utility function with case-insensitive matching.
frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/utils/codeListPageUtils.test.ts Added tests for filterCodeLists utility function.
frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeListsActionsBar/CodeListsActionsBar.test.tsx Added tests for search functionality in CodeListsActionsBar.
frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeListPage.test.tsx Updated tests for CodeListPage to include new search scenarios.

Possibly related PRs

Suggested labels

area/ui-editor, quality/testing

Suggested reviewers

  • ErlingHauan
  • TomasEng

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

@standeren standeren assigned TomasEng and unassigned standeren Jan 15, 2025
@TomasEng TomasEng removed their assignment Jan 15, 2025
@ErlingHauan ErlingHauan self-assigned this Jan 16, 2025
Copy link
Contributor

@ErlingHauan ErlingHauan left a comment

Choose a reason for hiding this comment

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

Test

Søket fungerer kjapt og smidig 😊

Men ser at autocomplete er skrudd på, og jeg syns personlig den blir litt i veien, f. eks:
bilde

Kan vi skru det av?

@ErlingHauan ErlingHauan assigned standeren and unassigned ErlingHauan Jan 16, 2025
@standeren
Copy link
Contributor Author

Test

Søket fungerer kjapt og smidig 😊

Men ser at autocomplete er skrudd på, og jeg syns personlig den blir litt i veien, f. eks: bilde

Kan vi skru det av?

Hm, har ikke tenkt så mye på det egt 🤔 Det er vel på by default på de fleste input-felter vi har. Jeg er usikker på hva DS sier om det, men umiddelbart tenker jeg at et søkefelt kanskje burde ha autocomplete? Dersom én person har ansvar for å utvikle én kodeliste i en app (eller kanskje mer aktuelt i org-kontekst i fremtiden) blant mange kodelister, så vil det være kjekt å ha autocomplete, eller?
Jeg er på tynn is her altså 😅

@standeren standeren assigned ErlingHauan and unassigned standeren Jan 16, 2025
Copy link
Contributor

@ErlingHauan ErlingHauan left a comment

Choose a reason for hiding this comment

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

Godt poeng!
Ser at Designsystemet ikke sier så mye om det, så vi kan godt beholde det.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/content-library Area: Related to library for shared resources frontend skip-documentation Issues where updating documentation is not relevant skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-domain1
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Support search for code lists in library
4 participants