feat(agent): 产线功能菜单按 require_project 标记,无会话当前项目时点击报错
This commit is contained in:
parent
d47a4a5d47
commit
349752b473
@ -9,6 +9,7 @@ if not uid:
|
||||
|
||||
# 1. 解析当前产线:用户当前项目 → sd_projects.pipeline_id
|
||||
pipeline_id = ''
|
||||
pid = ''
|
||||
try:
|
||||
dbname = get_module_dbname('pipeline_core')
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
@ -45,14 +46,25 @@ except Exception:
|
||||
|
||||
buttons = []
|
||||
|
||||
# 固定「工作空间」按钮(通用能力,所有 agent 都有)
|
||||
# 无当前项目时,点击「需要项目」的按钮弹报错(不打开页面)
|
||||
_no_proj_script = "var m=new bricks.Message({title:'提示',message:'请先在会话中切换项目'});m.open();"
|
||||
|
||||
def _bind(url, require_project):
|
||||
if require_project and not pid:
|
||||
return {
|
||||
"wid": "self", "event": "click", "actiontype": "script", "target": "self",
|
||||
"script": _no_proj_script,
|
||||
}
|
||||
return {
|
||||
"wid": "self", "event": "click", "actiontype": "urlwidget",
|
||||
"target": "self", "options": {"url": url},
|
||||
}
|
||||
|
||||
# 固定「工作空间」按钮(通用能力,所有 agent 都有;依赖当前项目)
|
||||
buttons.append({
|
||||
"widgettype": "Button",
|
||||
"options": {"label": "🗂 工作空间", "css": "small", "id": "menu_btn_ws"},
|
||||
"binds": [{
|
||||
"wid": "self", "event": "click", "actiontype": "urlwidget",
|
||||
"target": "self", "options": {"url": entire_url("/pipeline-sdlc/api/workspace_popup.dspy")},
|
||||
}],
|
||||
"binds": [_bind(entire_url("/pipeline-sdlc/api/workspace_popup.dspy"), True)],
|
||||
})
|
||||
|
||||
for i, m in enumerate(menus):
|
||||
@ -60,16 +72,14 @@ for i, m in enumerate(menus):
|
||||
url = str(m.get("url", "") or "")
|
||||
if not url:
|
||||
continue
|
||||
require_project = bool(m.get("require_project", False))
|
||||
width = str(m.get("width", "85%") or "85%")
|
||||
height = str(m.get("height", "80%") or "80%")
|
||||
open_url = entire_url("/pipeline_core/api/agent_menu_open.dspy") + "?url=" + url + "&title=" + label + "&width=" + width + "&height=" + height
|
||||
buttons.append({
|
||||
"widgettype": "Button",
|
||||
"options": {"label": label, "css": "small", "id": "menu_btn_%d" % i},
|
||||
"binds": [{
|
||||
"wid": "self", "event": "click", "actiontype": "urlwidget",
|
||||
"target": "self", "options": {"url": open_url},
|
||||
}],
|
||||
"binds": [_bind(open_url, require_project)],
|
||||
})
|
||||
|
||||
return _json.dumps({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user