mirror of https://github.com/langgenius/dify.git
fix: preserve custom icons in exported DSL (#33424)
Signed-off-by: majiayu000 <1835304752@qq.com>
This commit is contained in:
parent
fb41b215c8
commit
f21288df5a
|
|
@ -556,8 +556,11 @@ class AppDslService:
|
|||
"app": {
|
||||
"name": app_model.name,
|
||||
"mode": app_model.mode.value if isinstance(app_model.mode, AppMode) else app_model.mode,
|
||||
"icon": app_model.icon if app_model.icon_type == "image" else "🤖",
|
||||
"icon_background": "#FFEAD5" if app_model.icon_type == "image" else app_model.icon_background,
|
||||
"icon": app_model.icon,
|
||||
"icon_type": (
|
||||
app_model.icon_type.value if isinstance(app_model.icon_type, IconType) else app_model.icon_type
|
||||
),
|
||||
"icon_background": app_model.icon_background,
|
||||
"description": app_model.description,
|
||||
"use_icon_as_answer_icon": app_model.use_icon_as_answer_icon,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -672,6 +672,44 @@ def test_export_dsl_delegates_by_mode(monkeypatch):
|
|||
assert model_calls == [True]
|
||||
|
||||
|
||||
def test_export_dsl_preserves_icon_and_icon_type(monkeypatch):
|
||||
monkeypatch.setattr(AppDslService, "_append_workflow_export_data", lambda **_kwargs: None)
|
||||
|
||||
emoji_app = SimpleNamespace(
|
||||
mode=AppMode.WORKFLOW.value,
|
||||
tenant_id="tenant-1",
|
||||
name="Emoji App",
|
||||
icon="🎨",
|
||||
icon_type=IconType.EMOJI,
|
||||
icon_background="#FF5733",
|
||||
description="App with emoji icon",
|
||||
use_icon_as_answer_icon=True,
|
||||
app_model_config=None,
|
||||
)
|
||||
yaml_output = AppDslService.export_dsl(emoji_app)
|
||||
data = yaml.safe_load(yaml_output)
|
||||
assert data["app"]["icon"] == "🎨"
|
||||
assert data["app"]["icon_type"] == "emoji"
|
||||
assert data["app"]["icon_background"] == "#FF5733"
|
||||
|
||||
image_app = SimpleNamespace(
|
||||
mode=AppMode.WORKFLOW.value,
|
||||
tenant_id="tenant-1",
|
||||
name="Image App",
|
||||
icon="https://example.com/icon.png",
|
||||
icon_type=IconType.IMAGE,
|
||||
icon_background="#FFEAD5",
|
||||
description="App with image icon",
|
||||
use_icon_as_answer_icon=False,
|
||||
app_model_config=None,
|
||||
)
|
||||
yaml_output = AppDslService.export_dsl(image_app)
|
||||
data = yaml.safe_load(yaml_output)
|
||||
assert data["app"]["icon"] == "https://example.com/icon.png"
|
||||
assert data["app"]["icon_type"] == "image"
|
||||
assert data["app"]["icon_background"] == "#FFEAD5"
|
||||
|
||||
|
||||
def test_append_workflow_export_data_filters_and_overrides(monkeypatch):
|
||||
workflow_dict = {
|
||||
"graph": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue