Skip to content

Refactor Hub tenant themes for SurveyJS 3 (paged API, Endatix client, vertical slice) #912

Description

@PeterMarinov

Goal

Make tenant Theme Editor logic easy to maintain through the SurveyJS 3 upgrade: consume paged GET /themes, talk to the API only via lib/endatix-api, and keep CRUD + Creator dialogs in a dedicated features/themes vertical slice—not nested under forms/.

Parent: endatix-hub#908 (SurveyJS 3.0.2). API envelope: endatix#991. Same Hub paging pattern as form templates (endatix#990).

Implementation Notes

Work is in the Hub branch that also lands SurveyJS 3. Track here so review and release notes stay on the themes refactor, not the whole upgrade.

Paged client (lib/endatix-api/themes/)

  • list() returns one NormalizedPagedResponse page (items, hasNextPage, totals).
  • listAll() drains pages for the Theme Editor chooser (no paging UI), bounded max pages.
  • Query builder: paging + sort + created/modified filters (buildListThemesEndpoint).
  • Path ids via validateEndatixId on update/delete.
  • Drop getThemes / parseThemesPayload from services/api.ts. Paged envelope only—no array dual-read.

Server actions

  • Map ApiResult with toResult(...). Chooser uses listAll.
  • Keep action names (getThemesAction, createThemeAction, …) to limit churn.

Vertical slice (features/themes/)

Slice Role
create-theme / update-theme / delete-theme / list-themes CRUD actions
list-forms-for-theme Delete guard
update-form-theme Assign themeId on a form
manage-theme-editor Hook + save/delete dialogs
  • Shared: types.ts (StoredTheme). Client barrel index.ts (UI/hook only). Actions via server.ts or slice paths—do not re-export "use server" from the client barrel.
  • Form editor still hosts Creator; import theme UI from @/features/themes/manage-theme-editor.
  • Hub chrome / SurveyJS tokens stay in lib/themes/ (not tenant CRUD).

Docs

  • hub/project-structure.md (Themes table), hub/DESIGN.md, hub/AGENTS.md, ARCHITECTURE.md (dialog paths).

Acceptance Criteria

  • Hub reads GET /themes as Paged.items only (Theme Editor not empty against API after #991).
  • Theme HTTP lives in lib/endatix-api/themes/ with list vs listAll; tests cover the query contract.
  • Theme actions live under features/themes/{verb-noun}/ and return Result via toResult.
  • Theme save/delete dialogs + useThemeManagement live in manage-theme-editor; form editor imports them.
  • lib/themes/ remains Hub product tokens only.
  • Unit tests for actions, dialogs, and the management hook pass.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🎁 white-labeling-and-themingFeature Area is White Labeling & ThemingdocumentationImprovements or additions to documentationendatix-hubRequires changes in the Endatix Hub part of the reporelatedThis issue is related to other work but not dependent.survey-jsIssue is closely related to SurveyJS, Survey Creator or other Survey librariestech-debtTechnical debt. Addressing this will address known issue or opportunity to improve the codebase

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions