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

View File

@@ -84,6 +84,7 @@ export class SecretsScanService {
try {
const connections = this.connectionManager.getConnections();
for (const conn of connections) {
if (conn.status === 'paused') continue;
try {
const provider = this.connectionManager.getProvider(conn.id);
connectionsScanned++;

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,

View File

@@ -19,6 +19,7 @@ export class OpsServer {
public logsHandler!: handlers.LogsHandler;
public webhookHandler!: handlers.WebhookHandler;
public actionsHandler!: handlers.ActionsHandler;
public actionLogHandler!: handlers.ActionLogHandler;
constructor(gitopsAppRef: GitopsApp) {
this.gitopsAppRef = gitopsAppRef;
@@ -61,6 +62,7 @@ export class OpsServer {
this.pipelinesHandler = new handlers.PipelinesHandler(this);
this.logsHandler = new handlers.LogsHandler(this);
this.actionsHandler = new handlers.ActionsHandler(this);
this.actionLogHandler = new handlers.ActionLogHandler(this);
logger.success('OpsServer TypedRequest handlers initialized');
}

View File

@@ -0,0 +1,30 @@
import * as plugins from '../../plugins.ts';
import type { OpsServer } from '../classes.opsserver.ts';
import * as interfaces from '../../../ts_interfaces/index.ts';
import { requireValidIdentity } from '../helpers/guards.ts';
export class ActionLogHandler {
public typedrouter = new plugins.typedrequest.TypedRouter();
constructor(private opsServerRef: OpsServer) {
this.opsServerRef.typedrouter.addTypedRouter(this.typedrouter);
this.registerHandlers();
}
private registerHandlers(): void {
this.typedrouter.addTypedHandler(
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetActionLog>(
'getActionLog',
async (dataArg) => {
await requireValidIdentity(this.opsServerRef.adminHandler, dataArg);
const result = await this.opsServerRef.gitopsAppRef.actionLog.query({
limit: dataArg.limit,
offset: dataArg.offset,
entityType: dataArg.entityType,
});
return result;
},
),
);
}
}

View File

@@ -11,6 +11,10 @@ export class ConnectionsHandler {
this.registerHandlers();
}
private get actionLog() {
return this.opsServerRef.gitopsAppRef.actionLog;
}
private registerHandlers(): void {
// Get all connections
this.typedrouter.addTypedHandler(
@@ -36,6 +40,14 @@ export class ConnectionsHandler {
dataArg.baseUrl,
dataArg.token,
);
this.actionLog.append({
actionType: 'create',
entityType: 'connection',
entityId: connection.id,
entityName: connection.name,
details: `Created ${dataArg.providerType} connection "${dataArg.name}" (${dataArg.baseUrl})`,
username: dataArg.identity.username,
});
return { connection };
},
),
@@ -55,6 +67,42 @@ export class ConnectionsHandler {
token: dataArg.token,
},
);
const fields = [
dataArg.name && 'name',
dataArg.baseUrl && 'baseUrl',
dataArg.token && 'token',
].filter(Boolean).join(', ');
this.actionLog.append({
actionType: 'update',
entityType: 'connection',
entityId: dataArg.connectionId,
entityName: connection.name,
details: `Updated connection "${connection.name}" (fields: ${fields})`,
username: dataArg.identity.username,
});
return { connection };
},
),
);
// Pause/resume connection
this.typedrouter.addTypedHandler(
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_PauseConnection>(
'pauseConnection',
async (dataArg) => {
await requireValidIdentity(this.opsServerRef.adminHandler, dataArg);
const connection = await this.opsServerRef.gitopsAppRef.connectionManager.pauseConnection(
dataArg.connectionId,
dataArg.paused,
);
this.actionLog.append({
actionType: dataArg.paused ? 'pause' : 'resume',
entityType: 'connection',
entityId: dataArg.connectionId,
entityName: connection.name,
details: `${dataArg.paused ? 'Paused' : 'Resumed'} connection "${connection.name}"`,
username: dataArg.identity.username,
});
return { connection };
},
),
@@ -69,6 +117,16 @@ export class ConnectionsHandler {
const result = await this.opsServerRef.gitopsAppRef.connectionManager.testConnection(
dataArg.connectionId,
);
const conn = this.opsServerRef.gitopsAppRef.connectionManager.getConnections()
.find((c) => c.id === dataArg.connectionId);
this.actionLog.append({
actionType: 'test',
entityType: 'connection',
entityId: dataArg.connectionId,
entityName: conn?.name || dataArg.connectionId,
details: `Tested connection: ${result.ok ? 'success' : `failed — ${result.error || 'unknown error'}`}`,
username: dataArg.identity.username,
});
return result;
},
),
@@ -80,9 +138,19 @@ export class ConnectionsHandler {
'deleteConnection',
async (dataArg) => {
await requireValidIdentity(this.opsServerRef.adminHandler, dataArg);
const conn = this.opsServerRef.gitopsAppRef.connectionManager.getConnections()
.find((c) => c.id === dataArg.connectionId);
await this.opsServerRef.gitopsAppRef.connectionManager.deleteConnection(
dataArg.connectionId,
);
this.actionLog.append({
actionType: 'delete',
entityType: 'connection',
entityId: dataArg.connectionId,
entityName: conn?.name || dataArg.connectionId,
details: `Deleted connection "${conn?.name || dataArg.connectionId}"`,
username: dataArg.identity.username,
});
return { ok: true };
},
),

View File

@@ -7,3 +7,4 @@ export { PipelinesHandler } from './pipelines.handler.ts';
export { LogsHandler } from './logs.handler.ts';
export { WebhookHandler } from './webhook.handler.ts';
export { ActionsHandler } from './actions.handler.ts';
export { ActionLogHandler } from './actionlog.handler.ts';

View File

@@ -11,6 +11,10 @@ export class PipelinesHandler {
this.registerHandlers();
}
private get actionLog() {
return this.opsServerRef.gitopsAppRef.actionLog;
}
private registerHandlers(): void {
// Get pipelines
this.typedrouter.addTypedHandler(
@@ -54,6 +58,14 @@ export class PipelinesHandler {
dataArg.connectionId,
);
await provider.retryPipeline(dataArg.projectId, dataArg.pipelineId);
this.actionLog.append({
actionType: 'update',
entityType: 'pipeline',
entityId: dataArg.pipelineId,
entityName: `Pipeline #${dataArg.pipelineId}`,
details: `Retried pipeline #${dataArg.pipelineId} in project ${dataArg.projectId}`,
username: dataArg.identity.username,
});
return { ok: true };
},
),
@@ -69,6 +81,14 @@ export class PipelinesHandler {
dataArg.connectionId,
);
await provider.cancelPipeline(dataArg.projectId, dataArg.pipelineId);
this.actionLog.append({
actionType: 'delete',
entityType: 'pipeline',
entityId: dataArg.pipelineId,
entityName: `Pipeline #${dataArg.pipelineId}`,
details: `Cancelled pipeline #${dataArg.pipelineId} in project ${dataArg.projectId}`,
username: dataArg.identity.username,
});
return { ok: true };
},
),

