mirror of
https://github.com/urbit/shrub.git
synced 2025-01-05 11:09:30 +03:00
interface: use md-store %edit instead of %add
This commit is contained in:
parent
85a61ca1c5
commit
0eb89a5715
@ -5,7 +5,7 @@ import {
|
|||||||
|
|
||||||
Text
|
Text
|
||||||
} from '@tlon/indigo-react';
|
} from '@tlon/indigo-react';
|
||||||
import { addTag, Association, Group, metadataUpdate, PermVariation, removeTag } from '@urbit/api';
|
import { addTag, Association, Group, PermVariation, removeTag, metadataEdit } from '@urbit/api';
|
||||||
import { Form, Formik } from 'formik';
|
import { Form, Formik } from 'formik';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@ -107,7 +107,7 @@ export function GraphPermissions(props: GraphPermissionsProps) {
|
|||||||
};
|
};
|
||||||
const allWriters = Array.from(writers).map(w => `~${w}`);
|
const allWriters = Array.from(writers).map(w => `~${w}`);
|
||||||
if (values.readerComments !== readerComments) {
|
if (values.readerComments !== readerComments) {
|
||||||
await airlock.poke(metadataUpdate(association, {
|
await airlock.poke(metadataEdit(association, {
|
||||||
vip: values.readerComments ? 'reader-comments' : ''
|
vip: values.readerComments ? 'reader-comments' : ''
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ import {
|
|||||||
Label, ManagedTextInputField as Input,
|
Label, ManagedTextInputField as Input,
|
||||||
Text
|
Text
|
||||||
} from '@tlon/indigo-react';
|
} from '@tlon/indigo-react';
|
||||||
import { Association, metadataUpdate } from '@urbit/api';
|
import _ from 'lodash';
|
||||||
|
import { Association, metadataEdit } from '@urbit/api';
|
||||||
import { Form, Formik } from 'formik';
|
import { Form, Formik } from 'formik';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { uxToHex } from '~/logic/lib/util';
|
import { uxToHex } from '~/logic/lib/util';
|
||||||
@ -32,9 +33,13 @@ export function ChannelDetails(props: ChannelDetailsProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async (values: FormSchema, actions) => {
|
const onSubmit = async (values: FormSchema, actions) => {
|
||||||
const { title, description } = values;
|
values.color = uxToHex(values.color);
|
||||||
const color = uxToHex(values.color);
|
const promises = _.compact(_.map(values, (value,k) => {
|
||||||
await airlock.poke(metadataUpdate(association, { title, color, description }));
|
return value !== initialValues[k]
|
||||||
|
? airlock.poke(metadataEdit(association, { [k]: value }))
|
||||||
|
: null;
|
||||||
|
}));
|
||||||
|
await Promise.all(promises);
|
||||||
actions.setStatus({ success: null });
|
actions.setStatus({ success: null });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
leaveGraph,
|
leaveGraph,
|
||||||
metadataRemove
|
metadataRemove
|
||||||
} from '@urbit/api';
|
} from '@urbit/api';
|
||||||
import React, { useCallback, useRef } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { Link, useHistory } from 'react-router-dom';
|
import { Link, useHistory } from 'react-router-dom';
|
||||||
import { isChannelAdmin, isHost } from '~/logic/lib/group';
|
import { isChannelAdmin, isHost } from '~/logic/lib/group';
|
||||||
import { useHashLink } from '~/logic/lib/useHashLink';
|
import { useHashLink } from '~/logic/lib/useHashLink';
|
||||||
@ -31,7 +31,6 @@ interface ChannelPopoverRoutesProps {
|
|||||||
export function ChannelPopoverRoutes(props: ChannelPopoverRoutesProps) {
|
export function ChannelPopoverRoutes(props: ChannelPopoverRoutesProps) {
|
||||||
const { association, group } = props;
|
const { association, group } = props;
|
||||||
useHashLink();
|
useHashLink();
|
||||||
const overlayRef = useRef<HTMLElement>();
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const onDismiss = useCallback(() => {
|
const onDismiss = useCallback(() => {
|
||||||
@ -63,7 +62,6 @@ export function ChannelPopoverRoutes(props: ChannelPopoverRoutesProps) {
|
|||||||
height="100%"
|
height="100%"
|
||||||
width="100%"
|
width="100%"
|
||||||
spacing={[3, 5, 7]}
|
spacing={[3, 5, 7]}
|
||||||
ref={overlayRef}
|
|
||||||
dismiss={onDismiss}
|
dismiss={onDismiss}
|
||||||
>
|
>
|
||||||
<Row
|
<Row
|
||||||
|
@ -4,9 +4,10 @@ import {
|
|||||||
ManagedToggleSwitchField as Checkbox,
|
ManagedToggleSwitchField as Checkbox,
|
||||||
Text
|
Text
|
||||||
} from '@tlon/indigo-react';
|
} from '@tlon/indigo-react';
|
||||||
import { changePolicy, Enc, metadataUpdate } from '@urbit/api';
|
import _ from 'lodash';
|
||||||
|
import { changePolicy, Enc } from '@urbit/api';
|
||||||
import { Group, GroupPolicy } from '@urbit/api/groups';
|
import { Group, GroupPolicy } from '@urbit/api/groups';
|
||||||
import { Association } from '@urbit/api/metadata';
|
import { Association, metadataEdit, MetadataEditField } from '@urbit/api/metadata';
|
||||||
import { Form, Formik, FormikHelpers } from 'formik';
|
import { Form, Formik, FormikHelpers } from 'formik';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
@ -58,16 +59,26 @@ export function GroupAdminSettings(props: GroupAdminSettingsProps) {
|
|||||||
actions: FormikHelpers<FormSchema>
|
actions: FormikHelpers<FormSchema>
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const { title, description, picture, color, isPrivate, adminMetadata } = values;
|
const { color, isPrivate, adminMetadata } = values;
|
||||||
|
const update = (upd: MetadataEditField) =>
|
||||||
|
airlock.poke(metadataEdit(association, upd));
|
||||||
|
|
||||||
const uxColor = uxToHex(color);
|
const uxColor = uxToHex(color);
|
||||||
const vip = adminMetadata ? '' : 'member-metadata';
|
const vip = adminMetadata ? '' : 'member-metadata';
|
||||||
await airlock.poke(metadataUpdate(props.association, {
|
const promises = _.compact(_.map(['title', 'description', 'picture'] as const,
|
||||||
title,
|
(k) => {
|
||||||
description,
|
const edit: MetadataEditField = { [k]: values[k] };
|
||||||
picture,
|
return (values[k] !== initialValues[k])
|
||||||
color: uxColor,
|
? update(edit)
|
||||||
vip
|
: null;
|
||||||
}));
|
}));
|
||||||
|
if(vip !== metadata.vip) {
|
||||||
|
promises.push(update({ vip }));
|
||||||
|
}
|
||||||
|
if(uxColor !== metadata.color) {
|
||||||
|
promises.push(update({ color: uxColor }));
|
||||||
|
}
|
||||||
|
await Promise.all(promises);
|
||||||
if (isPrivate !== currentPrivate) {
|
if (isPrivate !== currentPrivate) {
|
||||||
const resource = resourceFromPath(props.association.group);
|
const resource = resourceFromPath(props.association.group);
|
||||||
const newPolicy: Enc<GroupPolicy> = isPrivate
|
const newPolicy: Enc<GroupPolicy> = isPrivate
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Col, Icon, Row, Text } from '@tlon/indigo-react';
|
import { Col, Icon, Row, Text } from '@tlon/indigo-react';
|
||||||
import { Association, Group, metadataRemove, metadataUpdate } from '@urbit/api';
|
import { Association, Group, metadataRemove, metadataEdit } from '@urbit/api';
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { resourceFromPath, roleForShip } from '~/logic/lib/group';
|
import { resourceFromPath, roleForShip } from '~/logic/lib/group';
|
||||||
import { getModuleIcon, GraphModule } from '~/logic/lib/util';
|
import { getModuleIcon, GraphModule } from '~/logic/lib/util';
|
||||||
@ -22,7 +22,8 @@ export function GroupChannelSettings(props: GroupChannelSettingsProps) {
|
|||||||
|
|
||||||
const onChange = useCallback(
|
const onChange = useCallback(
|
||||||
async (resource: string, preview: boolean) => {
|
async (resource: string, preview: boolean) => {
|
||||||
await airlock.poke(metadataUpdate(associations.graph[resource], { preview }));
|
const association = associations.graph[resource];
|
||||||
|
await airlock.poke(metadataEdit(association, { preview }));
|
||||||
},
|
},
|
||||||
[associations.graph]
|
[associations.graph]
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { BaseLabel, Col, Label, Text } from '@tlon/indigo-react';
|
import { BaseLabel, Col, Label, Text } from '@tlon/indigo-react';
|
||||||
import { Association, createGroupFeed, disableGroupFeed, Group, metadataUpdate, PermVariation, resourceFromPath } from '@urbit/api';
|
import { Association, createGroupFeed, disableGroupFeed, Group, metadataEdit, PermVariation, resourceFromPath } from '@urbit/api';
|
||||||
import { Form, Formik, FormikHelpers } from 'formik';
|
import { Form, Formik, FormikHelpers } from 'formik';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import useMetadataState from '~/logic/state/metadata';
|
import useMetadataState from '~/logic/state/metadata';
|
||||||
@ -46,7 +46,11 @@ export function GroupFeedSettings(props: {
|
|||||||
values: FormSchema,
|
values: FormSchema,
|
||||||
actions: FormikHelpers<FormSchema>
|
actions: FormikHelpers<FormSchema>
|
||||||
) => {
|
) => {
|
||||||
await airlock.poke(metadataUpdate(feedAssoc, { vip: values.permissions.trim() as PermVariation }));
|
await airlock.poke(
|
||||||
|
metadataEdit(feedAssoc, {
|
||||||
|
vip: values.permissions.trim() as PermVariation
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
actions.setStatus({ success: null });
|
actions.setStatus({ success: null });
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user