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-groups') export class GitopsViewGroups extends DeesElement { @state() accessor connectionsState: appstate.IConnectionsState = { connections: [], activeConnectionId: null, }; @state() accessor dataState: appstate.IDataState = { projects: [], groups: [], secrets: [], pipelines: [], pipelineJobs: [], currentJobLog: '', }; @state() accessor selectedConnectionId: string = ''; private _autoRefreshHandler: () => void; constructor() { super(); const connSub = appstate.connectionsStatePart .select((s) => s) .subscribe((s) => { this.connectionsState = s; }); this.rxSubscriptions.push(connSub); const dataSub = appstate.dataStatePart .select((s) => s) .subscribe((s) => { this.dataState = s; }); this.rxSubscriptions.push(dataSub); this._autoRefreshHandler = () => this.handleAutoRefresh(); document.addEventListener('gitops-auto-refresh', this._autoRefreshHandler); } public override disconnectedCallback() { super.disconnectedCallback(); document.removeEventListener('gitops-auto-refresh', this._autoRefreshHandler); } private handleAutoRefresh(): void { this.loadGroups(); } public static styles = [ cssManager.defaultStyles, viewHostCss, ]; public render(): TemplateResult { const connectionOptions = this.connectionsState.connections.map((c) => ({ option: `${c.name} (${c.providerType})`, key: c.id, })); return html`