Skip to content

Add enable/disable functionality for custom templates#2750

Open
Tharanidk wants to merge 2 commits into
wso2:mainfrom
Tharanidk:enable-disable
Open

Add enable/disable functionality for custom templates#2750
Tharanidk wants to merge 2 commits into
wso2:mainfrom
Tharanidk:enable-disable

Conversation

@Tharanidk

Copy link
Copy Markdown
Contributor

Purpose

Previously, enable/disable was restricted to built-in templates only. This PR allows custom templates to be toggled as well, since enable/disable only affects control-plane listing.

Changes

  • platform-api: remove the managedBy restriction in SetVersionEnabled so custom templates can be enabled/disabled. Disabling is still blocked when the version is in use by a provider.
  • AI Workspace: show the enable/disable switch for all templates, not just read-only ones.
  • Provider template list: fetch all versions (not just the latest) so each family card shows the highest enabled version, falling back to the highest version with disabled styling when the whole family is disabled.

Resolves: #2692

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Custom template versions can now be enabled or disabled. The AI Workspace retrieves all template versions, selects versions per ownership and family based on enablement and version, and displays toggle controls for all template origins.

Changes

Custom template enablement and version selection

Layer / File(s) Summary
Custom template toggle service and validation
platform-api/internal/service/llm.go, platform-api/internal/service/llm_provider_template_test.go
SetVersionEnabled permits custom templates, preserves the in-use check when disabling, and tests both successful and blocked custom-template disables.
All-version retrieval and family selection
portals/ai-workspace/src/apis/providerTemplateApis.ts, portals/ai-workspace/src/pages/appShell/appShellPages/providerTemplate/ProviderTemplatesList.tsx
The API client can request all versions, while the list groups templates by ownership and family and selects the highest enabled version or highest version fallback.
Version enablement controls
portals/ai-workspace/src/pages/appShell/appShellPages/providerTemplate/ProviderTemplateOverview.tsx
Enable/disable labels and switches are rendered for built-in, custom, and gateway-originated templates.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProviderTemplatesList
  participant providerTemplateApis
  participant PlatformAPI
  ProviderTemplatesList->>providerTemplateApis: Request all template versions
  providerTemplateApis->>PlatformAPI: Fetch versions without latest-only filter
  PlatformAPI-->>providerTemplateApis: Return template versions
  providerTemplateApis-->>ProviderTemplatesList: Provide allVersions
  ProviderTemplatesList->>ProviderTemplatesList: Group families and select display versions
Loading

Possibly related PRs

  • wso2/api-platform#2456: Added the managedBy and version model/API fields used by the enablement and version-grouping changes.

Suggested reviewers: renuka-fernando, thivindu, ashera96

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers purpose and changes, but misses most required template sections like Goals, Approach, tests, docs, and security. Add the missing template sections, especially Goals, Approach, User stories, Documentation, Automation tests, Security checks, Samples, Related PRs, and Test environment.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: enabling/disabling custom templates.
Linked Issues check ✅ Passed The code matches issue #2692 by allowing custom templates to toggle, preserving the in-use block, and updating the UI and listings accordingly.
Out of Scope Changes check ✅ Passed The added API, UI, and listing changes all support custom template enable/disable behavior; no unrelated changes are evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
portals/ai-workspace/src/pages/appShell/appShellPages/providerTemplate/ProviderTemplatesList.tsx (1)

136-171: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate version-parsing/comparison logic across files.

parseVersion/isHigher here duplicates the same "parse v<major>.<minor> and compare" logic already implemented separately as parseVerNum in ProviderTemplateOverview.tsx. Extracting a shared compareTemplateVersions/parseTemplateVersion utility (e.g. alongside familyHandle in providerTemplateDisplay.ts) would prevent the two implementations from silently diverging as version semantics evolve.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@portals/ai-workspace/src/pages/appShell/appShellPages/providerTemplate/ProviderTemplatesList.tsx`
around lines 136 - 171, Extract the version parsing and comparison logic from
the familyCards useMemo into shared parseTemplateVersion/compareTemplateVersions
utilities alongside familyHandle in providerTemplateDisplay.ts, then update
ProviderTemplatesList and ProviderTemplateOverview to use them instead of local
parseVerNum, parseVersion, or isHigher implementations. Preserve the existing
v<major>.<minor> ordering and invalid-version behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@portals/ai-workspace/src/pages/appShell/appShellPages/providerTemplate/ProviderTemplatesList.tsx`:
- Around line 136-171: Extract the version parsing and comparison logic from the
familyCards useMemo into shared parseTemplateVersion/compareTemplateVersions
utilities alongside familyHandle in providerTemplateDisplay.ts, then update
ProviderTemplatesList and ProviderTemplateOverview to use them instead of local
parseVerNum, parseVersion, or isHigher implementations. Preserve the existing
v<major>.<minor> ordering and invalid-version behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 694831c7-8ba9-44c0-8096-f8d0afb5133e

📥 Commits

Reviewing files that changed from the base of the PR and between 5f8e7f8 and e8924b5.

📒 Files selected for processing (5)
  • platform-api/internal/service/llm.go
  • platform-api/internal/service/llm_provider_template_test.go
  • portals/ai-workspace/src/apis/providerTemplateApis.ts
  • portals/ai-workspace/src/pages/appShell/appShellPages/providerTemplate/ProviderTemplateOverview.tsx
  • portals/ai-workspace/src/pages/appShell/appShellPages/providerTemplate/ProviderTemplatesList.tsx
💤 Files with no reviewable changes (1)
  • platform-api/internal/service/llm.go

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Add Enable/disable support for custom templates

1 participant