|
|
@@ -17,7 +17,11 @@ from ..exceptions import (
|
|
|
TemplateValidationError,
|
|
|
)
|
|
|
from ..input import InputManager
|
|
|
-from ..template import Template
|
|
|
+from ..template import (
|
|
|
+ TEMPLATE_STATUS_DRAFT,
|
|
|
+ TEMPLATE_STATUS_PUBLISHED,
|
|
|
+ Template,
|
|
|
+)
|
|
|
from ..validators import get_validator_registry
|
|
|
from .helpers import (
|
|
|
apply_cli_overrides,
|
|
|
@@ -83,6 +87,16 @@ def list_templates(module_instance, raw: bool = False) -> list:
|
|
|
tags_list = template.metadata.tags or []
|
|
|
tags = ", ".join(tags_list) if tags_list else "-"
|
|
|
version = str(template.metadata.version) if template.metadata.version else ""
|
|
|
+
|
|
|
+ # Get status and format it
|
|
|
+ status = template.status
|
|
|
+ if status == TEMPLATE_STATUS_PUBLISHED:
|
|
|
+ status_display = "[green]Published[/green]"
|
|
|
+ elif status == TEMPLATE_STATUS_DRAFT:
|
|
|
+ status_display = "[dim]Draft[/dim]"
|
|
|
+ else: # TEMPLATE_STATUS_INVALID
|
|
|
+ status_display = "[red]Invalid[/red]"
|
|
|
+
|
|
|
schema = template.schema_version if hasattr(template, "schema_version") else "1.0"
|
|
|
library_name = template.metadata.library or ""
|
|
|
library_type = template.metadata.library_type or "git"
|
|
|
@@ -90,7 +104,19 @@ def list_templates(module_instance, raw: bool = False) -> list:
|
|
|
icon = IconManager.UI_LIBRARY_STATIC if library_type == "static" else IconManager.UI_LIBRARY_GIT
|
|
|
color = "yellow" if library_type == "static" else "blue"
|
|
|
library_display = f"[{color}]{icon} {library_name}[/{color}]"
|
|
|
- return (template.id, name, tags, version, schema, library_display)
|
|
|
+
|
|
|
+ # Apply dimmed style to entire row if draft
|
|
|
+ if status == TEMPLATE_STATUS_DRAFT:
|
|
|
+ template_id = f"[dim]{template.id}[/dim]"
|
|
|
+ name = f"[dim]{name}[/dim]"
|
|
|
+ tags = f"[dim]{tags}[/dim]"
|
|
|
+ version = f"[dim]{version}[/dim]"
|
|
|
+ schema = f"[dim]{schema}[/dim]"
|
|
|
+ library_display = f"[dim]{icon} {library_name}[/dim]"
|
|
|
+ else:
|
|
|
+ template_id = template.id
|
|
|
+
|
|
|
+ return (template_id, name, tags, version, status_display, schema, library_display)
|
|
|
|
|
|
module_instance.display.data_table(
|
|
|
columns=[
|
|
|
@@ -98,6 +124,7 @@ def list_templates(module_instance, raw: bool = False) -> list:
|
|
|
{"name": "Name"},
|
|
|
{"name": "Tags"},
|
|
|
{"name": "Version", "no_wrap": True},
|
|
|
+ {"name": "Status", "no_wrap": True},
|
|
|
{"name": "Schema", "no_wrap": True},
|
|
|
{"name": "Library", "no_wrap": True},
|
|
|
],
|
|
|
@@ -129,6 +156,16 @@ def search_templates(module_instance, query: str) -> list:
|
|
|
tags_list = template.metadata.tags or []
|
|
|
tags = ", ".join(tags_list) if tags_list else "-"
|
|
|
version = str(template.metadata.version) if template.metadata.version else ""
|
|
|
+
|
|
|
+ # Get status and format it
|
|
|
+ status = template.status
|
|
|
+ if status == TEMPLATE_STATUS_PUBLISHED:
|
|
|
+ status_display = "[green]Published[/green]"
|
|
|
+ elif status == TEMPLATE_STATUS_DRAFT:
|
|
|
+ status_display = "[dim]Draft[/dim]"
|
|
|
+ else: # TEMPLATE_STATUS_INVALID
|
|
|
+ status_display = "[red]Invalid[/red]"
|
|
|
+
|
|
|
schema = template.schema_version if hasattr(template, "schema_version") else "1.0"
|
|
|
library_name = template.metadata.library or ""
|
|
|
library_type = template.metadata.library_type or "git"
|
|
|
@@ -136,7 +173,19 @@ def search_templates(module_instance, query: str) -> list:
|
|
|
icon = IconManager.UI_LIBRARY_STATIC if library_type == "static" else IconManager.UI_LIBRARY_GIT
|
|
|
color = "yellow" if library_type == "static" else "blue"
|
|
|
library_display = f"[{color}]{icon} {library_name}[/{color}]"
|
|
|
- return (template.id, name, tags, version, schema, library_display)
|
|
|
+
|
|
|
+ # Apply dimmed style to entire row if draft
|
|
|
+ if status == TEMPLATE_STATUS_DRAFT:
|
|
|
+ template_id = f"[dim]{template.id}[/dim]"
|
|
|
+ name = f"[dim]{name}[/dim]"
|
|
|
+ tags = f"[dim]{tags}[/dim]"
|
|
|
+ version = f"[dim]{version}[/dim]"
|
|
|
+ schema = f"[dim]{schema}[/dim]"
|
|
|
+ library_display = f"[dim]{icon} {library_name}[/dim]"
|
|
|
+ else:
|
|
|
+ template_id = template.id
|
|
|
+
|
|
|
+ return (template_id, name, tags, version, status_display, schema, library_display)
|
|
|
|
|
|
module_instance.display.data_table(
|
|
|
columns=[
|
|
|
@@ -144,6 +193,7 @@ def search_templates(module_instance, query: str) -> list:
|
|
|
{"name": "Name"},
|
|
|
{"name": "Tags"},
|
|
|
{"name": "Version", "no_wrap": True},
|
|
|
+ {"name": "Status", "no_wrap": True},
|
|
|
{"name": "Schema", "no_wrap": True},
|
|
|
{"name": "Library", "no_wrap": True},
|
|
|
],
|