From 09dfd3804e033b13f7d24426c9dfb9720dfafc75 Mon Sep 17 00:00:00 2001 From: Junyi Date: Thu, 5 May 2022 20:55:35 +0800 Subject: [PATCH] fix(plugin-workflow): add document title (#363) --- packages/core/client/src/workflow/WorkflowCanvas.tsx | 9 ++++++++- packages/core/client/src/workflow/nodes/condition.tsx | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/workflow/WorkflowCanvas.tsx b/packages/core/client/src/workflow/WorkflowCanvas.tsx index 7b7efa1a1..087b3a3f5 100644 --- a/packages/core/client/src/workflow/WorkflowCanvas.tsx +++ b/packages/core/client/src/workflow/WorkflowCanvas.tsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import React, { useContext, useEffect } from 'react'; import { Dropdown, Menu, Button } from 'antd'; import { PlusOutlined } from '@ant-design/icons'; import { cx } from '@emotion/css'; @@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next'; import { useCollection, useCompile, + useDocumentTitle, useResourceActionContext } from '..'; import { Instruction, instructions, Node } from './nodes'; @@ -39,6 +40,12 @@ export function WorkflowCanvas() { const { t } = useTranslation(); const { data, refresh, loading } = useResourceActionContext(); + const { setTitle } = useDocumentTitle(); + useEffect(() => { + const { title } = data?.data ?? {}; + setTitle(`${title ? `${title} - ` : ''}${t('Workflow')}`); + }, [data?.data]); + if (!data?.data && !loading) { return
{t('Load failed')}
; } diff --git a/packages/core/client/src/workflow/nodes/condition.tsx b/packages/core/client/src/workflow/nodes/condition.tsx index c34a8307d..d9103ce07 100644 --- a/packages/core/client/src/workflow/nodes/condition.tsx +++ b/packages/core/client/src/workflow/nodes/condition.tsx @@ -131,8 +131,6 @@ function CalculationConfig({ value, onChange }) { ); } -console.log(i18n.t('Collection name')); - export default { title: '{{t("Condition")}}', type: 'condition',