View File

@@ -11,6 +11,10 @@ export class SecretsHandler {
this.registerHandlers();
}
private get actionLog() {
return this.opsServerRef.gitopsAppRef.actionLog;
}
private registerHandlers(): void {
// Get all secrets (cache-first, falls back to live fetch)
this.typedrouter.addTypedHandler(
@@ -146,6 +150,14 @@ export class SecretsHandler {
// Refresh cache for this entity
const scanService = this.opsServerRef.gitopsAppRef.secretsScanService;
scanService.scanEntity(dataArg.connectionId, dataArg.scope, dataArg.scopeId).catch(() => {});
this.actionLog.append({
actionType: 'create',
entityType: 'secret',
entityId: `${dataArg.scopeId}/${dataArg.key}`,
entityName: dataArg.key,
details: `Created ${dataArg.scope} secret "${dataArg.key}" in ${dataArg.scopeId}`,
username: dataArg.identity.username,
});
return { secret };
},
),
@@ -166,6 +178,14 @@ export class SecretsHandler {
// Refresh cache for this entity
const scanService = this.opsServerRef.gitopsAppRef.secretsScanService;
scanService.scanEntity(dataArg.connectionId, dataArg.scope, dataArg.scopeId).catch(() => {});
this.actionLog.append({
actionType: 'update',
entityType: 'secret',
entityId: `${dataArg.scopeId}/${dataArg.key}`,
entityName: dataArg.key,
details: `Updated ${dataArg.scope} secret "${dataArg.key}" in ${dataArg.scopeId}`,
username: dataArg.identity.username,
});
return { secret };
},
),
@@ -188,6 +208,14 @@ export class SecretsHandler {
// Refresh cache for this entity
const scanService = this.opsServerRef.gitopsAppRef.secretsScanService;
scanService.scanEntity(dataArg.connectionId, dataArg.scope, dataArg.scopeId).catch(() => {});
this.actionLog.append({
actionType: 'delete',
entityType: 'secret',
entityId: `${dataArg.scopeId}/${dataArg.key}`,
entityName: dataArg.key,
details: `Deleted ${dataArg.scope} secret "${dataArg.key}" from ${dataArg.scopeId}`,
username: dataArg.identity.username,
});
return { ok: true };
},
),

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
export type TActionType = 'create' | 'update' | 'delete' | 'pause' | 'resume' | 'test' | 'scan';
export type TActionEntity = 'connection' | 'secret' | 'pipeline';
export interface IActionLogEntry {
id: string;
timestamp: number;
actionType: TActionType;
entityType: TActionEntity;
entityId: string;
entityName: string;
details: string;
username: string;
}

