chore: restore pane view

This commit is contained in:
Aleix Soler 2025-05-23 18:54:24 +02:00
parent 73ab30bcad
commit efcbe9df43
3 changed files with 32 additions and 53 deletions

51
main.ts
View file

@ -11,6 +11,9 @@ import { MetadataIntegration } from './integrations/metadata-cache';
import { WorkspaceIntegration } from './integrations/workspace';
import { FileContextMenuIntegration } from 'integrations/context-menu/file-context-menu-integration';
import { NoteStatusSettingTab } from 'integrations/settings/settings-tab';
//
// Importar vistas
import { StatusPaneViewController } from './views/status-pane-view';
// Importar componentes UI
import { StatusBar } from 'components/status-bar';
@ -40,15 +43,9 @@ export default class NoteStatus extends Plugin {
try {
await this.loadSettings();
this.initializeServices();
// 2. Registrar vistas y componentes UI
// this.registerViews();
this.registerViews();
this.initializeUI();
// 3. Inicializar integraciones
this.initializeIntegrations();
// 4. Registrar comandos
// this.registerCommands();
@ -72,15 +69,15 @@ export default class NoteStatus extends Plugin {
}
private registerViews() {
// Registrar vista del panel de estado
// this.registerView('status-pane', (leaf) => {
// return new StatusPaneView(leaf, this);
// });
// Register status pane view
this.registerView('status-pane', (leaf) => {
return new StatusPaneViewController(leaf, this);
});
// Añadir ícono en la barra lateral
// this.addRibbonIcon('status-pane', 'Open status pane', () => {
// this.openStatusPane();
// });
// Add ribbon icon
this.addRibbonIcon('status-pane', 'Open status pane', () => {
this.openStatusPane();
});
// Añadir pestaña de configuración
// this.addSettingTab(new NoteStatusSettingTab(this.app, this, this.statusService));
@ -229,18 +226,18 @@ export default class NoteStatus extends Plugin {
}
private async openStatusPane() {
// // Comprobar si ya está abierto
// const existing = this.app.workspace.getLeavesOfType('status-pane')[0];
// if (existing) {
// this.app.workspace.setActiveLeaf(existing);
// return;
// }
// Check if already open
const existing = this.app.workspace.getLeavesOfType('status-pane')[0];
if (existing) {
this.app.workspace.setActiveLeaf(existing);
return;
}
// // Crear una nueva hoja
// const leaf = this.app.workspace.getLeftLeaf(false);
// if (leaf) {
// await leaf.setViewState({ type: 'status-pane', active: true });
// }
// Create new leaf
const leaf = this.app.workspace.getLeftLeaf(false);
if (leaf) {
await leaf.setViewState({ type: 'status-pane', active: true });
}
}
async saveSettings() {
@ -283,4 +280,4 @@ export default class NoteStatus extends Plugin {
// // Limpiar componentes UI
// this.statusBar.unload();
}
}
}

View file

@ -0,0 +1,2 @@
export { StatusPaneView } from './status-pane-view';
export { StatusPaneViewController } from './status-pane-view-controller';

View file

@ -1,4 +1,4 @@
import { TFile, WorkspaceLeaf, View, Menu, Notice } from 'obsidian';
import { TFile, WorkspaceLeaf, View, Notice } from 'obsidian';
import { NoteStatusSettings } from '../../models/types';
import { StatusService } from '../../services/status-service';
import NoteStatus from 'main';
@ -9,7 +9,7 @@ export class StatusPaneViewController extends View {
private settings: NoteStatusSettings;
private statusService: StatusService;
private plugin: NoteStatus;
private searchQuery: string = '';
private searchQuery = '';
private paginationState = {
itemsPerPage: 100,
currentPage: {} as Record<string, number>
@ -47,6 +47,10 @@ export class StatusPaneViewController extends View {
this.renderer.createHeader(containerEl, this.settings.compactView, {
onSearch: (query) => {
this.paginationState = {
itemsPerPage: 100,
currentPage: {} as Record<string, number>
}
this.searchQuery = query;
this.renderGroups(query);
},
@ -103,7 +107,6 @@ export class StatusPaneViewController extends View {
window.dispatchEvent(new CustomEvent('note-status:settings-changed'));
},
onContextMenu: (e, file) => {
this.showFileContextMenu(e, file);
},
onPageChange: (status, page) => {
this.paginationState.currentPage[status] = page;
@ -140,29 +143,6 @@ export class StatusPaneViewController extends View {
return filteredGroups;
}
private showFileContextMenu(e: MouseEvent, file: TFile): void {
const menu = new Menu();
menu.addItem((item) =>
item.setTitle('Change status')
.setIcon('tag')
.onClick(() => {
const position = { x: e.clientX, y: e.clientY };
this.plugin.statusContextMenu.showForSingleFile(file, position);
})
);
menu.addItem((item) =>
item.setTitle('Open in new tab')
.setIcon('lucide-external-link')
.onClick(() => {
this.app.workspace.openLinkText(file.path, file.path, 'tab');
})
);
menu.showAtMouseEvent(e);
}
updateSettings(settings: NoteStatusSettings): void {
this.settings = settings;
this.containerEl.toggleClass('note-status-compact-view', settings.compactView);