mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 04:52:06 +03:00
Merge pull request #3959 from urbit/mp/publish/writers
publish: Restore basic 'add writers' form
This commit is contained in:
commit
433c9d94a9
57
pkg/interface/src/views/apps/publish/components/Writers.js
Normal file
57
pkg/interface/src/views/apps/publish/components/Writers.js
Normal 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;
|
@ -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>
|
||||
);
|
||||
|
@ -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" ? (
|
||||
|
Loading…
Reference in New Issue
Block a user