View File

@@ -7,5 +7,5 @@ export interface IProviderConnection {
baseUrl: string;
token: string;
createdAt: number;
status: 'connected' | 'disconnected' | 'error';
status: 'connected' | 'disconnected' | 'error' | 'paused';
}

View File

@@ -4,3 +4,4 @@ export * from './project.ts';
export * from './group.ts';
export * from './secret.ts';
export * from './pipeline.ts';
export * from './actionlog.ts';

View File

@@ -0,0 +1,19 @@
import * as plugins from '../plugins.ts';
import * as data from '../data/index.ts';
export interface IReq_GetActionLog extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_GetActionLog
> {
method: 'getActionLog';
request: {
identity: data.IIdentity;
limit?: number;
offset?: number;
entityType?: data.TActionEntity;
};
response: {
entries: data.IActionLogEntry[];
total: number;
};
}

View File

@@ -63,6 +63,21 @@ export interface IReq_TestConnection extends plugins.typedrequestInterfaces.impl
};
}
export interface IReq_PauseConnection extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_PauseConnection
> {
method: 'pauseConnection';
request: {
identity: data.IIdentity;
connectionId: string;
paused: boolean;
};
response: {
connection: data.IProviderConnection;
};
}
export interface IReq_DeleteConnection extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_DeleteConnection

View File

@@ -7,3 +7,4 @@ export * from './pipelines.ts';
export * from './logs.ts';
export * from './webhook.ts';
export * from './actions.ts';
export * from './actionlog.ts';

View File

@@ -29,6 +29,11 @@ export interface IDataState {
currentJobLog: string;
}
export interface IActionLogState {
entries: interfaces.data.IActionLogEntry[];
total: number;
}
export interface IUiState {
activeView: string;
autoRefresh: boolean;
@@ -70,6 +75,15 @@ export const dataStatePart = await appState.getStatePart<IDataState>(
'soft',
);
export const actionLogStatePart = await appState.getStatePart<IActionLogState>(
'actionLog',
{
entries: [],
total: 0,
},
'soft',
);
export const uiStatePart = await appState.getStatePart<IUiState>(
'ui',
{
@@ -227,6 +241,58 @@ export const deleteConnectionAction = connectionsStatePart.createAction<{
}
});
export const pauseConnectionAction = connectionsStatePart.createAction<{
connectionId: string;
paused: boolean;
}>(async (statePartArg, dataArg) => {
const context = getActionContext();
try {
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
interfaces.requests.IReq_PauseConnection
>('/typedrequest', 'pauseConnection');
await typedRequest.fire({
identity: context.identity!,
...dataArg,
});
// Re-fetch to get updated status
const listReq = new plugins.domtools.plugins.typedrequest.TypedRequest<
interfaces.requests.IReq_GetConnections
>('/typedrequest', 'getConnections');
const listResp = await listReq.fire({ identity: context.identity! });
return { ...statePartArg.getState(), connections: listResp.connections };
} catch (err) {
console.error('Failed to pause/resume connection:', err);
return statePartArg.getState();
}
});
export const updateConnectionAction = connectionsStatePart.createAction<{
connectionId: string;
name?: string;
baseUrl?: string;
token?: string;
}>(async (statePartArg, dataArg) => {
const context = getActionContext();
try {
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
interfaces.requests.IReq_UpdateConnection
>('/typedrequest', 'updateConnection');
await typedRequest.fire({
identity: context.identity!,
...dataArg,
});
// Re-fetch to get updated data
const listReq = new plugins.domtools.plugins.typedrequest.TypedRequest<
interfaces.requests.IReq_GetConnections
>('/typedrequest', 'getConnections');
const listResp = await listReq.fire({ identity: context.identity! });
return { ...statePartArg.getState(), connections: listResp.connections };
} catch (err) {
console.error('Failed to update connection:', err);
return statePartArg.getState();
}
});
// ============================================================================
// Projects Actions
// ============================================================================
@@ -567,6 +633,33 @@ export const fetchJobLogAction = dataStatePart.createAction<{
}
});
// ============================================================================
// Action Log Actions
// ============================================================================
export const fetchActionLogAction = actionLogStatePart.createAction<{
limit?: number;
offset?: number;
entityType?: interfaces.data.TActionEntity;
} | null>(async (statePartArg, dataArg) => {
const context = getActionContext();
try {
const typedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
interfaces.requests.IReq_GetActionLog
>('/typedrequest', 'getActionLog');
const response = await typedRequest.fire({
identity: context.identity!,
limit: dataArg?.limit,
offset: dataArg?.offset,
entityType: dataArg?.entityType,
});
return { entries: response.entries, total: response.total };
} catch (err) {
console.error('Failed to fetch action log:', err);
return statePartArg.getState();
}
});
// ============================================================================
// UI Actions
// ============================================================================

