diff --git a/components/SettingsUI.tsx/BehaviourSettings.tsx b/components/SettingsUI.tsx/BehaviourSettings.tsx index af8bd5a..a84ef8c 100644 --- a/components/SettingsUI.tsx/BehaviourSettings.tsx +++ b/components/SettingsUI.tsx/BehaviourSettings.tsx @@ -52,6 +52,21 @@ export const BehaviourSettings: React.FC = ({ settings, onChange }) => { } /> + + + { + const value = parseInt(e.target.value) || 15000; + onChange("vaultSizeLimit", value); + }} + /> + ); }; diff --git a/constants/defaultSettings.ts b/constants/defaultSettings.ts index a987418..ce52a3c 100644 --- a/constants/defaultSettings.ts +++ b/constants/defaultSettings.ts @@ -27,4 +27,5 @@ export const DEFAULT_PLUGIN_SETTINGS: PluginSettings = { statusBarNoStatusText: "No status", statusBarShowNoStatusIcon: false, statusBarShowNoStatusText: true, + vaultSizeLimit: 15000, // Disable dashboard and grouped view for vaults with more notes than this limit }; diff --git a/integrations/views/grouped-status-view.tsx b/integrations/views/grouped-status-view.tsx index 54cf3f2..d7d7618 100644 --- a/integrations/views/grouped-status-view.tsx +++ b/integrations/views/grouped-status-view.tsx @@ -151,7 +151,8 @@ export class GroupedStatusView extends ItemView { key === "useCustomStatusesOnly" || key === "customStatuses" || key === "useMultipleStatuses" || - key === "strictStatuses" + key === "strictStatuses" || + key === "vaultSizeLimit" ) { onDataChange(); } @@ -181,6 +182,19 @@ export class GroupedStatusView extends ItemView { container.empty(); container.addClass("grouped-status-view-container"); + // Check if vault exceeds the size limit + const files = BaseNoteStatusService.app.vault.getMarkdownFiles(); + const vaultSizeLimit = settingsService.settings.vaultSizeLimit || 15000; + + if (vaultSizeLimit > 0 && files.length > vaultSizeLimit) { + // Show disabled message + container.createEl("div", { + cls: "grouped-status-view-disabled", + text: `Grouped Status View disabled: Vault has ${files.length} notes (limit: ${vaultSizeLimit}). You can adjust this limit in plugin settings.`, + }); + return; + } + this.root = createRoot(container); this.root.render( 0 && files.length > vaultSizeLimit) { + // Show disabled message + container.createEl("div", { + cls: "status-dashboard-disabled", + text: `Dashboard disabled: Vault has ${files.length} notes (limit: ${vaultSizeLimit}). You can adjust this limit in plugin settings.`, + }); + return; + } + this.root = createRoot(container); // Set up event listeners @@ -334,7 +347,8 @@ export class StatusDashboardView extends ItemView { key === "useCustomStatusesOnly" || key === "customStatuses" || key === "useMultipleStatuses" || - key === "strictStatuses" + key === "strictStatuses" || + key === "vaultSizeLimit" ) { handleVaultChange(); handleFileChange(); diff --git a/styles/components/dashboard.css b/styles/components/dashboard.css index e929206..975f531 100644 --- a/styles/components/dashboard.css +++ b/styles/components/dashboard.css @@ -310,6 +310,21 @@ color: var(--text-muted); } +.status-dashboard-disabled { + display: flex; + align-items: center; + justify-content: center; + height: 100%; + padding: var(--size-4-4); + text-align: center; + font-size: var(--font-ui-medium); + color: var(--text-muted); + background: var(--background-secondary); + border: 2px dashed var(--background-modifier-border); + border-radius: var(--radius-m); + margin: var(--size-4-4); +} + /* Scrollbar */ .status-dashboard-content::-webkit-scrollbar { width: var(--scrollbar-width); diff --git a/styles/components/grouped-view.css b/styles/components/grouped-view.css index 372938b..9c0485d 100644 --- a/styles/components/grouped-view.css +++ b/styles/components/grouped-view.css @@ -210,6 +210,21 @@ font-size: var(--font-ui-medium); } +.grouped-status-view-disabled { + display: flex; + align-items: center; + justify-content: center; + height: 100%; + padding: var(--size-4-4); + text-align: center; + font-size: var(--font-ui-medium); + color: var(--text-muted); + background: var(--background-secondary); + border: 2px dashed var(--background-modifier-border); + border-radius: var(--radius-m); + margin: var(--size-4-4); +} + /* Scrollbar */ .grouped-status-content::-webkit-scrollbar, .grouped-status-files-list::-webkit-scrollbar { diff --git a/types/pluginSettings.ts b/types/pluginSettings.ts index adcc1c7..d41945f 100644 --- a/types/pluginSettings.ts +++ b/types/pluginSettings.ts @@ -30,5 +30,6 @@ export type PluginSettings = { statusBarNoStatusText: string; // Custom text for status bar when no status statusBarShowNoStatusIcon: boolean; // Whether to show icon in status bar for no status statusBarShowNoStatusText: boolean; // Whether to show text in status bar for no status + vaultSizeLimit: number; // Disable dashboard and grouped view for vaults with more notes than this limit [key: string]: unknown; };