permalinks: hide permalink footer from the same resource

fixes urbit/landscape#759
This commit is contained in:
James Acklin 2021-05-03 17:01:56 -04:00
parent 884aa98832
commit 02e5bd0c5c

View File

@ -21,7 +21,7 @@ import GlobalApi from "~/logic/api/global";
import { getModuleIcon, useHovering } from "~/logic/lib/util";
import useMetadataState from "~/logic/state/metadata";
import { Association, resourceFromPath, GraphNode } from "@urbit/api";
import { Link } from "react-router-dom";
import { Link, useLocation } from "react-router-dom";
import useGraphState from "~/logic/state/graph";
import { GraphNodeContent } from "../notifications/graph";
import { TranscludedNode } from "./TranscludedNode";
@ -52,6 +52,7 @@ function GraphPermalink(
) {
const { full = false, showOurContact, pending, link, graph, group, index, api, transcluded } = props;
const history = useHistory();
const location = useLocation();
const { hovering, bind } = useHovering();
const { ship, name } = resourceFromPath(graph);
const node = useGraphState(
@ -89,6 +90,26 @@ function GraphPermalink(
history.push(`/perma${permalink.slice(16)}`);
};
const [nodeGroupHost, nodeGroupName] = association.group.split('/').slice(-2);
const [nodeChannelHost, nodeChannelName] = association.resource
.split('/')
.slice(-2);
const [
locChannelName,
locChannelHost,
,
,
,
locGroupName,
locGroupHost
] = location.pathname.split('/').reverse();
const isInSameResource =
locChannelHost === nodeChannelHost &&
locChannelName === nodeChannelName &&
locGroupName === nodeGroupName &&
locGroupHost === nodeGroupHost;
return (
<Col
width="100%"
@ -116,6 +137,7 @@ function GraphPermalink(
<PermalinkDetails
known
showTransclusion={showTransclusion}
showDetails={!isInSameResource}
icon={getModuleIcon(association.metadata.config.graph)}
title={association.metadata.title}
permalink={permalink}
@ -136,13 +158,15 @@ function PermalinkDetails(props: {
icon: any;
permalink: string;
showTransclusion?: boolean;
showDetails?: boolean;
known?: boolean;
}) {
const { title, icon, permalink, known, showTransclusion } = props;
const { title, icon, permalink, known, showTransclusion , showDetails } = props;
const rowTransclusionStyle = showTransclusion
? { p: '12px 12px 11px 11px' }
: { p: '12px' };
if (showDetails) {
return (
<Row
{...rowTransclusionStyle}
@ -162,6 +186,14 @@ function PermalinkDetails(props: {
</Row>
</Row>
);
} else {
return (
<Row
height='12px'
width="100%"
/>
);
}
}
export function PermalinkEmbed(props: {