Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display the homeserver next to federated spaces inside /explore #179

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pages/explore/DisplayFederatedHomeserverDomain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const FederatedSpan = ({ children }) => {
return <span className="ml-2 overflow-hidden text-ellipsis text-muted">{children}</span>;
};

export default FederatedSpan;
15 changes: 13 additions & 2 deletions pages/explore/TreePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
BreadcrumbList,
BreadcrumbSeparator,
} from '@/components/UI/shadcn/Breadcrumb';
import DisplayFederatedHomeserverDomain from './DisplayFederatedHomeserverDomain';

const TreePath = ({ selectedSpaceChildren }) => {
const TreePath = ({ selectedSpaceChildren, federated }) => {
return (
<>
<Breadcrumb className="overflow-hidden">
Expand All @@ -36,7 +37,14 @@ const TreePath = ({ selectedSpaceChildren }) => {
asChild
className="grid w-full grid-flow-col justify-start gap-2"
>
<Link href={`/explore/${roomId}`}>{path[0].name}</Link>
<Link href={`/explore/${roomId}`}>
{path[0].name}
{federated && (
<DisplayFederatedHomeserverDomain>
{federated}
</DisplayFederatedHomeserverDomain>
)}
</Link>
</DropdownMenuItem>
);
}
Expand All @@ -59,6 +67,9 @@ const TreePath = ({ selectedSpaceChildren }) => {
<BreadcrumbLink asChild>
<Link disabled href={`/explore/${roomId}`}>
{path[0].name}
{federated && (
<DisplayFederatedHomeserverDomain>{federated}</DisplayFederatedHomeserverDomain>
)}
</Link>
</BreadcrumbLink>
</BreadcrumbItem>
Expand Down
35 changes: 28 additions & 7 deletions pages/explore/[[...roomId]].js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { Progress } from '@/components/UI/shadcn/Progress';
import ExploreMatrixActions from './manage-room/ExploreMatrixActions';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/UI/shadcn/Tabs';
import { useMediaQuery } from '@/lib/utils';
import DisplayFederatedHomeserverDomain from './DisplayFederatedHomeserverDomain';

/**
* Explore component for managing room hierarchies and content.
Expand Down Expand Up @@ -150,6 +151,12 @@ export default function Explore() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [router.query?.roomId, matrix.initialSyncDone, cachedSpace]);

const extractHomeserverFromRoomId = (roomId) => {
const parts = roomId.split(':');

return parts[1];
};

const removeChildFromParent = async (idToRemove) => {
if (idToRemove === roomId) {
toast.error('You cannot remove the parent room from itself');
Expand Down Expand Up @@ -241,11 +248,18 @@ export default function Explore() {
{
accessorKey: 'name',
header: 'Name',
cell: ({ row }) => (
<Link target={row.target} href={row.href} rel="noopener noreferrer" className="flex items-center justify-between">
{row.getValue('name')}
</Link>
),
cell: ({ row }) => {
const homeserver = extractHomeserverFromRoomId(row.roomId);

return (
<Link target={row.target} href={row.href} rel="noopener noreferrer" className="flex items-center justify-between">
{row.getValue('name')}
{homeserver !== matrixClient.getDomain() && (
<DisplayFederatedHomeserverDomain>{homeserver}</DisplayFederatedHomeserverDomain>
)}
</Link>
);
},
},
{
id: 'actions',
Expand Down Expand Up @@ -331,7 +345,14 @@ export default function Explore() {
content={window.location.href}
title={
!_.isEmpty(selectedSpaceChildren) && (
<TreePath selectedSpaceChildren={selectedSpaceChildren} iframeRoomId={iframeRoomId} />
<TreePath
selectedSpaceChildren={selectedSpaceChildren}
iframeRoomId={iframeRoomId}
federated={
extractHomeserverFromRoomId(roomId) !== matrixClient.getDomain() &&
extractHomeserverFromRoomId(roomId)
}
/>
)
}
roomName={selectedSpaceChildren[selectedSpaceChildren.length - 1][0].name}
Expand All @@ -341,7 +362,7 @@ export default function Explore() {
myPowerLevel={myPowerLevel}
setActiveContentView={setActiveContentView}
joinRule={selectedSpaceChildren[selectedSpaceChildren.length - 1][0].join_rule}
service="/explore"
service="/explore"
/>

<Tabs
Expand Down