mirror of
https://github.com/docmost/docmost.git
synced 2026-05-17 23:14:07 +08:00
refactor(backlinks): nest space details its own object
This commit is contained in:
@@ -71,9 +71,9 @@ export function BacklinksList({
|
|||||||
key={item.id}
|
key={item.id}
|
||||||
component={Link}
|
component={Link}
|
||||||
to={
|
to={
|
||||||
item.spaceSlug
|
item.space?.slug
|
||||||
? buildPageUrl(
|
? buildPageUrl(
|
||||||
item.spaceSlug,
|
item.space.slug,
|
||||||
item.slugId,
|
item.slugId,
|
||||||
item.title ?? undefined,
|
item.title ?? undefined,
|
||||||
)
|
)
|
||||||
@@ -88,9 +88,9 @@ export function BacklinksList({
|
|||||||
<Text size="sm" fw={500} lineClamp={1}>
|
<Text size="sm" fw={500} lineClamp={1}>
|
||||||
{item.title || t("Untitled")}
|
{item.title || t("Untitled")}
|
||||||
</Text>
|
</Text>
|
||||||
{item.spaceName && (
|
{item.space?.name && (
|
||||||
<Text size="xs" c="dimmed" lineClamp={1}>
|
<Text size="xs" c="dimmed" lineClamp={1}>
|
||||||
{item.spaceName}
|
{item.space.name}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ export interface IBacklinkPageItem {
|
|||||||
title: string | null;
|
title: string | null;
|
||||||
icon: string | null;
|
icon: string | null;
|
||||||
spaceId: string;
|
spaceId: string;
|
||||||
spaceSlug: string | null;
|
space: { id: string; slug: string; name: string } | null;
|
||||||
spaceName: string | null;
|
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
emptyCursorPaginationResult,
|
emptyCursorPaginationResult,
|
||||||
} from '@docmost/db/pagination/cursor-pagination';
|
} from '@docmost/db/pagination/cursor-pagination';
|
||||||
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
||||||
|
import { jsonObjectFrom } from 'kysely/helpers/postgres';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BacklinkRepo {
|
export class BacklinkRepo {
|
||||||
@@ -121,23 +122,25 @@ export class BacklinkRepo {
|
|||||||
icon: string | null;
|
icon: string | null;
|
||||||
spaceId: string;
|
spaceId: string;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
spaceSlug: string | null;
|
space: { id: string; slug: string; name: string } | null;
|
||||||
spaceName: string | null;
|
|
||||||
}>(pagination.limit);
|
}>(pagination.limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = this.db
|
const query = this.db
|
||||||
.selectFrom('pages')
|
.selectFrom('pages')
|
||||||
.leftJoin('spaces', 'spaces.id', 'pages.spaceId')
|
.select((eb) => [
|
||||||
.select([
|
|
||||||
'pages.id',
|
'pages.id',
|
||||||
'pages.slugId',
|
'pages.slugId',
|
||||||
'pages.title',
|
'pages.title',
|
||||||
'pages.icon',
|
'pages.icon',
|
||||||
'pages.spaceId',
|
'pages.spaceId',
|
||||||
'pages.updatedAt',
|
'pages.updatedAt',
|
||||||
'spaces.slug as spaceSlug',
|
jsonObjectFrom(
|
||||||
'spaces.name as spaceName',
|
eb
|
||||||
|
.selectFrom('spaces')
|
||||||
|
.select(['spaces.id', 'spaces.slug', 'spaces.name'])
|
||||||
|
.whereRef('spaces.id', '=', 'pages.spaceId'),
|
||||||
|
).as('space'),
|
||||||
])
|
])
|
||||||
.where('pages.deletedAt', 'is', null)
|
.where('pages.deletedAt', 'is', null)
|
||||||
.where('pages.id', 'in', pageIds);
|
.where('pages.id', 'in', pageIds);
|
||||||
|
|||||||
Reference in New Issue
Block a user