Skip to content

Add workflow settings#25

Closed
neilmcclelland wants to merge 1 commit intomainfrom
feature/KMS20-4086-make-workflow-settings
Closed

Add workflow settings#25
neilmcclelland wants to merge 1 commit intomainfrom
feature/KMS20-4086-make-workflow-settings

Conversation

@neilmcclelland
Copy link
Copy Markdown
Contributor

@neilmcclelland neilmcclelland commented Feb 25, 2026

Fixes #24

Summary by CodeRabbit

  • New Features

    • Settings dialog with workflow configuration management
    • Save workflow settings with change tracking and validation
    • Role-based access controls for viewing and managing settings
  • Refactor

    • Relocated settings access from side navigation to user info menu
    • Consolidated language and workflow settings in unified dialog interface
    • Added localization strings for workflow settings UI and messages

@neilmcclelland neilmcclelland self-assigned this Feb 25, 2026
@neilmcclelland neilmcclelland marked this pull request as draft March 2, 2026 09:35
@neilmcclelland neilmcclelland force-pushed the feature/KMS20-4086-make-workflow-settings branch from 45e8766 to d5b7b00 Compare March 2, 2026 15:55
@neilmcclelland neilmcclelland marked this pull request as ready for review March 2, 2026 15:55
Comment thread webapp/config/config.json Outdated
Comment thread webapp/controller/BaseController.ts Outdated
@neilmcclelland neilmcclelland force-pushed the feature/KMS20-4086-make-workflow-settings branch from d5b7b00 to 6a730f6 Compare March 5, 2026 11:27
spusala-sap
spusala-sap previously approved these changes Mar 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

This PR introduces a workflow settings feature by adding API endpoints for managing workflow configurations and restructuring settings access from a dedicated route to a modal dialog. The old Settings view and controller are removed, replaced with a SettingsDialog fragment that provides language and workflow settings management with role-based access control.

Changes

Cohort / File(s) Summary
Mock Server & API
mock.mjs
Added in-memory workflowSettings object with GET/PATCH routes for /cmk/v1/tenant1-id/tenantConfigurations/workflow and a GET route for /cmk/v1/tenant1-id/tenantInfo returning static tenant role data.
Role-Based Access Model
webapp/Component.ts, webapp/common/Types.ts
Extended RoleBasedAccessData interface with new settings permission block containing canView (auditor/key admin/tenant admin) and canManage (tenant admin only) fields.
Settings Dialog Implementation
webapp/controller/BaseController.ts, webapp/controller/settings/SettingsDialog.controller.ts, webapp/resources/fragments/settings/SettingsDialog.fragment.xml
Added dialog handler with lazy initialization in BaseController, new SettingsDialogHandler class managing dialog lifecycle (language selection, workflow settings load/save, API integration), and corresponding UI fragment with language and workflow settings pages.
UI Layer Restructuring
webapp/resources/fragments/UserInfoPopover.fragment.xml, webapp/view/App.view.xml
Replaced navigation list with button-based popover menu; removed fixed settings navigation item from side navigation.
Removed Settings Views
webapp/controller/Settings.controller.ts, webapp/view/Settings.view.xml
Deleted standalone Settings controller (language selection logic) and corresponding view; functionality migrated to SettingsDialog.
Route Handling
webapp/controller/App.controller.ts
Removed explicit switch case for routeName === 'settings'; settings route now falls through to default behavior.
Localization
webapp/i18n/i18n_en.properties
Added workflow-related UI text keys (settings labels, success/error messages, field names) and updated language key from "Language" to "Language Settings".

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as Popover Menu
    participant BaseCtrl as BaseController
    participant DialogHandler as SettingsDialogHandler
    participant API as API Server
    participant Models as JSON Models

    User->>UI: Click settings button
    UI->>BaseCtrl: onOpenSettingsDialog()
    BaseCtrl->>DialogHandler: new SettingsDialogHandler(view)
    BaseCtrl->>DialogHandler: open()
    DialogHandler->>API: GET tenantInfo
    API-->>DialogHandler: { role: "TEST" }
    DialogHandler->>API: GET tenantConfigurations/workflow
    API-->>DialogHandler: workflow settings
    DialogHandler->>Models: Initialize language & workflow models
    DialogHandler->>UI: Display SettingsDialog
    User->>UI: Modify workflow settings
    UI->>Models: Update workflow model
    User->>UI: Click Save
    DialogHandler->>API: PATCH tenantConfigurations/workflow
    API-->>DialogHandler: Updated settings
    DialogHandler->>Models: Update models & show success toast
    User->>UI: Click Close
    DialogHandler->>UI: Close dialog
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

