MCPcopy
hub / github.com/koala73/worldmonitor / renderFeature

Method renderFeature

src/components/RuntimeConfigPanel.ts:240–266  ·  view source on GitHub ↗
(feature: RuntimeFeatureDefinition)

Source from the content-addressed store, hash-verified

238 }
239
240 private renderFeature(feature: RuntimeFeatureDefinition): string {
241 const enabled = isFeatureEnabled(feature.id);
242 const available = isFeatureAvailable(feature.id);
243 const effectiveSecrets = getEffectiveSecrets(feature);
244 const allStaged = !available && effectiveSecrets.every(
245 (k) => getSecretState(k).valid || (this.pendingSecrets.has(k) && this.validatedKeys.get(k) !== false)
246 );
247 const pillClass = available ? 'ok' : allStaged ? 'staged' : 'warn';
248 const pillLabel = available ? t('modals.runtimeConfig.status.ready') : allStaged ? t('modals.runtimeConfig.status.staged') : t('modals.runtimeConfig.status.needsKeys');
249 const secrets = effectiveSecrets.map((key) => this.renderSecretRow(key)).join('');
250 const desktop = isDesktopRuntime();
251 const fallbackHtml = available || allStaged ? '' : `<p class="runtime-feature-fallback fallback">${escapeHtml(feature.fallback)}</p>`;
252
253 return `
254 <section class="runtime-feature ${available ? 'available' : allStaged ? 'staged' : 'degraded'}">
255 <header class="runtime-feature-header">
256 <label>
257 <input type="checkbox" data-toggle="${feature.id}" ${enabled ? 'checked' : ''} ${desktop ? '' : 'disabled'}>
258 <span>${escapeHtml(feature.name)}</span>
259 </label>
260 <span class="runtime-pill ${pillClass}">${pillLabel}</span>
261 </header>
262 <div class="runtime-secrets">${secrets}</div>
263 ${fallbackHtml}
264 </section>
265 `;
266 }
267
268 private renderSecretRow(key: RuntimeSecretKey): string {
269 const state = getSecretState(key);

Callers 1

renderMethod · 0.95

Calls 8

renderSecretRowMethod · 0.95
isFeatureEnabledFunction · 0.90
isFeatureAvailableFunction · 0.90
getEffectiveSecretsFunction · 0.90
getSecretStateFunction · 0.90
tFunction · 0.90
isDesktopRuntimeFunction · 0.90
escapeHtmlFunction · 0.90

Tested by

no test coverage detected