mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-12 15:01:38 +03:00
interface: surface member-metadata functionality
This commit is contained in:
parent
e972010e2d
commit
61ba382957
@ -31,6 +31,7 @@ interface FormSchema {
|
|||||||
color: string;
|
color: string;
|
||||||
isPrivate: boolean;
|
isPrivate: boolean;
|
||||||
picture: string;
|
picture: string;
|
||||||
|
adminMetadata: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formSchema = Yup.object({
|
const formSchema = Yup.object({
|
||||||
@ -38,6 +39,7 @@ const formSchema = Yup.object({
|
|||||||
description: Yup.string(),
|
description: Yup.string(),
|
||||||
color: Yup.string(),
|
color: Yup.string(),
|
||||||
isPrivate: Yup.boolean(),
|
isPrivate: Yup.boolean(),
|
||||||
|
adminMetadata: Yup.boolean()
|
||||||
});
|
});
|
||||||
|
|
||||||
interface GroupAdminSettingsProps {
|
interface GroupAdminSettingsProps {
|
||||||
@ -58,6 +60,7 @@ export function GroupAdminSettings(props: GroupAdminSettingsProps) {
|
|||||||
color: metadata?.color,
|
color: metadata?.color,
|
||||||
picture: metadata?.picture,
|
picture: metadata?.picture,
|
||||||
isPrivate: currentPrivate,
|
isPrivate: currentPrivate,
|
||||||
|
adminMetadata: metadata.vip !== 'member-metadata'
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async (
|
const onSubmit = async (
|
||||||
@ -65,13 +68,15 @@ export function GroupAdminSettings(props: GroupAdminSettingsProps) {
|
|||||||
actions: FormikHelpers<FormSchema>
|
actions: FormikHelpers<FormSchema>
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const { title, description, picture, color, isPrivate } = values;
|
const { title, description, picture, color, isPrivate, adminMetadata } = values;
|
||||||
const uxColor = uxToHex(color);
|
const uxColor = uxToHex(color);
|
||||||
|
const vip = adminMetadata ? '' : 'member-metadata';
|
||||||
await props.api.metadata.update(props.association, {
|
await props.api.metadata.update(props.association, {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
picture,
|
picture,
|
||||||
color: uxColor,
|
color: uxColor,
|
||||||
|
vip
|
||||||
});
|
});
|
||||||
if (isPrivate !== currentPrivate) {
|
if (isPrivate !== currentPrivate) {
|
||||||
const resource = resourceFromPath(props.association.group);
|
const resource = resourceFromPath(props.association.group);
|
||||||
@ -135,6 +140,13 @@ export function GroupAdminSettings(props: GroupAdminSettingsProps) {
|
|||||||
caption="If enabled, users must be invited to join the group"
|
caption="If enabled, users must be invited to join the group"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
|
<Checkbox
|
||||||
|
id="adminMetadata"
|
||||||
|
label="Restrict channel adding to admins"
|
||||||
|
caption="If enabled, users must be an admin to add a channel to the group"
|
||||||
|
disabled={disabled}
|
||||||
|
/>
|
||||||
|
|
||||||
<AsyncButton
|
<AsyncButton
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
primary
|
primary
|
||||||
|
@ -85,6 +85,7 @@ export function Sidebar(props: SidebarProps) {
|
|||||||
workspace={props.workspace}
|
workspace={props.workspace}
|
||||||
/>
|
/>
|
||||||
<SidebarListHeader
|
<SidebarListHeader
|
||||||
|
associations={associations}
|
||||||
contacts={props.contacts}
|
contacts={props.contacts}
|
||||||
baseUrl={props.baseUrl}
|
baseUrl={props.baseUrl}
|
||||||
groups={props.groups}
|
groups={props.groups}
|
||||||
|
@ -16,10 +16,11 @@ import { SidebarListConfig, Workspace } from "./types";
|
|||||||
import { Link, useHistory } from 'react-router-dom';
|
import { Link, useHistory } from 'react-router-dom';
|
||||||
import { getGroupFromWorkspace } from "~/logic/lib/workspace";
|
import { getGroupFromWorkspace } from "~/logic/lib/workspace";
|
||||||
import { roleForShip } from "~/logic/lib/group";
|
import { roleForShip } from "~/logic/lib/group";
|
||||||
import {Groups, Rolodex} from "~/types";
|
import {Groups, Rolodex, Associations} from "~/types";
|
||||||
|
|
||||||
export function SidebarListHeader(props: {
|
export function SidebarListHeader(props: {
|
||||||
initialValues: SidebarListConfig;
|
initialValues: SidebarListConfig;
|
||||||
|
associations: Associations;
|
||||||
groups: Groups;
|
groups: Groups;
|
||||||
contacts: Rolodex;
|
contacts: Rolodex;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
@ -39,7 +40,10 @@ export function SidebarListHeader(props: {
|
|||||||
|
|
||||||
const groupPath = getGroupFromWorkspace(props.workspace);
|
const groupPath = getGroupFromWorkspace(props.workspace);
|
||||||
const role = props.groups?.[groupPath] ? roleForShip(props.groups[groupPath], window.ship) : undefined;
|
const role = props.groups?.[groupPath] ? roleForShip(props.groups[groupPath], window.ship) : undefined;
|
||||||
const isAdmin = (role === "admin") || (props.workspace?.type === 'home');
|
const memberMetadata =
|
||||||
|
groupPath ? props.associations.contacts?.[groupPath].metadata.vip === 'member-metadata' : false;
|
||||||
|
|
||||||
|
const isAdmin = memberMetadata || (role === "admin") || (props.workspace?.type === 'home');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row
|
<Row
|
||||||
|
Loading…
Reference in New Issue
Block a user