mirror of
https://github.com/docmost/docmost.git
synced 2026-08-21 11:31:05 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd920ec024 |
@@ -40,7 +40,6 @@ 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";
|
||||
@@ -128,7 +127,6 @@ 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 />} />}
|
||||
|
||||
@@ -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 type { QueryParams } from "@/lib/types.ts";
|
||||
import { 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,11 +14,6 @@ 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: "" };
|
||||
@@ -105,31 +100,6 @@ 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,7 +15,6 @@ import {
|
||||
IconSparkles,
|
||||
IconHistory,
|
||||
IconShieldCheck,
|
||||
IconChartBar,
|
||||
} from "@tabler/icons-react";
|
||||
import { Link, useLocation } from "react-router-dom";
|
||||
import classes from "./settings.module.css";
|
||||
@@ -39,7 +38,6 @@ 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";
|
||||
@@ -127,13 +125,6 @@ const groupedData: DataGroup[] = [
|
||||
role: "owner",
|
||||
env: "selfhosted",
|
||||
},
|
||||
{
|
||||
label: "Page analytics",
|
||||
icon: IconChartBar,
|
||||
path: "/settings/analytics",
|
||||
feature: Feature.PAGE_ANALYTICS,
|
||||
role: "owner",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -234,9 +225,6 @@ export default function SettingsSidebar() {
|
||||
case "Verified pages":
|
||||
prefetchHandler = prefetchVerifiedPages;
|
||||
break;
|
||||
case "Page analytics":
|
||||
prefetchHandler = prefetchPageAnalytics;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
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");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
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,17 +1,15 @@
|
||||
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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>{t("404 page not found")} - Docmost</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("404 page not found")} />
|
||||
<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,5 +1,3 @@
|
||||
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";
|
||||
@@ -15,6 +13,7 @@ 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();
|
||||
@@ -40,9 +39,7 @@ export default function AiSettings() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>AI settings - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title="AI settings" />
|
||||
<SettingsTitle title={t("AI settings")} />
|
||||
|
||||
<Tabs color="dark" value={activeTab} onChange={handleTabChange}>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
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 { getAppName, getAppUrl } from "@/lib/config";
|
||||
import { 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";
|
||||
@@ -17,6 +16,7 @@ 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,11 +49,7 @@ export default function UserApiKeys() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("API keys")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("API keys")} />
|
||||
|
||||
<SettingsTitle title={t("API keys")} />
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
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";
|
||||
@@ -15,6 +13,7 @@ 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();
|
||||
@@ -47,11 +46,7 @@ export default function WorkspaceApiKeys() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("API management")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("API management")} />
|
||||
|
||||
<SettingsTitle title={t("API management")} />
|
||||
|
||||
|
||||
@@ -10,11 +10,9 @@ 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 {
|
||||
@@ -26,8 +24,25 @@ 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 { daysToRetention, retentionToDays, RetentionUnit } from "@/ee/utils";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
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();
|
||||
@@ -81,11 +96,7 @@ export default function AuditLogs() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Audit log")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Audit log")} />
|
||||
|
||||
<SettingsTitle title={t("Audit log")} />
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
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";
|
||||
@@ -9,6 +7,7 @@ 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();
|
||||
@@ -20,9 +19,7 @@ export default function Billing() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>Billing - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title="Billing" />
|
||||
<SettingsTitle title="Billing" />
|
||||
|
||||
<BillingTrial />
|
||||
|
||||
@@ -15,7 +15,6 @@ 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',
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
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";
|
||||
@@ -9,6 +7,7 @@ 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);
|
||||
@@ -21,9 +20,7 @@ export default function License() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>License - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title="License" />
|
||||
<SettingsTitle title="License" />
|
||||
|
||||
<ActivateLicenseForm />
|
||||
|
||||
@@ -1,421 +0,0 @@
|
||||
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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
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" });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
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,17 +1,16 @@
|
||||
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();
|
||||
@@ -68,11 +67,7 @@ export default function VerifiedPages() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Verified pages")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Verified pages")} />
|
||||
|
||||
<SettingsTitle title={t("Verified pages")} />
|
||||
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Login")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Login")} />
|
||||
|
||||
<CloudLoginForm />
|
||||
</>
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { SetupWorkspaceForm } from "@/features/auth/components/setup-workspace-form.tsx";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import React from "react";
|
||||
import { getAppName } from "@/lib/config.ts";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function CreateWorkspace() {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>Create Workspace - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title="Create Workspace" />
|
||||
<SetupWorkspaceForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { getAppName, isCloud } from "@/lib/config.ts";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
import SettingsTitle from "@/components/settings/settings-title.tsx";
|
||||
import {
|
||||
Alert,
|
||||
@@ -37,6 +36,7 @@ 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,9 +64,7 @@ export default function Security() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>Security - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title="Security" />
|
||||
<SettingsTitle title={t("Security")} />
|
||||
|
||||
<EnforceMfa />
|
||||
|
||||
@@ -22,8 +22,6 @@ 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 {
|
||||
@@ -44,6 +42,7 @@ 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();
|
||||
@@ -247,11 +246,7 @@ export default function TemplateEditor() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Edit template")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Edit template")} />
|
||||
|
||||
{editorToolbarEnabled && editor && (
|
||||
<FixedToolbar editor={editor} templateMode />
|
||||
|
||||
@@ -13,11 +13,9 @@ 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,
|
||||
@@ -31,6 +29,7 @@ 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();
|
||||
@@ -102,11 +101,7 @@ export default function TemplateList() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Templates")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Templates")} />
|
||||
|
||||
<Container size="900" pt="xl">
|
||||
<Group justify="space-between" mb="xl">
|
||||
|
||||
@@ -14,33 +14,3 @@ 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,13 +1,10 @@
|
||||
import { ForgotPasswordForm } from "@/features/auth/components/forgot-password-form";
|
||||
import { getAppName } from "@/lib/config";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function ForgotPassword() {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>Forgot Password - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title="Forgot Password" />
|
||||
<ForgotPasswordForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>{t("Invitation Signup")} - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Invitation Signup")} />
|
||||
<InviteSignUpForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Login")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Login")} />
|
||||
<LoginForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
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();
|
||||
@@ -23,11 +22,7 @@ export default function PasswordReset() {
|
||||
if (isError || !resetToken) {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Password Reset")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Password Reset")} />
|
||||
<Container my={40}>
|
||||
<Text size="lg" ta="center">
|
||||
{t("Invalid or expired password reset link")}
|
||||
@@ -49,11 +44,7 @@ export default function PasswordReset() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Password Reset")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Password Reset")} />
|
||||
<PasswordResetForm resetToken={resetToken} />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
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();
|
||||
@@ -35,11 +34,7 @@ export default function SetupWorkspace() {
|
||||
) {
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Setup Workspace")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Setup Workspace")} />
|
||||
<SetupWorkspaceForm />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -2,20 +2,15 @@ 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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Home")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Home")} />
|
||||
<Container size={"900"} pt="xl">
|
||||
<HomeAiPrompt />
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@ 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";
|
||||
@@ -29,6 +27,7 @@ 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();
|
||||
@@ -82,11 +81,7 @@ export default function LabelPage() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{labelName} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={labelName} />
|
||||
|
||||
<Container size={820} py="xl">
|
||||
<Stack gap="lg">
|
||||
|
||||
@@ -3,7 +3,6 @@ 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";
|
||||
@@ -18,6 +17,7 @@ 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,9 +110,10 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
||||
paddingTop: "calc(var(--page-header-height) + 6px)",
|
||||
}}
|
||||
>
|
||||
<Helmet>
|
||||
<title>{`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle
|
||||
title={`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}
|
||||
withAppName={false}
|
||||
/>
|
||||
<MemoizedPageHeader readOnly={!canEdit} />
|
||||
<div
|
||||
style={{
|
||||
@@ -159,9 +160,10 @@ function PageContent({ pageSlug }: { pageSlug: string | undefined }) {
|
||||
return (
|
||||
page && (
|
||||
<div>
|
||||
<Helmet>
|
||||
<title>{`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle
|
||||
title={`${page?.icon || ""} ${getPageTitle(page?.title, page?.isBase, t)}`}
|
||||
withAppName={false}
|
||||
/>
|
||||
|
||||
<MemoizedPageHeader readOnly={!canEdit} />
|
||||
|
||||
|
||||
@@ -5,21 +5,16 @@ 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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Preferences")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Preferences")} />
|
||||
<SettingsTitle title={t("Preferences")} />
|
||||
|
||||
<AccountTheme />
|
||||
|
||||
@@ -4,22 +4,17 @@ 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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("My Profile")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("My Profile")} />
|
||||
<SettingsTitle title={t("My Profile")} />
|
||||
|
||||
<AccountAvatar />
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Manage Group")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Manage Group")} />
|
||||
<SettingsTitle title={t("Manage Group")} />
|
||||
<GroupDetails />
|
||||
<GroupMembersList />
|
||||
|
||||
@@ -3,9 +3,8 @@ 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();
|
||||
@@ -13,9 +12,7 @@ export default function Groups() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>{t("Groups")} - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Groups")} />
|
||||
<SettingsTitle title={t("Groups")} />
|
||||
|
||||
<Group my="md" justify="flex-end">
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Public sharing")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Public sharing")} />
|
||||
<SettingsTitle title={t("Public sharing")} />
|
||||
|
||||
<Alert variant="light" color="blue" icon={<IconInfoCircle />}>
|
||||
|
||||
@@ -3,9 +3,8 @@ 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();
|
||||
@@ -13,11 +12,7 @@ export default function Spaces() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Spaces")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Spaces")} />
|
||||
<SettingsTitle title={t("Spaces")} />
|
||||
|
||||
<Group my="md" justify="flex-end">
|
||||
|
||||
@@ -6,11 +6,10 @@ 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();
|
||||
@@ -38,11 +37,7 @@ export default function WorkspaceMembers() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Members")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Members")} />
|
||||
<SettingsTitle title={t("Members")} />
|
||||
|
||||
{/* <WorkspaceInviteSection /> */}
|
||||
|
||||
@@ -2,21 +2,19 @@ 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 { getAppName, isCloud } from "@/lib/config.ts";
|
||||
import { Helmet } from "react-helmet-async";
|
||||
import { isCloud } from "@/lib/config.ts";
|
||||
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 (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>Workspace Settings - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title="Workspace Settings" />
|
||||
<SettingsTitle title={t("General")} />
|
||||
<WorkspaceIcon />
|
||||
<WorkspaceNameForm />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
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";
|
||||
@@ -14,6 +13,7 @@ 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,12 +56,14 @@ export default function SharedPage() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Helmet>
|
||||
<title>{`${data?.page?.title || t("untitled")}`}</title>
|
||||
<DocumentTitle
|
||||
title={data?.page?.title || t("untitled")}
|
||||
withAppName={false}
|
||||
>
|
||||
{!data?.share.searchIndexing && (
|
||||
<meta name="robots" content="noindex" />
|
||||
)}
|
||||
</Helmet>
|
||||
</DocumentTitle>
|
||||
|
||||
<Container fluid={fullWidth} size={fullWidth ? undefined : 900} p={0}>
|
||||
<ReadonlyPageEditor
|
||||
|
||||
@@ -2,8 +2,7 @@ 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 {getAppName} from "@/lib/config.ts";
|
||||
import {Helmet} from "react-helmet-async";
|
||||
import { DocumentTitle } from "@/components/ui/document-title.tsx";
|
||||
|
||||
export default function SpaceHome() {
|
||||
const {spaceSlug} = useParams();
|
||||
@@ -11,9 +10,7 @@ export default function SpaceHome() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>{space?.name || 'Overview'} - {getAppName()}</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={space?.name || 'Overview'} />
|
||||
<Container size={"900"} pt="xl">
|
||||
{space && <SpaceHomeTabs/>}
|
||||
</Container>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
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();
|
||||
@@ -22,11 +21,7 @@ export default function Spaces() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>
|
||||
{t("Spaces")} - {getAppName()}
|
||||
</title>
|
||||
</Helmet>
|
||||
<DocumentTitle title={t("Spaces")} />
|
||||
|
||||
<Container size={"800"} pt="xl">
|
||||
<Group justify="space-between" mb="xl">
|
||||
|
||||
@@ -26,7 +26,6 @@ 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 = [];
|
||||
@@ -51,7 +50,6 @@ try {
|
||||
}),
|
||||
LoggerModule,
|
||||
NoopAuditModule,
|
||||
NoopPageAnalyticsModule,
|
||||
CoreModule,
|
||||
DatabaseModule,
|
||||
EnvironmentModule,
|
||||
|
||||
@@ -15,7 +15,6 @@ 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',
|
||||
|
||||
@@ -42,7 +42,6 @@ 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,7 +13,6 @@ export enum WorkspaceCaslSubject {
|
||||
Attachment = 'attachment',
|
||||
API = 'api_key',
|
||||
Audit = 'audit',
|
||||
PageAnalytics = 'page_analytics'
|
||||
}
|
||||
|
||||
export type IWorkspaceAbility =
|
||||
@@ -23,5 +22,4 @@ export type IWorkspaceAbility =
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.Group]
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.Attachment]
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.API]
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.Audit]
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.PageAnalytics];
|
||||
| [WorkspaceCaslAction, WorkspaceCaslSubject.Audit];
|
||||
|
||||
@@ -51,10 +51,6 @@ 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)
|
||||
@@ -69,7 +65,6 @@ 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)
|
||||
@@ -93,13 +88,6 @@ 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'
|
||||
|
||||
@@ -35,10 +35,6 @@ 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')
|
||||
@@ -51,8 +47,6 @@ 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)
|
||||
@@ -85,14 +79,6 @@ 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(
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
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();
|
||||
}
|
||||
-16
@@ -437,7 +437,6 @@ export interface WorkspaceInvitations {
|
||||
}
|
||||
|
||||
export interface Workspaces {
|
||||
pageAnalyticsRetentionDays: Generated<number>;
|
||||
auditRetentionDays: Generated<number>;
|
||||
trashRetentionDays: Generated<number>;
|
||||
billingEmail: string | null;
|
||||
@@ -545,20 +544,6 @@ 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;
|
||||
@@ -677,7 +662,6 @@ export interface DB {
|
||||
pagePermissions: PagePermissions;
|
||||
pageHistory: PageHistory;
|
||||
pageLabels: PageLabels;
|
||||
pageAnalytics: PageAnalytics;
|
||||
pageVerifications: PageVerifications;
|
||||
pageVerifiers: PageVerifiers;
|
||||
pages: Pages;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Insertable, Selectable, Updateable } from 'kysely';
|
||||
import {
|
||||
AiChats,
|
||||
PageAnalytics as _PageAnalytics,
|
||||
AiChatMessages,
|
||||
Attachments,
|
||||
BaseProperties,
|
||||
@@ -108,10 +107,6 @@ 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: 94dab45633...05529bcf97
@@ -1,14 +0,0 @@
|
||||
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 {}
|
||||
@@ -1,21 +0,0 @@
|
||||
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,7 +9,6 @@ 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}',
|
||||
}
|
||||
|
||||
@@ -82,8 +81,6 @@ 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,14 +92,6 @@ 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: {
|
||||
|
||||
Reference in New Issue
Block a user