mirror of
https://github.com/bfloydd/streams.git
synced 2026-07-22 12:50:25 +00:00
add stream disable feature
This commit is contained in:
parent
9bd62b0024
commit
1ff5b3d728
10 changed files with 109 additions and 12 deletions
13
main.ts
13
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) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
41
styles.css
41
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
|
||||
*********************************************************/
|
||||
|
|
|
|||
Loading…
Reference in a new issue