Bläddra i källkod

Merge pull request #2271 from visuddhinanda/development

Development
visuddhinanda 11 månader sedan
förälder
incheckning
64409c096b

+ 12 - 3
api-v8/app/Http/Controllers/TaskStatusController.php

@@ -94,6 +94,17 @@ class TaskStatusController extends Controller
             return $this->error('no status', 400, 400);
         }
 
+        $task->status = $request->get('status');
+        $task->editor_id = $user['user_uid'];
+        $task->save();
+        if ($task->type === 'workflow') {
+            return $this->ok(
+                [
+                    "rows" => TaskResource::collection(resource: [$task]),
+                    "count" => 1,
+                ]
+            );
+        }
         switch ($request->get('status')) {
             case 'published':
                 $this->pushChange('published', $id);
@@ -167,9 +178,7 @@ class TaskStatusController extends Controller
                 }
                 break;
         }
-        $task->status = $request->get('status');
-        $task->editor_id = $user['user_uid'];
-        $task->save();
+
         # auto start with ai assistant
         $autoStart = array_merge($this->getChange('published'), $this->getChange('restarted'));
         foreach ($autoStart as $taskId) {

+ 4 - 0
dashboard-v4/dashboard/src/components/discussion/Discussion.tsx

@@ -51,6 +51,10 @@ const DiscussionWidget = ({
     }
   }, [showTopicId]);
 