feature

Suggested reviewers

  • Ayurshi-Singh
  • spusala-sap

Poem

🐰 Hops with glee, the settings now bloom,
No more separate route, just a dialog room,
Workflows can dance with toggles and sliders,
While role-based guards keep them safe from outsiders!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only references 'Fixes #24' without providing the required sections from the template (category, detailed description, notes, or release notes). Update the description to follow the template: add category prefix (e.g., 'feat:'), provide detailed explanation of changes, and include release notes or 'NONE'.
Out of Scope Changes check ❓ Inconclusive All changes are scoped to implementing workflow settings, except for unrelated modifications to user popover navigation and removal of the old Settings controller that go beyond workflow settings implementation. Clarify whether the UserInfoPopover restructuring and Settings controller removal are intentional refactoring or should be separated into a different PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add workflow settings' is concise, clear, and directly matches the main change across the PR, which implements a complete workflow settings feature.
Linked Issues check ✅ Passed The PR implements a comprehensive workflow settings feature with backend endpoints, UI components, and role-based access control, aligning with issue #24's objective to add workflow settings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/KMS20-4086-make-workflow-settings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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 (3)
webapp/controller/settings/SettingsDialog.controller.ts (2)

107-115: Consider graceful handling instead of throwing on invalid language index.

If selectedLanguage is not found, throwing an error could crash the dialog. A safer approach would be to fall back to a default language or simply not change the language.