View File

@@ -19,6 +19,7 @@ import type { GitopsViewSecrets } from './views/secrets/index.js';
import type { GitopsViewPipelines } from './views/pipelines/index.js';
import type { GitopsViewBuildlog } from './views/buildlog/index.js';
import type { GitopsViewActions } from './views/actions/index.js';
import type { GitopsViewActionlog } from './views/actionlog/index.js';
@customElement('gitops-dashboard')
export class GitopsDashboard extends DeesElement {
@@ -41,6 +42,7 @@ export class GitopsDashboard extends DeesElement {
{ name: 'Pipelines', iconName: 'lucide:play', element: (async () => (await import('./views/pipelines/index.js')).GitopsViewPipelines)() },
{ name: 'Build Log', iconName: 'lucide:scrollText', element: (async () => (await import('./views/buildlog/index.js')).GitopsViewBuildlog)() },
{ name: 'Actions', iconName: 'lucide:zap', element: (async () => (await import('./views/actions/index.js')).GitopsViewActions)() },
{ name: 'Action Log', iconName: 'lucide:scroll', element: (async () => (await import('./views/actionlog/index.js')).GitopsViewActionlog)() },
];
private resolvedViewTabs: Array<{ name: string; iconName: string; element: any }> = [];

View File

@@ -0,0 +1,101 @@
import * as plugins from '../../../plugins.js';
import * as appstate from '../../../appstate.js';
import { viewHostCss } from '../../shared/index.js';
import {
DeesElement,
customElement,
html,
state,
css,
cssManager,
type TemplateResult,
} from '@design.estate/dees-element';
@customElement('gitops-view-actionlog')
export class GitopsViewActionlog extends DeesElement {
@state()
accessor actionLogState: appstate.IActionLogState = {
entries: [],
total: 0,
};
@state()
accessor selectedEntityType: string = 'all';
private _autoRefreshHandler: () => void;
constructor() {
super();
const sub = appstate.actionLogStatePart
.select((s) => s)
.subscribe((s) => { this.actionLogState = s; });
this.rxSubscriptions.push(sub);
this._autoRefreshHandler = () => this.refresh();
document.addEventListener('gitops-auto-refresh', this._autoRefreshHandler);
}
public override disconnectedCallback() {
super.disconnectedCallback();
document.removeEventListener('gitops-auto-refresh', this._autoRefreshHandler);
}
public static styles = [
cssManager.defaultStyles,
viewHostCss,
];
public render(): TemplateResult {
const entityOptions = [
{ option: 'All', key: 'all' },
{ option: 'Connection', key: 'connection' },
{ option: 'Secret', key: 'secret' },
{ option: 'Pipeline', key: 'pipeline' },
];
return html`
<div class="view-title">Action Log</div>
<div class="view-description">Audit trail of all operations performed in the system</div>
<div class="toolbar">
<dees-input-dropdown
.label=${'Entity Type'}
.options=${entityOptions}
.selectedOption=${entityOptions.find((o) => o.key === this.selectedEntityType)}
@selectedOption=${(e: CustomEvent) => {
this.selectedEntityType = e.detail.key;
this.refresh();
}}
></dees-input-dropdown>
<dees-button @click=${() => this.refresh()}>Refresh</dees-button>
</div>
<dees-table
.heading1=${'Action Log'}
.heading2=${`${this.actionLogState.total} entries total`}
.data=${this.actionLogState.entries}
.displayFunction=${(item: any) => ({
Time: new Date(item.timestamp).toLocaleString(),
Action: item.actionType,
Entity: item.entityType,
Name: item.entityName,
Details: item.details,
User: item.username,
})}
.dataActions=${[]}
></dees-table>
`;
}
async firstUpdated() {
await this.refresh();
}
private async refresh() {
const entityType = this.selectedEntityType === 'all'
? undefined
: this.selectedEntityType as any;
await appstate.actionLogStatePart.dispatchAction(appstate.fetchActionLogAction, {
limit: 100,
entityType,
});
}
}

View File

@@ -66,6 +66,11 @@ export class GitopsViewConnections extends DeesElement {
Created: new Date(item.createdAt).toLocaleDateString(),
})}
.dataActions=${[
{
name: 'Edit',
iconName: 'lucide:edit',
action: async (item: any) => { await this.editConnection(item); },
},
{
name: 'Test',
iconName: 'lucide:plug',
@@ -76,6 +81,31 @@ export class GitopsViewConnections extends DeesElement {
);
},
},
{
name: 'Pause/Resume',
iconName: 'lucide:pauseCircle',
action: async (item: any) => {
const isPaused = item.status === 'paused';
const actionLabel = isPaused ? 'Resume' : 'Pause';
await plugins.deesCatalog.DeesModal.createAndShow({
heading: `${actionLabel} Connection`,
content: html`<p style="color: #fff;">Are you sure you want to ${actionLabel.toLowerCase()} connection "${item.name}"?</p>`,
menuOptions: [
{ name: 'Cancel', action: async (modal: any) => { modal.destroy(); } },
{
name: actionLabel,
action: async (modal: any) => {
await appstate.connectionsStatePart.dispatchAction(
appstate.pauseConnectionAction,
{ connectionId: item.id, paused: !isPaused },
);
modal.destroy();
},
},
],
});
},
},
{
name: 'Delete',
iconName: 'lucide:trash2',
@@ -112,6 +142,51 @@ export class GitopsViewConnections extends DeesElement {
await appstate.connectionsStatePart.dispatchAction(appstate.fetchConnectionsAction, null);
}
private async editConnection(item: any) {
await plugins.deesCatalog.DeesModal.createAndShow({
heading: 'Edit Connection',
content: html`
<style>
.form-row { margin-bottom: 16px; }
.form-info { font-size: 13px; color: #888; margin-bottom: 16px; }
</style>
<div class="form-info">Provider: ${item.providerType}</div>
<div class="form-row">
<dees-input-text .label=${'Name'} .key=${'name'} .value=${item.name}></dees-input-text>
</div>
<div class="form-row">
<dees-input-text .label=${'Base URL'} .key=${'baseUrl'} .value=${item.baseUrl}></dees-input-text>
</div>
<div class="form-row">
<dees-input-text .label=${'API Token (leave empty to keep current)'} .key=${'token'} type="password"></dees-input-text>
</div>
`,
menuOptions: [
{ name: 'Cancel', action: async (modal: any) => { modal.destroy(); } },
{
name: 'Save',
action: async (modal: any) => {
const inputs = modal.shadowRoot.querySelectorAll('dees-input-text');
const data: any = {};
for (const input of inputs) {
data[input.key] = input.value || '';
}
await appstate.connectionsStatePart.dispatchAction(
appstate.updateConnectionAction,
{
connectionId: item.id,
name: data.name,
baseUrl: data.baseUrl,
...(data.token ? { token: data.token } : {}),
},
);
modal.destroy();
},
},
],
});
}
private async addConnection() {
await plugins.deesCatalog.DeesModal.createAndShow({
heading: 'Add Connection',

View File

@@ -171,11 +171,24 @@ export class GitopsViewSecrets extends DeesElement {
name: 'Delete',
iconName: 'lucide:trash2',
action: async (item: any) => {
await appstate.dataStatePart.dispatchAction(appstate.deleteSecretAction, {
connectionId: this.selectedConnectionId,
scope: item.scope,
scopeId: item.scopeId,
key: item.key,
await plugins.deesCatalog.DeesModal.createAndShow({
heading: 'Delete Secret',
content: html`<p style="color: #fff;">Are you sure you want to delete secret "${item.key}"?</p>`,
menuOptions: [
{ name: 'Cancel', action: async (modal: any) => { modal.destroy(); } },
{
name: 'Delete',
action: async (modal: any) => {
await appstate.dataStatePart.dispatchAction(appstate.deleteSecretAction, {
connectionId: this.selectedConnectionId,
scope: item.scope,
scopeId: item.scopeId,
key: item.key,
});
modal.destroy();
},
},
],
});
},
},