@bigbinary/neeto-folders-frontend 2.1.0-beta1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -1
- package/app/javascript/src/translations/en.json +82 -0
- package/dist/.ready +1 -1
- package/dist/cjs/components.js +5 -4
- package/dist/cjs/components.js.map +1 -1
- package/dist/cjs/hooks.js +2 -2
- package/dist/cjs/utils.js +2 -2
- package/dist/cjs/v2/components.js +946 -40
- package/dist/cjs/v2/components.js.map +1 -1
- package/dist/components.js +5 -4
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +2 -2
- package/dist/{index-BXvkr7vp.js → index-CbypYFzw.js} +2 -2
- package/dist/{index-BXvkr7vp.js.map → index-CbypYFzw.js.map} +1 -1
- package/dist/{index-DCIRHXw_.js → index-DPGZgR3c.js} +2 -2
- package/dist/{index-DCIRHXw_.js.map → index-DPGZgR3c.js.map} +1 -1
- package/dist/{internal-UIifJzTd.js → internal-Cg8w0New.js} +8 -2
- package/dist/internal-Cg8w0New.js.map +1 -0
- package/dist/{internal-DAkDv0P1.js → internal-DkESa3he.js} +8 -1
- package/dist/internal-DkESa3he.js.map +1 -0
- package/dist/{useFolderActions-DCKQrv0G.js → useFolderActions-C1AHYJua.js} +2 -2
- package/dist/{useFolderActions-DCKQrv0G.js.map → useFolderActions-C1AHYJua.js.map} +1 -1
- package/dist/{useFolderActions-DImaQ3gr.js → useFolderActions-D_egbV70.js} +2 -2
- package/dist/{useFolderActions-DImaQ3gr.js.map → useFolderActions-D_egbV70.js.map} +1 -1
- package/dist/utils.js +2 -2
- package/dist/v2/components.js +949 -46
- package/dist/v2/components.js.map +1 -1
- package/package.json +9 -9
- package/types.d.ts +64 -0
- package/dist/internal-DAkDv0P1.js.map +0 -1
- package/dist/internal-UIifJzTd.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,7 +13,8 @@ structure, configs, data etc.
|
|
|
13
13
|
- [Installation](#installation-1)
|
|
14
14
|
- [Instructions for development](#instructions-for-development)
|
|
15
15
|
- [Usage](#usage-1)
|
|
16
|
-
2. [
|
|
16
|
+
2. [Folder access](#folder-access)
|
|
17
|
+
3. [Instructions for Publishing](#instructions-for-publishing)
|
|
17
18
|
|
|
18
19
|
## Development with Host Application
|
|
19
20
|
|
|
@@ -389,6 +390,179 @@ import * as constants from "@bigbinary/neeto-folders-frontend/constants";
|
|
|
389
390
|
- `[QUERY_KEYS.FOLDERS, config.folderType, QUERY_KEYS.DETAILS, folderId]`:
|
|
390
391
|
Target folder details of a folder with id `folderId`
|
|
391
392
|
|
|
393
|
+
## Folder access
|
|
394
|
+
|
|
395
|
+
Drive-style internal sharing for folders and the items in them. Every node is
|
|
396
|
+
**Only me**, **Workspace** or **Restricted** (named people), with **View** or
|
|
397
|
+
**Manage** capability. A node with no setting of its own inherits from its
|
|
398
|
+
container, the default when nothing is set anywhere is Workspace/Manage, and a
|
|
399
|
+
node's creator always has Manage.
|
|
400
|
+
|
|
401
|
+
The engine stores and resolves access. It never decides who may change it:
|
|
402
|
+
**authorization is the host's job.** Check that the acting user has Manage
|
|
403
|
+
(and that every member you save is an active user of the organization) before
|
|
404
|
+
calling any write below. Keep the feature behind a host flag; the tables are
|
|
405
|
+
additive, so with the flag off nothing reads them.
|
|
406
|
+
|
|
407
|
+
### Wiring
|
|
408
|
+
|
|
409
|
+
1. Run `rails g neeto_folders_engine:install` to copy the
|
|
410
|
+
`neeto_folders_engine_access_entries` and
|
|
411
|
+
`neeto_folders_engine_access_members` migrations, and the one that drops
|
|
412
|
+
the unique sibling-name index (sibling folders may share a name, since a
|
|
413
|
+
viewer may not be able to see the one already using it).
|
|
414
|
+
|
|
415
|
+
2. Configure who is acting and who owns content created without a person
|
|
416
|
+
(seeds, API keys). Both lambdas are read at call time.
|
|
417
|
+
|
|
418
|
+
```ruby
|
|
419
|
+
# config/initializers/neeto_folders_engine.rb
|
|
420
|
+
NeetoFoldersEngine.configure do |config|
|
|
421
|
+
config.current_user_id = -> { Current.user&.id }
|
|
422
|
+
config.default_owner_id = ->(organization_id) { Organization.find(organization_id).oldest_admin_id }
|
|
423
|
+
end
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
3. `NeetoFoldersEngine::Folder` is already accessible (its container is
|
|
427
|
+
`parent`). Opt each item model in, naming its container association and the
|
|
428
|
+
attribute shown in the share pane:
|
|
429
|
+
|
|
430
|
+
```ruby
|
|
431
|
+
class Article < ApplicationRecord
|
|
432
|
+
include NeetoFoldersEngine::Accessible
|
|
433
|
+
accessible container: :category, display_name: :title
|
|
434
|
+
end
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Every record gets an access entry on create. Override the private
|
|
438
|
+
`initial_root_access` to change what a new top-level node starts as (the
|
|
439
|
+
default is `{ access_type: :workspace, capability: :manage }`). Moving an
|
|
440
|
+
inheriting node to the top level keeps the access it had.
|
|
441
|
+
|
|
442
|
+
### How access is resolved
|
|
443
|
+
|
|
444
|
+
Every node has an access entry. It always records the node's creator, and it
|
|
445
|
+
has an `access_type` and `capability` only when access was set on that node;
|
|
446
|
+
otherwise the node inherits. Access is worked out in two steps.
|
|
447
|
+
|
|
448
|
+
**1. Resolve: walk up until a node has a setting.**
|
|
449
|
+
|
|
450
|
+
```
|
|
451
|
+
resolve(node):
|
|
452
|
+
creator = node's own creator
|
|
453
|
+
current = node
|
|
454
|
+
up to MAX_DEPTH + 1 times:
|
|
455
|
+
if current has an access_type: return that setting (source: current)
|
|
456
|
+
current = current's container (parent folder, or an item's folder)
|
|
457
|
+
stop if there is no container
|
|
458
|
+
return Workspace/Manage (source: nil)
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
The closest setting wins and replaces everything above it; nothing is merged
|
|
462
|
+
or intersected. In this tree:
|
|
463
|
+
|
|
464
|
+
```
|
|
465
|
+
L1 Restricted (Bob: View)
|
|
466
|
+
└── L2 (inherits)
|
|
467
|
+
└── L3 Workspace/Manage
|
|
468
|
+
└── Note (inherits)
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
L2 is Restricted with Bob on View, from L1. Note is Workspace/Manage, from L3:
|
|
472
|
+
a child with its own setting is not narrowed by a Restricted folder above it.
|
|
473
|
+
|
|
474
|
+
**2. Capability: what a given user gets from that setting.**
|
|
475
|
+
|
|
476
|
+
```
|
|
477
|
+
capability_for(node, user):
|
|
478
|
+
user created the node → Manage
|
|
479
|
+
user created the node the setting comes from → Manage
|
|
480
|
+
Workspace → the setting's capability, for everyone
|
|
481
|
+
Restricted → the user's capability in the setting's member list, else nil
|
|
482
|
+
Only me → nil
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
`nil` means the node is invisible to that user. So creators always manage
|
|
486
|
+
what they made, even inside someone else's View-only folder, and the creator
|
|
487
|
+
of an Only me or Restricted folder manages everything that inherits from it.
|
|
488
|
+
Membership counts only on the setting that decides: being a member of L1
|
|
489
|
+
gives nothing on a nested folder with its own Restricted list.
|
|
490
|
+
|
|
491
|
+
`resolve_many` runs the same walk for many nodes at once, one query per tree
|
|
492
|
+
level, and preloads Restricted member lists. `AccessQuery` is the same rule in
|
|
493
|
+
SQL for filtering lists and search; tests keep the two in parity. Its
|
|
494
|
+
`topmost` returns visible nodes whose container the user can't see, which is
|
|
495
|
+
what makes a folder you were shared into show up as a root in "Shared with
|
|
496
|
+
me".
|
|
497
|
+
|
|
498
|
+
Because the closest setting wins, moving an inheriting node changes its
|
|
499
|
+
access to whatever the new parent resolves to, while a node with its own
|
|
500
|
+
setting keeps it. This is what `MovePreview` checks. A move to the top level
|
|
501
|
+
saves the node's current access as its own setting first, so it doesn't
|
|
502
|
+
change.
|
|
503
|
+
|
|
504
|
+
### Reading and writing access
|
|
505
|
+
|
|
506
|
+
- `NeetoFoldersEngine::AccessQuery.new(scope, user_id:)` filters any
|
|
507
|
+
accessible scope in SQL: `.visible`, `.manageable`, and
|
|
508
|
+
`.topmost(mine: true | false)` for a "Mine" / "Shared with me" root split.
|
|
509
|
+
Use it for lists and search so only accessible records come back.
|
|
510
|
+
- `NeetoFoldersEngine::AccessResolver.resolve(node)` /
|
|
511
|
+
`.resolve_many(nodes)` and `.capability_for(node, user, resolution:)` resolve
|
|
512
|
+
access in Ruby (`:manage`, `:view` or `nil`).
|
|
513
|
+
- `NeetoFoldersEngine::AccessPayload.build_many(nodes, viewer_id:, users_by_id_proc:)`
|
|
514
|
+
builds the `access` payload the frontend components expect. The proc
|
|
515
|
+
receives user ids and returns
|
|
516
|
+
`{ id => { name:, email:, profile_image_url:, active: } }`.
|
|
517
|
+
- `NeetoFoldersEngine::AccessEntries::UpdateService.new(node, access_type:, capability:, member_ids_with_capability: [{ user_id:, capability: }]).process`
|
|
518
|
+
is the only write path. Pass `access_type: nil` to make a node inherit
|
|
519
|
+
again.
|
|
520
|
+
- `NeetoFoldersEngine::InheritingDescendantsQuery.new(folder, item_models: [Article]).call(limit: 10)`
|
|
521
|
+
returns `{ names:, total: }` for what a change to `folder` would also affect.
|
|
522
|
+
- `NeetoFoldersEngine::MovePreview.new([[node, destination_or_nil], ...], item_models: [Article]).call`
|
|
523
|
+
returns `{ moved_count:, changing_count:, name:, destination_name:, affected_count: }`:
|
|
524
|
+
which moves would change who can see the node (only inheriting nodes moving
|
|
525
|
+
into a folder can). Serve it from an endpoint and set `config.api.previewMove`
|
|
526
|
+
(called with `{ moves: [{ id, kind: "folder" | "item", parentId }] }`); the
|
|
527
|
+
Move and Reorder panes then confirm before a move that changes access.
|
|
528
|
+
`MoveToFolderPane` takes `getMoves(parentId)` to list the moves it makes.
|
|
529
|
+
- `NeetoFoldersEngine::AccessEntry.reassign_ownership!(from_user_id:, to_user_id:, organization_id:)`
|
|
530
|
+
hands a leaving user's content to someone else; the host picks `to_user_id`
|
|
531
|
+
from the same organization.
|
|
532
|
+
|
|
533
|
+
### Backfill
|
|
534
|
+
|
|
535
|
+
Records created before the host adopted access have no entries. Run the
|
|
536
|
+
idempotent backfill per organization before turning the flag on; top-level
|
|
537
|
+
records become Workspace/Manage (today's behaviour), nested ones inherit, and
|
|
538
|
+
missing creators are set to `owner_id`.
|
|
539
|
+
|
|
540
|
+
```ruby
|
|
541
|
+
NeetoFoldersEngine::AccessEntries::BackfillService.new(
|
|
542
|
+
organization_id: organization.id, owner_id: organization.oldest_admin_id, models: [Category, Article]
|
|
543
|
+
).process
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
### Frontend
|
|
547
|
+
|
|
548
|
+
```js
|
|
549
|
+
import {
|
|
550
|
+
AccessPill,
|
|
551
|
+
AccessShareDialog,
|
|
552
|
+
capWho,
|
|
553
|
+
} from "@bigbinary/neeto-folders-frontend/v2/components";
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
- `AccessPill`: `access`, `viewerId`. Shows who can see a node.
|
|
557
|
+
- `AccessShareDialog`: `isOpen`, `kind` (`"folder"` or `"article"`), `node`,
|
|
558
|
+
`access`, `viewerId`, `members` (the people picker's candidates), `affected`
|
|
559
|
+
(`{ names, total }`), `isSaving`, `onClose`, `onSave`. Mount it with
|
|
560
|
+
`key={node.id}`. `onSave` receives
|
|
561
|
+
`{ accessType, capability, members: [{ userId, capability }] }`, or all
|
|
562
|
+
`null` values when the node goes back to inheriting.
|
|
563
|
+
- `capWho(t, source, viewer)`: the label and "who" line for an access source,
|
|
564
|
+
for toasts and similar copy.
|
|
565
|
+
|
|
392
566
|
## Instructions for Publishing
|
|
393
567
|
|
|
394
568
|
Consult the
|
|
@@ -39,7 +39,89 @@
|
|
|
39
39
|
"reorderFolder": {
|
|
40
40
|
"title": "Reorder {{ folders }}"
|
|
41
41
|
},
|
|
42
|
+
"moveAccess": {
|
|
43
|
+
"title": "Change access?",
|
|
44
|
+
"single": "{{name, anyCase}} inherits its access, so it will follow {{destination, anyCase}} after the move.",
|
|
45
|
+
"batch_one": "{{count}} of the {{total}} moved items inherits its access, so it will follow {{destination, anyCase}} after the move.",
|
|
46
|
+
"batch_other": "{{count}} of the {{total}} moved items inherit their access, so they will follow {{destination, anyCase}} after the move.",
|
|
47
|
+
"batchNewFolders_one": "{{count}} of the {{total}} moved items inherits its access, so it will follow its new {{ folder }} after the move.",
|
|
48
|
+
"batchNewFolders_other": "{{count}} of the {{total}} moved items inherit their access, so they will follow their new {{ folders }} after the move.",
|
|
49
|
+
"affected_one": "{{count}} item inside will change too.",
|
|
50
|
+
"affected_other": "{{count}} items inside will change too.",
|
|
51
|
+
"submit": "Move"
|
|
52
|
+
},
|
|
42
53
|
"errors": {
|
|
43
54
|
"blank": "{{entity}} cannot be blank"
|
|
55
|
+
},
|
|
56
|
+
"access": {
|
|
57
|
+
"dialog": {
|
|
58
|
+
"title": "Who can access this {{kind}}",
|
|
59
|
+
"inheriting": "This {{kind}} inherits its access from the parent folder <strong>{{parent}}</strong>, which has",
|
|
60
|
+
"custom": "This {{kind}} has custom access and is not inheriting the parent folder <strong>{{parent}}</strong>'s access.",
|
|
61
|
+
"label": {
|
|
62
|
+
"workspace": "Workspace access",
|
|
63
|
+
"onlyMe": "Only me",
|
|
64
|
+
"onlyName": "Only {{name}}",
|
|
65
|
+
"restricted": "Restricted access"
|
|
66
|
+
},
|
|
67
|
+
"who": {
|
|
68
|
+
"workspace": "Accessible to everyone in the workspace",
|
|
69
|
+
"onlyYou": "Accessible only to you",
|
|
70
|
+
"onlyName": "Accessible only to {{name}}",
|
|
71
|
+
"restricted_one": "Accessible to {{count}} team member",
|
|
72
|
+
"restricted_other": "Accessible to {{count}} team members"
|
|
73
|
+
},
|
|
74
|
+
"customToggle": "Set custom {{kind}} access",
|
|
75
|
+
"customToggleHelp": "Give this {{kind}} its own access instead of the access it inherits from the parent folder.",
|
|
76
|
+
"types": {
|
|
77
|
+
"only_me": "Only me",
|
|
78
|
+
"workspace": "Workspace",
|
|
79
|
+
"restricted": "Restricted",
|
|
80
|
+
"only_name": "Only {{name}}"
|
|
81
|
+
},
|
|
82
|
+
"descriptions": {
|
|
83
|
+
"only_me_folder": "Only you can see this folder and everything inside it.",
|
|
84
|
+
"only_me_article": "Only you can see this article.",
|
|
85
|
+
"workspace": "Everyone in your workspace.",
|
|
86
|
+
"restricted": "Only the team members you choose.",
|
|
87
|
+
"only_name_folder": "Only {{name}} can see this folder and everything inside it.",
|
|
88
|
+
"only_name_article": "Only {{name}} can see this article."
|
|
89
|
+
},
|
|
90
|
+
"capability": "Capability",
|
|
91
|
+
"capabilityFor": "Capability for {{name}}",
|
|
92
|
+
"everyoneCan": "Everyone in the workspace can",
|
|
93
|
+
"view": "View",
|
|
94
|
+
"manage": "Manage",
|
|
95
|
+
"manageHint": "Manage means write — up to whatever each person's role already allows elsewhere in NeetoKB.",
|
|
96
|
+
"selectMembers": "Select team members",
|
|
97
|
+
"selectMembersHint": {
|
|
98
|
+
"folder": "Selected team members will get access to this folder and all the nested folders within this folder.",
|
|
99
|
+
"article": "Selected team members will get access to this article."
|
|
100
|
+
},
|
|
101
|
+
"searchPlaceholder": "Search team members by name",
|
|
102
|
+
"noMatch": "No team members match \"{{query}}\".",
|
|
103
|
+
"selectedCount": "{{count}} selected",
|
|
104
|
+
"selectOneOrMore": "Select one or more",
|
|
105
|
+
"done": "Done",
|
|
106
|
+
"peopleWithAccess": "People with access",
|
|
107
|
+
"you": "You",
|
|
108
|
+
"createdThisFolder": "Created this folder",
|
|
109
|
+
"remove": "Remove",
|
|
110
|
+
"removeName": "Remove {{name}}",
|
|
111
|
+
"onlyYouUntil": "Only you, until you add someone",
|
|
112
|
+
"onlyNameUntil": "Only {{name}}, until you add someone",
|
|
113
|
+
"peopleCount": "{{count}} people",
|
|
114
|
+
"demoteHint": "Grants they hold on nested items with custom access are kept.",
|
|
115
|
+
"affected_one": "Saving this also updates <strong>{{count}} nested item</strong> still inheriting from here: {{names}}.",
|
|
116
|
+
"affected_other": "Saving this also updates <strong>{{count}} nested items</strong> still inheriting from here: {{names}}.",
|
|
117
|
+
"namesAndMore": "{{names}} and {{more}} more"
|
|
118
|
+
},
|
|
119
|
+
"pill": {
|
|
120
|
+
"sharedWithYou": "Shared with you",
|
|
121
|
+
"onlyYou": "Only you",
|
|
122
|
+
"onlyName": "Only {{name}}",
|
|
123
|
+
"restricted_one": "{{count}} person",
|
|
124
|
+
"restricted_other": "{{count}} people"
|
|
125
|
+
}
|
|
44
126
|
}
|
|
45
127
|
}
|
package/dist/.ready
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Built at 2026-11-
|
|
1
|
+
Built at 2026-11-11T12:42:34.437Z
|
package/dist/cjs/components.js
CHANGED
|
@@ -9,11 +9,11 @@ var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
|
|
|
9
9
|
var Alert = require('@bigbinary/neetoui/Alert');
|
|
10
10
|
var reactI18next = require('react-i18next');
|
|
11
11
|
var reactRouterDom = require('react-router-dom');
|
|
12
|
-
var useFolderActions = require('../useFolderActions-
|
|
12
|
+
var useFolderActions = require('../useFolderActions-D_egbV70.js');
|
|
13
13
|
var injectCss = require('../inject-css-D3Ee0dJK.js');
|
|
14
14
|
var constants = require('./constants.js');
|
|
15
|
-
var utils = require('../index-
|
|
16
|
-
var internal = require('../internal-
|
|
15
|
+
var utils = require('../index-DPGZgR3c.js');
|
|
16
|
+
var internal = require('../internal-DkESa3he.js');
|
|
17
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
18
18
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
19
19
|
var Pane = require('@bigbinary/neetoui/Pane');
|
|
@@ -690,7 +690,8 @@ var MoveFolderPane = function MoveFolderPane(_ref) {
|
|
|
690
690
|
payload: payload,
|
|
691
691
|
config: {
|
|
692
692
|
showToastr: false
|
|
693
|
-
}
|
|
693
|
+
},
|
|
694
|
+
initialSlug: item.sid
|
|
694
695
|
}, {
|
|
695
696
|
onSuccess: function onSuccess() {
|
|
696
697
|
var _config$onUpdateSucce;
|