Merge branch 'release/next-js' into tbcs/typescript-cleanup

This commit is contained in:
Matilde Park 2021-05-10 20:20:13 -04:00
commit 05e3d4c75c
21 changed files with 472 additions and 194 deletions

View File

@ -70,10 +70,11 @@
::
++ transform-proxy-update
|= vas=vase
^- (unit vase)
^- (quip card (unit vase))
:: TODO: should check if user is allowed to %add, %remove, %edit
:: contact
=/ =update:store !<(update:store vas)
:- ~
?- -.update
%initial ~
%add `vas

View File

@ -43,8 +43,8 @@
::
++ transform-proxy-update
|= vas=vase
^- (unit vase)
`vas
^- (quip card (unit vase))
``vas
::
++ resource-for-update
|= =vase

View File

@ -1,6 +1,6 @@
/- *group, metadata=metadata-store
/+ store=graph-store, mdl=metadata, res=resource, graph, group, default-agent,
dbug, verb, push-hook
dbug, verb, push-hook, agentio
::
~% %graph-push-hook-top ..part ~
|%
@ -25,6 +25,25 @@
$% state-zero
state-one
==
::
:: TODO: come back to this and potentially use send a %t
:: to be notified of validator changes
+$ cache
$: graph-to-mark=(map resource:res (unit mark))
perm-marks=(map [mark @tas] tube:clay)
transform-marks=(map mark tube:clay)
==
::
+$ inflated-state
$: state-one
cache
==
::
+$ cache-action
$% [%graph-to-mark (pair resource:res (unit mark))]
[%perm-marks (pair (pair mark @tas) tube:clay)]
[%transform-marks (pair mark tube:clay)]
==
--
::
%- agent:dbug
@ -33,7 +52,8 @@
%- (agent:push-hook config)
^- agent
=-
=| state-one
~% %graph-push-hook-agent ..scry.hook-core ~
=| inflated-state
=* state -
|_ =bowl:gall
+* this .
@ -41,10 +61,11 @@
grp ~(. group bowl)
gra ~(. graph bowl)
met ~(. mdl bowl)
hc ~(. hook-core bowl)
hc ~(. hook-core bowl +.state)
io ~(. agentio bowl)
::
++ on-init on-init:def
++ on-save !>(state)
++ on-save !>(-.state)
++ on-load
|= =vase
=+ !<(old=versioned-state vase)
@ -53,9 +74,26 @@
=? old ?=(%0 -.old)
[%1 ~]
?> ?=(%1 -.old)
`this(state old)
`this(-.state old, +.state *cache)
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
?. =(mark %graph-cache-hook)
[~ this]
=/ a=cache-action !<(cache-action vase)
=* c +.state
=* graph-to-mark graph-to-mark.c
=* perm-marks perm-marks.c
=* transform-marks transform-marks.c
=. c
?- -.a
%graph-to-mark c(graph-to-mark (~(put by graph-to-mark) p.a q.a))
%perm-marks c(perm-marks (~(put by perm-marks) p.a q.a))
%transform-marks c(transform-marks (~(put by transform-marks) p.a q.a))
==
[~ this(+.state c)]
::
++ on-poke on-poke:def
++ on-agent on-agent:def
++ on-watch on-watch:def
++ on-leave on-leave:def
@ -72,32 +110,64 @@
::
++ on-fail on-fail:def
++ transform-proxy-update
~/ %transform-proxy-update
|= vas=vase
^- (unit vase)
^- (quip card (unit vase))
=/ =update:store !<(update:store vas)
=* rid resource.q.update
=. p.update now.bowl
?- -.q.update
%add-nodes
?. (is-allowed-add:hc rid nodes.q.update)
~
=/ mark (get-mark:gra rid)
?~ mark `vas
|^
=/ transform
!< $-([index:store post:store atom ?] [index:store post:store])
%. !>(*indexed-post:store)
.^(tube:clay (scry:hc %cc %home /[u.mark]/transform-add-nodes))
=/ [* result=(list [index:store node:store])]
%+ roll
(flatten-node-map ~(tap by nodes.q.update))
(transform-list transform)
=. nodes.q.update
%- ~(gas by *(map index:store node:store))
result
[~ !>(update)]
=| cards=(list card)
=^ allowed cards (is-allowed-add:hc rid nodes.q.update)
?. allowed
[cards ~]
=/ mark-cached (~(has by graph-to-mark) rid)
=/ mark
?: mark-cached
(~(got by graph-to-mark) rid)
(get-mark:gra rid)
?~ mark
[cards `vas]
=< $
~% %transform-add-nodes ..transform-proxy-update ~
|%
++ $
^- (quip card (unit vase))
=/ transform-cached (~(has by transform-marks) u.mark)
=/ =tube:clay
?: transform-cached
(~(got by transform-marks) u.mark)
.^(tube:clay (scry:hc %cc %home /[u.mark]/transform-add-nodes))
=/ transform
!< $-([index:store post:store atom ?] [index:store post:store])
%. !>(*indexed-post:store)
tube
=/ [* result=(list [index:store node:store])]
%+ roll
(flatten-node-map ~(tap by nodes.q.update))
(transform-list transform)
=. nodes.q.update
%- ~(gas by *(map index:store node:store))
result
:_ [~ !>(update)]
%+ weld cards
%- zing
:~ ?: mark-cached ~
:_ ~
%+ poke-self:pass:io %graph-cache-hook
!> ^- cache-action
[%graph-to-mark rid mark]
::
?: transform-cached ~
:_ ~
%+ poke-self:pass:io %graph-cache-hook
!> ^- cache-action
[%transform-marks u.mark tube]
==
::
++ flatten-node-map
~/ %flatten-node-map
|= lis=(list [index:store node:store])
^- (list [index:store node:store])
|^
@ -129,6 +199,7 @@
--
::
++ transform-list
~/ %transform-list
|= transform=$-([index:store post:store atom ?] [index:store post:store])
|= $: [=index:store =node:store]
[indices=(set index:store) lis=(list [index:store node:store])]
@ -151,27 +222,32 @@
--
::
%remove-posts
?. (is-allowed-remove:hc resource.q.update indices.q.update)
=| cards=(list card)
=^ allowed cards
(is-allowed-remove:hc rid indices.q.update)
:- cards
?. allowed
~
`vas
::
%add-graph ~
%remove-graph ~
%add-signatures ~
%remove-signatures ~
%archive-graph ~
%unarchive-graph ~
%add-tag ~
%remove-tag ~
%keys ~
%tags ~
%tag-queries ~
%run-updates ~
%add-graph [~ ~]
%remove-graph [~ ~]
%add-signatures [~ ~]
%remove-signatures [~ ~]
%archive-graph [~ ~]
%unarchive-graph [~ ~]
%add-tag [~ ~]
%remove-tag [~ ~]
%keys [~ ~]
%tags [~ ~]
%tag-queries [~ ~]
%run-updates [~ ~]
==
::
++ resource-for-update resource-for-update:gra
::
++ initial-watch
~/ %initial-watch
|= [=path =resource:res]
^- vase
|^
@ -211,11 +287,13 @@
==
--
::
^| ^= hook-core
|_ =bowl:gall
~% %graph-push-hook-helper ..card.hook-core ~
^= hook-core
|_ [=bowl:gall =cache]
+* grp ~(. group bowl)
met ~(. mdl bowl)
gra ~(. graph bowl)
io ~(. agentio bowl)
::
++ scry
|= [care=@t desk=@t =path]
@ -225,14 +303,38 @@
::
++ perm-mark
|= [=resource:res perm=@t vip=vip-metadata:metadata =indexed-post:store]
^- permissions:store
^- [permissions:store (list card)]
|^
=- (check vip)
!< check=$-(vip-metadata:metadata permissions:store)
%. !>(indexed-post)
=/ mark (get-mark:gra resource)
?~ mark |=(=vase !>([%no %no %no]))
.^(tube:clay (scry %cc %home /[u.mark]/(perm-mark-name perm)))
=/ mark-cached (~(has by graph-to-mark.cache) resource)
=/ mark
?: mark-cached
(~(got by graph-to-mark.cache) resource)
(get-mark:gra resource)
?~ mark
[[%no %no %no] ~]
=/ key [u.mark (perm-mark-name perm)]
=/ perms-cached (~(has by perm-marks.cache) key)
=/ =tube:clay
?: perms-cached
(~(got by perm-marks.cache) key)
.^(tube:clay (scry %cc %home /[u.mark]/(perm-mark-name perm)))
=/ check
!< $-(vip-metadata:metadata permissions:store)
(tube !>(indexed-post))
:- (check vip)
%- zing
:~ ?: mark-cached ~
:_ ~
%+ poke-self:pass:io %graph-cache-hook
!> ^- cache-action
[%graph-to-mark resource mark]
::
?: perms-cached ~
:_ ~
%+ poke-self:pass:io %graph-cache-hook
!> ^- cache-action
[%perm-marks [u.mark (perm-mark-name perm)] tube]
==
::
++ perm-mark-name
|= perm=@t
@ -252,15 +354,22 @@
reader.permissions
::
++ get-roles-writers-variation
~/ %get-roles-writers-variation
|= =resource:res
^- (unit [is-admin=? writers=(set ship) vip=vip-metadata:metadata])
=/ assoc=(unit association:metadata)
(peek-association:met %graph resource)
(peek-association:met %graph resource)
?~ assoc ~
=/ group=(unit group:grp)
(scry-group:grp group.u.assoc)
?~ group ~
=/ role=(unit (unit role-tag))
(role-for-ship:grp group.u.assoc src.bowl)
(role-for-ship-with-group:grp u.group group.u.assoc src.bowl)
=/ writers=(set ship)
(get-tagged-ships:grp group.u.assoc [%graph resource %writers])
%^ get-tagged-ships-with-group:grp
u.group
group.u.assoc
[%graph resource %writers]
?~ role ~
=/ is-admin=?
?=(?([~ %admin] [~ %moderator]) u.role)
@ -274,39 +383,58 @@
[(snag (dec (lent index)) index) p.post.node]
::
++ is-allowed-add
~/ %is-allowed-add
|= [=resource:res nodes=(map index:store node:store)]
^- ?
^- [? (list card)]
|^
%- (bond |.(%.n))
%- (bond |.([%.n ~]))
%+ biff (get-roles-writers-variation resource)
|= [is-admin=? writers=(set ship) vip=vip-metadata:metadata]
^- (unit ?)
^- (unit [? (list card)])
%- some
%+ levy ~(tap by nodes)
|= [=index:store =node:store]
=/ parent-index=index:store
(scag (dec (lent index)) index)
?: (~(has by nodes) parent-index) %.y
?: ?=(%| -.post.node)
%.n
?. =(author.p.post.node src.bowl)
%.n
=/ =permissions:store
%^ add-mark resource vip
(node-to-indexed-post node)
=/ =permission-level:store
(get-permission permissions is-admin writers)
?- permission-level
%yes %.y
%no %.n
::
%self
=/ parent-node=node:store
(got-node:gra resource parent-index)
?: ?=(%| -.post.parent-node)
%.n
=(author.p.post.parent-node src.bowl)
==
=/ a ~(tap by nodes)
=| cards=(list card)
|- ^- [? (list card)]
?~ a [& cards]
=/ c (check i.a is-admin writers vip)
?. -.c
[| (weld cards +.c)]
$(a t.a, cards (weld cards +.c))
::
++ check
|= $: [=index:store =node:store]
is-admin=?
writers=(set ship)
vip=vip-metadata:metadata
==
^- [? (list card)]
=/ parent-index=index:store
(scag (dec (lent index)) index)
?: (~(has by nodes) parent-index)
[%.y ~]
?: ?=(%| -.post.node)
[%.n ~]
?. =(author.p.post.node src.bowl)
[%.n ~]
=/ added
%^ add-mark resource vip
(node-to-indexed-post node)
=* permissions -.added
=* cards +.added
=/ =permission-level:store
(get-permission permissions is-admin writers)
:_ cards
?- permission-level
%yes %.y
%no %.n
::
%self
=/ parent-node=node:store
(got-node:gra resource parent-index)
?: ?=(%| -.post.parent-node)
%.n
=(author.p.post.parent-node src.bowl)
==
::
++ add-mark
|= [=resource:res vip=vip-metadata:metadata =indexed-post:store]
@ -314,29 +442,43 @@
--
::
++ is-allowed-remove
~/ %is-allowed-remove
|= [=resource:res indices=(set index:store)]
^- ?
^- [? (list card)]
|^
%- (bond |.(%.n))
%- (bond |.([%.n ~]))
%+ biff (get-roles-writers-variation resource)
|= [is-admin=? writers=(set ship) vip=vip-metadata:metadata]
%- some
%+ levy ~(tap by indices)
|= =index:store
^- ?
=/ =node:store
(got-node:gra resource index)
?: ?=(%| -.post.node) %.n
=/ =permissions:store
%^ remove-mark resource vip
(node-to-indexed-post node)
=/ =permission-level:store
(get-permission permissions is-admin writers)
?- permission-level
%yes %.y
%no %.n
%self =(author.p.post.node src.bowl)
==
%- some
=/ a ~(tap by indices)
=| cards=(list card)
|- ^- [? (list card)]
?~ a [& cards]
=/ c (check i.a is-admin writers vip)
?. -.c
[| (weld cards +.c)]
$(a t.a, cards (weld cards +.c))
::
++ check
|= [=index:store is-admin=? writers=(set ship) vip=vip-metadata:metadata]
^- [? (list card)]
=/ =node:store
(got-node:gra resource index)
?: ?=(%| -.post.node)
[%.n ~]
=/ removed
%^ remove-mark resource vip
(node-to-indexed-post node)
=* permissions -.removed
=* cards +.removed
=/ =permission-level:store
(get-permission permissions is-admin writers)
:_ cards
?- permission-level
%yes %.y
%no %.n
%self =(author.p.post.node src.bowl)
==
::
++ remove-mark
|= [=resource:res vip=vip-metadata:metadata =indexed-post:store]

View File

@ -18,9 +18,20 @@
++ orm orm:store
++ orm-log orm-log:store
+$ debug-input [%validate-graph =resource:store]
::
+$ cache
$: validators=(map mark dais:clay)
==
::
:: TODO: come back to this and potentially use ford runes or otherwise
:: send a %t to be notified of validator changes
+$ inflated-state
$: state-5
cache
==
--
::
=| state-5
=| inflated-state
=* state -
::
%- agent:dbug
@ -32,7 +43,7 @@
def ~(. (default-agent this %|) bowl)
::
++ on-init [~ this]
++ on-save !>(state)
++ on-save !>(-.state)
++ on-load
|= =old=vase
^- (quip card _this)
@ -108,7 +119,7 @@
(gas:orm-log ~ [now.bowl logged-update] ~)
==
::
%5 [cards this(state old)]
%5 [cards this(-.state old, +.state *cache)]
==
::
++ on-watch
@ -180,7 +191,9 @@
!(~(has by graphs) resource)
== ==
~| "validation of graph {<resource>} failed using mark {<mark>}"
?> (validate-graph graph mark)
=^ is-valid state
(validate-graph graph mark)
?> is-valid
=/ =logged-update:store
[time %add-graph resource graph mark overwrite]
=/ =update-log:store
@ -217,6 +230,10 @@
(~(got by graphs) resource)
~| "cannot add duplicate nodes to {<resource>}"
?< (check-for-duplicates graph ~(key by nodes))
~| "validation of nodes failed using mark {<mark>}"
=^ is-valid state
(check-validity ~(tap by nodes) mark)
?> is-valid
=/ =update-log:store (~(got by update-logs) resource)
=. update-log
(put:orm-log update-log time [time [%add-nodes resource nodes]])
@ -231,6 +248,17 @@
(add-node-list resource graph mark (sort-nodes nodes))
==
::
++ check-validity
|= [lis=(list (pair index:store node:store)) mark=(unit ^mark)]
^- [? _state]
|-
?~ lis [& state]
=^ is-valid state
(validate-graph (gas:orm ~ [(rear p.i.lis) q.i.lis]~) mark)
?. is-valid
[| state]
$(lis t.lis)
::
++ check-for-duplicates
|= [=graph:store nodes=(set index:store)]
^- ?
@ -288,8 +316,6 @@
==
^- graph:store
?< ?=(~ index)
~| "validation of node failed using mark {<mark>}"
?> (validate-graph (gas:orm ~ [i.index node]~) mark)
=* atom i.index
%^ put:orm
graph
@ -588,18 +614,24 @@
^- (quip card _state)
=/ [=graph:store mark=(unit mark:store)]
(~(got by graphs) resource.debug-input)
?> (validate-graph graph mark)
=^ is-valid state
(validate-graph graph mark)
?> is-valid
[~ state]
::
++ validate-graph
|= [=graph:store mark=(unit mark:store)]
^- ?
?~ mark %.y
^- [? _state]
?~ mark [%.y state]
=/ has-dais (~(has by validators) u.mark)
=/ =dais:clay
?: has-dais
(~(got by validators) u.mark)
.^ =dais:clay
%cb
/(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[u.mark]
==
:_ state(validators (~(put by validators) u.mark dais))
|- ^- ?
?~ graph %.y
%+ roll (tap:orm graph)
@ -617,7 +649,9 @@
++ poke-import
|= arc=*
^- (quip card _state)
(import:store arc our.bowl)
=^ cards -.state
(import:store arc our.bowl)
[cards state]
--
::
++ on-peek

View File

@ -47,8 +47,9 @@
::
++ transform-proxy-update
|= vas=vase
^- (unit vase)
^- (quip card (unit vase))
=/ =update:store !<(update:store vas)
:- ~
?: ?=(%initial -.update)
~
|^

View File

@ -59,8 +59,9 @@
::
++ transform-proxy-update
|= vas=vase
^- (unit vase)
^- (quip card (unit vase))
=/ =update:store !<(update:store vas)
:- ~
?. ?=(?(%add %remove) -.update)
~
=/ role=(unit (unit role-tag))

View File

@ -75,7 +75,12 @@
=/ grp=(unit group)
(scry-group rid)
?~ grp ~
=* group u.grp
(role-for-ship-with-group u.grp rid ship)
::
++ role-for-ship-with-group
|= [grp=group rid=resource =ship]
^- (unit (unit role-tag))
=* group grp
=* policy policy.group
=* tags tags.group
=/ admins=(set ^ship)
@ -106,8 +111,13 @@
^- (set ship)
=/ grp=(unit group)
(scry-group rid)
?~ grp ~
(~(get ju tags.u.grp) tag)
?~ grp ~
(get-tagged-ships-with-group u.grp rid tag)
::
++ get-tagged-ships-with-group
|= [grp=group rid=resource =tag]
^- (set ship)
(~(get ju tags.grp) tag)
::
++ is-managed
|= rid=resource

View File

@ -26,6 +26,7 @@
::
/- *push-hook
/+ default-agent, resource, verb, versioning, agentio
~% %push-hook-top ..part ~
|%
+$ card card:agent:gall
::
@ -84,6 +85,7 @@
%.n
::
++ push-hook
~/ %push-hook
|* =config
$_ ^|
|_ bowl:gall
@ -113,7 +115,7 @@
::
++ transform-proxy-update
|~ vase
*(unit vase)
*[(list card) (unit vase)]
:: +initial-watch: produce initial state for a subscription
::
:: .resource is the resource being subscribed to.
@ -175,6 +177,7 @@
=* state -
^- agent:gall
=<
~% %push-agent-lib ..poke-hook-action ~
|_ =bowl:gall
+* this .
og ~(. push-hook bowl)
@ -267,6 +270,7 @@
!>(state)
::
++ on-poke
~/ %on-poke
|= [=mark =vase]
^- (quip card:agent:gall agent:gall)
?: =(mark %push-hook-action)
@ -283,6 +287,7 @@
[cards this]
::
++ on-watch
~/ %on-watch
|= =path
^- (quip card:agent:gall agent:gall)
?: ?=([%version ~] path)
@ -320,6 +325,7 @@
--
::
++ on-agent
~/ %on-agent
|= [=wire =sign:agent:gall]
^- (quip card:agent:gall agent:gall)
?. ?=([%helper %push-hook @ *] wire)
@ -373,6 +379,7 @@
[%x %min-version ~] ``version+!>(version.config)
==
--
~% %push-helper-lib ..card ~
|_ =bowl:gall
+* og ~(. push-hook bowl)
ver ~(. versioning [bowl [update-mark version min-version]:config])
@ -380,6 +387,7 @@
pass pass:io
::
++ poke-hook-action
~/ %poke-hook-action
|= =action
^- (quip card:agent:gall _state)
|^
@ -448,6 +456,7 @@
[%pass wire %agent [our.bowl store-name.config] %watch store-path.config]
::
++ push-updates
~/ %push-updates
|= =cage
^- (list card:agent:gall)
%+ roll (resource-for-update q.cage)
@ -484,6 +493,7 @@
--
::
++ forward-update
~/ %forward-update
|= =cage
^- (list card:agent:gall)
=- lis
@ -494,35 +504,32 @@
^- [(list card:agent:gall) (unit vase)]
=/ =path
resource+(en-path:resource rid)
=/ =wire (make-wire path)
=* ship entity.rid
=. tf-vas
=/ out=(pair (list card:agent:gall) (unit vase))
?. =(our.bowl ship)
:: do not transform before forwarding
::
`vas
``vas
:: use cached transform
::
?^ tf-vas tf-vas
?^ tf-vas `tf-vas
:: transform before poking store
::
(transform-proxy-update:og vas)
~| "forwarding failed during transform. mark: {<p.cage>} resource: {<rid>}"
?> ?=(^ tf-vas)
=/ =dock
:- ship
?. =(our.bowl ship)
:: forward to host
::
dap.bowl
:: poke our store
~| "forwarding failed during transform. mark: {<p.cage>} rid: {<rid>}"
?> ?=(^ q.out)
:_ q.out
:_ (weld lis p.out)
=/ =wire (make-wire path)
=- [%pass wire %agent - %poke [current-version:ver u.q.out]]
:- ship
?. =(our.bowl ship)
:: forward to host
::
store-name.config
=/ cag=^cage
:- current-version:ver
u.tf-vas
:_ tf-vas
[[%pass wire %agent dock %poke cag] lis]
dap.bowl
:: poke our store
::
store-name.config
::
++ ver-from-path
|= =path
@ -532,6 +539,7 @@
(slav %ud i.extra)
::
++ resource-for-update
~/ %resource-for-update
|= =vase
^- (list resource)
%~ tap in

20
pkg/arvo/mar/graph/cache/hook.hoon vendored Normal file
View File

@ -0,0 +1,20 @@
/- metadata=metadata-store, res=resource
|%
+$ cache-action
$% [%graph-to-mark (pair resource:res (unit mark))]
[%perm-marks (pair (pair mark @tas) tube:clay)]
[%transform-marks (pair mark tube:clay)]
==
--
::
|_ act=cache-action
++ grad %noun
++ grow
|%
++ noun act
--
++ grab
|%
++ noun cache-action
--
--

View File

@ -9133,9 +9133,38 @@
}
},
"remark-breaks": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/remark-breaks/-/remark-breaks-2.0.1.tgz",
"integrity": "sha512-CZKI8xdPUnvMqPxYEIBBUg8C0B0kyn14lkW0abzhfh/P71YRIxCC3wvBh6AejQL602OxF6kNRl1x4HAZA07JyQ=="
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/remark-breaks/-/remark-breaks-2.0.2.tgz",
"integrity": "sha512-LsQnPPQ7Fzp9RTjj4IwdEmjPOr9bxe9zYKWhs9ZQOg9hMg8rOfeeqQ410cvVdIK87Famqza1CKRxNkepp2EvUA==",
"requires": {
"unist-util-visit": "^2.0.0"
},
"dependencies": {
"unist-util-is": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.1.0.tgz",
"integrity": "sha512-ZOQSsnce92GrxSqlnEEseX0gi7GH9zTJZ0p9dtu87WRb/37mMPO2Ilx1s/t9vBHrFhbgweUwb+t7cIn5dxPhZg=="
},
"unist-util-visit": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz",
"integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-is": "^4.0.0",
"unist-util-visit-parents": "^3.0.0"
}
},
"unist-util-visit-parents": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz",
"integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==",
"requires": {
"@types/unist": "^2.0.0",
"unist-util-is": "^4.0.0"
}
}
}
},
"remark-disable-tokenizers": {
"version": "1.1.0",

View File

@ -42,7 +42,7 @@
"react-virtuoso": "^0.20.3",
"react-visibility-sensor": "^5.1.1",
"remark": "^12.0.0",
"remark-breaks": "^2.0.1",
"remark-breaks": "^2.0.2",
"remark-disable-tokenizers": "1.1.0",
"stacktrace-js": "^2.0.2",
"style-loader": "^1.3.0",

View File

@ -58,13 +58,7 @@ const tokenizeMessage = (text) => {
|| (str === '`' && !isInCodeBlock)
) {
isInCodeBlock = true;
} else if (
(str.endsWith('`') && str !== '`')
|| (str === '`' && isInCodeBlock)
) {
isInCodeBlock = false;
}
}
if(isRef(str) && !isInCodeBlock) {
if (currTextLine.length > 0 || currTextBlock.length > 0) {
// If we're in the middle of a message, add it to the stack and reset
@ -105,6 +99,13 @@ const tokenizeMessage = (text) => {
} else {
currTextLine.push(str);
}
if (
(str.endsWith('`') && str !== '`')
|| (str === '`' && isInCodeBlock)
) {
isInCodeBlock = false;
}
});
}
currTextBlock.push(currTextLine.join(' '))

View File

@ -491,7 +491,8 @@ export const Message = React.memo(({
width='36px'
textAlign='right'
left={0}
top='3px'
top='2px'
lineHeight="tall"
fontSize={0}
gray
>

View File

@ -87,7 +87,7 @@ class LinkWindow extends Component<LinkWindowProps, {}> {
}
return (
<Box ref={ref}>
<LinkItem key={index.toString()} {...linkProps} />;
<LinkItem key={index.toString()} {...linkProps} />
</Box>
);
});

View File

@ -172,7 +172,7 @@ function DaySection({
{_.map(timeboxes.sort(sortTimeboxes), ([date, nots], i: number) =>
_.map(nots.sort(sortIndexedNotification), (not, j: number) => (
<Notification
key={getNotificationKey(time, not)}
key={getNotificationKey(date, not)}
api={api}
notification={not}
archived={archive}

View File

@ -90,7 +90,8 @@ export function GroupLink(
<Box display='flex' alignItems='center'>
<Icon icon='Users' color='gray' mr='1' />
<Text fontSize='0'color='gray' >
{preview.members}
{preview.members}
{' '}
{preview.members > 1 ? 'peers' : 'peer'}
</Text>
</Box>

View File

@ -203,8 +203,9 @@ function InviteActions(props: {
app?: string;
uid?: string;
}) {
const { resource, api, app, uid } = props;
const { status, resource, api, app, uid } = props;
const inviteAccept = useInviteAccept(resource, api, app, uid);
const set = useGroupState(s => s.set);
const inviteDecline = useCallback(async () => {
if (!(app && uid)) {
@ -213,15 +214,18 @@ function InviteActions(props: {
await api.invite.decline(app, uid);
}, [app, uid]);
const hideJoin = useCallback(async () => {
await api.groups.hide(resource);
}, [api, resource]);
const { status } = props;
if (status) {
if(status.progress === 'done') {
return null;
const hideJoin = useCallback(async (e) => {
if(status?.progress === 'done') {
set(s => {
delete s.pendingJoin[resource]
});
e.stopPropagation();
return;
}
await api.groups.hide(resource);
}, [api, resource, status]);
if (status) {
return (
<Row gapX={2} alignItems="center" height={4}>
<StatelessAsyncButton
@ -229,7 +233,7 @@ function InviteActions(props: {
backgroundColor="white"
onClick={hideJoin}
>
Cancel
{status?.progress === 'done' ? 'Dismiss' : 'Cancel'}
</StatelessAsyncButton>
</Row>
);

View File

@ -31,7 +31,7 @@ return;
const action = props.owner ? 'Archive' : 'Leave';
const description = props.owner
? 'Permanently delete this group. (All current members will no longer see this group.)'
? 'Permanently archive this group. (All current members will no longer see this group.)'
: 'You can rejoin if it is an open group, or if you are reinvited';
const icon = props.owner ? 'X' : 'LogOut';

View File

@ -220,28 +220,24 @@ const header = ({ children, depth, ...rest }) => {
const level = depth;
const inner =
level === 1 ? (
<H1 display='block'>{children}</H1>
<H1 display="block">{children}</H1>
) : level === 2 ? (
<H2 display='block'>{children}</H2>
<H2 display="block">{children}</H2>
) : level === 3 ? (
<H3 display='block'>{children}</H3>
<H3 display="block">{children}</H3>
) : (
<H4 display='block'>{children}</H4>
<H4 display="block">{children}</H4>
);
return (
<Box {...rest} mt={2} mb={4}>
{inner}
</Box>
);
return <Box {...rest}>{inner}</Box>;
};
const renderers = {
heading: header,
break: () => {
return <Box display='block' width='100%' height={2}></Box>
return <Box display="block" width="100%" height={2}></Box>;
},
thematicBreak: () => {
return <Box display='block' width='100%' height={2}></Box>
return <Box display="block" width="100%" height={2}></Box>;
},
inlineCode: ({ language, value }) => {
return (
@ -258,28 +254,32 @@ const renderers = {
},
strong: ({ children }) => {
return (
<Text fontWeight="bold" lineHeight='1'>
<Text fontWeight="bold" lineHeight="1">
{children}
</Text>
);
},
emphasis: ({ children }) => {
return (
<Text fontStyle="italic" fontSize={1} lineHeight={'20px'}>
<Text fontStyle="italic" fontSize={1} lineHeight="tall">
{children}
</Text>
)
</Text>
);
},
blockquote: ({ children, tall, ...rest }) => {
blockquote: ({ children, depth, tall, ...rest }) => {
if (depth > 1) {
return children;
}
return (
<Text
lineHeight="20px"
lineHeight="tall"
display="block"
borderLeft="1px solid"
color="black"
paddingLeft={2}
py={1}
mb={1}
mb={1}
>
{children}
</Text>
@ -287,7 +287,7 @@ const renderers = {
},
paragraph: ({ children }) => {
return (
<Text fontSize={1} lineHeight={'20px'}>
<Text fontSize={1} lineHeight="tall">
{children}
</Text>
);
@ -329,7 +329,13 @@ const renderers = {
},
link: (props) => {
return (
<Anchor href={props.url} borderBottom="1" color="black" target="_blank">
<Anchor
display="inline"
href={props.url}
borderBottom="1"
color="black"
target="_blank"
>
{props.children}
</Anchor>
);
@ -342,7 +348,7 @@ const renderers = {
);
},
'graph-mention': ({ ship }) => <Mention api={{} as any} ship={ship} />,
'image': ({ url }) => (
image: ({ url }) => (
<Box mt="1" mb="2" flexShrink={0}>
<RemoteContent key={url} url={url} />
</Box>
@ -366,15 +372,26 @@ const renderers = {
);
},
root: ({ tall, children }) =>
tall
? <Box
display='grid'
style={{ 'gridTemplateColumns': 'minmax(0,1fr)', 'rowGap': '1rem' }}
>
{children}
</Box>
: <Box>{children}</Box>,
text: ({ value }) => value,
tall ? (
<Box
display="grid"
style={{ gridTemplateColumns: 'minmax(0,1fr)', rowGap: '1rem' }}
>
{children}
</Box>
) : (
<Box>{children}</Box>
),
text: ({ value }) => (
<>
{value.split('\n').map((v, idx) => (
<React.Fragment key={idx}>
{idx !== 0 ? <br /> : null}
{v}
</React.Fragment>
))}
</>
),
};
export function Graphdown<T extends {} = {}>(
@ -390,7 +407,13 @@ export function Graphdown<T extends {} = {}>(
const Renderer = renderers[ast.type] ?? (() => `unknown element: ${type}`);
return (
<Renderer transcluded={transcluded} depth={depth} {...rest} {...nodeRest} tall={tall}>
<Renderer
transcluded={transcluded}
depth={depth}
{...rest}
{...nodeRest}
tall={tall}
>
{children.map((c) => (
<Graphdown
transcluded={transcluded}

View File

@ -1,5 +1,6 @@
import remark from 'remark';
import RemarkDisableTokenizers from 'remark-disable-tokenizers';
import RemarkBreaks from 'remark-breaks';
const DISABLED_BLOCK_TOKENS = [
'indentedCode',
@ -12,7 +13,7 @@ const DISABLED_BLOCK_TOKENS = [
'table',
];
const DISABLED_INLINE_TOKENS = ['autoLink', 'url', 'email', 'reference'];
const DISABLED_INLINE_TOKENS = ['autoLink', 'url', 'email', 'reference', 'html'];
const tallParser = remark().freeze();
@ -27,6 +28,7 @@ const wideParser = remark()
inline: DISABLED_INLINE_TOKENS,
},
],
RemarkBreaks,
])
.freeze();

View File

@ -6,7 +6,7 @@ import {
import { Enc, GroupPolicy } from '@urbit/api';
import { Form, Formik, FormikHelpers } from 'formik';
import React, { ReactElement, useCallback } from 'react';
import { useHistory } from 'react-router-dom';
import { RouteComponentProps, useHistory } from 'react-router-dom';
import * as Yup from 'yup';
import GlobalApi from '~/logic/api/global';
import { useWaitForProps } from '~/logic/lib/useWaitForProps';
@ -31,7 +31,7 @@ interface NewGroupProps {
api: GlobalApi;
}
export function NewGroup(props: NewGroupProps): ReactElement {
export function NewGroup(props: NewGroupProps & RouteComponentProps): ReactElement {
const { api } = props;
const history = useHistory();
const initialValues: FormSchema = {