feat(app-configs): warn when persistent volume label is used by other apps - #223
Conversation
… apps Auto-fetch volume inventory and show yellow warning when label is shared. Keep plain Input; no AutoComplete/Select.
📝 WalkthroughWalkthroughAdds typed volume inventory retrieval and helper utilities, then uses the inventory in app configuration to warn when non-bind persistent volumes are shared with other applications. ChangesPersistent volume warnings
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant AppConfigs
participant ApiManager
participant VolumesAPI
participant volumeHelpers
AppConfigs->>ApiManager: getAllVolumes()
ApiManager->>VolumesAPI: GET /user/system/volumes/
VolumesAPI-->>ApiManager: VolumesListResponse
ApiManager-->>AppConfigs: volume inventory
AppConfigs->>volumeHelpers: resolvePhysicalVolumeName()
AppConfigs->>volumeHelpers: getOtherAppsUsingVolume()
volumeHelpers-->>AppConfigs: other application names
AppConfigs->>AppConfigs: Render localized warning
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Replace null with undefined in AppConfigs conditional render and volume helper test fixtures; loosen VolumeInfo options typing accordingly.
Add apps.app_config_vol_in_use_warning with %s placeholder to every non-English locale file.
Fix CI prettier --check failure on volume in-use warning UI.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/utils/volumeHelpers.ts (1)
45-50: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDocstring says "a single
%s" but implementation replaces all occurrences.Replace a single
%splaceholder in a localized template string. Thesplit('%s').join(value)implementation actually replaces every%soccurrence (as the accompanying test confirms). Update the comment to avoid confusing future readers.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/utils/volumeHelpers.ts` around lines 45 - 50, Update the docstring for formatLocalized to state that it replaces all `%s` occurrences in the localized template, matching the existing split('%s').join(value) behavior and tests.src/containers/apps/appDetails/AppConfigs.tsx (1)
59-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAd hoc response type duplicates
VolumesListResponse.The
.thencallback re-declares the response shape as{ volumes?: VolumeListItem[] }, butgetAllVolumes()already returns a typedPromise<VolumesListResponse>whosevolumesfield is required, not optional. Reusing the imported type avoids the two shapes drifting apart.♻️ Proposed cleanup
+import { VolumesListResponse } from '../../../models/VolumeInfo' ... - .then((data: { volumes?: VolumeListItem[] }) => { + .then((data: VolumesListResponse) => {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/containers/apps/appDetails/AppConfigs.tsx` around lines 59 - 68, Replace the ad hoc `.then` callback response type in the volume-loading flow with the existing `VolumesListResponse` type returned by `getAllVolumes()`. Import and reuse that shared type, and access the required `volumes` field without the optional fallback while preserving the existing unmount guard and state update.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/models/VolumeInfo.ts`:
- Around line 1-11: Update the DockerVolumeInfo.options property to be optional
so callers can omit it when no options map is available, while preserving the
existing string-keyed object type and compatibility with null-valued data where
required.
In `@src/utils/volumeHelpers.test.ts`:
- Around line 13-22: Update the volume info type used by the test helper so
DockerVolumeInfo.options is optional and can be omitted, then remove the
options: null property from the returned object. Ensure the related VolumeInfo
definition and helper return type remain consistent without introducing null.
---
Nitpick comments:
In `@src/containers/apps/appDetails/AppConfigs.tsx`:
- Around line 59-68: Replace the ad hoc `.then` callback response type in the
volume-loading flow with the existing `VolumesListResponse` type returned by
`getAllVolumes()`. Import and reuse that shared type, and access the required
`volumes` field without the optional fallback while preserving the existing
unmount guard and state update.
In `@src/utils/volumeHelpers.ts`:
- Around line 45-50: Update the docstring for formatLocalized to state that it
replaces all `%s` occurrences in the localized template, matching the existing
split('%s').join(value) behavior and tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f770fb7f-f9f2-4d4b-8c14-2afd26a3b736
📒 Files selected for processing (6)
src/api/ApiManager.tssrc/containers/apps/appDetails/AppConfigs.tsxsrc/locales/en-US.jsonsrc/models/VolumeInfo.tssrc/utils/volumeHelpers.test.tssrc/utils/volumeHelpers.ts
options is optional on DockerVolumeInfo; drop explicit undefined to avoid null/undefined noise in tests.
Summary
GET /user/system/volumes/(CapRover PR #2440) when App Configs loads for apps with persistent data.Alertunder that volume row.Design notes
Input(no AutoComplete/Select).captain--{label}.Test plan
yarn test --watchAll=false --testPathPattern=volumeHelpers(17/17)hasPersistentDataon a captain build that includes #2440Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests