Merge pull request #3819 from urbit/mp/links/delete

links: add link deletion
This commit is contained in:
matildepark 2020-10-29 12:58:30 -04:00 committed by GitHub
commit 3d1942e8df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -48,6 +48,7 @@ export function LinkResource(props: LinkResourceProps) {
? associations.graph[appPath]
: { metadata: {} };
const contactDetails = contacts[resource["group-path"]] || {};
const group = groups[resource["group-path"]] || {};
const graph = graphs[resourcePath] || null;
useEffect(() => {
@ -83,6 +84,8 @@ export function LinkResource(props: LinkResourceProps) {
hideNicknames={hideNicknames}
baseUrl={resourceUrl}
color={uxToHex(contact?.color || '0x0')}
group={group}
api={api}
/>
);
})}

View File

@ -5,6 +5,8 @@ import { Sigil } from '~/logic/lib/sigil';
import { Link } from 'react-router-dom';
import { cite } from '~/logic/lib/util';
import { roleForShip } from "~/logic/lib/group";
export const LinkItem = (props) => {
const {
node,
@ -13,7 +15,9 @@ export const LinkItem = (props) => {
avatar,
resource,
hideAvatars,
hideNicknames
hideNicknames,
api,
group
} = props;
const URLparser = new RegExp(
@ -35,6 +39,9 @@ export const LinkItem = (props) => {
const baseUrl = props.baseUrl || `/~404/${resource}`;
const ourRole = group ? roleForShip(group, window.ship) : undefined;
const [ship, name] = resource.split("/");
return (
<Row minWidth='0' flexShrink='0' width="100%" alignItems="center" py={3} bg="white">
{img}
@ -58,6 +65,7 @@ export const LinkItem = (props) => {
<Link to={`${baseUrl}/${index}`}>
<Text color="gray">{size} comments</Text>
</Link>
{(ourRole === "admin") && <Text color='red' ml='2' cursor='pointer' onClick={() => api.graph.removeNodes(`~${ship}`, name, [node.post.index])}>Delete</Text>}
</Box>
</Col>
</Row>