Implement module registry for better seperation

未关闭
#440 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
eslint, typescript

调研方向

Start by reading the module setup in src/lib/modules/types.ts and src/lib/modules/index.ts, then trace the existing navigation and request handling through nav-items.ts, +layout.svelte, NavigationProgress, +layout.server.ts, and hooks.server.ts. Check how storage and Trino configuration and handleStorageConnection are currently loaded. Done means enabled modules alone initialize and handle their routes, disabled module routes return 404, and the specified unit and E2E cases pass.

由索引模型根据 Issue 内容生成。

描述

Goal: Every module can be switched on and off independently with a feature flag

  1. Module contract. Add src/lib/modules/types.ts defining a CockpitModule: id, routePrefix, enabled, navigation entry, page title, optional init() and optional server handle. The registry lives in src/lib/modules/index.ts and is a static list.
  2. Move storage and Trino onto it.
    • The sidebar (nav-items.ts), page titles (+layout.svelte), NavigationProgress and +layout.server.ts all read from the registry.
    • hooks.server.ts returns 404 for routes of disabled modules and only runs a module's handle on its own routes. handleStorageConnection moves into the storage module.
    • init runs init() only for enabled modules.
  3. Validate config only for enabled modules. The storage and Trino configs are no longer imported unconditionally. They're parsed in their module's init(), so an invalid variable stops the server only when that module is enabled.
  4. New STACKABLE_COCKPIT_TRINO_ENABLED flag
  5. Boundaries. An ESLint rule (import/no-restricted-paths) stops modules importing each other.

Tests

  • Unit tests for the registry and hook logic.
  • E2E: with a module disabled, pages and API return 404, it's missing from the sidebar, and the server starts even with invalid config for it. With it enabled, the existing flows still work.

Result: a new module becomes one module.ts entry plus its own folders. The central files only change for shared concerns.

主要语言
TypeScript
星标
1
派生
0
平均合并
3 天 12 小时
30 天内合并 PR
31

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

stackabletech/cockpit 的其他 Issue

查看 stackabletech/cockpit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。