|
1 | | -import { OnboardingConfig } from "../../utils/OnboardingConfigManager"; |
| 1 | +import { OnboardingConfig, OnboardingConfigManager } from "../../utils/OnboardingConfigManager"; |
2 | 2 | import { t } from "../../translations/helper"; |
3 | 3 | import { setIcon } from "obsidian"; |
| 4 | +import type TaskProgressBarPlugin from "../../index"; |
4 | 5 |
|
5 | 6 | export class ConfigPreview { |
| 7 | + private configManager: OnboardingConfigManager; |
| 8 | + |
| 9 | + constructor(configManager: OnboardingConfigManager) { |
| 10 | + this.configManager = configManager; |
| 11 | + } |
| 12 | + |
6 | 13 | /** |
7 | 14 | * Render configuration preview |
8 | 15 | */ |
@@ -145,6 +152,95 @@ export class ConfigPreview { |
145 | 152 | config.settings.fileParsingConfig.enableWorkerProcessing ? t("Enabled") : t("Disabled") |
146 | 153 | ); |
147 | 154 | } |
| 155 | + |
| 156 | + // Show configuration change preview |
| 157 | + this.renderConfigurationChanges(containerEl, config); |
| 158 | + |
| 159 | + // Customization note |
| 160 | + const note = containerEl.createDiv("customization-note"); |
| 161 | + note.createEl("p", { |
| 162 | + text: t( |
| 163 | + "You can adjust any of these settings later in the plugin settings." |
| 164 | + ), |
| 165 | + cls: "note-text", |
| 166 | + }); |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Render configuration changes preview |
| 171 | + */ |
| 172 | + private renderConfigurationChanges(containerEl: HTMLElement, config: OnboardingConfig) { |
| 173 | + try { |
| 174 | + const preview = this.configManager.getConfigurationPreview(config.mode); |
| 175 | + |
| 176 | + // Show change summary section |
| 177 | + const changesSection = containerEl.createDiv("config-changes-summary"); |
| 178 | + changesSection.createEl("h3", { text: t("Configuration Changes") }); |
| 179 | + |
| 180 | + // User custom views preserved |
| 181 | + if (preview.userCustomViewsPreserved.length > 0) { |
| 182 | + const preservedSection = changesSection.createDiv("preserved-views"); |
| 183 | + const preservedHeader = preservedSection.createDiv("preserved-header"); |
| 184 | + const preservedIcon = preservedHeader.createSpan("preserved-icon"); |
| 185 | + setIcon(preservedIcon, "shield-check"); |
| 186 | + preservedHeader.createSpan("preserved-text").setText( |
| 187 | + t("Your custom views will be preserved") + ` (${preview.userCustomViewsPreserved.length})` |
| 188 | + ); |
| 189 | + |
| 190 | + const preservedList = preservedSection.createEl("ul", { cls: "preserved-views-list" }); |
| 191 | + preview.userCustomViewsPreserved.forEach(view => { |
| 192 | + const item = preservedList.createEl("li"); |
| 193 | + const viewIcon = item.createSpan(); |
| 194 | + setIcon(viewIcon, view.icon || "list"); |
| 195 | + item.createSpan().setText(" " + view.name); |
| 196 | + }); |
| 197 | + } |
| 198 | + |
| 199 | + // Views to be added |
| 200 | + if (preview.viewsToAdd.length > 0) { |
| 201 | + const addedSection = changesSection.createDiv("added-views"); |
| 202 | + const addedIcon = addedSection.createSpan("change-icon"); |
| 203 | + setIcon(addedIcon, "plus-circle"); |
| 204 | + addedSection.createSpan("change-text").setText( |
| 205 | + t("New views to be added") + ` (${preview.viewsToAdd.length})` |
| 206 | + ); |
| 207 | + } |
| 208 | + |
| 209 | + // Views to be updated |
| 210 | + if (preview.viewsToUpdate.length > 0) { |
| 211 | + const updatedSection = changesSection.createDiv("updated-views"); |
| 212 | + const updatedIcon = updatedSection.createSpan("change-icon"); |
| 213 | + setIcon(updatedIcon, "refresh-cw"); |
| 214 | + updatedSection.createSpan("change-text").setText( |
| 215 | + t("Existing views to be updated") + ` (${preview.viewsToUpdate.length})` |
| 216 | + ); |
| 217 | + } |
| 218 | + |
| 219 | + // Settings changes |
| 220 | + if (preview.settingsChanges.length > 0) { |
| 221 | + const settingsChangesSection = changesSection.createDiv("settings-changes"); |
| 222 | + const settingsIcon = settingsChangesSection.createSpan("change-icon"); |
| 223 | + setIcon(settingsIcon, "settings"); |
| 224 | + settingsChangesSection.createSpan("change-text").setText(t("Feature changes")); |
| 225 | + |
| 226 | + const changesList = settingsChangesSection.createEl("ul", { cls: "settings-changes-list" }); |
| 227 | + preview.settingsChanges.forEach(change => { |
| 228 | + const item = changesList.createEl("li"); |
| 229 | + item.setText(change); |
| 230 | + }); |
| 231 | + } |
| 232 | + |
| 233 | + // Safety note |
| 234 | + const safetyNote = changesSection.createDiv("safety-note"); |
| 235 | + const safetyIcon = safetyNote.createSpan("safety-icon"); |
| 236 | + setIcon(safetyIcon, "info"); |
| 237 | + safetyNote.createSpan("safety-text").setText( |
| 238 | + t("Only template settings will be applied. Your existing custom configurations will be preserved.") |
| 239 | + ); |
| 240 | + |
| 241 | + } catch (error) { |
| 242 | + console.warn("Could not generate configuration preview:", error); |
| 243 | + } |
148 | 244 | } |
149 | 245 |
|
150 | 246 | /** |
|
0 commit comments