Skip to content

Conversation

@atomicgamedeveloper
Copy link
Contributor

@atomicgamedeveloper atomicgamedeveloper commented Jul 25, 2025

Add configurable GitLab settings in user account section

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactoring (unchecked)
  • Security patch (unchecked)
  • UI/UX improvement

Description

This PR addresses issue #1211 by converting hardcoded GitLab constants into settings that users can modify through a new settings form in the Account section. It is a reopened version of #1249 to finalize it with tests and new constants, like commonLibraryName. Key changes include:

  • Created a new settings Redux slice to manage GitLab configuration
  • Added persistent storage of settings using localStorage
  • Replaced direct constant usage with getter functions throughout the codebase
  • Implemented a settings form UI in the Account section
  • Updated tests to use mocks for the new constant getter functions

These changes allow users to customize:

  • GitLab group name (GROUP_NAME)
  • Digital Twin directory (DT_DIRECTORY)
  • Common library project ID (COMMON_LIBRARY_PROJECT_ID)
  • Runner tag for CI execution (RUNNER_TAG)

Testing

  • Added unit tests to verify the settings slice functions correctly.
    • Updated existing tests to use the new constant getter functions.
  • Manually tested the settings form to ensure values persist between sessions.
  • Verified that changes to settings properly affect GitLab operations.

Impact

  • Improves flexibility by allowing users to customize GitLab interactions.
  • Enhances user experience by providing a UI to modify these settings.
  • Helps with different GitLab configurations without code changes.
  • Settings are immediately applied after saving.

Additional Information

The settings form includes a reset to defaults option in case someone needs to revert their changes.


Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have added tests for all the new code and any changes made to existing code.

@codecov
Copy link

codecov bot commented Jul 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.72%. Comparing base (a4eae5b) to head (1df49ab).
⚠️ Report is 1 commits behind head on feature/distributed-demo.

Additional details and impacted files
@@                     Coverage Diff                      @@
##           feature/distributed-demo    #1297      +/-   ##
============================================================
+ Coverage                     95.40%   95.72%   +0.31%     
============================================================
  Files                            98      103       +5     
  Lines                          2744     2875     +131     
  Branches                        440      480      +40     
============================================================
+ Hits                           2618     2752     +134     
+ Misses                          123      120       -3     
  Partials                          3        3              
Files with missing lines Coverage Δ
client/src/model/backend/gitlab/backend.ts 100.00% <100.00%> (ø)
...odel/backend/gitlab/digitalTwinConfig/constants.ts 100.00% <100.00%> (ø)
...ackend/gitlab/digitalTwinConfig/settingsUtility.ts 100.00% <100.00%> (ø)
.../src/model/backend/gitlab/execution/logFetching.ts 93.33% <100.00%> (+0.11%) ⬆️
...src/model/backend/gitlab/execution/pipelineCore.ts 100.00% <ø> (ø)
...c/model/backend/gitlab/execution/statusChecking.ts 100.00% <100.00%> (ø)
client/src/model/backend/gitlab/gitlabFactory.ts 100.00% <ø> (ø)
client/src/model/backend/gitlab/instance.ts 100.00% <100.00%> (ø)
client/src/model/backend/interfaces/execution.ts 100.00% <ø> (ø)
...t/src/model/backend/interfaces/sharedInterfaces.ts 100.00% <100.00%> (ø)
... and 27 more
Components Coverage Δ
Website 95.72% <100.00%> (+0.31%) ⬆️
Lib Microservice ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@prasadtalasila
Copy link
Contributor

@atomicgamedeveloper The settings are completely independent of the OAuth user information coming from gitlab. It is ok to skip the handling of OAuth sessionstorage issue from this PR.

@prasadtalasila prasadtalasila requested a review from Copilot August 21, 2025 12:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR converts hardcoded GitLab constants into configurable settings that users can modify through a new settings form in the Account section. The implementation provides a Redux-based settings management system with persistent localStorage storage.

  • Created a settings Redux slice with persistent localStorage integration
  • Added a new settings form UI in the Account section for users to customize GitLab configurations
  • Replaced direct constant usage with getter functions throughout the codebase to support dynamic configuration

Reviewed Changes

Copilot reviewed 41 out of 42 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
client/src/store/settings.slice.ts New Redux slice managing GitLab settings with localStorage persistence
client/src/route/account/SettingsForm.tsx New React component providing a form interface for modifying GitLab settings
client/src/model/backend/gitlab/digitalTwinConfig/settingsUtility.ts New utility functions providing both hook and non-hook access to settings
client/src/store/store.ts Updated to include settings slice and middleware for localStorage persistence
client/test/unit/store/settings.slice.test.ts Unit tests for the settings slice functionality
client/test/unit/routes/SettingsForm.test.tsx Unit tests for the settings form component
client/test/e2e/tests/Settings.test.ts End-to-end tests for the settings functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@prasadtalasila
Copy link
Contributor

@copilot review

Copy link
Contributor

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

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

@atomicgamedeveloper please see a partial review of the PR.

],
globalSetup: 'test/e2e/setup/global.setup.ts',
globalTeardown: 'test/e2e/setup/global-teardown.ts',
reportSlowTests: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this help?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of our tests are slow so this gets rid of the warning.

Copy link
Contributor

@prasadtalasila prasadtalasila left a comment

Choose a reason for hiding this comment

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

@atomicgamedeveloper Thanks for the updates. Please check the comments. In addition to them so general comments.

  1. Please update classDiagramOfPreviewUtil.png
  2. The LocalStorage of the browser has two JSON objects - dtaas_settings and settings. Both contain the same JSON object. Is it possible to just use one, say settings?

expect(mockApi.createRepositoryFile).toHaveBeenCalledWith(
2,
'path/file',
'master',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this branch name be flexible so that the changes made by Settings can potentially be tested? I guess mock handling the branch name can be changed to be more flexible.

- Changed imports from 'model/backend/gitlab/UtilityInterfaces' to 'model/backend/interfaces/utilityInterfaces' in multiple files.
- Updated the usage of FileState and FileType enums to ensure consistency across the application.
- Refactored file type handling in various components to use the new FileType enum.
- Adjusted tests to reflect changes in file type handling and imports.
- Cleaned up unused imports and improved code readability.
- Update documentation
- Add missing coverage
- Removed afterEach hooks that called jest.clearAllMocks() from multiple test files as mocks were being reset consistently
- Ensured that jest.restoreAllMocks() is still called where necessary to reset mock implementations.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 5, 2025

@prasadtalasila prasadtalasila merged commit 6802dbd into INTO-CPS-Association:feature/distributed-demo Sep 5, 2025
5 checks passed
@prasadtalasila prasadtalasila added this to the Release v0.8 milestone Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants