feat: add support for disabling specific tools in self-hosting

- Introduced build-time and runtime options to disable tools for compliance or security.
- Updated documentation to include instructions for disabling tools in Docker and Kubernetes setups.
- Added translations for disabled tool messages in multiple languages.
- Implemented logic to filter out disabled tools from the toolbox and shortcuts in the application.
- Created utility functions to manage disabled tools configuration.
This commit is contained in:
alam00000 committed 2026-03-28 23:45:17 +05:30
1 parent 59ebb4d358
commit 9a7cf1636b
30 files changed
+417 -7

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
import type { AppConfig } from '@/types';
const disabledToolsSet = new Set<string>(__DISABLED_TOOLS__);
let runtimeConfigLoaded = false;
export async function loadRuntimeConfig(): Promise<void> {
if (runtimeConfigLoaded) return;
runtimeConfigLoaded = true;
try {
const response = await fetch(`${import.meta.env.BASE_URL}config.json`, {
cache: 'no-cache',
});
if (!response.ok) return;
const config: AppConfig = await response.json();
if (Array.isArray(config.disabledTools)) {
for (const toolId of config.disabledTools) {
if (typeof toolId === 'string') {
disabledToolsSet.add(toolId);
}
}
}
} catch {}
}
export function isToolDisabled(toolId: string): boolean {
return disabledToolsSet.has(toolId);
}
export function getToolIdFromPath(): string | null {
const path = window.location.pathname;
const withExt = path.match(/\/([^/]+)\.html$/);
if (withExt) return withExt[1];
const withoutExt = path.match(/\/([^/]+)\/?$/);
return withoutExt?.[1] ?? null;
}
export function isCurrentPageDisabled(): boolean {
const toolId = getToolIdFromPath();
if (!toolId) return false;
return isToolDisabled(toolId);
}