({
mutationFn: (data) => updateShare(data),
onSuccess: (data) => {
- queryClient.refetchQueries({
+ queryClient.invalidateQueries({
predicate: (item) =>
- ["share-for-page"].includes(item.queryKey[0] as string),
+ ["share-for-page", "share-list"].includes(item.queryKey[0] as string),
+ });
+ },
+ onError: (error, params) => {
+ if (error?.["status"] === 404) {
+ queryClient.removeQueries({
+ predicate: (item) =>
+ ["share-for-page"].includes(item.queryKey[0] as string),
+ });
+ }
+
+ notifications.show({
+ message: error?.["response"]?.data?.message || "Share share not found",
+ color: "red",
});
},
});
@@ -87,14 +111,33 @@ export function useUpdateShareMutation() {
export function useDeleteShareMutation() {
const { t } = useTranslation();
+ const queryClient = useQueryClient();
+
return useMutation({
mutationFn: (shareId: string) => deleteShare(shareId),
- onSuccess: () => {
+ onSuccess: (data) => {
+ queryClient.removeQueries({
+ predicate: (item) =>
+ ["share-for-page"].includes(item.queryKey[0] as string),
+ });
+
+ queryClient.invalidateQueries({
+ predicate: (item) =>
+ ["share-list"].includes(item.queryKey[0] as string),
+ });
+
notifications.show({ message: t("Share deleted successfully") });
},
onError: (error) => {
+ if (error?.["status"] === 404) {
+ queryClient.removeQueries({
+ predicate: (item) =>
+ ["share-for-page"].includes(item.queryKey[0] as string),
+ });
+ }
+
notifications.show({
- message: t("Failed to delete share"),
+ message: error?.["response"]?.data?.message || "Failed to delete share",
color: "red",
});
},
diff --git a/apps/client/src/features/share/types/share.types.ts b/apps/client/src/features/share/types/share.types.ts
index 2228bf9d..8163fa06 100644
--- a/apps/client/src/features/share/types/share.types.ts
+++ b/apps/client/src/features/share/types/share.types.ts
@@ -25,6 +25,7 @@ export interface ISharedItem extends IShare {
id: string;
name: string;
slug: string;
+ userRole: string;
};
creator: {
id: string;
@@ -37,21 +38,17 @@ export interface ISharedPage extends IShare {
page: IPage;
share: IShare & {
level: number;
- sharedPage: { id: string; slugId: string; title: string };
+ sharedPage: { id: string; slugId: string; title: string; icon: string };
};
}
export interface IShareForPage extends IShare {
level: number;
- page: {
- id: string;
- title: string;
- slugId: string;
- };
sharedPage: {
id: string;
slugId: string;
title: string;
+ icon: string;
};
}
diff --git a/apps/client/src/pages/settings/shares/shares.tsx b/apps/client/src/pages/settings/shares/shares.tsx
index f071737a..1a5a118e 100644
--- a/apps/client/src/pages/settings/shares/shares.tsx
+++ b/apps/client/src/pages/settings/shares/shares.tsx
@@ -3,6 +3,9 @@ import { Helmet } from "react-helmet-async";
import { getAppName } from "@/lib/config.ts";
import { useTranslation } from "react-i18next";
import ShareList from "@/features/share/components/share-list.tsx";
+import { Alert, Text } from "@mantine/core";
+import { IconInfoCircle } from "@tabler/icons-react";
+import React from "react";
export default function Shares() {
const { t } = useTranslation();
@@ -11,10 +14,17 @@ export default function Shares() {
<>
- {t("Shares")} - {getAppName()}
+ {t("Public sharing")} - {getAppName()}
-
+
+
+ }>
+ {t(
+ "Publicly shared pages from spaces you are a member of will appear here",
+ )}
+
+
>
);
diff --git a/apps/client/src/pages/share/shared-page.tsx b/apps/client/src/pages/share/shared-page.tsx
index 0741b221..76f80819 100644
--- a/apps/client/src/pages/share/shared-page.tsx
+++ b/apps/client/src/pages/share/shared-page.tsx
@@ -22,7 +22,7 @@ export default function SingleSharedPage() {
if (shareId && data) {
if (data.share.key !== shareId) {
// affects parent share, what to do?
- //navigate(`/share/${data.share.key}/${pageSlug}`);
+ navigate(`/share/${data.share.key}/${pageSlug}`);
}
}
}, [shareId, data]);
@@ -41,7 +41,8 @@ export default function SingleSharedPage() {
return (
- {`${data?.page?.icon || ""} ${data?.page?.title || t("untitled")}`}
+ {`${data?.page?.title || t("untitled")}`}
+ {!data?.share.searchIndexing && }
diff --git a/apps/server/src/core/share/share.service.ts b/apps/server/src/core/share/share.service.ts
index 854c5e59..c8d9adac 100644
--- a/apps/server/src/core/share/share.service.ts
+++ b/apps/server/src/core/share/share.service.ts
@@ -69,7 +69,7 @@ export class ShareService {
key: generateSlugId(),
pageId: page.id,
includeSubPages: createShareDto.includeSubPages,
- searchIndexing: true,
+ searchIndexing: createShareDto.searchIndexing,
creatorId: authUserId,
spaceId: page.spaceId,
workspaceId,
@@ -126,6 +126,7 @@ export class ShareService {
'id',
'slugId',
'pages.title',
+ 'pages.icon',
'parentPageId',
sql`0`.as('level'),
])
@@ -137,6 +138,7 @@ export class ShareService {
'p.id',
'p.slugId',
'p.title',
+ 'p.icon',
'p.parentPageId',
// Increase the level by 1 for each ancestor.
sql`ph.level + 1`.as('level'),
@@ -150,11 +152,13 @@ export class ShareService {
'page_hierarchy.id as sharedPageId',
'page_hierarchy.slugId as sharedPageSlugId',
'page_hierarchy.title as sharedPageTitle',
+ 'page_hierarchy.icon as sharedPageIcon',
'page_hierarchy.level as level',
'shares.id',
'shares.key',
'shares.pageId',
'shares.includeSubPages',
+ 'shares.searchIndexing',
'shares.creatorId',
'shares.spaceId',
'shares.workspaceId',
@@ -166,18 +170,19 @@ export class ShareService {
.executeTakeFirst();
if (!share || share.workspaceId != workspaceId) {
- throw new NotFoundException('Shared page not found');
+ return undefined;
}
if (share.level === 1 && !share.includeSubPages) {
// we can only show a page if its shared ancestor permits it
- throw new NotFoundException('Shared page not found');
+ return undefined;
}
return {
id: share.id,
key: share.key,
includeSubPages: share.includeSubPages,
+ searchIndexing: share.searchIndexing,
pageId: share.pageId,
creatorId: share.creatorId,
spaceId: share.spaceId,
@@ -188,6 +193,7 @@ export class ShareService {
id: share.sharedPageId,
slugId: share.sharedPageSlugId,
title: share.sharedPageTitle,
+ icon: share.sharedPageIcon,
},
};
}