mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 18:12:47 +03:00
permalinks: hide permalink footer from the same resource
fixes urbit/landscape#759
This commit is contained in:
parent
884aa98832
commit
02e5bd0c5c
@ -21,7 +21,7 @@ import GlobalApi from "~/logic/api/global";
|
|||||||
import { getModuleIcon, useHovering } from "~/logic/lib/util";
|
import { getModuleIcon, useHovering } from "~/logic/lib/util";
|
||||||
import useMetadataState from "~/logic/state/metadata";
|
import useMetadataState from "~/logic/state/metadata";
|
||||||
import { Association, resourceFromPath, GraphNode } from "@urbit/api";
|
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 useGraphState from "~/logic/state/graph";
|
||||||
import { GraphNodeContent } from "../notifications/graph";
|
import { GraphNodeContent } from "../notifications/graph";
|
||||||
import { TranscludedNode } from "./TranscludedNode";
|
import { TranscludedNode } from "./TranscludedNode";
|
||||||
@ -52,6 +52,7 @@ function GraphPermalink(
|
|||||||
) {
|
) {
|
||||||
const { full = false, showOurContact, pending, link, graph, group, index, api, transcluded } = props;
|
const { full = false, showOurContact, pending, link, graph, group, index, api, transcluded } = props;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const location = useLocation();
|
||||||
const { hovering, bind } = useHovering();
|
const { hovering, bind } = useHovering();
|
||||||
const { ship, name } = resourceFromPath(graph);
|
const { ship, name } = resourceFromPath(graph);
|
||||||
const node = useGraphState(
|
const node = useGraphState(
|
||||||
@ -89,6 +90,26 @@ function GraphPermalink(
|
|||||||
history.push(`/perma${permalink.slice(16)}`);
|
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 (
|
return (
|
||||||
<Col
|
<Col
|
||||||
width="100%"
|
width="100%"
|
||||||
@ -116,6 +137,7 @@ function GraphPermalink(
|
|||||||
<PermalinkDetails
|
<PermalinkDetails
|
||||||
known
|
known
|
||||||
showTransclusion={showTransclusion}
|
showTransclusion={showTransclusion}
|
||||||
|
showDetails={!isInSameResource}
|
||||||
icon={getModuleIcon(association.metadata.config.graph)}
|
icon={getModuleIcon(association.metadata.config.graph)}
|
||||||
title={association.metadata.title}
|
title={association.metadata.title}
|
||||||
permalink={permalink}
|
permalink={permalink}
|
||||||
@ -136,13 +158,15 @@ function PermalinkDetails(props: {
|
|||||||
icon: any;
|
icon: any;
|
||||||
permalink: string;
|
permalink: string;
|
||||||
showTransclusion?: boolean;
|
showTransclusion?: boolean;
|
||||||
|
showDetails?: boolean;
|
||||||
known?: boolean;
|
known?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { title, icon, permalink, known, showTransclusion } = props;
|
const { title, icon, permalink, known, showTransclusion , showDetails } = props;
|
||||||
const rowTransclusionStyle = showTransclusion
|
const rowTransclusionStyle = showTransclusion
|
||||||
? { p: '12px 12px 11px 11px' }
|
? { p: '12px 12px 11px 11px' }
|
||||||
: { p: '12px' };
|
: { p: '12px' };
|
||||||
|
|
||||||
|
if (showDetails) {
|
||||||
return (
|
return (
|
||||||
<Row
|
<Row
|
||||||
{...rowTransclusionStyle}
|
{...rowTransclusionStyle}
|
||||||
@ -162,6 +186,14 @@ function PermalinkDetails(props: {
|
|||||||
</Row>
|
</Row>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Row
|
||||||
|
height='12px'
|
||||||
|
width="100%"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PermalinkEmbed(props: {
|
export function PermalinkEmbed(props: {
|
||||||
|
Loading…
Reference in New Issue
Block a user