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

refactor(pages-api): change parameter for layout operations to just use layout name #14683

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

Conversation

Jondyr
Copy link
Member

@Jondyr Jondyr commented Feb 17, 2025

Description

Remove file extension formatting on layoutName parameter of service
repository layer methods in AltinnAppGitRepository. This makes the
method more consistent with the other methods and follows layer
responsibilities (service layer does not need to know or specify file
extension).

Testing:

  • Operations acting on layout sets or layouts should be tested on
    frontend

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

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)

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • Refactor

    • Standardized layout naming by removing redundant file extensions, ensuring consistent references and smoother integration across the application.
  • Tests

    • Updated test configurations to reflect the new naming convention, maintaining reliable validations.

Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

📝 Walkthrough

Walkthrough

This pull request standardizes the handling of layout names by removing the ".json" extension from layout name variables throughout the codebase. Changes were made in the repository, service, event handler, and test files to update constants, method signatures, and variable names, ensuring that layout names are consistently managed. Where necessary, the ".json" extension is now appended during file path construction instead of being embedded in the layout name.

Changes

File(s) Change Summary
backend/src/Designer/.../AltinnAppGitRepository.cs Updated constant InitialLayoutFileName (removed ".json"), renamed variables in GetFormLayouts, updated file name extraction in GetLayoutNames, and revised method signatures (GetPathToLayoutFile, UpdateFormLayoutName) to work with layout names without the extension.
backend/src/Designer/.../AppDevelopmentService.cs Removed ".json" extensions in method implementations for SaveFormLayout, DeleteFormLayout, UpdateFormLayoutName, AddComponentToLayout, and UpdateLayoutReferences, reflecting the new naming conventions.
backend/src/Designer/.../ComponentIdChangedLayoutsHandler.cs Renamed the variable from layoutName to layoutFileName and derived a clean layoutName by stripping ".json", with an added initialization for component reference updates.
backend/src/Designer/.../TextsService.cs Modified file path construction in UpdateKeysInLayoutsInLayoutSet to append ".json" and adjusted the return logic for updated file lists.
Test Files:
backend/tests/Designer.Tests/.../AltinnAppGitRepositoryTests.cs,
.../TextsServiceTest.cs,
.../GetOptionListsReferencesTests.cs,
.../OptionsServiceTests.cs
Removed the ".json" extension from layout name constants and expected values in multiple tests to align with the updated naming convention.

Possibly related PRs

  • feat: create endpoints for codelists on org level #14533: The changes in the main PR are related to those in the retrieved PR as both involve modifications to the handling of layout names and file paths, specifically removing the .json extension from layout names in various methods, including those in the AltinnAppGitRepository class.

Suggested labels

quality/code, skip-releasenotes, team/studio-domain1

Suggested reviewers

  • ErlingHauan

📜 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 4791e63 and 8eea8d3.

📒 Files selected for processing (8)
  • backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs (1 hunks)
  • backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs (5 hunks)
  • backend/src/Designer/Services/Implementation/AppDevelopmentService.cs (5 hunks)
  • backend/src/Designer/Services/Implementation/TextsService.cs (1 hunks)
  • backend/tests/Designer.Tests/Controllers/OptionsController/GetOptionListsReferencesTests.cs (2 hunks)
  • backend/tests/Designer.Tests/Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs (3 hunks)
  • backend/tests/Designer.Tests/Services/OptionsServiceTests.cs (2 hunks)
  • backend/tests/Designer.Tests/Services/TextsServiceTest.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • backend/src/Designer/Services/Implementation/TextsService.cs
  • backend/tests/Designer.Tests/Services/OptionsServiceTests.cs
  • backend/tests/Designer.Tests/Controllers/OptionsController/GetOptionListsReferencesTests.cs
  • backend/tests/Designer.Tests/Services/TextsServiceTest.cs
  • backend/src/Designer/EventHandlers/ComponentIdChanged/ComponentIdChangedLayoutsHandler.cs
  • backend/tests/Designer.Tests/Infrastructure/GitRepository/AltinnAppGitRepositoryTests.cs
  • backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs
  • backend/src/Designer/Services/Implementation/AppDevelopmentService.cs
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Run dotnet build and test (macos-latest)
  • GitHub Check: Run dotnet build and test (windows-latest)
  • GitHub Check: Run integration tests against actual gitea and db
  • GitHub Check: Check Quartz update
  • GitHub Check: Format check

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 solution/studio/designer Issues related to the Altinn Studio Designer solution. backend labels Feb 17, 2025
@Jondyr Jondyr linked an issue Feb 17, 2025 that may be closed by this pull request
4 tasks
@Jondyr Jondyr force-pushed the spr/main/cf35ff23 branch 2 times, most recently from 891dd77 to 8e042b7 Compare February 17, 2025 12:23
@github-actions github-actions bot added area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. area/text-editor Area: Related to creating, translating and editing texts. quality/testing Tests that are missing, needs to be created or could be improved. frontend labels Feb 17, 2025
@Jondyr Jondyr changed the title refactor: change parameter for DeleteLayout to just use layout name refactor: change parameter for layout operations to just use layout name Feb 17, 2025
@Jondyr Jondyr force-pushed the spr/main/cf35ff23 branch 2 times, most recently from 31d2f69 to e886d3a Compare February 17, 2025 13:30
@Jondyr Jondyr force-pushed the spr/main/cf35ff23 branch 3 times, most recently from e743118 to 59b0493 Compare February 18, 2025 14:43
@Jondyr Jondyr changed the title refactor: change parameter for layout operations to just use layout name refactor(pages-api): change parameter for layout operations to just use layout name Feb 18, 2025
Copy link
Contributor

@lassopicasso lassopicasso 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 to me 😄 Always great to make things consistent 💪

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.76%. Comparing base (f2104d9) to head (c78bd45).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14683   +/-   ##
=======================================
  Coverage   95.76%   95.76%           
=======================================
  Files        1914     1914           
  Lines       24948    24948           
  Branches     2857     2857           
=======================================
  Hits        23891    23891           
  Misses        798      798           
  Partials      259      259           

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

…se layout name

Remove file extension formatting on layoutName parameter of service
repository layer methods in AltinnAppGitRepository. This makes the
method more consistent with the other methods and follows layer
responsibilities (service layer does not need to know or specify file
extension).

# Testing:
- [ ] Operations acting on layout sets or layouts should be tested on
frontend

commit-id:cf35ff23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/text-editor Area: Related to creating, translating and editing texts. area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. backend frontend quality/testing Tests that are missing, needs to be created or could be improved. solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-domain2
Projects
Status: 🧪 Test
Development

Successfully merging this pull request may close these issues.

2 participants