71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
// file: crates/ksp-app-config-desk/frontend/ts/shell_registry.ts
|
|
// version: 1
|
|
|
|
//! Declarative shell and specialized-editor registry for Config Desk frontend extensibility.
|
|
|
|
export type ViewId = "overview" | "documents" | "profiles" | "environment" | "logging";
|
|
|
|
export interface ViewDescriptor {
|
|
title: string;
|
|
description: string;
|
|
panelId: string;
|
|
}
|
|
|
|
export interface SpecializedEditorDescriptor {
|
|
fileId: string;
|
|
viewId: ViewId;
|
|
label: string;
|
|
}
|
|
|
|
export const viewRegistry: Record<ViewId, ViewDescriptor> = {
|
|
overview: {
|
|
title: "Vue d'ensemble",
|
|
description: "État sûr du bootstrap Config Desk et du runtime Logging actuellement actif.",
|
|
panelId: "overviewPanel",
|
|
},
|
|
documents: {
|
|
title: "Documents",
|
|
description: "Inventaire, diagnostics et réparation validée des documents Config enregistrés.",
|
|
panelId: "documentsPanel",
|
|
},
|
|
profiles: {
|
|
title: "Profils",
|
|
description: "Sélection default/explicite, vues global/profil/effective sûre et provenance Config.",
|
|
panelId: "profilesPanel",
|
|
},
|
|
environment: {
|
|
title: "Environnement / .env",
|
|
description: "Rapport sûr desired/effective/source/shadow et management atomique des variables .env KSP/KSPB.",
|
|
panelId: "environmentPanel",
|
|
},
|
|
logging: {
|
|
title: "Logging",
|
|
description: "Édition typée, hot reload runtime, profils actifs et panneau de test du routing Logging KSP.",
|
|
panelId: "loggingPanel",
|
|
},
|
|
};
|
|
|
|
const specializedEditorRegistry: SpecializedEditorDescriptor[] = [
|
|
{
|
|
fileId: "cfg.std.logging",
|
|
viewId: "logging",
|
|
label: "Ouvrir l'éditeur Logging",
|
|
},
|
|
];
|
|
|
|
export function registeredViewIds(): ViewId[] {
|
|
return Object.keys(viewRegistry) as ViewId[];
|
|
}
|
|
|
|
export function isViewId(value: string): value is ViewId {
|
|
return Object.prototype.hasOwnProperty.call(viewRegistry, value);
|
|
}
|
|
|
|
export function specializedEditorForFileId(fileId: string): SpecializedEditorDescriptor | null {
|
|
return specializedEditorRegistry.find(descriptor => descriptor.fileId === fileId) ?? null;
|
|
}
|
|
|
|
export function requestViewActivation(viewId: ViewId): void {
|
|
window.dispatchEvent(new CustomEvent("ksp:activate-view", { detail: { viewId } }));
|
|
}
|