Conversation
45e8766 to
d5b7b00
Compare
d5b7b00 to
6a730f6
Compare
Fixes #24
6a730f6 to
5d7706e
Compare
📝 WalkthroughWalkthroughThis 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
selectedLanguageis 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 inEnums.tsor a constants file for consistency and maintainability, similar to howUserRolesis 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 addingmaxconstraints toStepInputfields.The
StepInputfields havemin="1"which prevents zero/negative values, but nomaxconstraint. 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
📒 Files selected for processing (12)
mock.mjswebapp/Component.tswebapp/common/Types.tswebapp/controller/App.controller.tswebapp/controller/BaseController.tswebapp/controller/Settings.controller.tswebapp/controller/settings/SettingsDialog.controller.tswebapp/i18n/i18n_en.propertieswebapp/resources/fragments/UserInfoPopover.fragment.xmlwebapp/resources/fragments/settings/SettingsDialog.fragment.xmlwebapp/view/App.view.xmlwebapp/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
|
closing due to branch name, opened #95 |
Fixes #24
Summary by CodeRabbit
New Features
Refactor