Files
gitmost/apps/client/src/lib/config.ts
claude code agent 180 36ae4bd3d3 feat(page-tree): gate compact tree density behind COMPACT_PAGE_TREE flag
Make the denser page-tree layout opt-in instead of hardcoded, so row
density can be toggled per deployment via the COMPACT_PAGE_TREE runtime
config flag.

- doc-tree: extract ROW_HEIGHT_STANDARD (32) / ROW_HEIGHT_COMPACT (26);
  default the virtualizer row stride to STANDARD density.
- client: isCompactPageTreeEnabled() in lib/config (reads
  COMPACT_PAGE_TREE, default true); used by space-tree and shared-tree
  to choose the row height.
- server: EnvironmentService.isCompactPageTreeEnabled() and expose
  COMPACT_PAGE_TREE through the window runtime config (static.module).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 16:54:09 +03:00

113 lines
2.8 KiB
TypeScript

import bytes from "bytes";
import { castToBoolean } from "@/lib/utils.tsx";
import { AvatarIconType } from "@/features/attachments/types/attachment.types.ts";
import { sanitizeUrl } from "@docmost/editor-ext";
declare global {
interface Window {
CONFIG?: Record<string, string>;
}
}
export function getAppName(): string {
return "Gitmost";
}
export function getAppUrl(): string {
return `${window.location.protocol}//${window.location.host}`;
}
export function getServerAppUrl(): string {
return getConfigValue("APP_URL");
}
export function getBackendUrl(): string {
return getAppUrl() + "/api";
}
export function getCollaborationUrl(): string {
const baseUrl =
getConfigValue("COLLAB_URL") ||
(import.meta.env.DEV ? process.env.APP_URL : getAppUrl());
const collabUrl = new URL("/collab", baseUrl);
collabUrl.protocol = collabUrl.protocol === "https:" ? "wss:" : "ws:";
return collabUrl.toString();
}
export function getSubdomainHost(): string {
return getConfigValue("SUBDOMAIN_HOST");
}
export function isCloud(): boolean {
return castToBoolean(getConfigValue("CLOUD"));
}
export function isCompactPageTreeEnabled(): boolean {
return castToBoolean(getConfigValue("COMPACT_PAGE_TREE", "true"));
}
export function getAvatarUrl(
avatarUrl: string,
type: AvatarIconType = AvatarIconType.AVATAR,
) {
if (!avatarUrl) return null;
if (avatarUrl?.startsWith("http")) return avatarUrl;
return getBackendUrl() + `/attachments/img/${type}/` + encodeURI(avatarUrl);
}
export function getSpaceUrl(spaceSlug: string) {
return "/s/" + spaceSlug;
}
export function getFileUrl(src: string) {
if (!src) return src;
if (src.startsWith("http")) return src;
if (src.startsWith("/api/")) {
// Remove the '/api' prefix
return getBackendUrl() + src.substring(4);
}
if (src.startsWith("/files/")) {
return getBackendUrl() + src;
}
return sanitizeUrl(src);
}
export function getFileUploadSizeLimit() {
const limit = getConfigValue("FILE_UPLOAD_SIZE_LIMIT", "50mb");
return bytes(limit);
}
export function getFileImportSizeLimit() {
const limit = getConfigValue("FILE_IMPORT_SIZE_LIMIT", "200mb");
return bytes(limit);
}
export function getDrawioUrl() {
return getConfigValue("DRAWIO_URL", "https://embed.diagrams.net");
}
export function getBillingTrialDays() {
return getConfigValue("BILLING_TRIAL_DAYS");
}
export function getPostHogHost() {
return getConfigValue("POSTHOG_HOST");
}
export function isPostHogEnabled(): boolean {
return Boolean(getPostHogHost() && getPostHogKey());
}
export function getPostHogKey() {
return getConfigValue("POSTHOG_KEY");
}
function getConfigValue(key: string, defaultValue: string = undefined): string {
const rawValue = import.meta.env.DEV
? process?.env?.[key]
: window?.CONFIG?.[key];
return rawValue ?? defaultValue;
}