+  useEffect(() => {
+    setChildrenDrawer(false);
+  }, [resId]);
+
   const showChildrenDrawer = (comment: IComment) => {
     console.debug("discussion comment", comment);
     setChildrenDrawer(true);

+ 15 - 11
dashboard-v4/dashboard/src/components/task/ProjectTask.tsx

@@ -5,6 +5,7 @@ import TaskTable from "../../components/task/TaskTable";
 import TaskRelation from "../../components/task/TaskRelation";
 import { useState } from "react";
 import { ITaskData } from "../../components/api/task";
+import { useIntl } from "react-intl";
 
 interface IWidget {
   studioName?: string;
@@ -20,13 +21,21 @@ const ProjectTask = ({
 }: IWidget) => {
   const [tasks, setTasks] = useState<ITaskData[]>([]);
   const [taskTree, setTaskTree] = useState<ITaskData[]>();
+  const intl = useIntl();
+
+  const onDataChange = (treeData: ITaskData[]) => {
+    setTaskTree(treeData);
+    const listData = treeToList(treeData);
+    setTasks(listData);
+    onChange && onChange(listData);
+  };
   return (
     <>
       <Tabs
         type="card"
         items={[
           {
-            label: "列表",
+            label: intl.formatMessage({ id: "labels.list" }),
             key: "list",
             children: (
               <TaskList
@@ -34,23 +43,18 @@ const ProjectTask = ({
                 studioName={studioName}
                 projectId={projectId}
                 taskTree={taskTree}
-                onChange={(treeData: ITaskData[]) => {
-                  setTaskTree(treeData);
-                  const listData = treeToList(treeData);
-                  setTasks(listData);
-                  onChange && onChange(listData);
-                }}
+                onChange={onDataChange}
               />
             ),
           },
           {
-            label: "表格",
+            label: intl.formatMessage({ id: "labels.table" }),
             key: "table",
-            children: <TaskTable tasks={tasks} />,
+            children: <TaskTable tasks={tasks} onChange={onDataChange} />,
           },
           {
-            label: "关系图",
-            key: "relation",
+            label: intl.formatMessage({ id: "labels.flowchart" }),
+            key: "flowchart",
             children: <TaskRelation tasks={tasks} />,
           },
         ]}

+ 30 - 9
dashboard-v4/dashboard/src/components/task/TaskRelation.tsx

@@ -13,18 +13,39 @@ const TaskRelation = ({ tasks }: IWidget) => {
 
   //节点样式
   const color = [
-    { status: "pending", fill: "white" },
-    { status: "published", fill: "orange" },
-    { status: "running", fill: "green" },
-    { status: "done", fill: "blue" },
-    { status: "restarted", fill: "red" },
-    { status: "closed", fill: "yellow" },
-    { status: "canceled", fill: "gray" },
-    { status: "expired", fill: "brown" },
+    {
+      status: "pending",
+      fill: "#fafafa",
+      stroke: "#d9d9d9",
+      color: "#000000d9",
+    },
+    {
+      status: "published",
+      fill: "#fff7e6",
+      stroke: "#ffd591",
+      color: "#d46b08",
+    },
+    { status: "running", fill: "#e6f7ff", stroke: "#91d5ff", color: "#1890ff" },
+    { status: "done", fill: "#f6ffed", stroke: "#b7eb8f", color: "#52c41a" },
+    {
+      status: "restarted",
+      fill: "r#fff2f0",
+      stroke: "#ffccc7",
+      color: "#ff4d4f",
+    },
+    {
+      status: "requested_restart",
+      fill: "#fffbe6",
+      stroke: "#ffe58f",
+      color: "#faad14",
+    },
+    { status: "closed", fill: "yellow", stroke: "#333", color: "#333" },
+    { status: "canceled", fill: "gray", stroke: "#333", color: "#333" },
+    { status: "expired", fill: "brown", stroke: "#333", color: "#333" },
   ];
 
   color.forEach((value) => {
-    mermaidText += `classDef ${value.status} fill:${value.fill},stroke:#333,stroke-width:2px;\n`;
+    mermaidText += `classDef ${value.status} fill:${value.fill},stroke:${value.stroke},color:${value.color},stroke-width:1px;\n`;
   });
 
   let relationLine = new Map<string, number>();

+ 1 - 1
dashboard-v4/dashboard/src/components/task/TaskStatus.tsx

@@ -37,7 +37,7 @@ const TaskStatus = ({ task }: IWidget) => {
       color = "default";
       break;
     case "published":
-      color = "default";
+      color = "orange";
       break;
     case "running":
       color = "processing";

+ 7 - 2
dashboard-v4/dashboard/src/components/task/TaskTable.tsx

@@ -14,8 +14,9 @@ interface ITaskHeading {
 
 interface IWidget {
   tasks?: ITaskData[];
+  onChange?: (treeData: ITaskData[]) => void;
 }
-const TaskTable = ({ tasks }: IWidget) => {
+const TaskTable = ({ tasks, onChange }: IWidget) => {
   const [tasksTitle, setTasksTitle] = useState<ITaskHeading[][]>();
   const [dataHeading, setDataHeading] = useState<string[]>();
   const [projects, setProjects] = useState<IProject[]>();
@@ -142,7 +143,11 @@ const TaskTable = ({ tasks }: IWidget) => {
                         )}
                       </div>
                       <div>
-                        <TaskStatusButton type="tag" task={taskData} />
+                        <TaskStatusButton
+                          type="tag"
+                          task={taskData}
+                          onChange={onChange}
+                        />
                       </div>
                     </div>
                   </td>

+ 3 - 0
dashboard-v4/dashboard/src/locales/en-US/label.ts

@@ -86,6 +86,9 @@ const items = {
   "labels.filters.or": "or",
   "labels.task.workflows": "Workflows",
   "labels.milestone": "milestone",
+  "labels.flowchart": "flowchart",
+  "labels.table": "table",
+  "labels.list": "list",
 };
 
 export default items;

+ 3 - 0
dashboard-v4/dashboard/src/locales/zh-Hans/label.ts

@@ -94,6 +94,9 @@ const items = {
   "labels.filters.or": "任一条件",
   "labels.task.workflows": "工作流",
   "labels.milestone": "里程碑",
+  "labels.flowchart": "流程图",
+  "labels.table": "表格",
+  "labels.list": "列表",
 };
 
 export default items;