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: replace filename validation messages #14434

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ErlingHauan
Copy link
Contributor

@ErlingHauan ErlingHauan commented Jan 16, 2025

Description

In some validation messages, we used the term "Filnavn" when we were not dealing with files in the UI.

Update for layout

bilde

Update for layout set

bilde

Update for code list library

bilde

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

  • Localization

    • Updated Norwegian error messages for name validation.
    • Consolidated error messages for invalid names across multiple components.
  • Error Handling

    • Simplified validation logic for page and file names.
    • Standardized error reporting with a single validation_errors.name_invalid message.
  • User Experience

    • Improved clarity of error messages for naming conventions.
    • Provided more specific guidance on valid name formats.

Copy link

coderabbitai bot commented Jan 16, 2025

📝 Walkthrough

Walkthrough

This pull request focuses on standardizing and consolidating error messages across multiple frontend components and utility functions. The changes primarily involve updating error message keys and removing specific validation checks for names and file names. The modifications aim to simplify error handling by using a more generic validation_errors.name_invalid error key instead of multiple specific error keys for different validation scenarios.

Changes

File Path Change Summary
frontend/language/src/nb.json Updated error messages for name validation and page uniqueness
frontend/libs/studio-content-library/.../*.test.tsx Updated error message references in test files
frontend/libs/studio-content-library/.../hooks/useCommonCodeListNameErrorMessages.ts Removed custom hook for file name error messages
frontend/packages/process-editor/.../CreateCustomReceiptForm.test.tsx Updated error message key for invalid layout set ID
frontend/packages/shared/src/utils/layoutSetsUtils.ts Modified error message key for layout set ID validation
frontend/packages/ux-editor-v3/src/utils/designViewUtils/*.ts Simplified page name error key generation logic

Possibly related issues

Possibly related PRs

Suggested labels

quality/testing, area/content-library

Suggested reviewers

  • Konrad-Simso

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1ca04d5 and fc435b1.

📒 Files selected for processing (2)
  • frontend/packages/ux-editor-v3/src/utils/designViewUtils/designViewUtils.test.ts (2 hunks)
  • frontend/packages/ux-editor/src/utils/designViewUtils/designViewUtils.test.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • frontend/packages/ux-editor/src/utils/designViewUtils/designViewUtils.test.ts
  • frontend/packages/ux-editor-v3/src/utils/designViewUtils/designViewUtils.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Testing

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.

@github-actions github-actions bot added area/process Area: Related to app process (e.g. signing, receipt, fill inn, payment, etc). area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution. frontend labels Jan 16, 2025
@ErlingHauan ErlingHauan changed the title Fix/filename validation messages fix: replace filename validation messages Jan 16, 2025
@ErlingHauan ErlingHauan linked an issue Jan 16, 2025 that may be closed by this pull request
@ErlingHauan ErlingHauan marked this pull request as ready for review January 16, 2025 10:54
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: 1

🧹 Nitpick comments (2)
frontend/packages/ux-editor-v3/src/utils/designViewUtils/designViewUtils.ts (1)

29-29: Consider consolidating duplicate implementations.

This file appears to be a duplicate of frontend/packages/ux-editor/src/utils/designViewUtils/designViewUtils.ts. While the change to use validation_errors.name_invalid is correct, having duplicate implementations could lead to maintenance issues.

Consider:

  1. Moving this shared logic to a common utility package
  2. Having both packages import from the common utility
  3. Deprecating one of the duplicate implementations if possible
frontend/packages/ux-editor/src/utils/designViewUtils/designViewUtils.test.ts (1)

51-51: Consider updating test descriptions to match new error handling.

While the changes to use validation_errors.name_invalid are correct, the test descriptions still reference specific error types (e.g., "returns length error key", "returns format error"). Consider updating these descriptions to reflect the consolidated error handling approach.

-    it('returns length error key when name is too long', () => {
+    it('returns invalid name error when name is too long', () => {

-    it('returns formate error when name contains period (.)', () => {
+    it('returns invalid name error when name contains period (.)', () => {

-    it('returns format error key when name contains illegal characters', () => {
+    it('returns invalid name error when name contains illegal characters', () => {

Also applies to: 60-60, 69-69

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 601280e and ebcca57.

📒 Files selected for processing (13)
  • frontend/language/src/nb.json (2 hunks)
  • frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeListsActionsBar/CreateNewCodeListModal/CreateNewCodeListModal.test.tsx (1 hunks)
  • frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/hooks/useCommonCodeListNameErrorMessages.ts (0 hunks)
  • frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/hooks/useInputCodeListNameErrorMessage.ts (1 hunks)
  • frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/hooks/useUploadCodeListNameErrorMessage.ts (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CreateCustomReceiptForm/CreateCustomReceiptForm.test.tsx (1 hunks)
  • frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceipt/CustomReceipt.test.tsx (1 hunks)
  • frontend/packages/shared/src/utils/layoutSetsUtils.ts (1 hunks)
  • frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/NavigationMenu/InputPopover/InputPopover.test.tsx (2 hunks)
  • frontend/packages/ux-editor-v3/src/utils/designViewUtils/designViewUtils.test.ts (2 hunks)
  • frontend/packages/ux-editor-v3/src/utils/designViewUtils/designViewUtils.ts (1 hunks)
  • frontend/packages/ux-editor/src/utils/designViewUtils/designViewUtils.test.ts (3 hunks)
  • frontend/packages/ux-editor/src/utils/designViewUtils/designViewUtils.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/hooks/useCommonCodeListNameErrorMessages.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Testing
🔇 Additional comments (9)
frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/hooks/useInputCodeListNameErrorMessage.ts (1)

7-7: LGTM! Error message key updated correctly.

The change from filename-specific validation to generic name validation aligns with the PR objectives. The new error message key is consistent with other files in the codebase.

frontend/packages/ux-editor/src/utils/designViewUtils/designViewUtils.ts (1)

29-29: LGTM! Error message key updated correctly.

The change to use validation_errors.name_invalid aligns with the PR objectives and maintains consistency across the codebase. The validation logic appropriately relies on the shared utility function.

frontend/packages/ux-editor-v3/src/utils/designViewUtils/designViewUtils.test.ts (1)

50-50: LGTM! Changes align with PR objectives.

The consolidation of error messages under validation_errors.name_invalid improves consistency in the UI by using a single, generic error key for name validation issues.

Also applies to: 59-59

frontend/libs/studio-content-library/src/ContentLibrary/LibraryBody/pages/CodeListPage/CodeListsActionsBar/CreateNewCodeListModal/CreateNewCodeListModal.test.tsx (1)

86-86: LGTM! Consistent error message handling.

The update to use validation_errors.name_invalid maintains consistency with the new error handling approach across the application.

frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CustomReceipt/CustomReceipt.test.tsx (1)

32-32: LGTM! Error message standardization applied correctly.

The update to use validation_errors.name_invalid in the layoutSetIdTextKeys object maintains consistency with the new error handling approach.

frontend/packages/ux-editor-v3/src/containers/DesignView/PageAccordion/NavigationMenu/InputPopover/InputPopover.test.tsx (1)

158-165: LGTM! Test assertions updated correctly.

The test assertions have been properly updated to use the new generic validation message key 'validation_errors.name_invalid' instead of filename-specific validation messages, aligning with the PR's objective to standardize validation messages.

Also applies to: 176-183

frontend/packages/process-editor/src/components/ConfigPanel/ConfigEndEvent/CustomReceiptContent/CreateCustomReceiptForm/CreateCustomReceiptForm.test.tsx (1)

197-197: LGTM! Test assertion updated correctly.

The test assertion has been properly updated to use the new generic validation message key 'validation_errors.name_invalid', consistent with the PR's objective to standardize validation messages.

frontend/packages/shared/src/utils/layoutSetsUtils.ts (1)

21-21: LGTM! Validation error key updated correctly.

The validation function has been properly updated to return the new generic validation message key 'validation_errors.name_invalid', consistent with the PR's objective to standardize validation messages.

frontend/language/src/nb.json (1)

1809-1809: LGTM! Error messages updated with clear and consistent wording.

The Norwegian translations have been properly updated:

  1. Page uniqueness error message is now more specific and user-friendly
  2. Name validation error message is now generic and reusable across different contexts

The changes align well with the PR's objective to standardize validation messages.

Also applies to: 1908-1908

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.65%. Comparing base (601280e) to head (fc435b1).
Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14434      +/-   ##
==========================================
- Coverage   95.65%   95.65%   -0.01%     
==========================================
  Files        1885     1884       -1     
  Lines       24495    24479      -16     
  Branches     2812     2809       -3     
==========================================
- Hits        23431    23415      -16     
  Misses        804      804              
  Partials      260      260              

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

@ErlingHauan ErlingHauan added skip-releasenotes Issues that do not make sense to list in our release notes skip-documentation Issues where updating documentation is not relevant labels Jan 16, 2025
@ErlingHauan ErlingHauan assigned Ildest and unassigned Ildest Jan 16, 2025
Copy link
Contributor

@Ildest Ildest left a comment

Choose a reason for hiding this comment

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

Lurt å endre fra filnavn til navn. Ett spørsmål om et begrep i koden.

@standeren standeren self-assigned this Jan 20, 2025
Copy link
Contributor

@standeren standeren left a comment

Choose a reason for hiding this comment

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

Looks good! ⭐
I have one question if we should say something about length? The regex says between 2 and 28 characters. Either add it to the general format error message or keep the length error message, but adapt it?

@standeren standeren assigned ErlingHauan and unassigned standeren Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/process Area: Related to app process (e.g. signing, receipt, fill inn, payment, etc). area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. 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: 🔎 Review
Development

Successfully merging this pull request may close these issues.

Validation messages refers to filename when not applicable
3 participants