Merge pull request #3959 from urbit/mp/publish/writers

publish: Restore basic 'add writers' form
This commit is contained in:
matildepark 2020-11-18 19:50:41 -05:00 committed by GitHub
commit 433c9d94a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 3 deletions

View File

@ -0,0 +1,57 @@
import React, { Component } from 'react';
import { Box, Text } from '@tlon/indigo-react';
import { ShipSearch } from '~/views/components/ShipSearch';
import { Formik, Form, FormikHelpers } from 'formik';
import { resourceFromPath } from '~/logic/lib/group';
import { AsyncButton } from '~/views/components/AsyncButton';
export class Writers extends Component {
render() {
const { association, groups, contacts, api } = this.props;
const [,,,name] = association?.['app-path'].split('/');
const resource = resourceFromPath(association?.['group-path']);
const onSubmit = async (values, actions) => {
try {
const ships = values.ships.map(e => `~${e}`);
await api.groups.addTag(
resource,
{ app: 'publish', tag: `writers-${name}` },
ships
);
actions.resetForm();
actions.setStatus({ success: null });
} catch (e) {
console.error(e);
actions.setStatus({ error: e.message });
}
};
return (
<Box maxWidth='512px'>
<Text display='block'>Writers</Text>
<Text display='block' mt='2' gray>Add additional writers to this notebook</Text>
<Formik
initialValues={{ ships: [] }}
onSubmit={onSubmit}
>
<Form>
<ShipSearch
groups={groups}
contacts={contacts}
id="ships"
label=""
maxLength={undefined}
/>
<AsyncButton width='100%' mt='3' primary>
Submit
</AsyncButton>
</Form>
</Formik>
</Box>
);
}
}
export default Writers;

View File

@ -14,6 +14,7 @@ import { uxToHex } from "~/logic/lib/util";
import { FormError } from "~/views/components/FormError";
import { ColorInput } from "~/views/components/ColorInput";
import { Association, Groups, Associations } from "~/types";
import Writers from '~/views/apps/publish/components/Writers';
import GroupifyForm from "./GroupifyForm";
interface FormSchema {
@ -99,6 +100,10 @@ export function ChannelSettings(props: ChannelSettingsProps) {
</Form>
</Formik>
<Box borderBottom="1" borderBottomColor="lightGray" width="100%" maxWidth="512px" />
{(metadata?.module === 'publish') && (<>
<Writers {...props} />
<Box borderBottom="1" borderBottomColor="lightGray" width="100%" maxWidth="512px" />
</>)}
<GroupifyForm {...props} />
</Col>
);

View File

@ -44,11 +44,12 @@ export function Resource(props: ResourceProps) {
baseUrl={props.baseUrl}
{...skelProps}
>
<ChannelSettings
<ChannelSettings
groups={props.groups}
contacts={props.contacts}
associations={props.associations}
api={api}
association={association}
association={association}
/>
</ResourceSkeleton>
);
@ -61,7 +62,7 @@ export function Resource(props: ResourceProps) {
notificationsGraphConfig={props.notificationsGraphConfig}
notificationsChatConfig={props.notificationsChatConfig}
baseUrl={props.baseUrl}
{...skelProps}
{...skelProps}
atRoot
>
{app === "chat" ? (