Implement module registry for better seperation

オープン
#440 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
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時間
マージ済み PR(30日)
31

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stackabletech/cockpit のほかの issue

stackabletech/cockpit の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。