mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 01:52:42 +03:00
links: use admin role for deletion check
This commit is contained in:
parent
380b7a2c92
commit
e1bbb25c6c
@ -48,6 +48,7 @@ export function LinkResource(props: LinkResourceProps) {
|
|||||||
? associations.graph[appPath]
|
? associations.graph[appPath]
|
||||||
: { metadata: {} };
|
: { metadata: {} };
|
||||||
const contactDetails = contacts[resource["group-path"]] || {};
|
const contactDetails = contacts[resource["group-path"]] || {};
|
||||||
|
const group = groups[resource["group-path"]] || {};
|
||||||
const graph = graphs[resourcePath] || null;
|
const graph = graphs[resourcePath] || null;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -83,6 +84,7 @@ export function LinkResource(props: LinkResourceProps) {
|
|||||||
hideNicknames={hideNicknames}
|
hideNicknames={hideNicknames}
|
||||||
baseUrl={resourceUrl}
|
baseUrl={resourceUrl}
|
||||||
color={uxToHex(contact?.color || '0x0')}
|
color={uxToHex(contact?.color || '0x0')}
|
||||||
|
group={group}
|
||||||
api={api}
|
api={api}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -5,6 +5,8 @@ import { Sigil } from '~/logic/lib/sigil';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { cite } from '~/logic/lib/util';
|
import { cite } from '~/logic/lib/util';
|
||||||
|
|
||||||
|
import { roleForShip } from "~/logic/lib/group";
|
||||||
|
|
||||||
export const LinkItem = (props) => {
|
export const LinkItem = (props) => {
|
||||||
const {
|
const {
|
||||||
node,
|
node,
|
||||||
@ -14,7 +16,8 @@ export const LinkItem = (props) => {
|
|||||||
resource,
|
resource,
|
||||||
hideAvatars,
|
hideAvatars,
|
||||||
hideNicknames,
|
hideNicknames,
|
||||||
api
|
api,
|
||||||
|
group
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const URLparser = new RegExp(
|
const URLparser = new RegExp(
|
||||||
@ -36,6 +39,7 @@ export const LinkItem = (props) => {
|
|||||||
|
|
||||||
const baseUrl = props.baseUrl || `/~404/${resource}`;
|
const baseUrl = props.baseUrl || `/~404/${resource}`;
|
||||||
|
|
||||||
|
const ourRole = group ? roleForShip(group, window.ship) : undefined;
|
||||||
const [ship, name] = resource.split("/");
|
const [ship, name] = resource.split("/");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -61,7 +65,7 @@ export const LinkItem = (props) => {
|
|||||||
<Link to={`${baseUrl}/${index}`}>
|
<Link to={`${baseUrl}/${index}`}>
|
||||||
<Text color="gray">{size} comments</Text>
|
<Text color="gray">{size} comments</Text>
|
||||||
</Link>
|
</Link>
|
||||||
{(author === window.ship) && <Text color='red' ml='2' cursor='pointer' onClick={() => api.graph.removeNodes(`~${ship}`, name, [node.post.index])}>Delete</Text>}
|
{(ourRole === "admin") && <Text color='red' ml='2' cursor='pointer' onClick={() => api.graph.removeNodes(`~${ship}`, name, [node.post.index])}>Delete</Text>}
|
||||||
</Box>
|
</Box>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
Loading…
Reference in New Issue
Block a user