publish: hide relevant inputs if we are missing permissions

This commit is contained in:
Liam Fitzgerald 2021-01-28 10:39:32 +10:00
parent fdf80d8eda
commit 4577df379d
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
5 changed files with 35 additions and 1304 deletions

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@ export function Note(props: NoteProps & RouteComponentProps) {
let adminLinks: JSX.Element | null = null;
if (window.ship === note?.post?.author) {
if (true || window.ship === note?.post?.author) {
adminLinks = (
<Box display="inline-block" verticalAlign="middle">
<Link to={`${baseUrl}/edit`}>

View File

@ -1,9 +1,10 @@
import React from "react";
import { RouteComponentProps } from "react-router-dom";
import { RouteComponentProps, Link } from "react-router-dom";
import { NotebookPosts } from "./NotebookPosts";
import { Col } from "@tlon/indigo-react";
import { Col, Box, Text, Button, Row } from "@tlon/indigo-react";
import GlobalApi from "~/logic/api/global";
import { Contacts, Rolodex, Groups, Associations, Graph, Association, Unreads } from "~/types";
import { useShowNickname } from "~/logic/lib/util";
interface NotebookProps {
api: GlobalApi;
@ -35,8 +36,27 @@ export function Notebook(props: NotebookProps & RouteComponentProps) {
return null; // Waiting on groups to populate
}
const relativePath = (p: string) => props.baseUrl + p;
const contact = notebookContacts?.[ship];
const isOwn = `~${window.ship}` === ship;
console.log(association.resource);
const showNickname = useShowNickname(contact);
return (
<Col gapY="4" pt={4} mx="auto" px={3} maxWidth="768px">
<Row justifyContent="space-between">
<Box>
<Text display='block'>{association.metadata?.title}</Text>
<Text color="lightGray">by </Text>
<Text fontFamily={showNickname ? 'sans' : 'mono'}>
{showNickname ? contact?.nickname : ship}
</Text>
</Box>
</Row>
<Box borderBottom="1" borderBottomColor="washedGray" />
<NotebookPosts
graph={graph}
host={ship}

View File

@ -18,7 +18,7 @@ export class Writers extends Component {
const ships = values.ships.map(e => `~${e}`);
await api.groups.addTag(
resource,
{ app: 'publish', tag: `writers-${name}` },
{ app: 'graph', resource: association.resource, tag: `writers` },
ships
);
actions.resetForm();
@ -28,7 +28,8 @@ export class Writers extends Component {
actions.setStatus({ error: e.message });
}
};
const writers = Array.from(groups?.[association?.group]?.tags.publish?.[`writers-${name}`] || new Set()).map(e => cite(`~${e}`)).join(', ');
const writers = Array.from(groups?.[association?.group]?.tags.graph[association.resource]?.writers || []).map(s => `~${s}`).join(', ');
return (
<Box maxWidth='512px'>
@ -51,10 +52,14 @@ export class Writers extends Component {
</AsyncButton>
</Form>
</Formik>
{writers.length > 0 && <>
{writers.length > 0 ? <>
<Text display='block' mt='2'>Current writers:</Text>
<Text mt='2' display='block' mono>{writers}</Text>
</>}
</> :
<Text display='block' mt='2'>
All group members can write to this channel
</Text>
}
</Box>
);
}

View File

@ -32,7 +32,9 @@ export default function NewPost(props: NewPostProps & RouteComponentProps) {
try {
const [noteId, nodes] = newPost(title, body)
await api.graph.addNodes(ship, book, nodes)
await waiter(p => p.graph.has(noteId));
await waiter(p =>
p.graph.has(noteId) && !p.graph.get(noteId)?.post?.pending
);
history.push(`${props.baseUrl}/note/${noteId}`);
} catch (e) {
console.error(e);