mirror of
https://github.com/docmost/docmost.git
synced 2026-08-21 11:31:05 +08:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
739da05d07 | ||
|
|
4a412899e8 | ||
|
|
fd81cd281f | ||
|
|
e204184ad8 | ||
|
|
19e2e8ba1c | ||
|
|
79bf2c3cd7 | ||
|
|
76ca723d90 | ||
|
|
734f59967e |
@@ -50,9 +50,9 @@
|
||||
"katex": "0.16.40",
|
||||
"lowlight": "3.3.0",
|
||||
"mantine-form-zod-resolver": "1.3.0",
|
||||
"mermaid": "11.16.1",
|
||||
"mermaid": "11.15.0",
|
||||
"mitt": "3.0.1",
|
||||
"nanoid": "3.3.17",
|
||||
"nanoid": "3.3.8",
|
||||
"posthog-js": "1.391.2",
|
||||
"react": "19.2.7",
|
||||
"react-clear-modal": "^2.0.18",
|
||||
|
||||
@@ -508,11 +508,6 @@
|
||||
"Allow viewers to comment": "Allow viewers to comment",
|
||||
"Allow viewers to add comments on pages in this space.": "Allow viewers to add comments on pages in this space.",
|
||||
"Toggle viewer comments": "Toggle viewer comments",
|
||||
"Hide comments from viewers": "Hide comments from viewers",
|
||||
"Viewers cannot see or add comments on pages in this space.": "Viewers cannot see or add comments on pages in this space.",
|
||||
"Toggle hide comments from viewers": "Toggle hide comments from viewers",
|
||||
"Turn off 'Allow viewers to comment' first": "Turn off 'Allow viewers to comment' first",
|
||||
"Turn off 'Hide comments from viewers' first": "Turn off 'Hide comments from viewers' first",
|
||||
"Public sharing is disabled at the workspace level": "Public sharing is disabled at the workspace level",
|
||||
"Prevent pages in this space from being shared publicly.": "Prevent pages in this space from being shared publicly.",
|
||||
"Page permissions": "Page permissions",
|
||||
|
||||
@@ -40,6 +40,7 @@ import WorkspaceApiKeys from "@/ee/api-key/pages/workspace-api-keys";
|
||||
import AiSettings from "@/ee/ai/pages/ai-settings.tsx";
|
||||
import BasePage from "@/ee/base/pages/base-page.tsx";
|
||||
import AuditLogs from "@/ee/audit/pages/audit-logs.tsx";
|
||||
import PageAnalytics from "@/ee/page-analytics/pages/page-analytics.tsx";
|
||||
import VerifiedPages from "@/ee/page-verification/pages/verified-pages.tsx";
|
||||
import TemplateList from "@/ee/template/pages/template-list";
|
||||
import TemplateEditor from "@/ee/template/pages/template-editor";
|
||||
@@ -127,6 +128,7 @@ export default function App() {
|
||||
<Route path={"ai"} element={<AiSettings />} />
|
||||
<Route path={"ai/mcp"} element={<AiSettings />} />
|
||||
<Route path={"audit"} element={<AuditLogs />} />
|
||||
<Route path={"analytics"} element={<PageAnalytics />} />
|
||||
<Route path={"verifications"} element={<VerifiedPages />} />
|
||||
{!isCloud() && <Route path={"license"} element={<License />} />}
|
||||
{isCloud() && <Route path={"billing"} element={<Billing />} />}
|
||||
|
||||
@@ -11,13 +11,11 @@ import { pageEditorAtom } from "@/features/editor/atoms/editor-atoms.ts";
|
||||
import AsideChatPanel from "@/ee/ai-chat/components/aside-chat-panel";
|
||||
import { PageDetailsAside } from "@/features/page-details/components/page-details-aside.tsx";
|
||||
import { ASIDE_PANEL_ID } from "@/hooks/use-toggle-aside.tsx";
|
||||
import { useCanViewComments } from "@/features/comment/hooks/use-can-view-comments.ts";
|
||||
|
||||
export default function Aside() {
|
||||
const [{ tab, isAsideOpen }, setAsideState] = useAtom(asideStateAtom);
|
||||
const { t } = useTranslation();
|
||||
const pageEditor = useAtomValue(pageEditorAtom);
|
||||
const canViewComments = useCanViewComments();
|
||||
const closeAside = () => setAsideState((s) => ({ ...s, isAsideOpen: false }));
|
||||
|
||||
useEffect(() => {
|
||||
@@ -25,18 +23,12 @@ export default function Aside() {
|
||||
document.getElementById(ASIDE_PANEL_ID)?.focus();
|
||||
}, [isAsideOpen, tab]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isAsideOpen && tab === "comments" && !canViewComments) {
|
||||
setAsideState({ tab: "", isAsideOpen: false });
|
||||
}
|
||||
}, [isAsideOpen, tab, canViewComments, setAsideState]);
|
||||
|
||||
let title: string;
|
||||
let component: ReactNode;
|
||||
|
||||
switch (tab) {
|
||||
case "comments":
|
||||
component = canViewComments ? <CommentListWithTabs /> : null;
|
||||
component = <CommentListWithTabs />;
|
||||
title = "Comments";
|
||||
break;
|
||||
case "toc":
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
} from "@/ee/billing/services/billing-service.ts";
|
||||
import { getSpaces } from "@/features/space/services/space-service.ts";
|
||||
import { getGroups } from "@/features/group/services/group-service.ts";
|
||||
import { QueryParams } from "@/lib/types.ts";
|
||||
import type { QueryParams } from "@/lib/types.ts";
|
||||
import { getWorkspaceMembers } from "@/features/workspace/services/workspace-service.ts";
|
||||
import { getLicenseInfo } from "@/ee/licence/services/license-service.ts";
|
||||
import { getSsoProviders } from "@/ee/security/services/security-service.ts";
|
||||
@@ -14,6 +14,11 @@ import { getApiKeys } from "@/ee/api-key";
|
||||
import { getAuditLogs } from "@/ee/audit/services/audit-service";
|
||||
import { getVerificationList } from "@/ee/page-verification/services/page-verification-service";
|
||||
import { getScimTokens } from "@/ee/scim/services/scim-token-service";
|
||||
import {
|
||||
getWorkspacePageAnalyticsDailyStats,
|
||||
getWorkspacePageAnalyticsTopPages,
|
||||
getWorkspacePageAnalyticsTotals,
|
||||
} from "@/ee/page-analytics/services/page-analytics-service";
|
||||
|
||||
export const prefetchWorkspaceMembers = () => {
|
||||
const params: QueryParams = { limit: 100, query: "" };
|
||||
@@ -100,6 +105,31 @@ export const prefetchVerifiedPages = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const prefetchPageAnalytics = () => {
|
||||
const dateRange = {
|
||||
startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)
|
||||
.toISOString()
|
||||
.slice(0, 10),
|
||||
endDate: new Date().toISOString().slice(0, 10),
|
||||
};
|
||||
const listParams = { ...dateRange, cursor: undefined, limit: 10 };
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ["workspace-page-analytics-totals", dateRange],
|
||||
queryFn: () => getWorkspacePageAnalyticsTotals(dateRange),
|
||||
});
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ["workspace-page-analytics-top-pages", listParams],
|
||||
queryFn: () => getWorkspacePageAnalyticsTopPages(listParams),
|
||||
});
|
||||
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ["workspace-page-analytics-daily-stats", listParams],
|
||||
queryFn: () => getWorkspacePageAnalyticsDailyStats(listParams),
|
||||
});
|
||||
};
|
||||
|
||||
export const prefetchScimTokens = () => {
|
||||
queryClient.prefetchQuery({
|
||||
queryKey: ["scim-token-list", { cursor: undefined }],
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
IconSparkles,
|
||||
IconHistory,
|
||||
IconShieldCheck,
|
||||
IconChartBar,
|
||||
} from "@tabler/icons-react";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
import classes from "./settings.module.css";
|
||||
@@ -38,6 +39,7 @@ import {
|
||||
prefetchWorkspaceMembers,
|
||||
prefetchAuditLogs,
|
||||
prefetchVerifiedPages,
|
||||
prefetchPageAnalytics,
|
||||
} from "@/components/settings/settings-queries.tsx";
|
||||
import AppVersion from "@/components/settings/app-version.tsx";
|
||||
import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
||||
@@ -125,6 +127,13 @@ const groupedData: DataGroup[] = [
|
||||
role: "owner",
|
||||
env: "selfhosted",
|
||||
},
|
||||
{
|
||||
label: "Page analytics",
|
||||
icon: IconChartBar,
|
||||
path: "/settings/analytics",
|
||||
feature: Feature.PAGE_ANALYTICS,
|
||||
role: "owner",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -225,6 +234,9 @@ export default function SettingsSidebar() {
|
||||
case "Verified pages":
|
||||
prefetchHandler = prefetchVerifiedPages;
|
||||
break;
|
||||
case "Page analytics":
|
||||
prefetchHandler = prefetchPageAnalytics;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import { describe, expect, it, beforeEach } from "vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { HelmetProvider } from "react-helmet-async";
|
||||
import { DocumentTitle } from "./document-title.tsx";
|
||||
|
||||
const renderTitle = (ui: React.ReactNode) =>
|
||||
render(<HelmetProvider>{ui}</HelmetProvider>);
|
||||
|
||||
describe("DocumentTitle", () => {
|
||||
beforeEach(() => {
|
||||
document.head.innerHTML = "<title>Docmost</title>";
|
||||
});
|
||||
|
||||
it("appends the app name", () => {
|
||||
renderTitle(<DocumentTitle title="Home" />);
|
||||
expect(document.title).toBe("Home - Docmost");
|
||||
});
|
||||
|
||||
it("omits the app name when asked", () => {
|
||||
renderTitle(<DocumentTitle title="My page" withAppName={false} />);
|
||||
expect(document.title).toBe("My page");
|
||||
});
|
||||
|
||||
it("falls back to the app name without a title", () => {
|
||||
renderTitle(<DocumentTitle />);
|
||||
expect(document.title).toBe("Docmost");
|
||||
});
|
||||
|
||||
it("never renders an empty title", () => {
|
||||
renderTitle(<DocumentTitle title="Spaces" />);
|
||||
const titles = Array.from(document.querySelectorAll("head > title"));
|
||||
expect(titles.every((node) => node.textContent !== "")).toBe(true);
|
||||
});
|
||||
|
||||
it("renders extra head children", () => {
|
||||
renderTitle(
|
||||
<DocumentTitle title="Shared">
|
||||
<meta name="robots" content="noindex" />
|
||||
</DocumentTitle>,
|
||||
);
|
||||
expect(
|
||||
document.querySelector('head > meta[name="robots"]')?.getAttribute("content"),
|
||||
).toBe("noindex");
|
||||
});
|
||||
});
|
||||
@@ -1,29 +0,0 @@
|
||||
import React from "react";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
|
||||
type DocumentTitleProps = {
|
||||
title?: string;
|
||||
withAppName?: boolean;
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
|
||||
export function DocumentTitle({
|
||||
title,
|
||||
withAppName = true,
|
||||
children,
|
||||
}: DocumentTitleProps) {
|
||||
const appName = getAppName();
|
||||
|
||||
let documentTitle = appName;
|
||||
if (title) {
|
||||
documentTitle = withAppName ? `${title} - ${appName}` : title;
|
||||
}
|
||||
|
||||
return (
|
||||
<Helmet>
|
||||
<title>{documentTitle}</title>
|
||||
{children}
|
||||
</Helmet>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
import { Title, Text, Button, Container, Group } from "@mantine/core";
|
||||
import classes from "./error-404.module.css";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export function Error404() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("404 page not found")} />
|
||||
<Helmet>
|
||||
<title>{t("404 page not found")} - Docmost</title>
|
||||
</Helmet>
|
||||
<Container className={classes.root}>
|
||||
<Title className={classes.title}>{t("404 page not found")}</Title>
|
||||
<Text c="dimmed" size="lg" ta="center" className={classes.description}>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import React from "react";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
@@ -13,7 +15,6 @@ import { Feature } from "@/ee/features";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function AiSettings() {
|
||||
const { t } = useTranslation();
|
||||
@@ -39,7 +40,9 @@ export default function AiSettings() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title="AI settings" />
|
||||
<Helmet>
|
||||
<title>AI settings - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("AI settings")} />
|
||||
|
||||
<Tabs color="dark" value={activeTab} onChange={handleTabChange}>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React, { useState } from "react";
|
||||
import { Anchor, Alert, Button, Group, Space, Text } from "@mantine/core";
|
||||
import { IconInfoCircle } from "@tabler/icons-react";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import SettingsTitle from "@/components/settings/settings-title";
|
||||
import { getAppUrl } from "@/lib/config";
|
||||
import { getAppName, getAppUrl } from "@/lib/config";
|
||||
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
||||
import { CreateApiKeyModal } from "@/ee/api-key/components/create-api-key-modal";
|
||||
import { ApiKeyCreatedModal } from "@/ee/api-key/components/api-key-created-modal";
|
||||
@@ -16,7 +17,6 @@ import { IApiKey } from "@/ee/api-key";
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function UserApiKeys() {
|
||||
const { t } = useTranslation();
|
||||
@@ -49,7 +49,11 @@ export default function UserApiKeys() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("API keys")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("API keys")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<SettingsTitle title={t("API keys")} />
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import React, { useState } from "react";
|
||||
import { Anchor, Button, Divider, Group, Space, Text } from "@mantine/core";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { Trans, useTranslation } from "react-i18next";
|
||||
import SettingsTitle from "@/components/settings/settings-title";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import { ApiKeyTable } from "@/ee/api-key/components/api-key-table";
|
||||
import { CreateApiKeyModal } from "@/ee/api-key/components/create-api-key-modal";
|
||||
import { ApiKeyCreatedModal } from "@/ee/api-key/components/api-key-created-modal";
|
||||
@@ -13,7 +15,6 @@ import { useGetApiKeysQuery } from "@/ee/api-key/queries/api-key-query.ts";
|
||||
import { IApiKey } from "@/ee/api-key";
|
||||
import useUserRole from '@/hooks/use-user-role.tsx';
|
||||
import RestrictApiToAdmins from "@/ee/api-key/components/restrict-api-to-admins";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function WorkspaceApiKeys() {
|
||||
const { t } = useTranslation();
|
||||
@@ -46,7 +47,11 @@ export default function WorkspaceApiKeys() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("API management")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("API management")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<SettingsTitle title={t("API management")} />
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@ import {
|
||||
Text,
|
||||
Tooltip,
|
||||
} from "@mantine/core";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { IconSettings } from "@tabler/icons-react";
|
||||
import SettingsTitle from "@/components/settings/settings-title";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import Paginate from "@/components/common/paginate";
|
||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||
import {
|
||||
@@ -24,25 +26,8 @@ import { IAuditLogParams } from "@/ee/audit/types/audit.types";
|
||||
import { eventFilterOptions } from "@/ee/audit/lib/audit-event-labels";
|
||||
import AuditLogsTable from "@/ee/audit/components/audit-logs-table";
|
||||
import useUserRole from "@/hooks/use-user-role";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
import { daysToRetention, retentionToDays, RetentionUnit } from "@/ee/utils";
|
||||
|
||||
type RetentionUnit = "days" | "months" | "years";
|
||||
|
||||
function daysToRetention(days: number): { amount: number; unit: RetentionUnit } {
|
||||
if (days >= 365 && days % 365 === 0) {
|
||||
return { amount: days / 365, unit: "years" };
|
||||
}
|
||||
if (days >= 30 && days % 30 === 0) {
|
||||
return { amount: days / 30, unit: "months" };
|
||||
}
|
||||
return { amount: days, unit: "days" };
|
||||
}
|
||||
|
||||
function retentionToDays(amount: number, unit: RetentionUnit): number {
|
||||
if (unit === "years") return amount * 365;
|
||||
if (unit === "months") return amount * 30;
|
||||
return amount;
|
||||
}
|
||||
|
||||
export default function AuditLogs() {
|
||||
const { t } = useTranslation();
|
||||
@@ -96,7 +81,11 @@ export default function AuditLogs() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Audit log")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Audit log")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<SettingsTitle title={t("Audit log")} />
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import BillingPlans from "@/ee/billing/components/billing-plans.tsx";
|
||||
import BillingTrial from "@/ee/billing/components/billing-trial.tsx";
|
||||
@@ -7,7 +9,6 @@ import React from "react";
|
||||
import BillingDetails from "@/ee/billing/components/billing-details.tsx";
|
||||
import { useBillingQuery } from "@/ee/billing/queries/billing-query.ts";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function Billing() {
|
||||
const { data: billing, isError: isBillingError } = useBillingQuery();
|
||||
@@ -19,7 +20,9 @@ export default function Billing() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title="Billing" />
|
||||
<Helmet>
|
||||
<title>Billing - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title="Billing" />
|
||||
|
||||
<BillingTrial />
|
||||
|
||||
@@ -15,11 +15,11 @@ export const Feature = {
|
||||
SCIM: 'scim',
|
||||
PAGE_VERIFICATION: 'page:verification',
|
||||
AUDIT_LOGS: 'audit:logs',
|
||||
PAGE_ANALYTICS: 'analytics:page-analytics',
|
||||
RETENTION: 'retention',
|
||||
SHARING_CONTROLS: 'sharing:controls',
|
||||
TEMPLATES: 'templates',
|
||||
VIEWER_COMMENTS: 'comment:viewer',
|
||||
HIDE_COMMENTS: 'comment:hide',
|
||||
PERSONAL_SPACES: 'spaces:personal',
|
||||
DOCX_EXPORT: 'export:docx',
|
||||
BASES: 'bases',
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import React from "react";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
@@ -7,7 +9,6 @@ import InstallationDetails from "@/ee/licence/components/installation-details.ts
|
||||
import OssDetails from "@/ee/licence/components/oss-details.tsx";
|
||||
import { useAtom } from "jotai/index";
|
||||
import { entitlementAtom } from "@/ee/entitlement/entitlement-atom";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function License() {
|
||||
const [entitlements] = useAtom(entitlementAtom);
|
||||
@@ -20,7 +21,9 @@ export default function License() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title="License" />
|
||||
<Helmet>
|
||||
<title>License - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title="License" />
|
||||
|
||||
<ActivateLicenseForm />
|
||||
|
||||
@@ -0,0 +1,421 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import {
|
||||
ActionIcon,
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
Group,
|
||||
NumberInput,
|
||||
Popover,
|
||||
Select,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Tooltip,
|
||||
} from "@mantine/core";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import SettingsTitle from "@/components/settings/settings-title";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import Paginate from "@/components/common/paginate";
|
||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||
import {
|
||||
usePageAnalyticsRetentionQuery,
|
||||
useUpdatePageAnalyticsRetentionMutation,
|
||||
useWorkspacePageAnalyticsDailyStatsQuery,
|
||||
useWorkspacePageAnalyticsTopPagesQuery,
|
||||
useWorkspacePageAnalyticsTotalsQuery,
|
||||
} from "@/ee/page-analytics/queries/page-analytics-query";
|
||||
import { Link } from "react-router-dom";
|
||||
import { formatLocalized, useDateFnsLocale } from "@/lib/date-locale";
|
||||
import { IconSettings } from "@tabler/icons-react";
|
||||
import {
|
||||
daysToRetention,
|
||||
formatNumber,
|
||||
retentionToDays,
|
||||
RetentionUnit,
|
||||
toISODate,
|
||||
} from "@/ee/utils";
|
||||
|
||||
type RangePreset = "7" | "30" | "90";
|
||||
|
||||
const DAILY_PAGE_SIZE = 10;
|
||||
|
||||
export default function PageAnalytics() {
|
||||
const { t } = useTranslation();
|
||||
const locale = useDateFnsLocale();
|
||||
const [rangePreset, setRangePreset] = useState<RangePreset>("30");
|
||||
const [topPagesLimit, setTopPagesLimit] = useState("10");
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
|
||||
const { data: retentionData } = usePageAnalyticsRetentionQuery();
|
||||
const updateRetention = useUpdatePageAnalyticsRetentionMutation();
|
||||
|
||||
const parsed = useMemo(
|
||||
() => daysToRetention(retentionData?.retentionDays ?? 365),
|
||||
[retentionData]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (settingsOpen) return;
|
||||
|
||||
setRetentionAmount(parsed.amount);
|
||||
setRetentionUnit(parsed.unit);
|
||||
}, [parsed]);
|
||||
|
||||
const [retentionAmount, setRetentionAmount] = useState<number | string>(
|
||||
parsed.amount
|
||||
);
|
||||
const [retentionUnit, setRetentionUnit] = useState<RetentionUnit>(parsed.unit);
|
||||
|
||||
const resetRetentionForm = useCallback(() => {
|
||||
const { amount, unit } = daysToRetention(retentionData?.retentionDays ?? 365);
|
||||
setRetentionAmount(amount);
|
||||
setRetentionUnit(unit);
|
||||
}, [setRetentionAmount, setRetentionUnit, retentionData]);
|
||||
|
||||
const {
|
||||
cursor: topPagesCursor,
|
||||
goNext: goNextTopPages,
|
||||
goPrev: goPrevTopPages,
|
||||
resetCursor: resetTopPagesCursor,
|
||||
} = useCursorPaginate();
|
||||
|
||||
const {
|
||||
cursor: dailyCursor,
|
||||
goNext: goNextDaily,
|
||||
goPrev: goPrevDaily,
|
||||
resetCursor: resetDailyCursor,
|
||||
} = useCursorPaginate();
|
||||
|
||||
const dateRange = useMemo(
|
||||
() => ({
|
||||
startDate: toISODate(rangePreset),
|
||||
endDate: new Date().toISOString().slice(0, 10),
|
||||
}),
|
||||
[rangePreset]
|
||||
);
|
||||
|
||||
const topPagesParams = useMemo(
|
||||
() => ({
|
||||
...dateRange,
|
||||
cursor: topPagesCursor,
|
||||
limit: Number(topPagesLimit),
|
||||
}),
|
||||
[dateRange, topPagesCursor, topPagesLimit]
|
||||
);
|
||||
|
||||
const formatDate = useCallback(
|
||||
(value?: Date | string | null) => {
|
||||
if (!value) return "-";
|
||||
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return "-";
|
||||
|
||||
return formatLocalized(date, "MMM dd, yyyy", "PP", locale);
|
||||
},
|
||||
[locale]
|
||||
);
|
||||
|
||||
const dailyParams = useMemo(
|
||||
() => ({
|
||||
...dateRange,
|
||||
cursor: dailyCursor,
|
||||
limit: DAILY_PAGE_SIZE,
|
||||
}),
|
||||
[dateRange, dailyCursor]
|
||||
);
|
||||
|
||||
const { data: totalsData } = useWorkspacePageAnalyticsTotalsQuery(dateRange);
|
||||
const { data: topPagesData, isLoading: isTopPagesLoading } =
|
||||
useWorkspacePageAnalyticsTopPagesQuery(topPagesParams);
|
||||
const { data: dailyData, isLoading: isDailyLoading } =
|
||||
useWorkspacePageAnalyticsDailyStatsQuery(dailyParams);
|
||||
|
||||
const handleRangeChange = (value: RangePreset) => {
|
||||
if (value) {
|
||||
setRangePreset(value);
|
||||
resetTopPagesCursor();
|
||||
resetDailyCursor();
|
||||
}
|
||||
};
|
||||
|
||||
const handleTopPagesLimitChange = (value: string | null) => {
|
||||
if (value) {
|
||||
setTopPagesLimit(value);
|
||||
resetTopPagesCursor();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Page analytics")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<SettingsTitle title={t("Page analytics")} />
|
||||
|
||||
<Group justify="space-between" mb="md">
|
||||
<Select
|
||||
value={rangePreset}
|
||||
onChange={handleRangeChange}
|
||||
data={[
|
||||
{ value: "7", label: t("Last 7 days") },
|
||||
{ value: "30", label: t("Last 30 days") },
|
||||
{ value: "90", label: t("Last 90 days") },
|
||||
]}
|
||||
w={160}
|
||||
size="sm"
|
||||
allowDeselect={false}
|
||||
/>
|
||||
<Popover
|
||||
position="bottom-end"
|
||||
shadow="md"
|
||||
width={260}
|
||||
withArrow
|
||||
opened={settingsOpen}
|
||||
onChange={(opened) => {
|
||||
if (!opened) resetRetentionForm();
|
||||
setSettingsOpen(opened);
|
||||
}}
|
||||
>
|
||||
<Popover.Target>
|
||||
<Tooltip label={t("Audit settings")}>
|
||||
<ActionIcon
|
||||
variant="default"
|
||||
size="input-sm"
|
||||
ml="auto"
|
||||
onClick={() => setSettingsOpen((o) => !o)}
|
||||
>
|
||||
<IconSettings size={16} />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
</Popover.Target>
|
||||
<Popover.Dropdown>
|
||||
<Text fz="sm" fw={500} mb={4}>
|
||||
{t("Retention")}
|
||||
</Text>
|
||||
<Text fz="xs" c="dimmed" mb="sm">
|
||||
{t("Logs older than this period are automatically deleted.")}
|
||||
</Text>
|
||||
<Group gap="xs" wrap="nowrap" mb="sm">
|
||||
<NumberInput
|
||||
value={retentionAmount}
|
||||
onChange={(val) => setRetentionAmount(val)}
|
||||
min={1}
|
||||
hideControls
|
||||
size="sm"
|
||||
w={60}
|
||||
/>
|
||||
<Select
|
||||
data={[
|
||||
{ value: "days", label: t("days") },
|
||||
{ value: "months", label: t("months") },
|
||||
{ value: "years", label: t("years") },
|
||||
]}
|
||||
value={retentionUnit}
|
||||
onChange={(value) => {
|
||||
if (value === "days" || value === "months" || value === "years") {
|
||||
setRetentionUnit(value);
|
||||
}
|
||||
}}
|
||||
size="sm"
|
||||
style={{ flex: 1 }}
|
||||
comboboxProps={{ withinPortal: false }}
|
||||
/>
|
||||
</Group>
|
||||
<Group gap="xs" grow>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="default"
|
||||
onClick={() => {
|
||||
resetRetentionForm();
|
||||
setSettingsOpen(false);
|
||||
}}
|
||||
>
|
||||
{t("Cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
onClick={() => {
|
||||
const num =
|
||||
typeof retentionAmount === "number" ? retentionAmount : 1;
|
||||
const clamped = Math.max(1, num);
|
||||
setRetentionAmount(clamped);
|
||||
const days = retentionToDays(clamped, retentionUnit);
|
||||
|
||||
if (days !== (retentionData?.retentionDays ?? 365)) {
|
||||
updateRetention.mutate({
|
||||
pageAnalyticsRetentionDays: Number(days),
|
||||
});
|
||||
}
|
||||
setSettingsOpen(false);
|
||||
}}
|
||||
loading={updateRetention.isPending}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</Group>
|
||||
</Popover.Dropdown>
|
||||
</Popover>
|
||||
</Group>
|
||||
|
||||
<SimpleGrid cols={{ base: 1, sm: 2, lg: 4 }} mb="md">
|
||||
<Card withBorder radius="md" p="md">
|
||||
<Text size="xs" c="dimmed">
|
||||
{t("Total views")}
|
||||
</Text>
|
||||
<Text fw={700} fz="xl">
|
||||
{formatNumber(totalsData?.totals.totalViews)}
|
||||
</Text>
|
||||
</Card>
|
||||
<Card withBorder radius="md" p="md">
|
||||
<Text size="xs" c="dimmed">
|
||||
{t("Unique visitors")}
|
||||
</Text>
|
||||
<Text fw={700} fz="xl">
|
||||
{formatNumber(totalsData?.totals.uniqueVisitors)}
|
||||
</Text>
|
||||
</Card>
|
||||
<Card withBorder radius="md" p="md">
|
||||
<Text size="xs" c="dimmed">
|
||||
{t("Authenticated visitors")}
|
||||
</Text>
|
||||
<Text fw={700} fz="xl">
|
||||
{formatNumber(totalsData?.totals.authenticatedVisitors)}
|
||||
</Text>
|
||||
</Card>
|
||||
<Card withBorder radius="md" p="md">
|
||||
<Text size="xs" c="dimmed">
|
||||
{t("Shared-link views")}
|
||||
</Text>
|
||||
<Text fw={700} fz="xl">
|
||||
{formatNumber(totalsData?.totals.sharedViews)}
|
||||
</Text>
|
||||
</Card>
|
||||
</SimpleGrid>
|
||||
|
||||
<SimpleGrid cols={{ base: 1, lg: 2 }} spacing="md">
|
||||
<Card withBorder radius="md" p="md">
|
||||
<Group justify="space-between" mb="sm">
|
||||
<Text fw={600}>{t("Top pages")}</Text>
|
||||
<Group gap="xs">
|
||||
{isTopPagesLoading && <Badge variant="light">{t("Loading")}</Badge>}
|
||||
<Select
|
||||
aria-label={t("Number of top pages")}
|
||||
data={[
|
||||
{ value: "10", label: t("Top 10") },
|
||||
{ value: "20", label: t("Top 20") },
|
||||
{ value: "50", label: t("Top 50") },
|
||||
{ value: "100", label: t("Top 100") },
|
||||
]}
|
||||
value={topPagesLimit}
|
||||
onChange={handleTopPagesLimitChange}
|
||||
w={100}
|
||||
size="xs"
|
||||
allowDeselect={false}
|
||||
/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Table striped highlightOnHover withTableBorder withColumnBorders>
|
||||
<Table.Thead>
|
||||
<Table.Tr>
|
||||
<Table.Th>{t("Page")}</Table.Th>
|
||||
<Table.Th>{t("Views")}</Table.Th>
|
||||
<Table.Th>{t("Visitors")}</Table.Th>
|
||||
<Table.Th>{t("Last viewed")}</Table.Th>
|
||||
</Table.Tr>
|
||||
</Table.Thead>
|
||||
<Table.Tbody>
|
||||
{(topPagesData?.items ?? []).map((item) => (
|
||||
<Table.Tr key={item.pageId}>
|
||||
<Table.Td>
|
||||
{item.pageSlugId ? (
|
||||
<Link to={`/p/${item.pageSlugId}`}>
|
||||
{item.pageTitle || t("Untitled")}
|
||||
</Link>
|
||||
) : (
|
||||
item.pageTitle || t("Untitled")
|
||||
)}
|
||||
</Table.Td>
|
||||
<Table.Td>{formatNumber(item.totalViews)}</Table.Td>
|
||||
<Table.Td>{formatNumber(item.uniqueVisitors)}</Table.Td>
|
||||
<Table.Td>{formatDate(item.lastViewedAt)}</Table.Td>
|
||||
</Table.Tr>
|
||||
))}
|
||||
{!isTopPagesLoading && (topPagesData?.items.length ?? 0) === 0 && (
|
||||
<Table.Tr>
|
||||
<Table.Td colSpan={4}>
|
||||
<Text c="dimmed" size="sm">
|
||||
{t("No analytics data for this range.")}
|
||||
</Text>
|
||||
</Table.Td>
|
||||
</Table.Tr>
|
||||
)}
|
||||
</Table.Tbody>
|
||||
</Table>
|
||||
{topPagesData?.items &&
|
||||
topPagesData.items.length > 0 &&
|
||||
(topPagesData.meta.hasPrevPage || topPagesData.meta.hasNextPage) && (
|
||||
<Paginate
|
||||
hasPrevPage={topPagesData.meta.hasPrevPage}
|
||||
hasNextPage={topPagesData.meta.hasNextPage}
|
||||
onPrev={goPrevTopPages}
|
||||
onNext={() => goNextTopPages(topPagesData.meta.nextCursor)}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card withBorder radius="md" p="md">
|
||||
<Group justify="space-between" mb="sm">
|
||||
<Text fw={600}>{t("Daily breakdown")}</Text>
|
||||
{isDailyLoading && <Badge variant="light">{t("Loading")}</Badge>}
|
||||
</Group>
|
||||
<Stack gap="xs">
|
||||
<Table striped highlightOnHover withTableBorder withColumnBorders>
|
||||
<Table.Thead>
|
||||
<Table.Tr>
|
||||
<Table.Th>{t("Date")}</Table.Th>
|
||||
<Table.Th>{t("Views")}</Table.Th>
|
||||
<Table.Th>{t("Visitors")}</Table.Th>
|
||||
</Table.Tr>
|
||||
</Table.Thead>
|
||||
<Table.Tbody>
|
||||
{(dailyData?.items ?? []).map((item) => (
|
||||
<Table.Tr key={item.viewDate}>
|
||||
<Table.Td>{item.viewDate}</Table.Td>
|
||||
<Table.Td>{formatNumber(item.totalViews)}</Table.Td>
|
||||
<Table.Td>{formatNumber(item.uniqueVisitors)}</Table.Td>
|
||||
</Table.Tr>
|
||||
))}
|
||||
{!isDailyLoading && (dailyData?.items.length ?? 0) === 0 && (
|
||||
<Table.Tr>
|
||||
<Table.Td colSpan={3}>
|
||||
<Text c="dimmed" size="sm">
|
||||
{t("No analytics data for this range.")}
|
||||
</Text>
|
||||
</Table.Td>
|
||||
</Table.Tr>
|
||||
)}
|
||||
</Table.Tbody>
|
||||
</Table>
|
||||
|
||||
{dailyData?.items &&
|
||||
dailyData.items.length > 0 &&
|
||||
(dailyData.meta.hasPrevPage || dailyData.meta.hasNextPage) && (
|
||||
<Paginate
|
||||
hasPrevPage={dailyData.meta.hasPrevPage}
|
||||
hasNextPage={dailyData.meta.hasNextPage}
|
||||
onPrev={goPrevDaily}
|
||||
onNext={() => goNextDaily(dailyData.meta.nextCursor)}
|
||||
/>
|
||||
)}
|
||||
</Stack>
|
||||
</Card>
|
||||
</SimpleGrid>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
getPageAnalyticsRetention,
|
||||
getWorkspacePageAnalyticsDailyStats,
|
||||
getWorkspacePageAnalyticsTopPages,
|
||||
getWorkspacePageAnalyticsTotals,
|
||||
updatePageAnalyticsRetention,
|
||||
} from "@/ee/page-analytics/services/page-analytics-service";
|
||||
import type { IPagination } from "@/lib/types";
|
||||
import type {
|
||||
WorkspaceAnalyticsDailyStat,
|
||||
WorkspaceAnalyticsListParams,
|
||||
WorkspaceAnalyticsParams,
|
||||
WorkspaceAnalyticsTopPage,
|
||||
WorkspaceAnalyticsTotals,
|
||||
} from "@/ee/page-analytics/types/page-analytics.types";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
|
||||
export function useWorkspacePageAnalyticsTotalsQuery(
|
||||
params?: WorkspaceAnalyticsParams,
|
||||
) {
|
||||
return useQuery<WorkspaceAnalyticsTotals, Error>({
|
||||
queryKey: ["workspace-page-analytics-totals", params],
|
||||
queryFn: () => getWorkspacePageAnalyticsTotals(params),
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
export function useWorkspacePageAnalyticsDailyStatsQuery(
|
||||
params?: WorkspaceAnalyticsListParams,
|
||||
) {
|
||||
return useQuery<IPagination<WorkspaceAnalyticsDailyStat>, Error>({
|
||||
queryKey: ["workspace-page-analytics-daily-stats", params],
|
||||
queryFn: () => getWorkspacePageAnalyticsDailyStats(params),
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
export function useWorkspacePageAnalyticsTopPagesQuery(
|
||||
params?: WorkspaceAnalyticsListParams,
|
||||
) {
|
||||
return useQuery<IPagination<WorkspaceAnalyticsTopPage>, Error>({
|
||||
queryKey: ["workspace-page-analytics-top-pages", params],
|
||||
queryFn: () => getWorkspacePageAnalyticsTopPages(params),
|
||||
placeholderData: keepPreviousData,
|
||||
});
|
||||
}
|
||||
|
||||
export function usePageAnalyticsRetentionQuery() {
|
||||
return useQuery({
|
||||
queryKey: ["page-analytics-retention"],
|
||||
queryFn: () => getPageAnalyticsRetention(),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdatePageAnalyticsRetentionMutation() {
|
||||
const queryClient = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (data: { pageAnalyticsRetentionDays: number }) =>
|
||||
updatePageAnalyticsRetention(data),
|
||||
onSuccess: () => {
|
||||
notifications.show({ message: t("Page analytics retention updated") });
|
||||
queryClient.invalidateQueries({ queryKey: ["page-analytics-retention"] });
|
||||
},
|
||||
onError: (error) => {
|
||||
const errorMessage = error["response"]?.data?.message;
|
||||
notifications.show({ message: errorMessage, color: "red" });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import api from "@/lib/api-client";
|
||||
import type { IPagination } from "@/lib/types";
|
||||
import type {
|
||||
WorkspaceAnalyticsDailyStat,
|
||||
WorkspaceAnalyticsListParams,
|
||||
WorkspaceAnalyticsParams,
|
||||
WorkspaceAnalyticsTopPage,
|
||||
WorkspaceAnalyticsTotals,
|
||||
} from "@/ee/page-analytics/types/page-analytics.types";
|
||||
|
||||
export async function getWorkspacePageAnalyticsTotals(
|
||||
params?: WorkspaceAnalyticsParams,
|
||||
): Promise<WorkspaceAnalyticsTotals> {
|
||||
const req = await api.post("/page-analytics/workspace-stats", params);
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function getWorkspacePageAnalyticsDailyStats(
|
||||
params?: WorkspaceAnalyticsListParams,
|
||||
): Promise<IPagination<WorkspaceAnalyticsDailyStat>> {
|
||||
const req = await api.post("/page-analytics/workspace-daily-stats", params);
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function getWorkspacePageAnalyticsTopPages(
|
||||
params?: WorkspaceAnalyticsListParams,
|
||||
): Promise<IPagination<WorkspaceAnalyticsTopPage>> {
|
||||
const req = await api.post("/page-analytics/workspace-top-pages", params);
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function getPageAnalyticsRetention(): Promise<{ retentionDays: number }> {
|
||||
const req = await api.post("/page-analytics/retention");
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function updatePageAnalyticsRetention(data: {
|
||||
pageAnalyticsRetentionDays: number;
|
||||
}): Promise<{ retentionDays: number }> {
|
||||
|
||||
const req = await api.post("/page-analytics/retention/update", data);
|
||||
return req.data;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { QueryParams } from "@/lib/types";
|
||||
|
||||
export type WorkspaceAnalyticsParams = {
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
};
|
||||
|
||||
export type WorkspaceAnalyticsListParams = WorkspaceAnalyticsParams &
|
||||
QueryParams;
|
||||
|
||||
export type BasicStats = {
|
||||
totalViews: number;
|
||||
uniqueVisitors: number;
|
||||
authenticatedVisitors: number;
|
||||
sharedViews: number;
|
||||
};
|
||||
|
||||
export type WorkspaceAnalyticsDailyStat = BasicStats & {
|
||||
viewDate: string;
|
||||
};
|
||||
|
||||
export type WorkspaceAnalyticsTopPage = BasicStats & {
|
||||
pageId: string;
|
||||
pageTitle: string | null;
|
||||
pageSlugId: string | null;
|
||||
lastViewedAt: string | null;
|
||||
};
|
||||
|
||||
export type WorkspaceAnalyticsTotals = {
|
||||
range: { startDate: string; endDate: string };
|
||||
totals: BasicStats;
|
||||
};
|
||||
@@ -1,16 +1,17 @@
|
||||
import { useState, useMemo } from "react";
|
||||
import { Group, MultiSelect, Select, Space, TextInput } from "@mantine/core";
|
||||
import { useDebouncedValue } from "@mantine/hooks";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
import SettingsTitle from "@/components/settings/settings-title";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import Paginate from "@/components/common/paginate";
|
||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||
import { useVerificationListQuery } from "@/ee/page-verification/queries/page-verification-query";
|
||||
import { IVerificationListParams } from "@/ee/page-verification/types/page-verification.types";
|
||||
import VerificationListTable from "@/ee/page-verification/components/verification-list-table";
|
||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function VerifiedPages() {
|
||||
const { t } = useTranslation();
|
||||
@@ -67,7 +68,11 @@ export default function VerifiedPages() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Verified pages")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Verified pages")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<SettingsTitle title={t("Verified pages")} />
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { CloudLoginForm } from "@/ee/components/cloud-login-form.tsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function CloudLogin() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Login")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Login")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<CloudLoginForm />
|
||||
</>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { SetupWorkspaceForm } from "@/features/auth/components/setup-workspace-form.tsx";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import React from "react";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
|
||||
export default function CreateWorkspace() {
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title="Create Workspace" />
|
||||
<Helmet>
|
||||
<title>Create Workspace - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<SetupWorkspaceForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
import { Group, Text, Switch, Tooltip } from "@mantine/core";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ISpace } from "@/features/space/types/space.types.ts";
|
||||
import { useUpdateSpaceMutation } from "@/features/space/queries/space-query.ts";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature.ts";
|
||||
import { Feature } from "@/ee/features.ts";
|
||||
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label.ts";
|
||||
|
||||
type SpaceHideCommentsToggleProps = {
|
||||
space: ISpace;
|
||||
};
|
||||
|
||||
export default function SpaceHideCommentsToggle({
|
||||
space,
|
||||
}: SpaceHideCommentsToggleProps) {
|
||||
const { t } = useTranslation();
|
||||
const hasHideComments = useHasFeature(Feature.HIDE_COMMENTS);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const allowViewerCommentsEnabled =
|
||||
space.settings?.comments?.allowViewerComments === true;
|
||||
const isDisabled = !hasHideComments || allowViewerCommentsEnabled;
|
||||
const tooltipLabel = !hasHideComments
|
||||
? upgradeLabel
|
||||
: t("Turn off 'Allow viewers to comment' first");
|
||||
const [checked, setChecked] = useState(
|
||||
space.settings?.comments?.hideCommentsFromViewers === true,
|
||||
);
|
||||
const updateSpaceMutation = useUpdateSpaceMutation();
|
||||
|
||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.currentTarget.checked;
|
||||
try {
|
||||
await updateSpaceMutation.mutateAsync({
|
||||
spaceId: space.id,
|
||||
hideCommentsFromViewers: value,
|
||||
});
|
||||
setChecked(value);
|
||||
} catch {
|
||||
// error handled by mutation
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Group justify="space-between" wrap="nowrap" gap="xl">
|
||||
<div>
|
||||
<Text size="md">{t("Hide comments from viewers")}</Text>
|
||||
<Text size="sm" c="dimmed">
|
||||
{t("Viewers cannot see or add comments on pages in this space.")}
|
||||
</Text>
|
||||
</div>
|
||||
<Tooltip label={tooltipLabel} disabled={!isDisabled} refProp="rootRef">
|
||||
<Switch
|
||||
checked={checked}
|
||||
onChange={handleChange}
|
||||
disabled={isDisabled}
|
||||
aria-label={t("Toggle hide comments from viewers")}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
@@ -17,12 +17,7 @@ export default function SpaceViewerCommentsToggle({
|
||||
const { t } = useTranslation();
|
||||
const hasViewerComments = useHasFeature(Feature.VIEWER_COMMENTS);
|
||||
const upgradeLabel = useUpgradeLabel();
|
||||
const hideCommentsEnabled =
|
||||
space.settings?.comments?.hideCommentsFromViewers === true;
|
||||
const isDisabled = !hasViewerComments || hideCommentsEnabled;
|
||||
const tooltipLabel = !hasViewerComments
|
||||
? upgradeLabel
|
||||
: t("Turn off 'Hide comments from viewers' first");
|
||||
const isDisabled = !hasViewerComments;
|
||||
const [checked, setChecked] = useState(
|
||||
space.settings?.comments?.allowViewerComments === true,
|
||||
);
|
||||
@@ -50,7 +45,7 @@ export default function SpaceViewerCommentsToggle({
|
||||
</Text>
|
||||
</div>
|
||||
<Tooltip
|
||||
label={tooltipLabel}
|
||||
label={upgradeLabel}
|
||||
disabled={!isDisabled}
|
||||
refProp="rootRef"
|
||||
>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName, isCloud } from "@/lib/config.ts";
|
||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import {
|
||||
Alert,
|
||||
@@ -36,7 +37,6 @@ import EnableScim from "@/ee/scim/components/enable-scim";
|
||||
import { useCursorPaginate } from "@/hooks/use-cursor-paginate";
|
||||
import Paginate from "@/components/common/paginate";
|
||||
import { IScimToken } from "@/ee/scim/types/scim-token.types";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
const SCIM_TOKEN_LIMIT = 5;
|
||||
|
||||
@@ -64,7 +64,9 @@ export default function Security() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title="Security" />
|
||||
<Helmet>
|
||||
<title>Security - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("Security")} />
|
||||
|
||||
<EnforceMfa />
|
||||
|
||||
@@ -22,6 +22,8 @@ import { useTranslation } from "react-i18next";
|
||||
import { useDisclosure, useWindowEvent } from "@mantine/hooks";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import { useEditor, EditorContent } from "@tiptap/react";
|
||||
import { templateExtensions } from "@/features/editor/extensions/extensions";
|
||||
import {
|
||||
@@ -42,7 +44,6 @@ import CalloutMenu from "@/features/editor/components/callout/callout-menu.tsx";
|
||||
import ColumnsMenu from "@/features/editor/components/columns/columns-menu.tsx";
|
||||
|
||||
import classes from "./template-editor.module.css";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function TemplateEditor() {
|
||||
const { t } = useTranslation();
|
||||
@@ -246,7 +247,11 @@ export default function TemplateEditor() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Edit template")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Edit template")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
{editorToolbarEnabled && editor && (
|
||||
<FixedToolbar editor={editor} templateMode />
|
||||
|
||||
@@ -13,9 +13,11 @@ import {
|
||||
} from "@mantine/core";
|
||||
import { modals } from "@mantine/modals";
|
||||
import { IconPlus } from "@tabler/icons-react";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import {
|
||||
useGetTemplatesQuery,
|
||||
useDeleteTemplateMutation,
|
||||
@@ -29,7 +31,6 @@ import useUserRole from "@/hooks/use-user-role";
|
||||
import CreateTemplateModal from "@/ee/template/components/create-template-modal";
|
||||
import { useAtomValue } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function TemplateList() {
|
||||
const { t } = useTranslation();
|
||||
@@ -101,7 +102,11 @@ export default function TemplateList() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Templates")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Templates")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<Container size="900" pt="xl">
|
||||
<Group justify="space-between" mb="xl">
|
||||
|
||||
@@ -14,3 +14,33 @@ export function exchangeTokenRedirectUrl(
|
||||
) {
|
||||
return getHostnameUrl(hostname) + "/api/auth/exchange?token=" + exchangeToken;
|
||||
}
|
||||
|
||||
export type RetentionUnit = "days" | "months" | "years";
|
||||
|
||||
export function daysToRetention(days: number): { amount: number; unit: RetentionUnit } {
|
||||
if (days >= 365 && days % 365 === 0) {
|
||||
return { amount: days / 365, unit: "years" };
|
||||
}
|
||||
if (days >= 30 && days % 30 === 0) {
|
||||
return { amount: days / 30, unit: "months" };
|
||||
}
|
||||
return { amount: days, unit: "days" };
|
||||
}
|
||||
|
||||
export function retentionToDays(amount: number, unit: RetentionUnit): number {
|
||||
if (unit === "years") return amount * 365;
|
||||
if (unit === "months") return amount * 30;
|
||||
return amount;
|
||||
}
|
||||
|
||||
export function toISODate(daysAgo: number | string): string {
|
||||
const daysNum = Number(daysAgo);
|
||||
|
||||
return new Date(Date.now() - daysNum * 24 * 60 * 60 * 1000)
|
||||
.toISOString()
|
||||
.slice(0, 10);
|
||||
}
|
||||
|
||||
export function formatNumber(value: number | null | undefined): string {
|
||||
return Number(value ?? 0).toLocaleString();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
import { usePageQuery } from "@/features/page/queries/page-query.ts";
|
||||
import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts";
|
||||
import { extractPageSlugId } from "@/lib";
|
||||
|
||||
export function useCanViewComments(): boolean {
|
||||
const { pageSlug } = useParams();
|
||||
const { data: page } = usePageQuery({ pageId: extractPageSlugId(pageSlug) });
|
||||
const { data: space } = useGetSpaceBySlugQuery(page?.space?.slug);
|
||||
|
||||
const canEdit = !page?.deletedAt && (page?.permissions?.canEdit ?? false);
|
||||
return (
|
||||
canEdit || space?.settings?.comments?.hideCommentsFromViewers !== true
|
||||
);
|
||||
}
|
||||
@@ -82,8 +82,6 @@ import {
|
||||
getCollabSocket,
|
||||
releaseCollabSocket,
|
||||
} from "@/features/editor/collab-socket";
|
||||
import clsx from "clsx";
|
||||
import { useCanViewComments } from "@/features/comment/hooks/use-can-view-comments.ts";
|
||||
|
||||
interface PageEditorProps {
|
||||
pageId: string;
|
||||
@@ -198,7 +196,6 @@ function CollabPageEditor({
|
||||
const { pageSlug } = useParams();
|
||||
const slugId = extractPageSlugId(pageSlug);
|
||||
const currentPageEditMode = useAtomValue(currentPageEditModeAtom);
|
||||
const canViewComments = useCanViewComments();
|
||||
const canScroll = useCallback(
|
||||
() => Boolean(isComponentMounted.current && editorRef.current),
|
||||
[isComponentMounted],
|
||||
@@ -375,7 +372,6 @@ function CollabPageEditor({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!canViewComments) return;
|
||||
document.addEventListener("ACTIVE_COMMENT_EVENT", handleActiveCommentEvent);
|
||||
return () => {
|
||||
document.removeEventListener(
|
||||
@@ -383,7 +379,7 @@ function CollabPageEditor({
|
||||
handleActiveCommentEvent,
|
||||
);
|
||||
};
|
||||
}, [canViewComments]);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setActiveCommentId(null);
|
||||
@@ -434,13 +430,7 @@ function CollabPageEditor({
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
"editor-container",
|
||||
!canViewComments && "comments-hidden",
|
||||
)}
|
||||
style={{ position: "relative" }}
|
||||
>
|
||||
<div className="editor-container" style={{ position: "relative" }}>
|
||||
<div ref={menuContainerRef}>
|
||||
<EditorContent editor={editor} />
|
||||
|
||||
@@ -490,21 +480,17 @@ function StaticPageEditor({
|
||||
content: any;
|
||||
ariaLabel: string;
|
||||
}) {
|
||||
const canViewComments = useCanViewComments();
|
||||
|
||||
return (
|
||||
<div className={clsx(!canViewComments && "comments-hidden")}>
|
||||
<EditorProvider
|
||||
editable={false}
|
||||
immediatelyRender={true}
|
||||
extensions={mainExtensions}
|
||||
content={content}
|
||||
editorProps={{
|
||||
attributes: {
|
||||
"aria-label": ariaLabel,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<EditorProvider
|
||||
editable={false}
|
||||
immediatelyRender={true}
|
||||
extensions={mainExtensions}
|
||||
content={content}
|
||||
editorProps={{
|
||||
attributes: {
|
||||
"aria-label": ariaLabel,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -315,8 +315,3 @@
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.comments-hidden .ProseMirror .comment-mark {
|
||||
background: none;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ import {
|
||||
useWatchPageMutation,
|
||||
useUnwatchPageMutation,
|
||||
} from "@/features/page/queries/watcher-query";
|
||||
import { useCanViewComments } from "@/features/comment/hooks/use-can-view-comments.ts";
|
||||
|
||||
interface PageHeaderMenuProps {
|
||||
readOnly?: boolean;
|
||||
@@ -66,7 +65,6 @@ interface PageHeaderMenuProps {
|
||||
export default function PageHeaderMenu({ readOnly }: PageHeaderMenuProps) {
|
||||
const { t } = useTranslation();
|
||||
const commentsTriggerProps = useAsideTriggerProps("comments");
|
||||
const canViewComments = useCanViewComments();
|
||||
const tocTriggerProps = useAsideTriggerProps("toc");
|
||||
const { pageSlug } = useParams();
|
||||
const { data: page } = usePageQuery({
|
||||
@@ -107,18 +105,16 @@ export default function PageHeaderMenu({ readOnly }: PageHeaderMenuProps) {
|
||||
|
||||
<PageShareModal readOnly={readOnly} />
|
||||
|
||||
{canViewComments && (
|
||||
<Tooltip label={t("Comments")} openDelay={250} withArrow>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="dark"
|
||||
aria-label={t("Comments")}
|
||||
{...commentsTriggerProps}
|
||||
>
|
||||
<IconMessage size={20} stroke={2} />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
)}
|
||||
<Tooltip label={t("Comments")} openDelay={250} withArrow>
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
color="dark"
|
||||
aria-label={t("Comments")}
|
||||
{...commentsTriggerProps}
|
||||
>
|
||||
<IconMessage size={20} stroke={2} />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
|
||||
{!page?.isBase && (
|
||||
<Tooltip label={t("Table of contents")} openDelay={250} withArrow>
|
||||
|
||||
@@ -4,7 +4,6 @@ import { useTranslation } from "react-i18next";
|
||||
import { ISpace } from "@/features/space/types/space.types.ts";
|
||||
import SpacePublicSharingToggle from "@/ee/security/components/space-public-sharing-toggle.tsx";
|
||||
import SpaceViewerCommentsToggle from "@/ee/security/components/space-viewer-comments-toggle.tsx";
|
||||
import SpaceHideCommentsToggle from "@/ee/security/components/space-hide-comments-toggle.tsx";
|
||||
|
||||
type SpaceSecuritySettingsProps = {
|
||||
space: ISpace;
|
||||
@@ -30,10 +29,6 @@ export default function SpaceSecuritySettings({
|
||||
<Divider my="lg" />
|
||||
|
||||
<SpaceViewerCommentsToggle space={space} />
|
||||
|
||||
<Divider my="lg" />
|
||||
|
||||
<SpaceHideCommentsToggle space={space} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ export interface ISpaceSharingSettings {
|
||||
|
||||
export interface ISpaceCommentsSettings {
|
||||
allowViewerComments?: boolean;
|
||||
hideCommentsFromViewers?: boolean;
|
||||
}
|
||||
|
||||
export interface ISpaceSettings {
|
||||
@@ -37,7 +36,6 @@ export interface ISpace {
|
||||
// for updates
|
||||
disablePublicSharing?: boolean;
|
||||
allowViewerComments?: boolean;
|
||||
hideCommentsFromViewers?: boolean;
|
||||
}
|
||||
|
||||
interface IMembership {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { ForgotPasswordForm } from "@/features/auth/components/forgot-password-form";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
|
||||
export default function ForgotPassword() {
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title="Forgot Password" />
|
||||
<Helmet>
|
||||
<title>Forgot Password - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<ForgotPasswordForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { InviteSignUpForm } from "@/features/auth/components/invite-sign-up-form.tsx";
|
||||
import {getAppName} from "@/lib/config.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function InviteSignup() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Invitation Signup")} />
|
||||
<Helmet>
|
||||
<title>{t("Invitation Signup")} - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<InviteSignUpForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import { LoginForm } from "@/features/auth/components/login-form";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function LoginPage() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Login")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Login")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<LoginForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { PasswordResetForm } from "@/features/auth/components/password-reset-form";
|
||||
import { Link, useSearchParams } from "react-router-dom";
|
||||
import { useVerifyUserTokenQuery } from "@/features/auth/queries/auth-query";
|
||||
import { Button, Container, Group, Text } from "@mantine/core";
|
||||
import APP_ROUTE from "@/lib/app-route";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function PasswordReset() {
|
||||
const { t } = useTranslation();
|
||||
@@ -22,7 +23,11 @@ export default function PasswordReset() {
|
||||
if (isError || !resetToken) {
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Password Reset")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Password Reset")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<Container my={40}>
|
||||
<Text size="lg" ta="center">
|
||||
{t("Invalid or expired password reset link")}
|
||||
@@ -44,7 +49,11 @@ export default function PasswordReset() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Password Reset")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Password Reset")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<PasswordResetForm resetToken={resetToken} />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { useWorkspacePublicDataQuery } from "@/features/workspace/queries/workspace-query.ts";
|
||||
import { SetupWorkspaceForm } from "@/features/auth/components/setup-workspace-form.tsx";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import React, { useEffect } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import APP_ROUTE from "@/lib/app-route.ts";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function SetupWorkspace() {
|
||||
const { t } = useTranslation();
|
||||
@@ -34,7 +35,11 @@ export default function SetupWorkspace() {
|
||||
) {
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Setup Workspace")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Setup Workspace")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<SetupWorkspaceForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -2,15 +2,20 @@ import { Container, Space } from "@mantine/core";
|
||||
import HomeTabs from "@/features/home/components/home-tabs";
|
||||
import HomeAiPrompt from "@/features/home/components/home-ai-prompt";
|
||||
import SpaceCarousel from "@/features/space/components/space-carousel.tsx";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function Home() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Home")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Home")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<Container size={"900"} pt="xl">
|
||||
<HomeAiPrompt />
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ import {
|
||||
} from "@tabler/icons-react";
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useDebouncedValue } from "@mantine/hooks";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import { useLabelPagesQuery } from "@/features/label/queries/label-query.ts";
|
||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query.ts";
|
||||
import { getLabelColor } from "@/features/label/utils/label-colors.ts";
|
||||
@@ -27,7 +29,6 @@ import { normalizeLabelName } from "@/features/label/utils/normalize-label.ts";
|
||||
import { SpaceFilterMenu } from "@/features/space/components/space-filter-menu.tsx";
|
||||
import { EmptyState } from "@/components/ui/empty-state";
|
||||
import classes from "@/features/label/label.module.css";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function LabelPage() {
|
||||
const { t } = useTranslation();
|
||||
@@ -81,7 +82,11 @@ export default function LabelPage() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={labelName} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{labelName} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<Container size={820} py="xl">
|
||||
<Stack gap="lg">
|
||||
|
||||
@@ -3,6 +3,7 @@ import { usePageQuery } from "@/features/page/queries/page-query";
|
||||
import { FullEditor } from "@/features/editor/full-editor";
|
||||
import { TitleEditor } from "@/features/editor/title-editor";
|
||||
import HistoryModal from "@/features/page-history/components/history-modal";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import PageHeader from "@/features/page/components/header/page-header.tsx";
|
||||
import { extractPageSlugId } from "@/lib";
|
||||
import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts";
|
||||
@@ -17,7 +18,6 @@ import { BaseView } from "@/ee/base/components/base-view";
|
||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
||||
import { Feature } from "@/ee/features";
|
||||
import { getPageTitle } from "@/features/page/page.utils";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
const MemoizedFullEditor = React.memo(FullEditor);
|
||||
const MemoizedTitleEditor = React.memo(TitleEditor);
|
||||
const MemoizedPageHeader = React.memo(PageHeader);
|
||||
@@ -110,10 +110,9 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
||||
paddingTop: "calc(var(--page-header-height) + 6px)",
|
||||
}}
|
||||
>
|
||||
<DocumentTitle
|
||||
title={`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}
|
||||
withAppName={false}
|
||||
/>
|
||||
<Helmet>
|
||||
<title>{`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}</title>
|
||||
</Helmet>
|
||||
<MemoizedPageHeader readOnly={!canEdit} />
|
||||
<div
|
||||
style={{
|
||||
@@ -160,10 +159,9 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
||||
return (
|
||||
page && (
|
||||
<div>
|
||||
<DocumentTitle
|
||||
title={`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}
|
||||
withAppName={false}
|
||||
/>
|
||||
<Helmet>
|
||||
<title>{`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}</title>
|
||||
</Helmet>
|
||||
|
||||
<MemoizedPageHeader readOnly={!canEdit} />
|
||||
|
||||
|
||||
@@ -5,16 +5,21 @@ import PageWidthPref from "@/features/user/components/page-width-pref.tsx";
|
||||
import PageEditPref from "@/features/user/components/page-state-pref";
|
||||
import FixedToolbarPref from "@/features/user/components/fixed-toolbar-pref";
|
||||
import NotificationPref from "@/features/user/components/notification-pref";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { Divider } from "@mantine/core";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function AccountPreferences() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Preferences")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Preferences")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("Preferences")} />
|
||||
|
||||
<AccountTheme />
|
||||
|
||||
@@ -4,17 +4,22 @@ import ChangePassword from "@/features/user/components/change-password";
|
||||
import { Divider } from "@mantine/core";
|
||||
import AccountAvatar from "@/features/user/components/account-avatar";
|
||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AccountMfaSection } from "@/features/user/components/account-mfa-section";
|
||||
import SessionList from "@/features/session/components/session-list";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function AccountSettings() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("My Profile")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("My Profile")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("My Profile")} />
|
||||
|
||||
<AccountAvatar />
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import GroupMembersList from "@/features/group/components/group-members";
|
||||
import GroupDetails from "@/features/group/components/group-details";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function GroupInfo() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Manage Group")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Manage Group")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("Manage Group")} />
|
||||
<GroupDetails />
|
||||
<GroupMembersList />
|
||||
|
||||
@@ -3,8 +3,9 @@ import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import { Group } from "@mantine/core";
|
||||
import CreateGroupModal from "@/features/group/components/create-group-modal";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
import {getAppName} from "@/lib/config.ts";
|
||||
import {Helmet} from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function Groups() {
|
||||
const { t } = useTranslation();
|
||||
@@ -12,7 +13,9 @@ export default function Groups() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Groups")} />
|
||||
<Helmet>
|
||||
<title>{t("Groups")} - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("Groups")} />
|
||||
|
||||
<Group my="md" justify="flex-end">
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
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";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function Shares() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Public sharing")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Public sharing")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("Public sharing")} />
|
||||
|
||||
<Alert variant="light" color="blue" icon={<IconInfoCircle />}>
|
||||
|
||||
@@ -3,8 +3,9 @@ import SpaceList from "@/features/space/components/space-list.tsx";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
import { Group } from "@mantine/core";
|
||||
import CreateSpaceModal from "@/features/space/components/create-space-modal.tsx";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function Spaces() {
|
||||
const { t } = useTranslation();
|
||||
@@ -12,7 +13,11 @@ export default function Spaces() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Spaces")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Spaces")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("Spaces")} />
|
||||
|
||||
<Group my="md" justify="flex-end">
|
||||
|
||||
@@ -6,10 +6,11 @@ import { useEffect, useState } from "react";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
import WorkspaceInvitesTable from "@/features/workspace/components/members/components/workspace-invites-table.tsx";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useAtom } from "jotai";
|
||||
import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function WorkspaceMembers() {
|
||||
const { t } = useTranslation();
|
||||
@@ -37,7 +38,11 @@ export default function WorkspaceMembers() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Members")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Members")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("Members")} />
|
||||
|
||||
{/* <WorkspaceInviteSection /> */}
|
||||
|
||||
@@ -2,19 +2,21 @@ import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import WorkspaceNameForm from "@/features/workspace/components/settings/components/workspace-name-form";
|
||||
import WorkspaceIcon from "@/features/workspace/components/settings/components/workspace-icon.tsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import { getAppName, isCloud } from "@/lib/config.ts";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import ManageHostname from "@/ee/components/manage-hostname.tsx";
|
||||
import { Divider } from "@mantine/core";
|
||||
import AllowMemberTemplates from "@/ee/security/components/allow-member-templates.tsx";
|
||||
import WorkspaceDefaultPageEditMode from "@/features/workspace/components/settings/components/workspace-default-page-edit-mode.tsx";
|
||||
import PersonalSpacesSetting from "@/ee/personal-space/components/personal-spaces-setting.tsx";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function WorkspaceSettings() {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title="Workspace Settings" />
|
||||
<Helmet>
|
||||
<title>Workspace Settings - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<SettingsTitle title={t("General")} />
|
||||
<WorkspaceIcon />
|
||||
<WorkspaceNameForm />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useSharePageQuery } from "@/features/share/queries/share-query.ts";
|
||||
import { Container } from "@mantine/core";
|
||||
@@ -13,7 +14,6 @@ import {
|
||||
sharedTreeDataAtom,
|
||||
} from "@/features/share/atoms/shared-page-atom.ts";
|
||||
import { isPageInTree } from "@/features/share/utils.ts";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function SharedPage() {
|
||||
const { t } = useTranslation();
|
||||
@@ -56,14 +56,12 @@ export default function SharedPage() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<DocumentTitle
|
||||
title={data?.page?.title || t("untitled")}
|
||||
withAppName={false}
|
||||
>
|
||||
<Helmet>
|
||||
<title>{`${data?.page?.title || t("untitled")}`}</title>
|
||||
{!data?.share.searchIndexing && (
|
||||
<meta name="robots" content="noindex" />
|
||||
)}
|
||||
</DocumentTitle>
|
||||
</Helmet>
|
||||
|
||||
<Container fluid={fullWidth} size={fullWidth ? undefined : 900} p={0}>
|
||||
<ReadonlyPageEditor
|
||||
|
||||
@@ -2,7 +2,8 @@ import {Container} from "@mantine/core";
|
||||
import SpaceHomeTabs from "@/features/space/components/space-home-tabs.tsx";
|
||||
import {useParams} from "react-router-dom";
|
||||
import {useGetSpaceBySlugQuery} from "@/features/space/queries/space-query.ts";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
import {getAppName} from "@/lib/config.ts";
|
||||
import {Helmet} from "react-helmet-async";
|
||||
|
||||
export default function SpaceHome() {
|
||||
const {spaceSlug} = useParams();
|
||||
@@ -10,7 +11,9 @@ export default function SpaceHome() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={space?.name || 'Overview'} />
|
||||
<Helmet>
|
||||
<title>{space?.name || 'Overview'} - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<Container size={"900"} pt="xl">
|
||||
{space && <SpaceHomeTabs/>}
|
||||
</Container>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { Container, Title, Text, Group, Box } from "@mantine/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import { useGetSpacesQuery } from "@/features/space/queries/space-query";
|
||||
import CreateSpaceModal from "@/features/space/components/create-space-modal";
|
||||
import { AllSpacesList } from "@/features/space/components/spaces-page";
|
||||
import FavoriteSpacesGrid from "@/features/space/components/spaces-page/favorite-spaces-grid";
|
||||
import { usePaginateAndSearch } from "@/hooks/use-paginate-and-search";
|
||||
import useUserRole from "@/hooks/use-user-role";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function Spaces() {
|
||||
const { t } = useTranslation();
|
||||
@@ -21,7 +22,11 @@ export default function Spaces() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DocumentTitle title={t("Spaces")} />
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Spaces")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
<Container size={"800"} pt="xl">
|
||||
<Group justify="space-between" mb="xl">
|
||||
|
||||
@@ -51,19 +51,19 @@
|
||||
"@nestjs-labs/nestjs-ioredis": "11.0.4",
|
||||
"@nestjs/bullmq": "11.0.4",
|
||||
"@nestjs/cache-manager": "3.1.3",
|
||||
"@nestjs/common": "11.1.28",
|
||||
"@nestjs/common": "11.1.27",
|
||||
"@nestjs/config": "4.0.4",
|
||||
"@nestjs/core": "11.1.27",
|
||||
"@nestjs/event-emitter": "3.1.0",
|
||||
"@nestjs/jwt": "11.0.2",
|
||||
"@nestjs/mapped-types": "2.1.1",
|
||||
"@nestjs/passport": "11.0.5",
|
||||
"@nestjs/platform-fastify": "11.1.28",
|
||||
"@nestjs/platform-socket.io": "11.1.28",
|
||||
"@nestjs/platform-fastify": "11.1.27",
|
||||
"@nestjs/platform-socket.io": "11.1.27",
|
||||
"@nestjs/schedule": "6.1.3",
|
||||
"@nestjs/terminus": "11.1.1",
|
||||
"@nestjs/throttler": "6.5.0",
|
||||
"@nestjs/websockets": "11.1.28",
|
||||
"@nestjs/websockets": "11.1.27",
|
||||
"@node-saml/passport-saml": "5.1.0",
|
||||
"@socket.io/redis-adapter": "8.3.0",
|
||||
"ai": "6.0.134",
|
||||
@@ -90,8 +90,8 @@
|
||||
"ldapts": "8.1.7",
|
||||
"mammoth": "1.12.0",
|
||||
"mime-types": "3.0.2",
|
||||
"msgpackr": "1.11.9",
|
||||
"nanoid": "5.1.16",
|
||||
"msgpackr": "^1.11.9",
|
||||
"nanoid": "5.1.7",
|
||||
"nestjs-cls": "6.2.0",
|
||||
"nestjs-kysely": "3.1.2",
|
||||
"nestjs-pino": "4.6.1",
|
||||
@@ -102,7 +102,7 @@
|
||||
"passport-google-oauth20": "2.0.0",
|
||||
"passport-jwt": "4.0.1",
|
||||
"pg-tsquery": "8.4.2",
|
||||
"pgvector": "0.2.1",
|
||||
"pgvector": "^0.2.1",
|
||||
"pino-http": "11.0.0",
|
||||
"pino-pretty": "13.1.3",
|
||||
"postgres": "3.4.8",
|
||||
|
||||
@@ -26,6 +26,7 @@ import KeyvRedis from '@keyv/redis';
|
||||
import { LoggerModule } from './common/logger/logger.module';
|
||||
import { ClsModule } from 'nestjs-cls';
|
||||
import { NoopAuditModule } from './integrations/audit/audit.module';
|
||||
import { NoopPageAnalyticsModule } from './integrations/page-analytics/page-analytics.module';
|
||||
import { ThrottleModule } from './integrations/throttle/throttle.module';
|
||||
|
||||
const enterpriseModules = [];
|
||||
@@ -50,6 +51,7 @@ try {
|
||||
}),
|
||||
LoggerModule,
|
||||
NoopAuditModule,
|
||||
NoopPageAnalyticsModule,
|
||||
CoreModule,
|
||||
DatabaseModule,
|
||||
EnvironmentModule,
|
||||
|
||||
@@ -15,10 +15,10 @@ export const Feature = {
|
||||
SCIM: 'scim',
|
||||
PAGE_VERIFICATION: 'page:verification',
|
||||
AUDIT_LOGS: 'audit:logs',
|
||||
PAGE_ANALYTICS: 'analytics:page-analytics',
|
||||
RETENTION: 'retention',
|
||||
SHARING_CONTROLS: 'sharing:controls',
|
||||
VIEWER_COMMENTS: 'comment:viewer',
|
||||
HIDE_COMMENTS: 'comment:hide',
|
||||
TEMPLATES: 'templates',
|
||||
PDF_EXPORT: 'export:pdf',
|
||||
PERSONAL_SPACES: 'spaces:personal',
|
||||
|
||||
@@ -42,6 +42,7 @@ function buildWorkspaceOwnerAbility() {
|
||||
can(WorkspaceCaslAction.Manage, WorkspaceCaslSubject.Attachment);
|
||||
can(WorkspaceCaslAction.Manage, WorkspaceCaslSubject.API);
|
||||
can(WorkspaceCaslAction.Manage, WorkspaceCaslSubject.Audit);
|
||||
can(WorkspaceCaslAction.Manage, WorkspaceCaslSubject.PageAnalytics);
|
||||
|
||||
return build();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ export enum WorkspaceCaslSubject {
|
||||
Attachment = 'attachment',
|
||||
API = 'api_key',
|
||||
Audit = 'audit',
|
||||
PageAnalytics = 'page_analytics'
|
||||
}
|
||||
|
||||
export type IWorkspaceAbility =
|
||||
@@ -22,4 +23,5 @@ export type IWorkspaceAbility =
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.Group]
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.Attachment]
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.API]
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.Audit];
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.Audit]
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.PageAnalytics];
|
||||
|
||||
@@ -89,29 +89,20 @@ export class CommentController {
|
||||
@Body()
|
||||
pagination: PaginationOptions,
|
||||
@AuthUser() user: User,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
) {
|
||||
const page = await this.pageRepo.findById(input.pageId);
|
||||
if (!page) {
|
||||
throw new NotFoundException('Page not found');
|
||||
}
|
||||
|
||||
await this.pageAccessService.validateCanViewComments(
|
||||
page,
|
||||
user,
|
||||
workspace.id,
|
||||
);
|
||||
await this.pageAccessService.validateCanView(page, user);
|
||||
|
||||
return this.commentService.findByPageId(page.id, pagination);
|
||||
}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('info')
|
||||
async findOne(
|
||||
@Body() input: CommentIdDto,
|
||||
@AuthUser() user: User,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
) {
|
||||
async findOne(@Body() input: CommentIdDto, @AuthUser() user: User) {
|
||||
const comment = await this.commentRepo.findById(input.commentId);
|
||||
if (!comment) {
|
||||
throw new NotFoundException('Comment not found');
|
||||
@@ -122,11 +113,7 @@ export class CommentController {
|
||||
throw new NotFoundException('Page not found');
|
||||
}
|
||||
|
||||
await this.pageAccessService.validateCanViewComments(
|
||||
page,
|
||||
user,
|
||||
workspace.id,
|
||||
);
|
||||
await this.pageAccessService.validateCanView(page, user);
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import { CommentMentionEmail } from '@docmost/transactional/emails/comment-menti
|
||||
import { CommentCreateEmail } from '@docmost/transactional/emails/comment-created-email';
|
||||
import { CommentResolvedEmail } from '@docmost/transactional/emails/comment-resolved-email';
|
||||
import { getPageTitle } from '../../../common/helpers';
|
||||
import { PageAccessService } from '../../page/page-access/page-access.service';
|
||||
|
||||
@Injectable()
|
||||
export class CommentNotificationService {
|
||||
@@ -26,7 +25,6 @@ export class CommentNotificationService {
|
||||
private readonly spaceMemberRepo: SpaceMemberRepo,
|
||||
private readonly pagePermissionRepo: PagePermissionRepo,
|
||||
private readonly watcherRepo: WatcherRepo,
|
||||
private readonly pageAccessService: PageAccessService,
|
||||
) {}
|
||||
|
||||
async processComment(data: ICommentNotificationJob, appUrl: string) {
|
||||
@@ -50,7 +48,7 @@ export class CommentNotificationService {
|
||||
);
|
||||
if (!context) return;
|
||||
|
||||
const { actor, pageTitle, pageUrl, spaceSettings } = context;
|
||||
const { actor, pageTitle, pageUrl } = context;
|
||||
const notifiedUserIds = new Set<string>();
|
||||
notifiedUserIds.add(actorId);
|
||||
|
||||
@@ -74,16 +72,7 @@ export class CommentNotificationService {
|
||||
pageId,
|
||||
[...usersWithSpaceAccess],
|
||||
);
|
||||
let accessibleUserIds = usersWithPageAccess;
|
||||
if (spaceSettings?.comments?.hideCommentsFromViewers === true) {
|
||||
accessibleUserIds =
|
||||
await this.pageAccessService.filterUserIdsWithPageEditAccess(
|
||||
spaceId,
|
||||
pageId,
|
||||
accessibleUserIds,
|
||||
);
|
||||
}
|
||||
const usersWithAccess = new Set(accessibleUserIds);
|
||||
const usersWithAccess = new Set(usersWithPageAccess);
|
||||
|
||||
for (const userId of mentionedUserIds) {
|
||||
if (!usersWithAccess.has(userId)) continue;
|
||||
@@ -156,7 +145,7 @@ export class CommentNotificationService {
|
||||
);
|
||||
if (!context) return;
|
||||
|
||||
const { actor, pageTitle, pageUrl, spaceSettings } = context;
|
||||
const { actor, pageTitle, pageUrl } = context;
|
||||
|
||||
const roles = await this.spaceMemberRepo.getUserSpaceRoles(
|
||||
commentCreatorId,
|
||||
@@ -177,16 +166,6 @@ export class CommentNotificationService {
|
||||
);
|
||||
if (hasPageAccess.length === 0) return;
|
||||
|
||||
if (spaceSettings?.comments?.hideCommentsFromViewers === true) {
|
||||
const editCapable =
|
||||
await this.pageAccessService.filterUserIdsWithPageEditAccess(
|
||||
spaceId,
|
||||
pageId,
|
||||
[commentCreatorId],
|
||||
);
|
||||
if (editCapable.length === 0) return;
|
||||
}
|
||||
|
||||
const notification = await this.notificationService.create({
|
||||
userId: commentCreatorId,
|
||||
workspaceId,
|
||||
@@ -246,7 +225,7 @@ export class CommentNotificationService {
|
||||
.executeTakeFirst(),
|
||||
this.db
|
||||
.selectFrom('spaces')
|
||||
.select(['id', 'slug', 'settings'])
|
||||
.select(['id', 'slug'])
|
||||
.where('id', '=', spaceId)
|
||||
.executeTakeFirst(),
|
||||
]);
|
||||
@@ -257,11 +236,6 @@ export class CommentNotificationService {
|
||||
|
||||
const pageUrl = `${appUrl}/s/${space.slug}/p/${page.slugId}`;
|
||||
|
||||
return {
|
||||
actor,
|
||||
pageTitle: getPageTitle(page.title),
|
||||
pageUrl,
|
||||
spaceSettings: (space.settings ?? null) as Record<string, any> | null,
|
||||
};
|
||||
return { actor, pageTitle: getPageTitle(page.title), pageUrl };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
SpaceCaslSubject,
|
||||
} from '../../casl/interfaces/space-ability.type';
|
||||
import { SpaceRepo } from '@docmost/db/repos/space/space.repo';
|
||||
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
||||
|
||||
@Injectable()
|
||||
export class PageAccessService {
|
||||
@@ -15,7 +14,6 @@ export class PageAccessService {
|
||||
private readonly pagePermissionRepo: PagePermissionRepo,
|
||||
private readonly spaceAbility: SpaceAbilityFactory,
|
||||
private readonly spaceRepo: SpaceRepo,
|
||||
private readonly spaceMemberRepo: SpaceMemberRepo,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -120,68 +118,8 @@ export class PageAccessService {
|
||||
|
||||
const space = await this.spaceRepo.findById(page.spaceId, workspaceId);
|
||||
const settings = space?.settings as Record<string, any> | null;
|
||||
if (
|
||||
!settings?.comments?.allowViewerComments ||
|
||||
settings?.comments?.hideCommentsFromViewers
|
||||
) {
|
||||
if (!settings?.comments?.allowViewerComments) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
}
|
||||
|
||||
async validateCanViewComments(
|
||||
page: Page,
|
||||
user: User,
|
||||
workspaceId: string,
|
||||
): Promise<void> {
|
||||
const { canEdit } = await this.validateCanViewWithPermissions(page, user);
|
||||
if (canEdit) {
|
||||
return;
|
||||
}
|
||||
|
||||
const space = await this.spaceRepo.findById(page.spaceId, workspaceId);
|
||||
const settings = space?.settings as Record<string, any> | null;
|
||||
if (settings?.comments?.hideCommentsFromViewers) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callers must pass userIds that already have space access (WS room members / pre-filtered notification recipients).
|
||||
*/
|
||||
async filterUserIdsWithPageEditAccess(
|
||||
spaceId: string,
|
||||
pageId: string,
|
||||
userIds: string[],
|
||||
): Promise<string[]> {
|
||||
if (userIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const spaceHasRestrictedPages =
|
||||
await this.pagePermissionRepo.hasRestrictedPagesInSpace(spaceId);
|
||||
const hasRestriction =
|
||||
spaceHasRestrictedPages &&
|
||||
(await this.pagePermissionRepo.hasRestrictedAncestor(pageId));
|
||||
|
||||
if (!hasRestriction) {
|
||||
const editCapableIds =
|
||||
await this.spaceMemberRepo.getUserIdsWithSpaceEditAccess(
|
||||
userIds,
|
||||
spaceId,
|
||||
);
|
||||
return userIds.filter((id) => editCapableIds.has(id));
|
||||
}
|
||||
|
||||
const results = await Promise.all(
|
||||
userIds.map(async (userId) => {
|
||||
const { canEdit } = await this.pagePermissionRepo.canUserEditPage(
|
||||
userId,
|
||||
pageId,
|
||||
);
|
||||
return canEdit ? userId : null;
|
||||
}),
|
||||
);
|
||||
|
||||
return results.filter((id): id is string => id !== null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ import {
|
||||
AUDIT_SERVICE,
|
||||
IAuditService,
|
||||
} from '../../integrations/audit/audit.service';
|
||||
import {
|
||||
PAGE_ANALYTICS_SERVICE,
|
||||
IPageAnalyticsService,
|
||||
} from '../../integrations/page-analytics/page-analytics.service';
|
||||
import { getPageTitle } from '../../common/helpers';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@@ -65,6 +69,7 @@ export class PageController {
|
||||
private readonly backlinkService: BacklinkService,
|
||||
private readonly labelService: LabelService,
|
||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||
@Inject(PAGE_ANALYTICS_SERVICE) private readonly pageAnalyticsService: IPageAnalyticsService,
|
||||
) {}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@@ -88,6 +93,13 @@ export class PageController {
|
||||
|
||||
const permissions = { canEdit, hasRestriction };
|
||||
|
||||
void this.pageAnalyticsService.track({
|
||||
pageId: page.id,
|
||||
workspaceId: page.workspaceId,
|
||||
spaceId: page.spaceId,
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
if (dto.format && dto.format !== 'json' && page.content) {
|
||||
const contentOutput =
|
||||
dto.format === 'markdown'
|
||||
|
||||
@@ -810,10 +810,6 @@ export class PageService {
|
||||
throw new BadRequestException('Invalid move position');
|
||||
}
|
||||
|
||||
if (dto.parentPageId && dto.parentPageId === dto.pageId) {
|
||||
throw new BadRequestException('A page cannot be its own parent');
|
||||
}
|
||||
|
||||
let parentPageId = null;
|
||||
if (movedPage.parentPageId === dto.parentPageId) {
|
||||
parentPageId = undefined;
|
||||
|
||||
@@ -35,6 +35,10 @@ import {
|
||||
AUDIT_SERVICE,
|
||||
IAuditService,
|
||||
} from '../../integrations/audit/audit.service';
|
||||
import {
|
||||
PAGE_ANALYTICS_SERVICE,
|
||||
IPageAnalyticsService,
|
||||
} from '../../integrations/page-analytics/page-analytics.service';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('shares')
|
||||
@@ -47,6 +51,8 @@ export class ShareController {
|
||||
private readonly pageAccessService: PageAccessService,
|
||||
private readonly licenseCheckService: LicenseCheckService,
|
||||
@Inject(AUDIT_SERVICE) private readonly auditService: IAuditService,
|
||||
@Inject(PAGE_ANALYTICS_SERVICE)
|
||||
private readonly pageAnalyticsService: IPageAnalyticsService,
|
||||
) {}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@@ -79,6 +85,14 @@ export class ShareController {
|
||||
throw new NotFoundException('Shared page not found');
|
||||
}
|
||||
|
||||
void this.pageAnalyticsService.track({
|
||||
pageId: shareData.page.id,
|
||||
workspaceId: workspace.id,
|
||||
spaceId: shareData.page.spaceId,
|
||||
shareId: shareData.share.id,
|
||||
userId: null,
|
||||
});
|
||||
|
||||
return {
|
||||
...shareData,
|
||||
features: this.licenseCheckService.resolveFeatures(
|
||||
|
||||
@@ -15,8 +15,4 @@ export class UpdateSpaceDto extends PartialType(CreateSpaceDto) {
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
allowViewerComments: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
hideCommentsFromViewers: boolean;
|
||||
}
|
||||
|
||||
@@ -30,35 +30,6 @@ import {
|
||||
IAuditService,
|
||||
} from '../../../integrations/audit/audit.service';
|
||||
|
||||
export function validateExclusiveCommentSettings(
|
||||
dto: Partial<
|
||||
Pick<UpdateSpaceDto, 'allowViewerComments' | 'hideCommentsFromViewers'>
|
||||
>,
|
||||
settingsBefore: Record<string, any>,
|
||||
): void {
|
||||
if (
|
||||
dto.allowViewerComments === undefined &&
|
||||
dto.hideCommentsFromViewers === undefined
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const allowViewerComments =
|
||||
dto.allowViewerComments ??
|
||||
settingsBefore.comments?.allowViewerComments ??
|
||||
false;
|
||||
const hideCommentsFromViewers =
|
||||
dto.hideCommentsFromViewers ??
|
||||
settingsBefore.comments?.hideCommentsFromViewers ??
|
||||
false;
|
||||
|
||||
if (allowViewerComments && hideCommentsFromViewers) {
|
||||
throw new BadRequestException(
|
||||
"'Allow viewers to comment' and 'Hide comments from viewers' cannot both be enabled",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SpaceService {
|
||||
constructor(
|
||||
@@ -170,8 +141,7 @@ export class SpaceService {
|
||||
|
||||
if (
|
||||
typeof updateSpaceDto.disablePublicSharing !== 'undefined' ||
|
||||
typeof updateSpaceDto.allowViewerComments !== 'undefined' ||
|
||||
typeof updateSpaceDto.hideCommentsFromViewers !== 'undefined'
|
||||
typeof updateSpaceDto.allowViewerComments !== 'undefined'
|
||||
) {
|
||||
const workspace = await this.workspaceRepo.findById(workspaceId, {
|
||||
withLicenseKey: true,
|
||||
@@ -198,17 +168,6 @@ export class SpaceService {
|
||||
) {
|
||||
throw new ForbiddenException('This feature requires a valid license');
|
||||
}
|
||||
|
||||
if (
|
||||
updateSpaceDto.hideCommentsFromViewers === true &&
|
||||
!this.licenseCheckService.hasFeature(
|
||||
workspace.licenseKey,
|
||||
Feature.HIDE_COMMENTS,
|
||||
workspace.plan,
|
||||
)
|
||||
) {
|
||||
throw new ForbiddenException('This feature requires a valid license');
|
||||
}
|
||||
}
|
||||
|
||||
const spaceBefore = await this.spaceRepo.findById(
|
||||
@@ -217,8 +176,6 @@ export class SpaceService {
|
||||
);
|
||||
const settingsBefore = (spaceBefore?.settings ?? {}) as Record<string, any>;
|
||||
|
||||
validateExclusiveCommentSettings(updateSpaceDto, settingsBefore);
|
||||
|
||||
const before: Record<string, any> = {};
|
||||
const after: Record<string, any> = {};
|
||||
|
||||
@@ -261,23 +218,6 @@ export class SpaceService {
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof updateSpaceDto.hideCommentsFromViewers !== 'undefined') {
|
||||
const prev = settingsBefore?.comments?.hideCommentsFromViewers ?? false;
|
||||
if (prev !== updateSpaceDto.hideCommentsFromViewers) {
|
||||
before.hideCommentsFromViewers = prev;
|
||||
after.hideCommentsFromViewers =
|
||||
updateSpaceDto.hideCommentsFromViewers;
|
||||
}
|
||||
|
||||
await this.spaceRepo.updateCommentSettings(
|
||||
updateSpaceDto.spaceId,
|
||||
workspaceId,
|
||||
'hideCommentsFromViewers',
|
||||
updateSpaceDto.hideCommentsFromViewers,
|
||||
trx,
|
||||
);
|
||||
}
|
||||
|
||||
updatedSpace = await this.spaceRepo.updateSpace(
|
||||
{
|
||||
name: updateSpaceDto.name,
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.createTable('page_analytics')
|
||||
.ifNotExists()
|
||||
.addColumn('id', 'uuid', (col) =>
|
||||
col.primaryKey().defaultTo(sql`gen_uuid_v7()`),
|
||||
)
|
||||
.addColumn('workspace_id', 'uuid', (col) =>
|
||||
col.references('workspaces.id').onDelete('cascade').notNull(),
|
||||
)
|
||||
.addColumn('page_id', 'uuid', (col) =>
|
||||
col.references('pages.id').onDelete('cascade').notNull(),
|
||||
)
|
||||
.addColumn('space_id', 'uuid', (col) =>
|
||||
col.references('spaces.id').onDelete('cascade'),
|
||||
)
|
||||
.addColumn('user_id', 'uuid', (col) =>
|
||||
col.references('users.id').onDelete('set null'),
|
||||
)
|
||||
.addColumn('share_id', 'uuid')
|
||||
.addColumn('visitor_id', 'varchar', (col) => col.notNull())
|
||||
.addColumn('view_date', 'varchar', (col) => col.notNull())
|
||||
.addColumn('hits', 'int8', (col) => col.notNull().defaultTo(1))
|
||||
.addColumn('last_viewed_at', 'timestamptz', (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.addColumn('created_at', 'timestamptz', (col) =>
|
||||
col.notNull().defaultTo(sql`now()`),
|
||||
)
|
||||
.execute();
|
||||
|
||||
await db.schema
|
||||
.createIndex('idx_page_analytics_workspace_page_date')
|
||||
.ifNotExists()
|
||||
.on('page_analytics')
|
||||
.columns(['workspace_id', 'page_id', 'view_date'])
|
||||
.execute();
|
||||
|
||||
await sql`
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS
|
||||
uq_page_analytics_workspace_page_identity
|
||||
ON page_analytics (
|
||||
workspace_id,
|
||||
page_id,
|
||||
COALESCE(user_id::text, visitor_id)
|
||||
)
|
||||
`.execute(db);
|
||||
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.addColumn('page_analytics_retention_days', 'int8', (col) => col)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await db.schema
|
||||
.alterTable('workspaces')
|
||||
.dropColumn('page_analytics_retention_days')
|
||||
.execute();
|
||||
|
||||
await db.schema.dropTable('page_analytics').ifExists().execute();
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
CacheKey,
|
||||
PERMISSION_CACHE_TTL_MS,
|
||||
} from '../../../common/helpers/cache-keys';
|
||||
import { SpaceRole } from '../../../common/helpers/types/permission';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceMemberRepo {
|
||||
@@ -279,32 +278,6 @@ export class SpaceMemberRepo {
|
||||
return new Set(rows.map((r) => r.userId));
|
||||
}
|
||||
|
||||
async getUserIdsWithSpaceEditAccess(
|
||||
userIds: string[],
|
||||
spaceId: string,
|
||||
): Promise<Set<string>> {
|
||||
if (userIds.length === 0) return new Set();
|
||||
|
||||
const rows = await this.db
|
||||
.selectFrom('spaceMembers')
|
||||
.select('userId')
|
||||
.where('userId', 'in', userIds)
|
||||
.where('spaceId', '=', spaceId)
|
||||
.where('spaceMembers.role', 'in', [SpaceRole.ADMIN, SpaceRole.WRITER])
|
||||
.unionAll(
|
||||
this.db
|
||||
.selectFrom('spaceMembers')
|
||||
.innerJoin('groupUsers', 'groupUsers.groupId', 'spaceMembers.groupId')
|
||||
.select('groupUsers.userId')
|
||||
.where('groupUsers.userId', 'in', userIds)
|
||||
.where('spaceMembers.spaceId', '=', spaceId)
|
||||
.where('spaceMembers.role', 'in', [SpaceRole.ADMIN, SpaceRole.WRITER]),
|
||||
)
|
||||
.execute();
|
||||
|
||||
return new Set(rows.map((r) => r.userId));
|
||||
}
|
||||
|
||||
async getSpaceIdsByGroupId(groupId: string): Promise<string[]> {
|
||||
const rows = await this.db
|
||||
.selectFrom('spaceMembers')
|
||||
|
||||
@@ -149,17 +149,6 @@ export class SpaceRepo {
|
||||
.executeTakeFirst();
|
||||
}
|
||||
|
||||
async getSpaceSettings(
|
||||
spaceId: string,
|
||||
): Promise<Record<string, any> | null> {
|
||||
const row = await this.db
|
||||
.selectFrom('spaces')
|
||||
.select('settings')
|
||||
.where('id', '=', spaceId)
|
||||
.executeTakeFirst();
|
||||
return (row?.settings as Record<string, any> | undefined) ?? null;
|
||||
}
|
||||
|
||||
async insertSpace(
|
||||
insertableSpace: InsertableSpace,
|
||||
trx?: KyselyTransaction,
|
||||
|
||||
+16
@@ -437,6 +437,7 @@ export interface WorkspaceInvitations {
|
||||
}
|
||||
|
||||
export interface Workspaces {
|
||||
pageAnalyticsRetentionDays: Generated<number>;
|
||||
auditRetentionDays: Generated<number>;
|
||||
trashRetentionDays: Generated<number>;
|
||||
billingEmail: string | null;
|
||||
@@ -544,6 +545,20 @@ export interface PagePermissions {
|
||||
updatedAt: Generated<Timestamp>;
|
||||
}
|
||||
|
||||
export interface PageAnalytics {
|
||||
id: Generated<string>;
|
||||
workspaceId: string;
|
||||
pageId: string;
|
||||
spaceId: string | null;
|
||||
shareId: string | null;
|
||||
userId: string | null;
|
||||
visitorId: string;
|
||||
viewDate: string;
|
||||
hits: Generated<number>;
|
||||
lastViewedAt: Generated<Timestamp>;
|
||||
createdAt: Generated<Timestamp>;
|
||||
}
|
||||
|
||||
export interface PageVerifications {
|
||||
id: Generated<string>;
|
||||
pageId: string;
|
||||
@@ -662,6 +677,7 @@ export interface DB {
|
||||
pagePermissions: PagePermissions;
|
||||
pageHistory: PageHistory;
|
||||
pageLabels: PageLabels;
|
||||
pageAnalytics: PageAnalytics;
|
||||
pageVerifications: PageVerifications;
|
||||
pageVerifiers: PageVerifiers;
|
||||
pages: Pages;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Insertable, Selectable, Updateable } from 'kysely';
|
||||
import {
|
||||
AiChats,
|
||||
PageAnalytics as _PageAnalytics,
|
||||
AiChatMessages,
|
||||
Attachments,
|
||||
BaseProperties,
|
||||
@@ -107,6 +108,10 @@ export type PageHistory = Selectable<History>;
|
||||
export type InsertablePageHistory = Insertable<History>;
|
||||
export type UpdatablePageHistory = Updateable<Omit<History, 'id'>>;
|
||||
|
||||
export type PageAnalytics = Selectable<_PageAnalytics>;
|
||||
export type InsertablePageAnalytics = Insertable<_PageAnalytics>;
|
||||
export type UpdatablePageAnalytics = Updateable<Omit<_PageAnalytics, 'id'>>;
|
||||
|
||||
// Comment
|
||||
export type Comment = Selectable<Comments>;
|
||||
export type InsertableComment = Insertable<Comments>;
|
||||
|
||||
+1
-1
Submodule apps/server/src/ee updated: f396df9bc5...94dab45633
@@ -0,0 +1,14 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { PAGE_ANALYTICS_SERVICE, NoopPageAnalyticsService } from './page-analytics.service';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [
|
||||
{
|
||||
provide: PAGE_ANALYTICS_SERVICE,
|
||||
useClass: NoopPageAnalyticsService,
|
||||
},
|
||||
],
|
||||
exports: [PAGE_ANALYTICS_SERVICE],
|
||||
})
|
||||
export class NoopPageAnalyticsModule {}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
export type PageAnalyticsPayload = {
|
||||
pageId: string;
|
||||
workspaceId?: string;
|
||||
spaceId?: string;
|
||||
shareId?: string;
|
||||
userId?: string | null;
|
||||
visitorId?: string;
|
||||
};
|
||||
|
||||
export const PAGE_ANALYTICS_SERVICE = Symbol('PAGE_ANALYTICS_SERVICE');
|
||||
|
||||
export interface IPageAnalyticsService {
|
||||
track(payload: PageAnalyticsPayload): void | Promise<void>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class NoopPageAnalyticsService implements IPageAnalyticsService {
|
||||
track(_payload: PageAnalyticsPayload): void {}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export enum QueueName {
|
||||
HISTORY_QUEUE = '{history-queue}',
|
||||
NOTIFICATION_QUEUE = '{notification-queue}',
|
||||
AUDIT_QUEUE = '{audit-queue}',
|
||||
PAGE_ANALYTICS_QUEUE = '{page-analytics-queue}',
|
||||
BASE_QUEUE = '{base-queue}',
|
||||
}
|
||||
|
||||
@@ -81,6 +82,8 @@ export enum QueueJob {
|
||||
|
||||
AUDIT_LOG = 'audit-log',
|
||||
AUDIT_CLEANUP = 'audit-cleanup',
|
||||
PAGE_ANALYTICS_TRACK = 'page-analytics-track',
|
||||
PAGE_ANALYTICS_CLEANUP = 'page-analytics-cleanup',
|
||||
|
||||
PDF_EXPORT_TASK = 'pdf-export-task',
|
||||
PDF_EXPORT_CLEANUP = 'pdf-export-cleanup',
|
||||
|
||||
@@ -92,6 +92,14 @@ import { GeneralQueueProcessor } from './processors/general-queue.processor';
|
||||
attempts: 3,
|
||||
},
|
||||
}),
|
||||
BullModule.registerQueue({
|
||||
name: QueueName.PAGE_ANALYTICS_QUEUE,
|
||||
defaultJobOptions: {
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
attempts: 3,
|
||||
},
|
||||
}),
|
||||
BullModule.registerQueue({
|
||||
name: QueueName.BASE_QUEUE,
|
||||
defaultJobOptions: {
|
||||
|
||||
@@ -3,8 +3,6 @@ import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { Cache } from 'cache-manager';
|
||||
import { Server, Socket } from 'socket.io';
|
||||
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
||||
import { SpaceRepo } from '@docmost/db/repos/space/space.repo';
|
||||
import { PageAccessService } from '../core/page/page-access/page-access.service';
|
||||
import {
|
||||
TREE_EVENTS,
|
||||
WS_SPACE_RESTRICTION_CACHE_PREFIX,
|
||||
@@ -19,8 +17,6 @@ export class WsService {
|
||||
|
||||
constructor(
|
||||
private readonly pagePermissionRepo: PagePermissionRepo,
|
||||
private readonly spaceRepo: SpaceRepo,
|
||||
private readonly pageAccessService: PageAccessService,
|
||||
@Inject(CACHE_MANAGER) private readonly cacheManager: Cache,
|
||||
) {}
|
||||
|
||||
@@ -71,24 +67,9 @@ export class WsService {
|
||||
spaceId: string,
|
||||
pageId: string,
|
||||
data: any,
|
||||
opts?: { bypassVisibilityCheck?: boolean },
|
||||
): Promise<void> {
|
||||
const room = getSpaceRoomName(spaceId);
|
||||
|
||||
if (
|
||||
!opts?.bypassVisibilityCheck &&
|
||||
(await this.spaceHidesCommentsFromViewers(spaceId))
|
||||
) {
|
||||
await this.broadcastToUsersMatching(room, null, data, (candidateIds) =>
|
||||
this.pageAccessService.filterUserIdsWithPageEditAccess(
|
||||
spaceId,
|
||||
pageId,
|
||||
candidateIds,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const hasRestrictions = await this.spaceHasRestrictions(spaceId);
|
||||
if (!hasRestrictions) {
|
||||
this.server.to(room).emit('message', data);
|
||||
@@ -137,17 +118,6 @@ export class WsService {
|
||||
excludeSocketId: string | null,
|
||||
pageId: string,
|
||||
data: any,
|
||||
): Promise<void> {
|
||||
await this.broadcastToUsersMatching(room, excludeSocketId, data, (ids) =>
|
||||
this.pagePermissionRepo.getUserIdsWithPageAccess(pageId, ids),
|
||||
);
|
||||
}
|
||||
|
||||
private async broadcastToUsersMatching(
|
||||
room: string,
|
||||
excludeSocketId: string | null,
|
||||
data: any,
|
||||
filterUserIds: (candidateUserIds: string[]) => Promise<string[]>,
|
||||
): Promise<void> {
|
||||
const sockets = await this.server.in(room).fetchSockets();
|
||||
|
||||
@@ -174,9 +144,15 @@ export class WsService {
|
||||
const candidateUserIds = Array.from(userSocketMap.keys());
|
||||
if (candidateUserIds.length === 0) return;
|
||||
|
||||
const allowedSet = new Set(await filterUserIds(candidateUserIds));
|
||||
const authorizedUserIds =
|
||||
await this.pagePermissionRepo.getUserIdsWithPageAccess(
|
||||
pageId,
|
||||
candidateUserIds,
|
||||
);
|
||||
|
||||
const authorizedSet = new Set(authorizedUserIds);
|
||||
for (const [userId, userSockets] of userSocketMap) {
|
||||
if (allowedSet.has(userId)) {
|
||||
if (authorizedSet.has(userId)) {
|
||||
for (const socket of userSockets) {
|
||||
socket.emit('message', data);
|
||||
}
|
||||
@@ -200,13 +176,6 @@ export class WsService {
|
||||
return hasRestrictions;
|
||||
}
|
||||
|
||||
private async spaceHidesCommentsFromViewers(
|
||||
spaceId: string,
|
||||
): Promise<boolean> {
|
||||
const settings = await this.spaceRepo.getSpaceSettings(spaceId);
|
||||
return settings?.comments?.hideCommentsFromViewers === true;
|
||||
}
|
||||
|
||||
private extractPageId(data: any): string | null {
|
||||
switch (data.operation) {
|
||||
case 'addTreeNode':
|
||||
|
||||
+8
-8
@@ -23,11 +23,11 @@
|
||||
"@casl/ability": "6.8.0",
|
||||
"@docmost/editor-ext": "workspace:*",
|
||||
"@floating-ui/dom": "1.7.3",
|
||||
"@hocuspocus/common": "4.5.0",
|
||||
"@hocuspocus/provider": "4.5.0",
|
||||
"@hocuspocus/provider-react": "4.5.0",
|
||||
"@hocuspocus/server": "4.5.0",
|
||||
"@hocuspocus/transformer": "4.5.0",
|
||||
"@hocuspocus/common": "4.4.0",
|
||||
"@hocuspocus/provider": "4.4.0",
|
||||
"@hocuspocus/provider-react": "4.4.0",
|
||||
"@hocuspocus/server": "4.4.0",
|
||||
"@hocuspocus/transformer": "4.4.0",
|
||||
"@joplin/turndown": "4.0.82",
|
||||
"@joplin/turndown-plugin-gfm": "1.0.64",
|
||||
"@sindresorhus/slugify": "3.0.0",
|
||||
@@ -65,7 +65,7 @@
|
||||
"date-fns": "4.1.0",
|
||||
"diff": "8.0.3",
|
||||
"docx": "9.7.1",
|
||||
"dompurify": "3.4.13",
|
||||
"dompurify": "3.4.12",
|
||||
"fractional-indexing-jittered": "1.0.0",
|
||||
"highlight.js": "11.11.1",
|
||||
"image-dimensions": "2.5.0",
|
||||
@@ -81,12 +81,12 @@
|
||||
"yjs": "^13.6.30"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nx/js": "23.1.1",
|
||||
"@nx/js": "22.7.2",
|
||||
"@types/bytes": "3.1.5",
|
||||
"@types/qrcode": "1.5.6",
|
||||
"@types/turndown": "5.0.6",
|
||||
"concurrently": "10.0.4",
|
||||
"nx": "23.1.1",
|
||||
"nx": "22.7.2",
|
||||
"tsx": "^4.21.0"
|
||||
},
|
||||
"workspaces": {
|
||||
|
||||
Generated
+645
-864
File diff suppressed because it is too large
Load Diff
+4
-6
@@ -7,11 +7,11 @@ overrides:
|
||||
prosemirror-changeset: 2.4.0
|
||||
glob: 13.0.6
|
||||
ws: 8.21.0
|
||||
dompurify: 3.4.13
|
||||
mermaid: 11.16.1
|
||||
dompurify: 3.4.12
|
||||
mermaid: 11.15.0
|
||||
undici: 7.29.0
|
||||
tmp: 0.2.7
|
||||
nanoid@^3: 3.3.17
|
||||
nanoid@^3: 3.3.8
|
||||
lodash-es: 4.18.1
|
||||
express-rate-limit: 8.2.2
|
||||
flatted: 3.4.2
|
||||
@@ -22,11 +22,9 @@ overrides:
|
||||
ip-address: 10.3.1
|
||||
fast-uri: 3.1.5
|
||||
form-data@>=4.0.0 <4.0.6: 4.0.6
|
||||
nanoid@>=4.0.0 <5.1.16: 5.1.16
|
||||
nanoid@>=4.0.0 <5.0.9: 5.1.16
|
||||
esbuild@>=0.27.3 <0.28.1: 0.28.1
|
||||
'@opentelemetry/core@>=2.0.0 <2.8.0': 2.9.0
|
||||
js-yaml@>=3.0.0 <3.15.1: 3.15.1
|
||||
js-yaml@>=4.0.0 <4.3.1: 4.3.1
|
||||
shamefullyHoist: true
|
||||
minimumReleaseAge: 4320
|
||||
allowBuilds:
|
||||
|
||||
Reference in New Issue
Block a user