diff --git a/main.ts b/main.ts index 97b14ee..389c721 100644 --- a/main.ts +++ b/main.ts @@ -26,7 +26,8 @@ export default class StreamsPlugin extends Plugin implements StreamsAPI { icon: 'book', showTodayInRibbon: false, addCommand: false, - encryptThisStream: false + encryptThisStream: false, + disabled: false }) ); @@ -39,7 +40,8 @@ export default class StreamsPlugin extends Plugin implements StreamsAPI { icon: 'book', showTodayInRibbon: false, addCommand: false, - encryptThisStream: false + encryptThisStream: false, + disabled: false }, new Date()) ); @@ -52,7 +54,8 @@ export default class StreamsPlugin extends Plugin implements StreamsAPI { icon: 'book', showTodayInRibbon: false, addCommand: false, - encryptThisStream: true + encryptThisStream: true, + disabled: false }) ); @@ -87,6 +90,10 @@ export default class StreamsPlugin extends Plugin implements StreamsAPI { stream.encryptThisStream = false; needsSave = true; } + if (stream.disabled === undefined) { + stream.disabled = false; + needsSave = true; + } } if (needsSave) { diff --git a/src/shared/types.ts b/src/shared/types.ts index b5877c2..ac50d72 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -24,6 +24,7 @@ export interface Stream { showTodayInRibbon: boolean; addCommand: boolean; encryptThisStream: boolean; // New field for encryption toggle + disabled: boolean; // New field for disabling streams } export interface StreamsSettings { diff --git a/src/slices/api/APIService.ts b/src/slices/api/APIService.ts index 0e94dde..b9c6580 100644 --- a/src/slices/api/APIService.ts +++ b/src/slices/api/APIService.ts @@ -94,7 +94,7 @@ export class APIService extends PluginAwareSliceService implements StreamsAPI { * @returns Array of streams that show in the ribbon */ public getRibbonStreams(): Stream[] { - return this.getStreams().filter(stream => stream.showTodayInRibbon); + return this.getStreams().filter(stream => stream.showTodayInRibbon && !stream.disabled); } /** @@ -102,7 +102,7 @@ export class APIService extends PluginAwareSliceService implements StreamsAPI { * @returns Array of streams with commands enabled */ public getCommandStreams(): Stream[] { - return this.getStreams().filter(stream => stream.addCommand); + return this.getStreams().filter(stream => stream.addCommand && !stream.disabled); } /** diff --git a/src/slices/calendar-navigation/CalendarNavigationService.ts b/src/slices/calendar-navigation/CalendarNavigationService.ts index 7994875..120e6a8 100644 --- a/src/slices/calendar-navigation/CalendarNavigationService.ts +++ b/src/slices/calendar-navigation/CalendarNavigationService.ts @@ -247,6 +247,11 @@ export class CalendarNavigationService extends SettingsAwareSliceService { if (component && typeof component.refreshBarStyle === 'function') { component.refreshBarStyle(); } + + // Update streams list for all existing components + if (component && typeof component.updateStreamsList === 'function' && settings.streams) { + component.updateStreamsList(settings.streams); + } } } diff --git a/src/slices/calendar-navigation/StreamsBarComponent.ts b/src/slices/calendar-navigation/StreamsBarComponent.ts index 71ccd83..6d9c0c3 100644 --- a/src/slices/calendar-navigation/StreamsBarComponent.ts +++ b/src/slices/calendar-navigation/StreamsBarComponent.ts @@ -941,7 +941,10 @@ export class StreamsBarComponent extends Component { this.streamsDropdown.empty(); - this.streams.forEach(stream => { + // Filter out disabled streams + const enabledStreams = this.streams.filter(stream => !stream.disabled); + + enabledStreams.forEach(stream => { const streamItem = this.streamsDropdown!.createDiv('streams-bar-stream-item'); const isSelected = stream.id === this.getActiveStreamId(); @@ -1202,6 +1205,12 @@ export class StreamsBarComponent extends Component { private handleSettingsChange(settings: any): void { // Apply the new bar style if it changed this.applyBarStyle(); + + // Update streams list if it changed + if (settings.streams) { + this.streams = settings.streams; + this.refreshStreamsDropdown(); + } } public refreshBarStyle(): void { diff --git a/src/slices/context-menu/MoveTextToStreamModal.ts b/src/slices/context-menu/MoveTextToStreamModal.ts index 57010c4..8825e72 100644 --- a/src/slices/context-menu/MoveTextToStreamModal.ts +++ b/src/slices/context-menu/MoveTextToStreamModal.ts @@ -146,16 +146,19 @@ export class MoveTextToStreamModal extends Modal { .setName('Target Stream') .setDesc('Select the stream to move the text to') .addDropdown(dropdown => { - this.streams.forEach(stream => { + // Filter out disabled streams + const enabledStreams = this.streams.filter(stream => !stream.disabled); + + enabledStreams.forEach(stream => { dropdown.addOption(stream.id, stream.name); }); - if (this.selectedStream) { + if (this.selectedStream && !this.selectedStream.disabled) { dropdown.setValue(this.selectedStream.id); } dropdown.onChange(value => { - this.selectedStream = this.streams.find(s => s.id === value) || null; + this.selectedStream = enabledStreams.find(s => s.id === value) || null; this.saveSettingsToState(); }); }); diff --git a/src/slices/ribbon-integration/RibbonService.ts b/src/slices/ribbon-integration/RibbonService.ts index d90c85b..1838bd1 100644 --- a/src/slices/ribbon-integration/RibbonService.ts +++ b/src/slices/ribbon-integration/RibbonService.ts @@ -59,7 +59,8 @@ export class RibbonService extends SettingsAwareSliceService { public initializeAllRibbonIcons(): void { // Create icons for all streams based on their visibility settings - this.getStreams().forEach(stream => { + // Filter out disabled streams + this.getStreams().filter(stream => !stream.disabled).forEach(stream => { this.createStreamIcons(stream); }); } diff --git a/src/slices/settings-management/SettingsService.ts b/src/slices/settings-management/SettingsService.ts index c24d086..472aa67 100644 --- a/src/slices/settings-management/SettingsService.ts +++ b/src/slices/settings-management/SettingsService.ts @@ -130,7 +130,8 @@ export class StreamsSettingTab extends PluginSettingTab { icon: 'file-text' as LucideIcon, showTodayInRibbon: true, addCommand: false, - encryptThisStream: false + encryptThisStream: false, + disabled: false }; this.plugin.settings.streams.push(newStream); await this.plugin.saveSettings(); @@ -148,6 +149,12 @@ export class StreamsSettingTab extends PluginSettingTab { private createStreamCard(container: HTMLElement, stream: Stream, index: number): HTMLElement { const card = container.createDiv('streams-plugin-card'); + + // Add disabled class if stream is disabled + if (stream.disabled) { + card.addClass('streams-plugin-card-disabled'); + } + card.createEl('h3', { text: stream.name }); return card; } @@ -204,6 +211,26 @@ export class StreamsSettingTab extends PluginSettingTab { // Encrypt this stream this.addEncryptionToggle(container, stream); + // Disable stream + const disableSetting = new Setting(container) + .setName('Disable stream') + .setDesc('When disabled, this stream will be hidden from selection lists and grayed out in settings') + .addToggle(toggle => toggle + .setValue(stream.disabled || false) + .onChange(async (value) => { + stream.disabled = value; + await this.plugin.saveSettings(); + eventBus.emit(EVENTS.SETTINGS_CHANGED, this.plugin.settings, 'settings-management'); + + // Refresh the display to update visual styling + this.display(); + })); + + // Add a class to identify the disable toggle for styling + if (stream.disabled) { + disableSetting.settingEl.addClass('streams-disable-toggle'); + } + // Remove stream new Setting(container) .addButton(button => button diff --git a/src/slices/stream-management/StreamSelectionModal.ts b/src/slices/stream-management/StreamSelectionModal.ts index b1e00b6..de10ab2 100644 --- a/src/slices/stream-management/StreamSelectionModal.ts +++ b/src/slices/stream-management/StreamSelectionModal.ts @@ -17,7 +17,10 @@ export class StreamSelectionModal extends Modal { contentEl.createEl('h2', { text: 'Select stream' }); - this.streams.forEach(stream => { + // Filter out disabled streams + const enabledStreams = this.streams.filter(stream => !stream.disabled); + + enabledStreams.forEach(stream => { new Setting(contentEl) .setName(stream.name) .setDesc(stream.folder) diff --git a/styles.css b/styles.css index 17e3efb..39b47fe 100644 --- a/styles.css +++ b/styles.css @@ -51,6 +51,47 @@ padding-bottom: 10px; } +/* Disabled stream styling */ +.streams-plugin-card-disabled { + opacity: 0.5; + background-color: var(--background-secondary-alt); + border: 1px solid var(--background-modifier-border-focus); + position: relative; +} + +.streams-plugin-card-disabled::before { + content: "DISABLED"; + position: absolute; + top: 10px; + right: 10px; + background-color: var(--text-error); + color: var(--text-on-accent); + padding: 2px 6px; + border-radius: 3px; + font-size: 10px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.5px; +} + +.streams-plugin-card-disabled h3 { + color: var(--text-muted); +} + +.streams-plugin-card-disabled .setting-item { + opacity: 0.7; +} + +.streams-plugin-card-disabled .setting-item .setting-item-control { + pointer-events: none; +} + +/* Allow the disable toggle itself to be clickable */ +.streams-plugin-card-disabled .streams-disable-toggle .setting-item-control { + pointer-events: auto; + opacity: 1; +} + /********************************************************* * STREAMS BAR - MAIN COMPONENT *********************************************************/