♻️ Suggested safer approach
 public onLanguageChanged(): void {
     const selectedLanguageIndex: number = this.settingsOneWayModel.getProperty('/selectedLanguageIndex') as number;
     const selectedLanguage = Object.entries(languageMapping)
         .find(([_, value]) => value === selectedLanguageIndex);
     if (!selectedLanguage) {
-        throw new Error('Invalid language index');
+        console.warn('Invalid language index, defaulting to EN');
+        setLanguage('EN', false);
+        return;
     }
     setLanguage(selectedLanguage[0], false);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@webapp/controller/settings/SettingsDialog.controller.ts` around lines 107 -
115, The onLanguageChanged handler throws when selectedLanguage is undefined
which can crash the dialog; update onLanguageChanged to handle a missing mapping
gracefully by checking the result of Object.entries(languageMapping).find(...)
and if not found either return early (do not call setLanguage) or call
setLanguage with a safe default (e.g., fallback key) instead of throwing; modify
the logic in onLanguageChanged (referencing settingsOneWayModel, languageMapping
and setLanguage) to implement the chosen fallback behavior and ensure no
exception is thrown for invalid indices.

168-179: Hardcoded role string 'TEST' should use a constant.

The role check tenantInfo?.role === 'TEST' uses a magic string. Consider defining this in Enums.ts or a constants file for consistency and maintainability, similar to how UserRoles is used elsewhere in the codebase.

♻️ Suggested approach

Add the role to an appropriate enum/constant:

// In Enums.ts or similar
export const TenantRoles = {
    TEST: 'TEST',
    // ... other roles
} as const;

Then use it here:

-const canEditWorkflowEnabled = tenantInfo?.role === 'TEST';
+const canEditWorkflowEnabled = tenantInfo?.role === TenantRoles.TEST;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@webapp/controller/settings/SettingsDialog.controller.ts` around lines 168 -
179, The hardcoded role string in getTenantInfo() (tenantInfo?.role === 'TEST')
should be replaced with a named constant/enum; add a TenantRoles export (e.g.,
export const TenantRoles = { TEST: 'TEST', ... } as const) in your Enums.ts (or
existing constants file) and change the comparison in getTenantInfo() to use
TenantRoles.TEST, keeping the rest of the logic (setting /canEditWorkflowEnabled
on settingsOneWayModel) unchanged.
webapp/resources/fragments/settings/SettingsDialog.fragment.xml (1)

99-121: Consider adding max constraints to StepInput fields.

The StepInput fields have min="1" which prevents zero/negative values, but no max constraint. This could allow users to enter unreasonably large values (e.g., 999999 days for retention). Consider adding sensible maximum limits based on business requirements.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@webapp/resources/fragments/settings/SettingsDialog.fragment.xml` around lines
99 - 121, Add upper bounds to the StepInput controls to prevent unreasonably
large values: for each StepInput bound to workflow>/minimumApprovals,
workflow>/defaultExpiryPeriodDays, workflow>/maxExpiryPeriodDays and
workflow>/retentionPeriodDays add a max="…" attribute with sensible limits (for
example set a max for approvals and use day-limits like 365 or another
business-approved value) while preserving the existing min="1", step="1", width
and enabled="{oneWay>/canEditWorkflowSettings}" settings; update only the
StepInput elements (not the labels) so the UI enforces the new upper limits.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@webapp/i18n/i18n_en.properties`:
- Around line 351-356: Remove the duplicate i18n entry for the key
"minimumApprovals" so it appears only once; locate the two occurrences near the
surrounding keys "workflowEnabled" and "approversVoting" in the
i18n_en.properties file and delete the redundant line (keep a single
"minimumApprovals=Minimum Approvals").

---

Nitpick comments:
In `@webapp/controller/settings/SettingsDialog.controller.ts`:
- Around line 107-115: The onLanguageChanged handler throws when
selectedLanguage is undefined which can crash the dialog; update
onLanguageChanged to handle a missing mapping gracefully by checking the result
of Object.entries(languageMapping).find(...) and if not found either return
early (do not call setLanguage) or call setLanguage with a safe default (e.g.,
fallback key) instead of throwing; modify the logic in onLanguageChanged
(referencing settingsOneWayModel, languageMapping and setLanguage) to implement
the chosen fallback behavior and ensure no exception is thrown for invalid
indices.
- Around line 168-179: The hardcoded role string in getTenantInfo()
(tenantInfo?.role === 'TEST') should be replaced with a named constant/enum; add
a TenantRoles export (e.g., export const TenantRoles = { TEST: 'TEST', ... } as
const) in your Enums.ts (or existing constants file) and change the comparison
in getTenantInfo() to use TenantRoles.TEST, keeping the rest of the logic
(setting /canEditWorkflowEnabled on settingsOneWayModel) unchanged.

In `@webapp/resources/fragments/settings/SettingsDialog.fragment.xml`:
- Around line 99-121: Add upper bounds to the StepInput controls to prevent
unreasonably large values: for each StepInput bound to
workflow>/minimumApprovals, workflow>/defaultExpiryPeriodDays,
workflow>/maxExpiryPeriodDays and workflow>/retentionPeriodDays add a max="…"
attribute with sensible limits (for example set a max for approvals and use
day-limits like 365 or another business-approved value) while preserving the
existing min="1", step="1", width and
enabled="{oneWay>/canEditWorkflowSettings}" settings; update only the StepInput
elements (not the labels) so the UI enforces the new upper limits.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3d6d27f6-4e0b-4bc7-b1a0-3d4a546faae7

📥 Commits

Reviewing files that changed from the base of the PR and between c946583 and 5d7706e.

📒 Files selected for processing (12)
  • mock.mjs
  • webapp/Component.ts
  • webapp/common/Types.ts
  • webapp/controller/App.controller.ts
  • webapp/controller/BaseController.ts
  • webapp/controller/Settings.controller.ts
  • webapp/controller/settings/SettingsDialog.controller.ts
  • webapp/i18n/i18n_en.properties
  • webapp/resources/fragments/UserInfoPopover.fragment.xml
  • webapp/resources/fragments/settings/SettingsDialog.fragment.xml
  • webapp/view/App.view.xml
  • webapp/view/Settings.view.xml
💤 Files with no reviewable changes (4)
  • webapp/controller/App.controller.ts
  • webapp/view/App.view.xml
  • webapp/view/Settings.view.xml
  • webapp/controller/Settings.controller.ts

Comment thread webapp/i18n/i18n_en.properties
@neilmcclelland
Copy link
Copy Markdown
Contributor Author

closing due to branch name, opened #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: Add workflows settings

3 participants