Skip to content

[NAE-2072] Workspaces #280

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

Open
wants to merge 6 commits into
base: release/7.0.0-rev2
Choose a base branch
from
Open

[NAE-2072] Workspaces #280

wants to merge 6 commits into from

Conversation

Kovy95
Copy link
Contributor

@Kovy95 Kovy95 commented May 21, 2025

Description

implements switch for workspaces

Implements NAE-2072

Dependencies

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

manually

Test Configuration

<Please describe configuration for tests to run if applicable, like program parameters, host OS, VM configuration etc. You can use >

Name Tested on
OS linux mint 21
Runtime Node 20.18.0
Dependency Manager NPM 10.8.2
Framework version Angular 17.3
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • New Features

    • Introduced workspace support across the application, allowing users to view and switch between multiple workspaces.
    • Added a workspace selection menu to the navigation drawer for easy switching.
    • User, case, task, and process entities now include workspace identification.
    • Added API endpoints and service methods for fetching and changing user workspaces.
  • Improvements

    • Enhanced user interface with visual cues for the active workspace.
    • Workspace management options are now available for users with multiple workspaces.
    • Improved safety checks to prevent runtime errors in process loading.
  • Style

    • Added new styling for selected workspace menu items.
  • Localization

    • Added workspace selection translations for English, German, and Slovak.

Kovy95 added 3 commits May 20, 2025 07:22
- add changing workspaces to doubledrawer menu
# Conflicts:
#	projects/netgrif-components-core/src/lib/user/models/iuser.ts
#	projects/netgrif-components-core/src/lib/user/services/user.service.ts
#	projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication-method-service.ts
#	projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication.service.ts
#	projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-user-resource.service.ts
- change funcionality
@Kovy95 Kovy95 self-assigned this May 21, 2025
Copy link

coderabbitai bot commented May 21, 2025

Walkthrough

The changes introduce workspace support across user, case, task, and process models, services, and UI components. New properties and interfaces for workspace identification are added, along with methods to retrieve and switch workspaces. The navigation drawer UI now includes a menu for workspace selection, and observables are set up to manage and display available workspaces to the user.

Changes

File(s) Change Summary
.../panels/panels.component.ts, .../sidemenu-example/sidemenu-example.component.ts Added workspaceId property with initial empty string to relevant objects for case, workflow, and allowed nets.
.../models/user.transformer.ts, .../models/user.ts, .../models/iuser.ts Added workspaceId property to user models and transformation logic.
.../navigation-double-drawer/abstract-navigation-double-drawer.ts Added workspace observables, workspace count, and methods to set/return active workspace in navigation drawer component.
.../process/net.ts Added private _workspaceId property with getter/setter to Net class.
.../process/process.service.ts Updated null-check in loadNetReference method to use optional chaining for safety.
.../resources/engine-endpoint/user-resource.service.ts Added getAllWorkspaces and changeWorkspace methods for workspace API interaction.
.../resources/interface/case.ts, .../resources/interface/petri-net-reference.ts, .../resources/interface/task.ts Added workspaceId: string property to Case, PetriNetReference, and Task interfaces.
.../user/models/workspace.ts Introduced new Workspace interface with id and defaultWorkspace properties.
.../user/services/user.service.ts Added workspace management: observable getter, methods for loading/changing workspaces, and updated user loading logic to handle workspaces.
.../utility/tests/mocks/mock-authentication-method-service.ts, .../utility/tests/mocks/mock-user-resource.service.ts Added workspaceId property to mock user resource objects in test utilities.
.../utility/tests/mocks/mock-authentication.service.ts Changed user roles argument in mock user login to an empty string.
.../utility/tests/utility/create-mock-case.ts, .../utility/tests/utility/create-mock-net.ts, .../utility/tests/utility/create-mock-task.ts Added workspaceId property to returned mock objects for case, net, and task test utilities.
.../navigation/navigation-double-drawer/navigation-double-drawer.component.html Added workspace selection menu and trigger button to navigation drawer UI.
.../navigation/navigation.theme.scss Added .menu-button-selected CSS class for styling selected workspace menu items.
.../assets/i18n/*.json Added new localized strings for workspace selection menu labels in English, German, and Slovak.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant NavDrawer as NavigationDoubleDrawerComponent
    participant UserService as UserService
    participant UserResource as UserResourceService

    User->>NavDrawer: Clicks workspace menu button
    NavDrawer->>UserService: get workspaces$
    UserService->>UserResource: getAllWorkspaces()
    UserResource-->>UserService: Array<Workspace>
    UserService-->>NavDrawer: workspaces$ observable emits workspaces
    User->>NavDrawer: Selects a workspace
    NavDrawer->>UserService: setWorkspace(workspaceId)
    UserService->>UserResource: changeWorkspace(workspaceId)
    UserResource-->>UserService: Updated UserResource
    UserService->>User: Reloads window to apply workspace change
Loading
sequenceDiagram
    participant UserService
    participant UserResource
    participant App

    UserService->>UserResource: getLoggedUser()
    UserResource-->>UserService: UserResource (with workspaceId)
    UserService->>UserService: transform UserResource to User (with workspaceId)
    UserService->>UserService: loadWorkspaces()
    UserService->>UserResource: getAllWorkspaces()
    UserResource-->>UserService: Array<Workspace>
    UserService-->>App: Emits user and workspaces observables
Loading

Suggested labels

Medium, Large


📜 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 b6109f7 and 2a2c555.

📒 Files selected for processing (4)
  • projects/netgrif-components-core/src/assets/i18n/de.json (1 hunks)
  • projects/netgrif-components-core/src/assets/i18n/en.json (1 hunks)
  • projects/netgrif-components-core/src/assets/i18n/sk.json (1 hunks)
  • projects/netgrif-components/src/lib/navigation/navigation-double-drawer/navigation-double-drawer.component.html (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • projects/netgrif-components-core/src/assets/i18n/sk.json
  • projects/netgrif-components-core/src/assets/i18n/en.json
  • projects/netgrif-components-core/src/assets/i18n/de.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • projects/netgrif-components/src/lib/navigation/navigation-double-drawer/navigation-double-drawer.component.html
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: task-list-completed
  • GitHub Check: Matrix Test (18)
  • GitHub Check: Matrix Test (20)
  • GitHub Check: Test with SonarCloud
  • GitHub Check: task-list-completed

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

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

🔭 Outside diff range comments (1)
projects/netgrif-components-core/src/lib/user/services/user.service.ts (1)

86-91: ⚠️ Potential issue

Add cleanup for the workspaces subject to prevent memory leaks.

The _workspaces ReplaySubject should be completed in ngOnDestroy:

 ngOnDestroy(): void {
     this._userChange$.complete();
     this._anonymousUserChange$.complete();
+    this._workspaces.complete();
     this._subAuth.unsubscribe();
     this._subAnonym.unsubscribe();
 }
🧹 Nitpick comments (4)
projects/nae-example-app/src/app/doc/sidemenu-example/sidemenu-example.component.ts (1)

44-44: Consider using a more meaningful default value for workspaceId.

Using empty strings ('') as default values for workspaceId may not clearly indicate whether a workspace is actually assigned. Consider using:

  • null or undefined for unassigned workspaces
  • A default workspace identifier (e.g., 'default')
  • A constant for the default workspace value

Example improvement:

-                workspaceId: ''
+                workspaceId: null // or 'default-workspace'

This makes the intent clearer and allows for better validation logic.

Also applies to: 57-57

projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-user-resource.service.ts (1)

24-24: Mock service updated consistently with interface changes.

The addition of workspaceId: '' to the mock UserResource maintains consistency with the workspace feature implementation.

Consider whether the empty string default is appropriate for all test scenarios. Some tests might benefit from having a mock workspace ID to verify workspace-specific behavior:

-workspaceId: '',
+workspaceId: 'test-workspace-id',
projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-net.ts (1)

34-34: Consider standardizing mock default values across utilities.

The workspace ID additions are correct, but there's an inconsistency in default values: this utility uses empty strings while create-mock-task.ts uses 'string'. Consider standardizing these values for consistent test behavior.

Standardize the default value pattern:

-        workspaceId: '',
+        workspaceId: 'string',
-        workspaceId: '',
+        workspaceId: 'string',

Also applies to: 47-47

projects/netgrif-components-core/src/lib/resources/engine-endpoint/user-resource.service.ts (1)

85-95: Fix JSDoc comment inconsistency.

The JSDoc comment incorrectly states this is a GET request, but the implementation uses POST which is appropriate for changing workspace state.

     /**
-     * Get all workspaces
+     * Change active workspace
      *
-     * **Request Type:** GET
+     * **Request Type:** POST
      *
-     * **Request URL:** {{baseUrl}}/api/user/workspaces
+     * **Request URL:** {{baseUrl}}/api/user/workspace
      */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e4b1097 and b6109f7.

📒 Files selected for processing (22)
  • projects/nae-example-app/src/app/doc/panels/panels.component.ts (2 hunks)
  • projects/nae-example-app/src/app/doc/sidemenu-example/sidemenu-example.component.ts (2 hunks)
  • projects/netgrif-components-core/src/lib/authentication/models/user.transformer.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts (5 hunks)
  • projects/netgrif-components-core/src/lib/process/net.ts (3 hunks)
  • projects/netgrif-components-core/src/lib/process/process.service.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/resources/engine-endpoint/user-resource.service.ts (2 hunks)
  • projects/netgrif-components-core/src/lib/resources/interface/case.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/resources/interface/petri-net-reference.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/resources/interface/task.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/user/models/iuser.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/user/models/user.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/user/models/workspace.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/user/services/user.service.ts (8 hunks)
  • projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication-method-service.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication.service.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-user-resource.service.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-case.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-net.ts (2 hunks)
  • projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-task.ts (1 hunks)
  • projects/netgrif-components/src/lib/navigation/navigation-double-drawer/navigation-double-drawer.component.html (1 hunks)
  • projects/netgrif-components/src/lib/navigation/navigation.theme.scss (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication.service.ts (1)
projects/netgrif-components-core/src/lib/user/models/user.ts (1)
  • User (7-64)
projects/netgrif-components-core/src/lib/resources/engine-endpoint/user-resource.service.ts (2)
projects/netgrif-components-core/src/lib/resources/resource-provider.service.ts (1)
  • Params (12-12)
projects/netgrif-components-core/src/lib/user/models/workspace.ts (1)
  • Workspace (2-5)
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts (1)
projects/netgrif-components-core/src/lib/user/models/workspace.ts (1)
  • Workspace (2-5)
projects/netgrif-components-core/src/lib/user/services/user.service.ts (3)
projects/netgrif-components-core/src/lib/user/models/workspace.ts (1)
  • Workspace (2-5)
projects/netgrif-components-core/src/lib/user/models/user.ts (1)
  • User (7-64)
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts (1)
  • user (310-312)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: task-list-completed
  • GitHub Check: Matrix Test (20)
  • GitHub Check: Matrix Test (18)
  • GitHub Check: Test with SonarCloud
  • GitHub Check: task-list-completed
🔇 Additional comments (24)
projects/netgrif-components/src/lib/navigation/navigation.theme.scss (1)

22-24: LGTM! Clean and consistent styling addition.

The new .menu-button-selected class follows the established pattern of using the primary palette color for selected states, consistent with other similar classes in the theme.

projects/netgrif-components-core/src/lib/user/models/workspace.ts (1)

2-5: Well-designed interface for workspace representation.

The Workspace interface is clean and appropriately minimal, with clear property names and types that align with the workspace functionality requirements.

projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-task.ts (1)

21-21: Mock utility properly updated for workspace support.

The addition of workspaceId maintains consistency with other mock properties and supports testing of workspace-aware functionality.

projects/netgrif-components-core/src/lib/process/process.service.ts (1)

272-272: LGTM: Improved null safety with optional chaining.

The change from !reference.stringId to !reference?.stringId provides better null safety by preventing potential runtime errors when reference is null or undefined. This defensive programming approach is especially valuable when handling external data sources.

projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication.service.ts (1)

22-22: LGTM: Correctly updated User constructor for workspace support.

The change properly aligns with the new User constructor signature by adding an empty string for workspaceId as the 7th parameter, with ['ADMIN'] correctly positioned as the 8th parameter for authorities. This maintains the mock's functionality while supporting the workspace feature.

projects/netgrif-components-core/src/lib/authentication/models/user.transformer.ts (1)

26-26: LGTM: Properly implements workspaceId transformation.

The addition of user.workspaceId correctly extracts the workspace information from the UserResource and passes it to the User constructor in the correct position. This ensures workspace data is properly mapped from the backend resource to the domain model.

projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-case.ts (1)

38-39: LGTM: Adds workspace support to mock case utility.

The addition of workspaceId: '' properly extends the mock Case object to support the workspace feature. Using an empty string as the default value is appropriate for testing scenarios and maintains consistency with other workspace-related mock utilities.

projects/netgrif-components-core/src/lib/process/net.ts (2)

26-29: LGTM - Consistent property declaration.

The workspaceId property follows the established pattern in the Net class with proper JSDoc documentation.


207-213: LGTM - Consistent getter and setter implementation.

The getter and setter methods follow the established pattern used by other properties in the Net class.

projects/netgrif-components/src/lib/navigation/navigation-double-drawer/navigation-double-drawer.component.html (2)

117-122: LGTM - Well-structured workspace menu.

The mat-menu implementation correctly uses Angular directives with proper async pipe handling, conditional styling, and workspace identification logic. The menu positioning and trigger configuration are appropriate.


124-130: LGTM - Properly implemented workspace selector button.

The button correctly uses structural directive for conditional display, proper Material Design button styling, tooltip integration, and menu triggering. The translation key usage follows the established pattern.

projects/netgrif-components-core/src/lib/resources/engine-endpoint/user-resource.service.ts (2)

13-13: LGTM - Proper import of Workspace interface.

The import statement correctly references the Workspace interface from the user models directory.


73-83: LGTM - Well-implemented getAllWorkspaces method.

The method follows the established service pattern with proper JSDoc documentation, correct HTTP method usage, and consistent return type handling.

projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts (4)

6-7: LGTM - Proper RxJS and interface imports.

The import statements correctly add the necessary RxJS operators and Workspace interface for the new functionality.


121-122: LGTM - Well-defined workspace properties.

The properties are properly typed and follow the established naming conventions in the component.


171-173: LGTM - Proper workspace observable initialization.

The workspace observable setup correctly uses the tap operator to maintain the workspace count and follows Angular best practices for observable handling in ngOnInit.


239-245: LGTM - Clean workspace management methods.

Both methods are well-implemented with clear responsibilities: setWorkspace delegates to the UserService for state management, and activeWorkspace provides direct access to the current workspace ID.

projects/netgrif-components-core/src/lib/user/services/user.service.ts (7)

2-2: LGTM!

The import additions are necessary for the new workspace functionality and follow the existing patterns.

Also applies to: 15-15


29-29: LGTM!

The workspace property follows the established pattern used for user observables in this service.

Also applies to: 42-42


48-49: LGTM!

The conditional logic properly handles workspace loading for different authentication scenarios.


74-76: LGTM!

The workspaces observable getter follows the established pattern used by other observables in this service.


189-189: LGTM!

The correction properly includes the workspaceId parameter to match the updated User constructor.


198-198: LGTM!

Loading workspaces after successfully loading the user is logical and follows the expected sequence of operations.


223-231: LGTM!

The method follows the established pattern for loading data from the user resource service, with appropriate error logging.

Comment on lines +37 to +40
/**
* **Example:** default
*/
workspaceId: string;
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

LGTM! Consistent interface extension.

The workspaceId property follows the established documentation pattern and type conventions. The "default" example value suggests proper fallback handling.

Consider whether validation should be added for workspace ID format and if this should be optional for backward compatibility:


🏁 Script executed:

#!/bin/bash
# Check if there are any existing usages of IUser that might break with this required property
rg -A 3 -B 3 "implements IUser|extends IUser|: IUser"

Length of output: 69072


Add workspaceId to all IUser implementations

The new required workspaceId: string on IUser is a breaking change for existing classes and interfaces that implement or extend IUser. You need to update them accordingly:

• In projects/netgrif-components-core/src/lib/user/models/user.ts
– Add a public workspaceId: string parameter to the User constructor (or make it optional with a default)
– Assign it to the class field so instances implement the new interface member

• In projects/netgrif-components-core/src/lib/resources/interface/user-resource-small.ts
– Add workspaceId: string; (or workspaceId?: string; for backward compatibility) to UserResourceSmall

Also update any mapping or factory methods that create User or UserResourceSmall to populate workspaceId.

🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/user/models/iuser.ts around lines 37
to 40, adding the required workspaceId property to the IUser interface is a
breaking change. To fix this, update all IUser implementations accordingly: in
projects/netgrif-components-core/src/lib/user/models/user.ts, add a public
workspaceId string parameter to the User constructor (optionally with a default
value) and assign it to the class field; in
projects/netgrif-components-core/src/lib/resources/interface/user-resource-small.ts,
add workspaceId as a string property (optionally make it optional for backward
compatibility). Also, update any factory or mapping methods that create User or
UserResourceSmall instances to ensure workspaceId is properly populated.

Comment on lines +8 to 9
return of({email: 'mail', id: 'id', username: 'username', realmId: 'realmId', name: 'name', firstName: 'name', surname: 'surname', lastName: 'surname', fullName: 'name surname', workspaceId: '',
groups: [], authorities: [], nextGroups: [], processRoles: []});
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Inconsistent workspace ID value in mock data.

The mock uses an empty string for workspaceId, but the IUser interface example suggests "default" as the expected value. This inconsistency could lead to test scenarios that don't match real-world usage.

Consider updating the mock to use a consistent default value:

-        return of({email: 'mail', id: 'id', username: 'username', realmId: 'realmId', name: 'name', firstName: 'name', surname: 'surname', lastName: 'surname', fullName: 'name surname', workspaceId: '',
+        return of({email: 'mail', id: 'id', username: 'username', realmId: 'realmId', name: 'name', firstName: 'name', surname: 'surname', lastName: 'surname', fullName: 'name surname', workspaceId: 'default',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return of({email: 'mail', id: 'id', username: 'username', realmId: 'realmId', name: 'name', firstName: 'name', surname: 'surname', lastName: 'surname', fullName: 'name surname', workspaceId: '',
groups: [], authorities: [], nextGroups: [], processRoles: []});
return of({
email: 'mail',
id: 'id',
username: 'username',
realmId: 'realmId',
name: 'name',
firstName: 'name',
surname: 'surname',
lastName: 'surname',
fullName: 'name surname',
workspaceId: 'default',
groups: [],
authorities: [],
nextGroups: [],
processRoles: []
});
🤖 Prompt for AI Agents
In
projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication-method-service.ts
at lines 8-9, the mock user object sets workspaceId to an empty string, which is
inconsistent with the IUser interface example that uses "default". Update the
workspaceId value in the mock to "default" to ensure test data aligns with
expected real-world values and avoid potential test discrepancies.

@@ -83,7 +84,8 @@ export class PanelsComponent implements OnInit {
email: 'test@netgrif.com',
fullName: 'Test Testovič'
},
immediateData: []
immediateData: [],
workspaceId: ''
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use consistent default workspace ID value.

Similar to the case object above, consider using "default" instead of an empty string for consistency.

-            workspaceId: ''
+            workspaceId: 'default'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
workspaceId: ''
workspaceId: 'default'
🤖 Prompt for AI Agents
In projects/nae-example-app/src/app/doc/panels/panels.component.ts at line 88,
the default value for workspaceId is set as an empty string, which is
inconsistent with the "case" object that uses "default". Change the default
value of workspaceId from an empty string to "default" to maintain consistency
across the code.

@@ -68,7 +68,8 @@
stringId: null,
petriNetId: null,
permissions: {},
users: {}
users: {},
workspaceId: ''
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use consistent default workspace ID value.

The empty string value for workspaceId is inconsistent with the "default" example shown in the IUser interface. For demo purposes, using a meaningful value would be better.

-            workspaceId: ''
+            workspaceId: 'default'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
workspaceId: ''
workspaceId: 'default'
🤖 Prompt for AI Agents
In projects/nae-example-app/src/app/doc/panels/panels.component.ts at line 72,
the default value for workspaceId is set to an empty string, which is
inconsistent with the "default" example in the IUser interface. Update the
workspaceId default value to match the meaningful default value used in the
IUser interface to maintain consistency and improve demo clarity.

Comment on lines +114 to +117
/**
* Workspace id
* */
workspaceId: string;
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Improve documentation consistency.

The workspaceId property documentation lacks an example value, unlike other properties in this interface. Consider adding an example for consistency.

     /**
-     * Workspace id
+     * **Example:** default
+     * 
+     * Workspace id
      * */

Verify that existing code creating Case objects won't break with this new required property:


🏁 Script executed:

#!/bin/bash
# Check for Case object creation that might miss the new required property
rg -A 5 -B 2 "new.*Case|Case.*=" --type ts

Length of output: 66678


Add a usage example for workspaceId (no breaking changes detected)

I didn’t find any object literals or new Case constructions missing the new required workspaceId field—most Case instances flow through service calls or are returned from the backend, so TypeScript will receive the field at runtime. However, the documentation on the workspaceId property should still be expanded to match the style of neighboring fields.

• File: projects/netgrif-components-core/src/lib/resources/interface/case.ts
• Lines: 114–117

Suggested diff:

    /**
-    * Workspace id
+    * **Example:** default
+    *
+    * Workspace id
     */
    workspaceId: string;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Workspace id
* */
workspaceId: string;
/**
* **Example:** default
*
* Workspace id
*/
workspaceId: string;
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/resources/interface/case.ts around
lines 114 to 117, the workspaceId property lacks an example value in its
documentation, unlike other properties in the interface. Add an example value to
the JSDoc comment for workspaceId to maintain consistency in documentation style
without changing the code functionality.

Comment on lines +51 to +54
/**
* Workspace id
* */
workspaceId: string;
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify all implementations are updated for the breaking change.

Adding the required workspaceId property to the PetriNetReference interface is a breaking change. Ensure all code that creates or implements this interface has been updated to include the new property.

Run the following script to verify all PetriNetReference implementations include the new property:


🏁 Script executed:

#!/bin/bash
# Description: Find all PetriNetReference object creations and verify workspaceId is included

# Search for PetriNetReference object creations
rg -A 10 -B 2 "PetriNetReference|new.*Net\("

# Search for files that might be missing workspaceId in object literals
ast-grep --pattern $'{ 
  $$$
  title: $_,
  $$$
}'

Length of output: 67189


Add workspaceId to all PetriNetReference instantiations

The new required workspaceId: string field on PetriNetReference is missing in several object literals and tests, causing type errors. Please update each literal to include workspaceId (use an empty string '' or appropriate value in tests). Key locations:

  • projects/netgrif-components/src/lib/panel/workflow-panel/workflow-panel.component.spec.ts
  • projects/netgrif-components/src/lib/panel/public-workflow-panel/public-workflow-panel.component.spec.ts
  • projects/netgrif-components/src/lib/dialog/new-case-dialog/new-case-dialog.component.spec.ts
  • projects/netgrif-components-core/src/lib/view/tree-case-view/tree-component/case-tree.service.spec.ts
  • projects/netgrif-components-core/src/lib/process/net.spec.ts

Example update in a spec file:

public workflow: PetriNetReference = {
  stringId: '',
  title: '',
  identifier: '',
  version: '',
  initials: '',
  defaultCaseName: '',
  createdDate: [],
  author: { email: '', fullName: '' },
  immediateData: undefined,
+ workspaceId: ''
};

Repeat for all other object literals where a PetriNetReference is created.

🤖 Prompt for AI Agents
In
projects/netgrif-components-core/src/lib/resources/interface/petri-net-reference.ts
around lines 51 to 54, the PetriNetReference interface was updated to include a
new required property workspaceId of type string, which is a breaking change. To
fix this, update all object literals and tests that create or implement
PetriNetReference across the codebase to include the workspaceId property with
an appropriate value, such as an empty string '' in tests. Key files to update
include workflow-panel.component.spec.ts,
public-workflow-panel.component.spec.ts, new-case-dialog.component.spec.ts,
case-tree.service.spec.ts, and net.spec.ts. Ensure every PetriNetReference
instantiation has workspaceId added to avoid type errors.

Comment on lines +73 to +76
/**
* Workspace id
* */
workspaceId: string;
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify all Task implementations include the new required property.

The addition of the required workspaceId property to the Task interface is a breaking change. All code that creates Task objects must be updated to include this property.

Run the following script to identify any Task object creations that might be missing the workspaceId:


🏁 Script executed:

#!/bin/bash
# Description: Find Task object creations and verify workspaceId inclusion

# Search for Task object creations and assignments
rg -A 15 "Task\s*=\s*{|:\s*Task\s*=|new.*Task\(|as\s+Task"

# Look for mock Task objects that might need updating
fd -e ts -x rg -l "Task.*mock|mock.*Task" {}

Length of output: 1368


🏁 Script executed:

#!/bin/bash
# 1. Find object literals explicitly annotated with Task:
echo "=== Object literals typed as Task ==="
rg -n -E ':\s*Task\s*=\s*\{' -n projects/netgrif-components-core || echo "No direct annotations found."

# 2. Find casts to Task:
echo -e "\n=== 'as Task' casts ==="
rg -n 'as\s\+Task' -n projects/netgrif-components-core || echo "No 'as Task' casts found."

# 3. Verify mocks include workspaceId:
echo -e "\n=== Checking mocks for workspaceId ==="
for f in $(fd -e ts -g "create-mock-task*.ts"); do
  if rg -q "workspaceId" "$f"; then
    echo "OK: workspaceId present in $f"
  else
    echo "MISSING: workspaceId not found in $f"
  fi
done

Length of output: 1397


Include workspaceId in all Task mocks

A required workspaceId is missing from one of your test fixtures, which will break Task implementations in tests.

• projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-task-outcome.ts
– Add a workspaceId: string entry to the exported mock object.

Please also scan for any other untyped Task literals or fixtures to ensure they include the new workspaceId property.

🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/resources/interface/task.ts around
lines 73 to 76, the Task interface now requires a workspaceId string property,
which is a breaking change. You need to update all Task object creations,
especially test mocks like in
projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-task-outcome.ts,
to include a workspaceId string field. Review all Task literals, casts, and
mocks across the codebase to ensure they define workspaceId to prevent runtime
errors.

@@ -13,6 +13,7 @@ export class User implements IUser {
public realmId: string,
public firstName: string,
public lastName: string,
public workspaceId: string,
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify constructor parameter placement doesn't break existing code.

Adding workspaceId in the middle of the constructor parameters is a breaking change if any code instantiates User objects using positional arguments rather than named parameters.

Run this script to verify all User constructor calls are compatible:


🏁 Script executed:

#!/bin/bash
# Description: Find all User constructor calls to verify they won't break with the new parameter

# Search for new User() instantiations
echo "=== Direct User constructor calls ==="
rg -A 3 "new User\(" --type ts

# Search for User constructor calls in factories or builders
echo -e "\n=== User creation in factories/transformers ==="
rg -A 5 "User\(" --type ts | grep -v "export class User"

# Check if UserTransformer or similar classes handle the new parameter
echo -e "\n=== UserTransformer implementations ==="
ast-grep --pattern 'class $_ {
  $$$
  transform($$$) {
    $$$
    new User($$$)
    $$$
  }
  $$$
}'

Length of output: 65160


Fix User constructor parameter placement to avoid breaking changes.

The workspaceId parameter was inserted mid‐constructor, but most new User(…) calls across the repo (in transformers, services, mocks and specs) still use the old argument order. You must either:

  • Move workspaceId to the end of the constructor signature in
    projects/netgrif-components-core/src/lib/user/models/user.ts, for example:
     constructor(
       public id: string,
       public username: string,
       public email: string,
       public realmId: string,
  • public workspaceId: string,
    public firstName: string,
    public lastName: string,
    /* … */
  • public workspaceId: string,
    ) { }
- Or update every `new User(…)` invocation to supply the new fifth argument. Critical locations include:  
• `authentication/models/user.transformer.ts`  
• `user/services/user.service.ts` (emptyUser)  
• `utility/tests/mocks/mock-authentication.service.ts`  
• `view/case-view/abstract-case-view.spec.ts`  
• …and dozens of other spec files under `projects/netgrif-components-core` and `projects/netgrif-components`  



<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
      constructor(
        public id: string,
        public username: string,
        public email: string,
        public realmId: string,
        public firstName: string,
        public lastName: string,
        public workspaceId: string,
        /* … */
      ) { }
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/user/models/user.ts at line 16, the
workspaceId parameter was added in the middle of the User constructor
parameters, causing breaking changes for existing positional constructor calls.
To fix this, move the workspaceId parameter to the end of the constructor
parameter list to preserve the original argument order. Alternatively, update
all new User(...) calls across the codebase to include the new fifth argument in
the correct position, especially in critical files like
authentication/models/user.transformer.ts, user/services/user.service.ts,
utility/tests/mocks/mock-authentication.service.ts, and
view/case-view/abstract-case-view.spec.ts.

@@ -84,6 +88,7 @@ export class Net implements PetriNetReferenceWithPermissions {
this._transactions = [];
this._roles = [];
this._uriNodeId = net.uriNodeId;
this._workspaceId = net.workspaceId
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix missing semicolon.

The constructor initialization is missing a semicolon at the end of the line.

-        this._workspaceId = net.workspaceId
+        this._workspaceId = net.workspaceId;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this._workspaceId = net.workspaceId
this._workspaceId = net.workspaceId;
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/process/net.ts at line 91, the
assignment statement setting this._workspaceId is missing a semicolon at the
end. Add a semicolon to properly terminate the statement.

Comment on lines +233 to +239
public changeWorkspace(workspaceId: string) {
this._userResource.changeWorkspace(workspaceId).subscribe(user => {
if (user) {
window.location.reload();
}
});
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling and input validation.

The method should handle potential failures and validate the input parameter:

 public changeWorkspace(workspaceId: string) {
+    if (!workspaceId) {
+        this._log.error('Workspace ID is required for workspace change');
+        return;
+    }
+    
     this._userResource.changeWorkspace(workspaceId).subscribe(user => {
         if (user) {
             window.location.reload();
         }
+    }, error => {
+        this._log.error('Changing workspace has failed!', error);
     });
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public changeWorkspace(workspaceId: string) {
this._userResource.changeWorkspace(workspaceId).subscribe(user => {
if (user) {
window.location.reload();
}
});
}
public changeWorkspace(workspaceId: string) {
if (!workspaceId) {
this._log.error('Workspace ID is required for workspace change');
return;
}
this._userResource.changeWorkspace(workspaceId).subscribe(user => {
if (user) {
window.location.reload();
}
}, error => {
this._log.error('Changing workspace has failed!', error);
});
}
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/user/services/user.service.ts around
lines 233 to 239, the changeWorkspace method lacks input validation and error
handling. Add a check to ensure workspaceId is valid before proceeding. Also,
add error handling in the subscription to manage potential failures from
changeWorkspace, such as logging the error or notifying the user, instead of
silently failing.

- add translations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant