Commit 2ecde6f
committed
Resolves #7411(FR-2893)
test-server: 10.122.10.107
## Summary
`FolderExplorerModalV2` already fetches the caller's host-level permission set via `useMergedAllowedStorageHostPermission`, and that set carries both `download-file` and `upload-file`. Until now only `download-file` was consumed; write/upload/edit were hard-coded to `true` and stayed enabled regardless of host permission. This PR splits the upload gate from the generic write gate, wires V2 to the host `upload-file` capability, and surfaces _why_ the button is disabled via a tooltip.
## Component changes (`BAIFileExplorer` / `ExplorerActionControls`)
- New optional `enableUpload?: boolean` prop on `BAIFileExplorer` and `ExplorerActionControls`.
- `enableUpload` gates: upload dropdown, mobile upload button, drag-drop overlay.
- `enableWrite` continues to gate: mkdir, create-file, inline rename.
- Default is `enableUpload = false` (opt-in), matching the convention of the other capability props (`enableDownload` / `enableDelete` / `enableWrite` / `enableEdit`).
- When `enableUpload` is falsy, the upload button's tooltip shows `comp:FileExplorer.NoUploadPermissionForHost` so users understand why the action is disabled.
## V2 wiring (`FolderExplorerModalV2`)
```tsx
const hasUploadContentPermission = _.includes(
unitedAllowedPermissionByVolume[vfolderNode?.host ?? ''],
'upload-file',
);
...
enableWrite={hasWriteContentPermission} // = true (unchanged; FR-2619 follow-up)
enableUpload={hasUploadContentPermission} // new gate
enableEdit={hasUploadContentPermission} // edit save = overwrite upload
```
`enableEdit` is gated by `upload-file` because the in-app text editor saves by overwriting the file via the upload API (`VFolderTextFileEditorModal` → `uploadFiles`). If the user lacks `upload-file`, the save would fail server-side anyway; disabling upfront keeps the UX honest.
## V1 wiring (`FolderExplorerModal`)
Since the new default is opt-in (`enableUpload = false`), V1 now explicitly passes `enableUpload={hasWriteContentPermission}` to preserve its previous bundled behavior. V1 still gates by `write_content` from the vfolder entity permission — adopting the host `upload-file` check would broaden V1's behavior change and is out of scope for this PR.
## i18n
New key `comp:FileExplorer.NoUploadPermissionForHost` added to `en.json` (source) and translated into all 20 target languages via the `fw:i18n-translator` agent (de, el, es, fi, fr, id, it, ja, ko, mn, ms, pl, pt, pt-BR, ru, th, tr, vi, zh-CN, zh-TW).
Korean: "호스트에 대한 업로드 권한이 없습니다."
## Out of scope
- `hasWriteContentPermission` and `hasDeleteContentPermission` remain hard-coded to `true`. There is no host-level permission for mkdir / create-file / rename / delete today; FR-2619 will revisit when the backend exposes the effective permission set.
- Separately, the storage host currently accepts uploads even when `upload-file` is not granted (server-side gap, observed during the Hyundai Mobis investigation). That belongs on the backend and is being tracked separately.
## Test plan
- [ ] V2 explorer — user without `upload-file` on the folder's host:
- Upload dropdown, mobile upload button, drag-drop overlay, and file-edit save are all disabled.
- Hovering the upload button shows the "no upload permission" tooltip (and the localized version when the UI language is switched).
- [ ] V2 explorer — mkdir / create-file / inline rename remain enabled regardless of `upload-file`.
- [ ] V2 explorer — user with `upload-file`: all upload and edit actions behave as before.
- [ ] V2 explorer — `download-file` gating is unchanged.
- [ ] V1 `FolderExplorerModal` — no behavior change: `write_content` continues to gate upload, mkdir, create-file, rename, and edit. Same disabled-vs-enabled outcome as `main`.
1 parent 32dbd20 commit 2ecde6f
25 files changed
Lines changed: 61 additions & 5 deletions
File tree
- packages/backend.ai-ui/src
- components/baiClient/FileExplorer
- locale
- react/src/components
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
61 | 66 | | |
62 | 67 | | |
63 | 68 | | |
| |||
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
| 89 | + | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
| |||
301 | 307 | | |
302 | 308 | | |
303 | 309 | | |
304 | | - | |
| 310 | + | |
305 | 311 | | |
306 | 312 | | |
307 | 313 | | |
| |||
326 | 332 | | |
327 | 333 | | |
328 | 334 | | |
| 335 | + | |
329 | 336 | | |
330 | 337 | | |
331 | 338 | | |
| |||
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
| |||
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
| |||
178 | 186 | | |
179 | 187 | | |
180 | 188 | | |
181 | | - | |
| 189 | + | |
182 | 190 | | |
183 | 191 | | |
184 | 192 | | |
| |||
237 | 245 | | |
238 | 246 | | |
239 | 247 | | |
240 | | - | |
241 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
242 | 258 | | |
243 | 259 | | |
244 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
342 | 343 | | |
343 | 344 | | |
344 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
0 commit comments