Merge branch 'release/next-userspace' into mp/chat/dms

This commit is contained in:
Matilde Park 2021-02-02 20:08:30 -05:00
commit 57f0cb1308
9 changed files with 120 additions and 13 deletions

View File

@ -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

View File

@ -38,7 +38,9 @@
%_ this
invites.state
%- ~(gas by *invites:store)
[%graph *invitatory:store]~
:~ [%graph *invitatory:store]
[%groups *invitatory:store]
==
==
::
++ on-save !>(state)

View File

@ -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

View File

@ -9,6 +9,8 @@
:: client side
[%join =resource =ship]
[%leave =resource]
::
[%invite =resource ships=(set ship) description=@t]
==
::

View File

@ -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 !>(~))

View File

@ -67,6 +67,18 @@ export default class GroupsApi extends BaseApi<StoreState> {
});
}
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);
}

View File

@ -12,8 +12,16 @@ export class InviteItem extends Component<{invite: Invite, onAccept: (i: any) =>
<>
<Box width='100%' p='4'>
<Box width='100%' verticalAlign='middle'>
<Text display='block' pb='2' gray><Text mono>{cite(props.invite.resource.ship)}</Text> invited you to <Text fontWeight='500'>{props.invite.resource.name}</Text></Text>
<Text display='block' pb='2' gray>
<Text mono>{cite(props.invite.resource.ship)}</Text>
{" "}invited you to{" "}
<Text fontWeight='500'>{props.invite.resource.name}</Text></Text>
</Box>
{props.invite.text && (
<Box pb="2">
<Text gray>{props.invite.text}</Text>
</Box>
)}
<Row>
<StatelessAsyncAction
name="accept"

View File

@ -1,8 +1,16 @@
import React, { useCallback, useRef, useMemo } from "react";
import _ from 'lodash';
import { Switch, Route, useHistory } from "react-router-dom";
import { Formik, Form } from "formik";
import * as Yup from 'yup';
import { Box, Text, Col, Button, Row } from "@tlon/indigo-react";
import {
ManagedTextInputField as Input,
Box,
Text,
Col,
Button,
Row
} from "@tlon/indigo-react";
import { ShipSearch } from "~/views/components/ShipSearch";
import { Association } from "~/types/metadata-update";
@ -25,6 +33,7 @@ interface InvitePopoverProps {
interface FormSchema {
emails: string[];
description: string;
ships: string[];
}
@ -46,14 +55,16 @@ export function InvitePopover(props: InvitePopoverProps) {
}, [history.push, props.baseUrl]);
useOutsideClick(innerRef, onOutsideClick);
const onSubmit = async ({ ships, emails }: { ships: string[] }, actions) => {
const onSubmit = async ({ ships, description }: FormSchema, actions) => {
// 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) {
@ -62,7 +73,7 @@ export function InvitePopover(props: InvitePopoverProps) {
}
};
const initialValues: FormSchema = { ships: [], emails: [] };
const initialValues: FormSchema = { ships: [], emails: [], description: '' };
return (
@ -110,6 +121,10 @@ export function InvitePopover(props: InvitePopoverProps) {
label=""
autoFocus
/>
<Input
id="description"
label="Enter a message for the invite"
/>
<FormError message="Failed to invite" />
{/* <ChipInput
id="emails"

View File

@ -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];