From e9a482e2935494d9422ef4704e7eda9a1d37f4c4 Mon Sep 17 00:00:00 2001 From: liwenrui Date: Sat, 15 Jul 2023 09:45:15 +0800 Subject: [PATCH] * refactor prompt menu. --- module/ai/view/prompts.html.php | 65 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/module/ai/view/prompts.html.php b/module/ai/view/prompts.html.php index 4abbeec20c..e0f013126a 100644 --- a/module/ai/view/prompts.html.php +++ b/module/ai/view/prompts.html.php @@ -10,6 +10,37 @@ */ ?> +ai->isExecutable($prompt); + $publishable = $prompt->status == 'draft'; + + /* Design button. */ + $html .= html::a(helper::createLink('ai', 'promptassignrole', "prompt=$prompt->id"), '', '', "class='btn' title='{$lang->ai->prompts->action->design}'"); + + /* Test / audit button. */ + $html .= html::a($executable ? $this->ai->getTestingLocation($prompt) : '#', '', '', "class='btn' title='{$lang->ai->prompts->action->test}'" . ($executable ? '' : " data-toggle='modal' data-target='#designConfirmModal'")); + + /* Edit button. */ + $html .= html::a(helper::createLink('ai', '', "prompt=$prompt->id"), '', '', "class='btn' title='{$lang->ai->prompts->action->edit}'"); + + /* Publish button. */ + $html .= html::a($publishable && $executable ? "javascript:togglePromptStatus($prompt->id)" : '#', '', '', "class='btn" . ($publishable ? '' : ' disabled') . "' title='{$lang->ai->prompts->action->publish}'" . ($executable ? '' : " data-toggle='modal' data-target='#designConfirmModal'")); + + /* Unpublish button. */ + $html .= html::a('#', '', '', "class='btn" . ($publishable ? ' disabled' : '') . "' title='{$lang->ai->prompts->action->unpublish}'" . ($publishable ? '' : " data-toggle='modal' data-target='#draftConfirmModal'")); + + echo $html; + } +?>