From 1093ad0e42e24938cb42803abde412a75c263b9e Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 3 Feb 2021 09:49:29 +1000 Subject: [PATCH 1/6] group-view: add %invite action --- pkg/arvo/lib/group-view.hoon | 8 ++++++++ pkg/arvo/sur/group-view.hoon | 2 ++ 2 files changed, 10 insertions(+) diff --git a/pkg/arvo/lib/group-view.hoon b/pkg/arvo/lib/group-view.hoon index 483b97a86..f3919891a 100644 --- a/pkg/arvo/lib/group-view.hoon +++ b/pkg/arvo/lib/group-view.hoon @@ -14,6 +14,7 @@ remove+remove join+join leave+leave + invite+invite == :: ++ create @@ -33,6 +34,13 @@ :~ resource+dejs:resource ship+(su ;~(pfix sig fed:ag)) == + :: + ++ invite + %- ot + :~ resource+dejs:resource + ships+(as (su ;~(pfix sig fed:ag))) + description+so + == -- :: ++ enjs diff --git a/pkg/arvo/sur/group-view.hoon b/pkg/arvo/sur/group-view.hoon index 4ffbcfc8a..549ae5430 100644 --- a/pkg/arvo/sur/group-view.hoon +++ b/pkg/arvo/sur/group-view.hoon @@ -9,6 +9,8 @@ :: client side [%join =resource =ship] [%leave =resource] + :: + [%invite =resource ships=(set ship) description=@t] == :: From e17bf318594b44d136795a43926a7949109a3f6c Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 3 Feb 2021 09:52:00 +1000 Subject: [PATCH 2/6] group-view: add -group-invite thread --- pkg/arvo/ted/group/invite.hoon | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 pkg/arvo/ted/group/invite.hoon diff --git a/pkg/arvo/ted/group/invite.hoon b/pkg/arvo/ted/group/invite.hoon new file mode 100644 index 000000000..ad42479ef --- /dev/null +++ b/pkg/arvo/ted/group/invite.hoon @@ -0,0 +1,58 @@ +/- spider, + metadata=metadata-store, + *group, + inv=invite-store, + store=group-store, + push-hook +/+ strandio, resource, view=group-view, grpl=group +=> +|% +++ strand strand:spider +++ poke poke:strandio +++ poke-our poke-our:strandio +++ gallify-bowl + |= =bowl:spider + ^- bowl:gall + :* [our src %$]:bowl + [~ ~] + [0 eny now byk]:bowl + == +:: +++ invite-ships + |= [ships=(set ship) rid=resource description=cord] + =/ m (strand ,~) + ^- form:m + ;< =bowl:spider bind:m get-bowl:strandio + =/ =action:inv + :^ %invites %groups (shaf %group-uid eny.bowl) + ^- multi-invite:inv + [our.bowl %group-push-hook rid ships description] + ;< ~ bind:m (poke-our %invite-hook invite-action+!>(action)) + (pure:m ~) +:: +++ add-pending + |= [ships=(set ship) rid=resource] + =/ m (strand ,~) + ^- form:m + =/ =action:store + [%change-policy rid %invite %add-invites ships] + ;< ~ bind:m (poke-our %group-push-hook %group-update !>(action)) + (pure:m ~) +-- +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([~ =action:view] arg) +?> ?=(%invite -.action) +;< =bowl:spider bind:m get-bowl:strandio +=/ =bowl:gall (gallify-bowl bowl) +?> (~(is-admin grpl bowl) our.bowl resource.action) +;< ~ bind:m + (invite-ships [ships resource description]:action) +=/ =group + (need (~(scry-group grpl bowl) resource.action)) +?: ?=(%open -.policy.group) + (pure:m !>(~)) +;< ~ bind:m (add-pending [ships resource]:action) +(pure:m !>(~)) From 63027861dc3ea7774b5bf352602ede1be2e904d3 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 3 Feb 2021 09:52:25 +1000 Subject: [PATCH 3/6] invite-store: add %groups in +on-init --- pkg/arvo/app/invite-store.hoon | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/arvo/app/invite-store.hoon b/pkg/arvo/app/invite-store.hoon index 47de74ba8..d7bbbf0c3 100644 --- a/pkg/arvo/app/invite-store.hoon +++ b/pkg/arvo/app/invite-store.hoon @@ -38,7 +38,9 @@ %_ this invites.state %- ~(gas by *invites:store) - [%graph *invitatory:store]~ + :~ [%graph *invitatory:store] + [%groups *invitatory:store] + == == :: ++ on-save !>(state) From 8bb8f0b206b3eb1005b86d7f1f23b9663996b374 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 3 Feb 2021 10:00:42 +1000 Subject: [PATCH 4/6] invites: update interface for new thread --- pkg/interface/src/logic/api/groups.ts | 12 ++++++++ pkg/interface/src/views/components/Invite.tsx | 10 ++++++- .../landscape/components/InvitePopover.tsx | 29 ++++++++++++++----- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/pkg/interface/src/logic/api/groups.ts b/pkg/interface/src/logic/api/groups.ts index 4e5182abe..de2f4b488 100644 --- a/pkg/interface/src/logic/api/groups.ts +++ b/pkg/interface/src/logic/api/groups.ts @@ -67,6 +67,18 @@ export default class GroupsApi extends BaseApi { }); } + invite(ship: string, name: string, ships: Patp[], description: string) { + const resource = makeResource(ship, name); + return this.viewThread('group-invite', { + invite: { + resource, + ships, + description + } + }); + + } + private proxyAction(action: GroupAction) { return this.action('group-push-hook', 'group-update', action); } diff --git a/pkg/interface/src/views/components/Invite.tsx b/pkg/interface/src/views/components/Invite.tsx index 34bbabfed..70c16ab4c 100644 --- a/pkg/interface/src/views/components/Invite.tsx +++ b/pkg/interface/src/views/components/Invite.tsx @@ -12,8 +12,16 @@ export class InviteItem extends Component<{invite: Invite, onAccept: (i: any) => <> - {cite(props.invite.resource.ship)} invited you to {props.invite.resource.name} + + {cite(props.invite.resource.ship)} + {" "}invited you to{" "} + {props.invite.resource.name} + {props.invite.text && ( + + {props.invite.text} + + )} { + const onSubmit = async ({ ships, description }: FormSchema, actions) => { if(props.workspace.type === 'home') { history.push(`/~landscape/dm/${deSig(ships[0])}`); return; } // TODO: how to invite via email? try { - const resource = resourceFromPath(association.group); - await ships.reduce( - (acc, s) => acc.then(() => api.contacts.invite(resource, `~${deSig(s)}`)), - Promise.resolve() + const { ship, name } = resourceFromPath(association.group); + await api.groups.invite( + ship, name, + _.compact(ships).map(s => `~${deSig(s)}`), + description ); + actions.setStatus({ success: null }); onOutsideClick(); } catch (e) { @@ -66,7 +77,7 @@ export function InvitePopover(props: InvitePopoverProps) { } }; - const initialValues: FormSchema = { ships: [], emails: [] }; + const initialValues: FormSchema = { ships: [], emails: [], description: '' }; return ( @@ -115,6 +126,10 @@ export function InvitePopover(props: InvitePopoverProps) { maxLength={props.workspace.type === 'home' ? 1 : undefined} autoFocus /> + {/* Date: Wed, 3 Feb 2021 10:01:06 +1000 Subject: [PATCH 5/6] JoinGroup: check correct associations key --- pkg/interface/src/views/landscape/components/JoinGroup.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/interface/src/views/landscape/components/JoinGroup.tsx b/pkg/interface/src/views/landscape/components/JoinGroup.tsx index cef007956..442891971 100644 --- a/pkg/interface/src/views/landscape/components/JoinGroup.tsx +++ b/pkg/interface/src/views/landscape/components/JoinGroup.tsx @@ -85,7 +85,7 @@ export function JoinGroup(props: JoinGroupProps) { await waiter((p: JoinGroupProps) => { return group in p.groups && (group in (p.associations?.graph ?? {}) - || group in (p.associations?.contacts ?? {})) + || group in (p.associations?.groups ?? {})) }); if(props.groups?.[group]?.hidden) { const { metadata } = associations.graph[group]; From 9d08d0d2b6503aa949bfcd90dd597010a7a50d9a Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 3 Feb 2021 10:34:16 +1000 Subject: [PATCH 6/6] graph-push-hook: fix +is-allowed --- pkg/arvo/app/graph-push-hook.hoon | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/arvo/app/graph-push-hook.hoon b/pkg/arvo/app/graph-push-hook.hoon index d210ddec2..6685a881e 100644 --- a/pkg/arvo/app/graph-push-hook.hoon +++ b/pkg/arvo/app/graph-push-hook.hoon @@ -97,7 +97,7 @@ ++ initial-watch |= [=path =resource:res] ^- vase - ?> (is-allowed resource bowl %.n) + ?> (is-allowed resource) !> ^- update:store ?~ path :: new subscribe @@ -185,8 +185,10 @@ reader.permissions :: ++ is-allowed - |= * - %.y + |= =resource:res + =/ group-res=resource:res + (need (peek-group:met %graph resource)) + (is-member:grp src.bowl group-res) :: ++ get-roles-writers-variation |= =resource:res