feat(core): add table actions (edit, pause, delete confirmation) and global action log

- Add Edit and Pause/Resume actions to connections table
- Add delete confirmation modal to secrets table
- Add 'paused' status to connections with full backend support
- Skip paused connections in health checks and secrets scanning
- Add global ActionLog service with filesystem persistence
- Instrument all mutation handlers (connections, secrets, pipelines) with action logging
- Add Action Log view with entity type filtering to dashboard
This commit is contained in:
2026-02-27 11:13:07 +00:00
parent 630b2502f3
commit 81ead52a72
22 changed files with 564 additions and 8 deletions

57
ts/classes/actionlog.ts Normal file
View File

@@ -0,0 +1,57 @@
import { logger } from '../logging.ts';
import type * as interfaces from '../../ts_interfaces/index.ts';
import type { StorageManager } from '../storage/index.ts';
const ACTIONLOG_PREFIX = '/actionlog/';
/**
* Persists and queries action log entries via StorageManager.
* Entries are stored as individual JSON files keyed by timestamp-id.
*/
export class ActionLog {
private storageManager: StorageManager;
constructor(storageManager: StorageManager) {
this.storageManager = storageManager;
}
async append(entry: Omit<interfaces.data.IActionLogEntry, 'id' | 'timestamp'>): Promise<interfaces.data.IActionLogEntry> {
const full: interfaces.data.IActionLogEntry = {
id: crypto.randomUUID(),
timestamp: Date.now(),
...entry,
};
const key = `${ACTIONLOG_PREFIX}${String(full.timestamp).padStart(16, '0')}-${full.id}.json`;
await this.storageManager.setJSON(key, full);
logger.debug(`Action logged: ${full.actionType} ${full.entityType} "${full.entityName}"`);
return full;
}
async query(opts: {
limit?: number;
offset?: number;
entityType?: interfaces.data.TActionEntity;
} = {}): Promise<{ entries: interfaces.data.IActionLogEntry[]; total: number }> {
const limit = opts.limit ?? 50;
const offset = opts.offset ?? 0;
const keys = await this.storageManager.list(ACTIONLOG_PREFIX);
// Sort by key descending (newest first — keys are timestamp-prefixed)
keys.sort((a, b) => b.localeCompare(a));
// Load all entries (or filter by entityType)
let entries: interfaces.data.IActionLogEntry[] = [];
for (const key of keys) {
const entry = await this.storageManager.getJSON<interfaces.data.IActionLogEntry>(key);
if (entry) {
if (opts.entityType && entry.entityType !== opts.entityType) continue;
entries.push(entry);
}
}
const total = entries.length;
entries = entries.slice(offset, offset + limit);
return { entries, total };
}
}

View File

@@ -38,6 +38,7 @@ export class ConnectionManager {
*/
private async testAllConnections(): Promise<void> {
for (const conn of this.connections) {
if (conn.status === 'paused') continue;
try {
const provider = this.getProvider(conn.id);
const result = await provider.testConnection();
@@ -178,10 +179,22 @@ export class ConnectionManager {
logger.info(`Connection deleted: ${id}`);
}
async pauseConnection(id: string, paused: boolean): Promise<interfaces.data.IProviderConnection> {
const conn = this.connections.find((c) => c.id === id);
if (!conn) throw new Error(`Connection not found: ${id}`);
conn.status = paused ? 'paused' : 'disconnected';
await this.persistConnection(conn);
logger.info(`Connection ${paused ? 'paused' : 'resumed'}: ${conn.name}`);
return { ...conn, token: '***' };
}
async testConnection(id: string): Promise<{ ok: boolean; error?: string }> {
const conn = this.connections.find((c) => c.id === id)!;
if (conn.status === 'paused') {
return { ok: false, error: 'Connection is paused' };
}
const provider = this.getProvider(id);
const result = await provider.testConnection();
const conn = this.connections.find((c) => c.id === id)!;
conn.status = result.ok ? 'connected' : 'error';
await this.persistConnection(conn);
return result;

View File

@@ -1,6 +1,7 @@
import * as plugins from '../plugins.ts';
import { logger } from '../logging.ts';
import { ConnectionManager } from './connectionmanager.ts';
import { ActionLog } from './actionlog.ts';
import { OpsServer } from '../opsserver/index.ts';
import { StorageManager } from '../storage/index.ts';
import { CacheDb, CacheCleaner, CachedProject, CachedSecret, SecretsScanService } from '../cache/index.ts';
@@ -13,6 +14,7 @@ export class GitopsApp {
public storageManager: StorageManager;
public smartSecret: plugins.smartsecret.SmartSecret;
public connectionManager: ConnectionManager;
public actionLog: ActionLog;
public opsServer: OpsServer;
public cacheDb: CacheDb;
public cacheCleaner: CacheCleaner;
@@ -27,6 +29,7 @@ export class GitopsApp {
});
this.smartSecret = new plugins.smartsecret.SmartSecret({ service: 'gitops' });
this.connectionManager = new ConnectionManager(this.storageManager, this.smartSecret);
this.actionLog = new ActionLog(this.storageManager);
this.cacheDb = CacheDb.getInstance({
storagePath: paths.defaultTsmDbPath,