mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-02 20:15:27 +03:00
group-store: add resource field to app-tag
Adds a resource field to the app-tag type, as apps will generally want to use tags to identify a specific resource
This commit is contained in:
parent
f2fd69df90
commit
9c0ad13abd
@ -37,26 +37,24 @@
|
||||
+$ versioned-state
|
||||
$% state-zero
|
||||
state-one
|
||||
state-two
|
||||
==
|
||||
::
|
||||
+$ state-zero
|
||||
$: %0
|
||||
=groups:state-zero:store
|
||||
==
|
||||
::
|
||||
[%0 *]
|
||||
::
|
||||
+$ state-one
|
||||
$: %1
|
||||
=groups
|
||||
=groups:groups-state-one
|
||||
==
|
||||
::
|
||||
+$ diff
|
||||
$% [%group-update update:store]
|
||||
[%group-initial groups]
|
||||
+$ state-two
|
||||
$: %2
|
||||
=groups
|
||||
==
|
||||
--
|
||||
::
|
||||
=| state-one
|
||||
=| state-two
|
||||
=* state -
|
||||
::
|
||||
%- agent:dbug
|
||||
@ -74,90 +72,37 @@
|
||||
++ on-load
|
||||
|= =old=vase
|
||||
=/ old !<(versioned-state old-vase)
|
||||
?: ?=(%1 -.old)
|
||||
`this(state old)
|
||||
|^
|
||||
:- :~ [%pass / %agent [our.bowl dap.bowl] %poke %noun !>(%perm-upgrade)]
|
||||
kick-all
|
||||
==
|
||||
=* paths ~(key by groups.old)
|
||||
=/ [unmanaged=(list path) managed=(list path)]
|
||||
(skid ~(tap in paths) |=(=path =('~' (snag 0 path))))
|
||||
=. groups (all-unmanaged unmanaged)
|
||||
=. groups (all-managed managed)
|
||||
this
|
||||
::
|
||||
++ all-managed
|
||||
|= paths=(list path)
|
||||
^+ groups
|
||||
?~ paths
|
||||
groups
|
||||
=/ [rid=resource =group]
|
||||
(migrate-group i.paths)
|
||||
%= $
|
||||
paths t.paths
|
||||
::
|
||||
groups
|
||||
(~(put by groups) rid group)
|
||||
?- -.old
|
||||
%2 `this(state old)
|
||||
::
|
||||
%1
|
||||
%_ $
|
||||
-.old %2
|
||||
groups.old (groups-1-to-2 groups.old)
|
||||
==
|
||||
::
|
||||
%0 $(old *state-two)
|
||||
==
|
||||
::
|
||||
++ all-unmanaged
|
||||
|= paths=(list path)
|
||||
^+ groups
|
||||
?~ paths
|
||||
groups
|
||||
?: |(=(/~/default i.paths) =(4 (lent i.paths)))
|
||||
$(paths t.paths)
|
||||
=/ [=resource =group]
|
||||
(migrate-unmanaged i.paths)
|
||||
%= $
|
||||
paths t.paths
|
||||
::
|
||||
groups
|
||||
(~(put by groups) resource group)
|
||||
==
|
||||
++ kick-all
|
||||
^- card
|
||||
:+ %give %kick
|
||||
:_ ~
|
||||
%~ tap by
|
||||
%+ roll ~(val by sup.bowl)
|
||||
|= [[=ship pax=path] paths=(set path)]
|
||||
(~(put in paths) pax)
|
||||
::
|
||||
++ migrate-unmanaged
|
||||
|= pax=path
|
||||
^- [resource group]
|
||||
=/ members=(set ship)
|
||||
(~(got by groups.old) pax)
|
||||
=| =invite:policy
|
||||
?> ?=(^ pax)
|
||||
=/ rid=resource
|
||||
(resource-from-old-path t.pax)
|
||||
++ groups-1-to-2
|
||||
|= =groups:groups-state-one
|
||||
^+ ^groups
|
||||
%- ~(run by groups)
|
||||
|= =group:groups-state-one
|
||||
=/ =tags
|
||||
(~(put ju *tags) %admin entity.rid)
|
||||
:- rid
|
||||
[members tags invite %.y]
|
||||
::
|
||||
++ resource-from-old-path
|
||||
|= pax=path
|
||||
^- resource
|
||||
?> ?=([@ @ *] pax)
|
||||
=/ ship
|
||||
(slav %p i.pax)
|
||||
[ship i.t.pax]
|
||||
::
|
||||
++ migrate-group
|
||||
|= pax=path
|
||||
=/ members
|
||||
(~(got by groups.old) pax)
|
||||
=| =invite:policy
|
||||
=/ rid=resource
|
||||
(resource-from-old-path pax)
|
||||
=/ =tags
|
||||
(~(put ju *tags) %admin entity.rid)
|
||||
[rid members tags invite %.n]
|
||||
(tags-1-to-2 tags.group)
|
||||
[members.group tags [policy hidden]:group]
|
||||
::
|
||||
++ tags-1-to-2
|
||||
|= =tags:groups-state-one
|
||||
^- ^tags
|
||||
%- ~(gas by *^tags)
|
||||
%+ murn
|
||||
~(tap by tags)
|
||||
|= [=tag:groups-state-one ships=(set ship)]
|
||||
?^ tag ~
|
||||
`[tag ships]
|
||||
--
|
||||
::
|
||||
++ on-poke
|
||||
@ -273,8 +218,8 @@
|
||||
|= arc=*
|
||||
^- (quip card _state)
|
||||
|^
|
||||
=/ sty=state-one
|
||||
[%1 (remake-groups ;;((tree [resource tree-group]) +.arc))]
|
||||
=/ sty=state-two
|
||||
[%2 (remake-groups ;;((tree [resource tree-group]) +.arc))]
|
||||
:_ sty
|
||||
%+ roll ~(tap by groups.sty)
|
||||
|= [[rid=resource grp=group] out=(list card)]
|
||||
|
@ -167,6 +167,7 @@
|
||||
%+ turn
|
||||
~(tap in sit)
|
||||
item
|
||||
::
|
||||
++ tag
|
||||
|= =^tag
|
||||
^- json
|
||||
@ -175,6 +176,7 @@
|
||||
%- pairs
|
||||
:~ app+s+app.tag
|
||||
tag+s+tag.tag
|
||||
resource+s+(enjs-path:resource resource.tag)
|
||||
==
|
||||
::
|
||||
++ policy
|
||||
@ -366,6 +368,7 @@
|
||||
%. json
|
||||
%- ot
|
||||
:~ app+so
|
||||
resource+dejs-path:resource
|
||||
tag+so
|
||||
==
|
||||
|
||||
|
@ -2,25 +2,6 @@
|
||||
^?
|
||||
|%
|
||||
::
|
||||
++ state-zero
|
||||
|%
|
||||
+$ group (set ship)
|
||||
::
|
||||
+$ group-action
|
||||
$% [%add members=group pax=path] :: add member to group
|
||||
[%remove members=group pax=path] :: remove member from group
|
||||
[%bundle pax=path] :: create group at path
|
||||
[%unbundle pax=path] :: delete group at path
|
||||
==
|
||||
::
|
||||
+$ group-update
|
||||
$% [%keys keys=(set path)] :: keys have changed
|
||||
[%path members=group pax=path]
|
||||
group-action
|
||||
==
|
||||
::
|
||||
+$ groups (map path group)
|
||||
--
|
||||
:: $action: request to change group-store state
|
||||
::
|
||||
:: %add-group: add a group
|
||||
|
@ -2,6 +2,22 @@
|
||||
::
|
||||
^?
|
||||
|%
|
||||
::
|
||||
++ groups-state-one
|
||||
|%
|
||||
+$ groups (map resource group)
|
||||
::
|
||||
+$ tag $@(group-tag [app=term tag=term])
|
||||
::
|
||||
+$ tags (jug tag ship)
|
||||
::
|
||||
+$ group
|
||||
$: members=(set ship)
|
||||
=tags
|
||||
=policy
|
||||
hidden=?
|
||||
==
|
||||
--
|
||||
:: $groups: a mapping from group-ids to groups
|
||||
::
|
||||
+$ groups (map resource group)
|
||||
@ -16,7 +32,7 @@
|
||||
:: Tags may be used and recognised differently across apps.
|
||||
:: for example, you could use tags like `%author`, `%bot`, `%flagged`...
|
||||
::
|
||||
+$ tag $@(group-tag [app=term tag=term])
|
||||
+$ tag $@(group-tag [app=term =resource tag=term])
|
||||
:: $role-tag: a kind of $group-tag that identifies a privileged user
|
||||
::
|
||||
:: These roles are
|
||||
|
Loading…
Reference in New Issue
Block a user