mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
refactor(settings): update settings UI for FileSource configuration
- Refactor FileSourceSettings component for dynamic configuration - Update IndexSettingsTab with improved worker processing controls - Update setting definitions to support new FileSource structure - Add settings migration for FileSource configuration changes - Remove legacy excludePatterns in favor of unified filter rules
This commit is contained in:
parent
8e292cb4f3
commit
d58f4873ce
4 changed files with 83 additions and 93 deletions
|
|
@ -436,7 +436,7 @@ export interface ProjectDetectionMethod {
|
|||
/** Type of detection method */
|
||||
type: "metadata" | "tag" | "link";
|
||||
/** For metadata: the property key (e.g., "project")
|
||||
* For tag: the tag name (e.g., "project")
|
||||
* For tag: the tag name (e.g., "project")
|
||||
* For link: the property key that contains links (e.g., "kind", "category") */
|
||||
propertyKey: string;
|
||||
/** For link type: optional filter for link values (e.g., only links containing "Project") */
|
||||
|
|
@ -572,8 +572,11 @@ export interface FileFilterRule {
|
|||
type: "file" | "folder" | "pattern";
|
||||
path: string;
|
||||
enabled: boolean;
|
||||
scope?: "both" | "inline" | "file"; // per-rule scope (default both)
|
||||
}
|
||||
|
||||
|
||||
|
||||
export enum FilterMode {
|
||||
WHITELIST = "whitelist",
|
||||
BLACKLIST = "blacklist",
|
||||
|
|
@ -647,7 +650,7 @@ export interface TaskProgressBarSettings {
|
|||
enablePriorityPicker: boolean;
|
||||
enablePriorityKeyboardShortcuts: boolean;
|
||||
enableDatePicker: boolean;
|
||||
|
||||
|
||||
// Date Parsing Settings
|
||||
customDateFormats: string[];
|
||||
enableCustomDateFormats: boolean;
|
||||
|
|
@ -1476,7 +1479,7 @@ export const DEFAULT_SETTINGS: TaskProgressBarSettings = {
|
|||
// Custom Date Format Defaults
|
||||
enableCustomDateFormats: false,
|
||||
customDateFormats: [],
|
||||
|
||||
|
||||
// Experimental Defaults
|
||||
experimental: {
|
||||
dataflowEnabled: false
|
||||
|
|
@ -1520,7 +1523,8 @@ export const DEFAULT_SETTINGS: TaskProgressBarSettings = {
|
|||
contentSource: "filename",
|
||||
stripExtension: true,
|
||||
defaultStatus: " ",
|
||||
defaultPriority: undefined
|
||||
defaultPriority: undefined,
|
||||
preferFrontmatterTitle: true
|
||||
},
|
||||
relationships: {
|
||||
enableChildRelationships: true,
|
||||
|
|
@ -1532,46 +1536,20 @@ export const DEFAULT_SETTINGS: TaskProgressBarSettings = {
|
|||
enableCaching: true,
|
||||
cacheTTL: 300000
|
||||
},
|
||||
advanced: {
|
||||
excludePatterns: ["**/.obsidian/**", "**/node_modules/**"],
|
||||
maxFileSize: 1048576
|
||||
},
|
||||
statusMapping: {
|
||||
enabled: true,
|
||||
metadataToSymbol: {
|
||||
// Completed variants
|
||||
'completed': 'x',
|
||||
'done': 'x',
|
||||
'finished': 'x',
|
||||
'complete': 'x',
|
||||
'checked': 'x',
|
||||
'x': 'x',
|
||||
|
||||
// In Progress variants
|
||||
'in-progress': '/',
|
||||
'in progress': '/',
|
||||
'inprogress': '/',
|
||||
'doing': '/',
|
||||
'working': '/',
|
||||
'/': '/',
|
||||
|
||||
// Planned variants
|
||||
'planned': '?',
|
||||
'todo': '?',
|
||||
'pending': '?',
|
||||
'?': '?',
|
||||
|
||||
// Abandoned variants
|
||||
'cancelled': '-',
|
||||
'canceled': '-',
|
||||
'abandoned': '-',
|
||||
'-': '-',
|
||||
|
||||
// Not Started variants
|
||||
'not-started': ' ',
|
||||
'not started': ' ',
|
||||
'new': ' ',
|
||||
' ': ' '
|
||||
'not started': ' '
|
||||
},
|
||||
symbolToMetadata: {
|
||||
'x': 'completed',
|
||||
|
|
|
|||
|
|
@ -637,6 +637,23 @@ function createFileTaskPropertiesSection(
|
|||
);
|
||||
}
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("Prefer Frontmatter Title"))
|
||||
.setDesc(
|
||||
t(
|
||||
"When updating task content, prefer updating frontmatter title over renaming the file. This protects the original filename.",
|
||||
),
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(config.fileTaskProperties.preferFrontmatterTitle)
|
||||
.onChange(async (value) => {
|
||||
plugin.settings.fileSource.fileTaskProperties.preferFrontmatterTitle =
|
||||
value;
|
||||
await plugin.saveSettings();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("Default Task Status"))
|
||||
.setDesc(t("Default status for newly created file tasks"))
|
||||
|
|
@ -677,8 +694,18 @@ function createStatusMappingSection(
|
|||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(config.statusMapping.enabled)
|
||||
.setValue(config.statusMapping?.enabled || false)
|
||||
.onChange(async (value) => {
|
||||
if(!config.statusMapping) {
|
||||
config.statusMapping = {
|
||||
enabled: false,
|
||||
metadataToSymbol: {},
|
||||
symbolToMetadata: {},
|
||||
autoDetect: false,
|
||||
caseSensitive: false,
|
||||
};
|
||||
}
|
||||
|
||||
plugin.settings.fileSource.statusMapping.enabled = value;
|
||||
await plugin.saveSettings();
|
||||
|
||||
|
|
@ -688,7 +715,7 @@ function createStatusMappingSection(
|
|||
}),
|
||||
);
|
||||
|
||||
if (config.statusMapping.enabled) {
|
||||
if (config.statusMapping && config.statusMapping.enabled) {
|
||||
new Setting(containerEl)
|
||||
.setName(t("Case Sensitive Matching"))
|
||||
.setDesc(t("Enable case-sensitive matching for status values"))
|
||||
|
|
@ -841,20 +868,19 @@ function createPerformanceSection(
|
|||
}),
|
||||
);
|
||||
|
||||
// Note: Worker Processing setting has been moved to IndexSettingsTab.ts > Performance Configuration section
|
||||
// This avoids duplication and provides centralized control for all worker processing
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("Enable Worker Processing"))
|
||||
.setDesc(
|
||||
t(
|
||||
"Use background workers for better performance (will be implemented in Phase 4)",
|
||||
),
|
||||
)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(config.performance.enableWorkerProcessing)
|
||||
.setDisabled(true) // Disabled until Phase 4
|
||||
.setName(t("Cache TTL"))
|
||||
.setDesc(t("Time-to-live for cached results in milliseconds (default: 300000 = 5 minutes)"))
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("300000")
|
||||
.setValue(String(config.performance.cacheTTL || 300000))
|
||||
.onChange(async (value) => {
|
||||
plugin.settings.fileSource.performance.enableWorkerProcessing =
|
||||
value;
|
||||
const ttl = parseInt(value) || 300000;
|
||||
plugin.settings.fileSource.performance.cacheTTL = ttl;
|
||||
await plugin.saveSettings();
|
||||
}),
|
||||
);
|
||||
|
|
@ -870,40 +896,6 @@ function createAdvancedSection(
|
|||
): void {
|
||||
new Setting(containerEl).setHeading().setName(t("Advanced"));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("Exclude Patterns"))
|
||||
.setDesc(
|
||||
t(
|
||||
"Comma-separated patterns for files to exclude from being recognized as tasks",
|
||||
),
|
||||
)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("**/.obsidian/**, **/node_modules/**")
|
||||
.setValue(config.advanced.excludePatterns.join(", "))
|
||||
.onChange(async (value) => {
|
||||
plugin.settings.fileSource.advanced.excludePatterns = value
|
||||
.split(",")
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => s.length > 0);
|
||||
await plugin.saveSettings();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("Maximum File Size"))
|
||||
.setDesc(t("Maximum file size in bytes to process (default: 1MB)"))
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("1048576")
|
||||
.setValue(config.advanced.maxFileSize.toString())
|
||||
.onChange(async (value) => {
|
||||
const size = parseInt(value) || 1048576;
|
||||
plugin.settings.fileSource.advanced.maxFileSize = size;
|
||||
await plugin.saveSettings();
|
||||
}),
|
||||
);
|
||||
|
||||
// Statistics section
|
||||
const statsContainer = containerEl.createDiv("file-source-stats");
|
||||
statsContainer.createEl("h5", { text: t("File Task Status") });
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { TaskProgressBarSettingTab } from "../../setting";
|
|||
import { t } from "../../translations/helper";
|
||||
import { SingleFolderSuggest } from "../AutoComplete";
|
||||
import { ConfirmModal } from "../ConfirmModal";
|
||||
import { createFileSourceSettings } from "./FileSourceSettings";
|
||||
|
||||
/**
|
||||
* Renders the Index Settings tab that consolidates all indexing-related settings
|
||||
|
|
@ -414,9 +413,7 @@ export function renderIndexSettingsTab(
|
|||
)
|
||||
.setHeading();
|
||||
|
||||
// Create a dedicated container for File Task settings
|
||||
const fileTaskContainer = containerEl.createDiv("file-task-settings-container");
|
||||
createFileSourceSettings(fileTaskContainer, settingTab.plugin);
|
||||
// File Task settings have been migrated to File Filter tab for central management.
|
||||
|
||||
// ========================================
|
||||
// SECTION 3: Performance Settings
|
||||
|
|
@ -431,16 +428,42 @@ export function renderIndexSettingsTab(
|
|||
.setDesc(
|
||||
t(
|
||||
"Use background worker for file parsing to improve performance. Recommended for large vaults.",
|
||||
),
|
||||
),
|
||||
)
|
||||
.addToggle((toggle) => {
|
||||
// Use the new fileSource.performance.enableWorkerProcessing setting
|
||||
toggle.setValue(
|
||||
settingTab.plugin.settings.fileParsingConfig
|
||||
.enableWorkerProcessing,
|
||||
settingTab.plugin.settings.fileSource?.performance
|
||||
?.enableWorkerProcessing ?? true,
|
||||
);
|
||||
toggle.onChange((value) => {
|
||||
settingTab.plugin.settings.fileParsingConfig.enableWorkerProcessing =
|
||||
value;
|
||||
// Ensure fileSource and performance objects exist
|
||||
if (!settingTab.plugin.settings.fileSource) {
|
||||
// Initialize with minimal required properties
|
||||
settingTab.plugin.settings.fileSource = {
|
||||
enabled: false,
|
||||
performance: {
|
||||
enableWorkerProcessing: true,
|
||||
enableCaching: true,
|
||||
cacheTTL: 300000
|
||||
}
|
||||
} as any;
|
||||
}
|
||||
if (!settingTab.plugin.settings.fileSource.performance) {
|
||||
settingTab.plugin.settings.fileSource.performance = {
|
||||
enableWorkerProcessing: true,
|
||||
enableCaching: true,
|
||||
cacheTTL: 300000
|
||||
};
|
||||
}
|
||||
// Update the setting
|
||||
settingTab.plugin.settings.fileSource.performance.enableWorkerProcessing = value;
|
||||
|
||||
// Also update the legacy fileParsingConfig for backward compatibility
|
||||
if (settingTab.plugin.settings.fileParsingConfig) {
|
||||
settingTab.plugin.settings.fileParsingConfig.enableWorkerProcessing = value;
|
||||
}
|
||||
|
||||
settingTab.applySettingsUpdate();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -227,7 +227,8 @@ function createDefaultFileSourceConfig(): FileSourceConfiguration {
|
|||
contentSource: "filename",
|
||||
stripExtension: true,
|
||||
defaultStatus: " ",
|
||||
defaultPriority: undefined
|
||||
defaultPriority: undefined,
|
||||
preferFrontmatterTitle: true
|
||||
},
|
||||
relationships: {
|
||||
enableChildRelationships: true,
|
||||
|
|
@ -239,10 +240,6 @@ function createDefaultFileSourceConfig(): FileSourceConfiguration {
|
|||
enableCaching: true,
|
||||
cacheTTL: 300000
|
||||
},
|
||||
advanced: {
|
||||
excludePatterns: ["**/.obsidian/**", "**/node_modules/**"],
|
||||
maxFileSize: 1048576
|
||||
},
|
||||
statusMapping: {
|
||||
enabled: true,
|
||||
metadataToSymbol: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue