From 188800c018c9e04a48cab8304532f099b51d4843 Mon Sep 17 00:00:00 2001 From: Junyi Date: Fri, 11 Nov 2022 23:37:41 +0800 Subject: [PATCH] Refactor: plugin-workflow client (#1077) * feat(plugin-worklfow): adjust ui * refactor(plugin-workflow): move locale into plugin * fix(plugin-workflow): fix executions history loading --- packages/core/client/src/locale/en_US.ts | 89 +------- packages/core/client/src/locale/ja_JP.ts | 89 +------- packages/core/client/src/locale/ru_RU.ts | 89 +------- packages/core/client/src/locale/tr_TR.ts | 89 +------- packages/core/client/src/locale/zh_CN.ts | 131 +----------- .../core/client/src/pm/PluginManagerLink.tsx | 2 +- .../antd/filter/FilterItem.tsx | 2 +- .../plugins/workflow/src/client/AddButton.tsx | 7 +- .../workflow/src/client/ExecutionCanvas.tsx | 14 +- .../src/client/ExecutionResourceProvider.tsx | 7 +- .../workflow/src/client/WorkflowCanvas.tsx | 72 +++++-- .../workflow/src/client/WorkflowProvider.tsx | 22 +- .../workflow/src/client/WorkflowShortcut.tsx | 5 +- .../workflow/src/client/calculators.tsx | 31 +-- .../client/components/CollectionFieldset.tsx | 5 +- .../src/client/components/Duration.tsx | 5 +- .../plugins/workflow/src/client/constants.tsx | 19 +- .../workflow/src/client/locale/en-US.ts | 89 ++++++++ .../workflow/src/client/locale/index.ts | 24 +++ .../workflow/src/client/locale/ja-JP.ts | 89 ++++++++ .../workflow/src/client/locale/ru-RU.ts | 89 ++++++++ .../workflow/src/client/locale/tr-TR.ts | 89 ++++++++ .../workflow/src/client/locale/zh-CN.ts | 129 ++++++++++++ .../workflow/src/client/nodes/calculation.tsx | 7 +- .../workflow/src/client/nodes/condition.tsx | 19 +- .../workflow/src/client/nodes/create.tsx | 3 +- .../workflow/src/client/nodes/delay.tsx | 13 +- .../workflow/src/client/nodes/index.tsx | 16 +- .../workflow/src/client/nodes/parallel.tsx | 20 +- .../workflow/src/client/nodes/query.tsx | 5 +- .../workflow/src/client/nodes/update.tsx | 5 +- .../workflow/src/client/schemas/collection.ts | 3 +- .../src/client/schemas/executions.tsx | 199 +++++++++--------- .../workflow/src/client/schemas/workflows.ts | 20 +- .../src/client/triggers/collection.tsx | 21 +- .../workflow/src/client/triggers/index.tsx | 5 +- .../client/triggers/schedule/EndsByField.tsx | 4 +- .../src/client/triggers/schedule/OnField.tsx | 12 +- .../client/triggers/schedule/RepeatField.tsx | 5 +- .../triggers/schedule/ScheduleConfig.tsx | 29 +-- .../src/client/triggers/schedule/index.tsx | 7 +- 41 files changed, 837 insertions(+), 743 deletions(-) create mode 100644 packages/plugins/workflow/src/client/locale/en-US.ts create mode 100644 packages/plugins/workflow/src/client/locale/index.ts create mode 100644 packages/plugins/workflow/src/client/locale/ja-JP.ts create mode 100644 packages/plugins/workflow/src/client/locale/ru-RU.ts create mode 100644 packages/plugins/workflow/src/client/locale/tr-TR.ts create mode 100644 packages/plugins/workflow/src/client/locale/zh-CN.ts diff --git a/packages/core/client/src/locale/en_US.ts b/packages/core/client/src/locale/en_US.ts index 60ddf9e42f..ec6e93a511 100644 --- a/packages/core/client/src/locale/en_US.ts +++ b/packages/core/client/src/locale/en_US.ts @@ -186,6 +186,7 @@ export default { "Foreign key 2": "Foreign key 2", "Add filter": "Add filter", "Add filter group": "Add filter group", + "Comparision": "Comparision", "is": "is", "is not": "is not", "is variable": "is variable", @@ -425,94 +426,6 @@ export default { "Aliyun OSS": "Aliyun OSS", "Tencent COS": "Tencent COS", "Amazon S3": "Amazon S3", - "Workflow": "Workflow", - "Execution history": "Execution history", - "Trigger type": "Trigger type", - "Description": "Description", - "Status": "Status", - "On": "On", - "Off": "Off", - "Version": "Version", - "Copy to new version": "Copy to new version", - "Load failed": "Load failed", - "Trigger": "Trigger", - "Collection event": "Collection event", - "Trigger on": "Trigger on", - "After record added": "After record added", - "After record updated": "After record updated", - "After record added or updated": "After record added or updated", - "After record deleted": "After record deleted", - "Changed fields": "Changed fields", - "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", - "Only triggers when match conditions": "Only triggers when match conditions", - "Schedule event": "Schedule event", - "Trigger mode": "Trigger mode", - "Based on certain date": "Based on certain date", - "Based on date field of collection": "Based on date field of collection", - "Starts on": "Starts on", - "Ends on": "Ends on", - "Exactly at": "Exactly at", - "Repeat mode": "Repeat mode", - "Repeat limit": "Repeat limit", - "No limit": "No limit", - "Seconds": "Seconds", - "Minutes": "Minutes", - "Hours": "Hours", - "Days": "Days", - "Weeks": "Weeks", - "Months": "Months", - "No repeat": "No repeat", - "Every": "Every", - "By minute": "By minute", - "By hour": "By hour", - "By day": "By day", - "By week": "By week", - "By month": "By month", - "By field": "By field", - "By custom date": "By custom date", - "Advanced": "Advanced", - "Advanced type": "Advanced", - "End": "End", - "Trigger context": "Trigger context", - "Node result": "Node result", - "Constant": "Constant", - "Boolean": "Boolean", - "String": "String", - "Comparison": "Comparison", - "Arithmetic calculation": "Arithmetic calculation", - "String operation": "String operation", - "On going": "On going", - "Succeeded": "Succeeded", - "Failed": "Failed", - "Canceled": "Canceled", - "This node contains branches, deleting will also be preformed to them, are you sure?": "This node contains branches, deleting will also be preformed to them, are you sure?", - "Control": "Control", - "Collection operations": "Collection operations", - "Node type": "Node type", - "Calculation": "Calculation", - "Configure calculation": "Configure calculation", - "Calculation result": "Calculation result", - "True": "True", - "False": "False", - "Condition": "Condition", - "Mode": "Mode", - "Continue when \"Yes\"": "Continue when \"Yes\"", - "Branch into \"Yes\" and \"No\"": "Branch into \"Yes\" and \"No\"", - "Conditions": "Conditions", - "Parallel branch": "Parallel branch", - "All succeeded": "All succeeded", - "Any succeeded": "Any succeeded", - "Continue after all branches succeeded": "Continue after all branches succeeded", - "Continue after any branch succeeded": "Continue after any branch succeeded", - "Create record": "Create record", - "Update record": "Update record", - "Query record": "Query record", - "Multiple records": "Multiple records", - "Please select collection first": "Please select collection first", - "Only update records matching conditions": "Only update records matching conditions", - "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.", - "Trigger in executed workflow cannot be modified": "Trigger in executed workflow cannot be modified", - "Node in executed workflow cannot be modified": "Node in executed workflow cannot be modified", "Unsaved changes": "Unsaved changes", "Are you sure you don't want to save?": "Are you sure you don't want to save?", "Dragging": "Dragging", diff --git a/packages/core/client/src/locale/ja_JP.ts b/packages/core/client/src/locale/ja_JP.ts index 0c7ad93206..885a598223 100644 --- a/packages/core/client/src/locale/ja_JP.ts +++ b/packages/core/client/src/locale/ja_JP.ts @@ -176,6 +176,7 @@ export default { "Foreign key 2": "外部キー2", "Add filter": "フィルターを追加", "Add filter group": "フィルターグループを追加", + "Comparision": "比較", "is": "が同じである", "is not": "が同じではない", "is variable": "が変数である", @@ -415,94 +416,6 @@ export default { "Aliyun OSS": "Aliyun OSS", "Tencent COS": "Tencent COS", "Amazon S3": "Amazon S3", - "Workflow": "ワークフロー", - "Execution history": "実行履歴", - "Trigger type": "トリガータイプ", - "Description": "説明", - "Status": "状態", - "On": "有効", - "Off": "無効", - "Version": "バージョン", - "Copy to new version": "新しいバージョンにコピー", - "Load failed": "読み込みに失敗しました", - "Trigger": "トリガー", - "Collection event": "コレクションイベント", - "Trigger on": "トリガータイミング", - "After record added": "レコードを追加した後", - "After record updated": "レコードを更新した後", - "After record added or updated": "レコードを追加もしくは更新した後", - "After record deleted": "レコードを削除した後", - "Changed fields": "フィールドが変更された時", - "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "選択したフィールドの 1 つが変更された場合にのみトリガーされます。 選択されていない場合は、フィールドが変更されたときにトリガーされることを意味します。 レコードが追加または削除されると、すべてのフィールドが変更されたと見なされます。", - "Only triggers when match conditions": "以下の条件を満たすと発動", - "Schedule event": "スケジュールイベント", - "Trigger mode": "トリガーモード", - "Based on certain date": "カスタム時間", - "Based on date field of collection": "コレクションのフィールド時間に基づく", - "Starts on": "開始", - "Ends on": "終了", - "Exactly at": "ちょうど", - "Repeat mode": "繰り返しパターン", - "Repeat limit": "繰り返し回数", - "No limit": "無制限", - "Seconds": "秒", - "Minutes": "分", - "Hours": "時", - "Days": "日", - "Weeks": "週", - "Months": "月", - "No repeat": "繰り返さない", - "Every": "毎", - "By minute": "分ごと", - "By hour": "時間ごと", - "By day": "日ごと", - "By week": "週ごと", - "By month": "月ごと", - "By field": "フィールドごと", - "By custom date": "カスタム時間", - "Advanced": "アドバンスド", - "Advanced type": "アドバンスタイプ", - "End": "終了", - "Trigger context": "トリガーフィールド", - "Node result": "ノードの結果", - "Constant": "定数", - "Boolean": "論理値", - "String": "文字列", - "Comparison": "比較", - "Arithmetic calculation": "算術演算", - "String operation": "文字列操作", - "On going": "処理中", - "Succeeded": "成功", - "Failed": "失敗", - "Canceled": "取消", - "This node contains branches, deleting will also be preformed to them, are you sure?": "ノードにはブランチが含まれており、そのすべてのブランチの下にあるすべての子ノードが同時に削除されます。続行してもよろしいですか?", - "Control": "プロセス制御", - "Collection operations": "フィールド操作", - "Node type": "ノードタイプ", - "Calculation": "演算", - "Configure calculation": "演算設定", - "Calculation result": "演算結果", - "True": "真", - "False": "偽", - "Condition": "条件", - "Mode": "モデル", - "Continue when \"Yes\"": "「はい」の場合に続行", - "Branch into \"Yes\" and \"No\"": "「はい」と「いいえ」で分岐して続行", - "Conditions": "条件設定", - "Parallel branch": "分岐", - "All succeeded": "すべて成功", - "Any succeeded": "いずれかが成功", - "Continue after all branches succeeded": "すべての分岐が成功した後に続行", - "Continue after any branch succeeded": "いずれかの分岐が成功した後に続行", - "Create record": "レコード追加", - "Update record": "レコード更新", - "Query record": "クエリ レコード", - "Multiple records": "複数レコード", - "Please select collection first": "先にコレクションを選択してください", - "Only update records matching conditions": "条件を満たすレコードのみ更新", - "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "値が割り当てられていないフィールドはデフォルト値に設定され、デフォルト値がないフィールドは null に設定されます", - "Trigger in executed workflow cannot be modified": "すでにワークフローを実行したトリガーは変更できません", - "Node in executed workflow cannot be modified": "すでに実行されたワークフローのノードは変更できません", "Unsaved changes": "変更が保存されていません", "Are you sure you don't want to save?": "変更を保存しなくてもよいですか?", "Dragging": "ドラッグ", diff --git a/packages/core/client/src/locale/ru_RU.ts b/packages/core/client/src/locale/ru_RU.ts index b2e98e4c59..df19194e13 100644 --- a/packages/core/client/src/locale/ru_RU.ts +++ b/packages/core/client/src/locale/ru_RU.ts @@ -176,6 +176,7 @@ export default { "Foreign key 2": "Внешний ключ 2", "Add filter": "Добавить фильтр", "Add filter group": "Добавить группу фильтров", + "Comparision": "Сравнение", "is": "соответствует", "is not": "не соответствует", "is variable": "это переменная", @@ -415,94 +416,6 @@ export default { "Aliyun OSS": "Aliyun OSS", "Tencent COS": "Tencent COS", "Amazon S3": "Amazon S3", - "Workflow": "Workflow", - "Execution history": "История запусков", - "Trigger type": "Тип триггера", - "Description": "Описание", - "Status": "Статус", - "On": "Вкл.", - "Off": "Выкл.", - "Version": "Версия", - "Copy to new version": "Скопировать в новую версию", - "Load failed": "Загрузка не удалась", - "Trigger": "Триггер", - "Collection event": "Событие коллекции", - "Trigger on": "Триггер на", - "After record added": "После добавления записи", - "After record updated": "После обновления записи", - "After record added or updated": "После добавления или обновления записи", - "After record deleted": "После удаления записи", - "Changed fields": "Измененные поля", - "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "Запускается только при изменении одного из выбранных полей. Если флажок не установлен, это означает, что он будет срабатывать при изменении любого поля. При добавлении или удалении записи любое поле считается измененным.", - "Only triggers when match conditions": "Срабатывает только при совпадении условий", - "Schedule event": "Событие по расписанию", - "Trigger mode": "Режим триггера", - "Based on certain date": "На основе определенной даты", - "Based on date field of collection": "На базе поля с датой в коллекции", - "Starts on": "Стартует с", - "Ends on": "Оканчивается в", - "Exactly at": "Ровно в", - "Repeat mode": "Режим повтора", - "Repeat limit": "Ограничение на повторы", - "No limit": "Нет ограничений", - "Seconds": "Секунды", - "Minutes": "Минуты", - "Hours": "Часы", - "Days": "Дни", - "Weeks": "Недели", - "Months": "Месяцы", - "No repeat": "Не повторять", - "Every": "Каждые", - "By minute": "По минутам", - "By hour": "По часам", - "By day": "По дням", - "By week": "По неделям", - "By month": "По месяцам", - "By field": "По полю", - "By custom date": "По пользовательской дате", - "Advanced": "Продвинутый", - "Advanced type": "Продвинутый", - "End": "Окончание", - "Trigger context": "Контекст триггера", - "Node result": "Результат Узла", - "Constant": "Константа", - "Boolean": "Логический", - "String": "Строка", - "Comparison": "Сравнение", - "Arithmetic calculation": "Арифметическое вычисление", - "String operation": "Операция со строкой", - "On going": "Непрерывный", - "Succeeded": "Успешный", - "Failed": "Неудачный", - "Canceled": "Прерванный", - "This node contains branches, deleting will also be preformed to them, are you sure?": "Этот узел содержит ветки, к ним тоже будет произведено удаление, вы уверены?", - "Control": "Управление", - "Collection operations": "Операции с Коллекцией", - "Node type": "Тип Узла", - "Calculation": "Вычисление", - "Configure calculation": "Настроить вычисление", - "Calculation result": "Результат вычисления", - "True": "Истина", - "False": "Ложь", - "Condition": "Условие", - "Mode": "Режим", - "Continue when \"Yes\"": "Продолжить когда \"Да\"", - "Branch into \"Yes\" and \"No\"": "Разветвление на \"Да\" and \"Нет\"", - "Conditions": "Условия", - "Parallel branch": "Параллельная ветвь", - "All succeeded": "Всё успешно", - "Any succeeded": "Что-то успешно", - "Continue after all branches succeeded": "Продолжать после успеха на всех ветвях", - "Continue after any branch succeeded": "Продолжать после успеха на любой из ветвей", - "Create record": "Создать запись", - "Update record": "Обновить запись", - "Query record": "Запрос записи", - "Multiple records": "Множество записей", - "Please select collection first": "Выберите сначала Коллекцию, пожалуйста", - "Only update records matching conditions": "Обновлять только записи, соответствующие условиям", - "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "Поля, которым не присвоено значение, будут установлены на значение по умолчанию, а поля, не имеющие значения по умолчанию, будут установлены на null.", - "Trigger in executed workflow cannot be modified": "Триггер в выполняемом рабочем процессе не может быть изменен", - "Node in executed workflow cannot be modified": "Узел в выполняемом рабочем процессе не может быть изменен", "Unsaved changes": "Несохраненные изменения", "Are you sure you don't want to save?": "Вы уверены, что не хотите сохранить?", "Dragging": "Перетаскивание", diff --git a/packages/core/client/src/locale/tr_TR.ts b/packages/core/client/src/locale/tr_TR.ts index 222179d8a4..e9317c567d 100644 --- a/packages/core/client/src/locale/tr_TR.ts +++ b/packages/core/client/src/locale/tr_TR.ts @@ -176,6 +176,7 @@ export default { "Foreign key 2": "Yabancı anahtar 2", "Add filter": "Filtre ekle", "Add filter group": "Filtre grubu ekle", + "Comparision": "Karşılaştırma", "is": "eşittir", "is not": "eşit değildir", "is variable": "is variable", @@ -414,94 +415,6 @@ export default { "Local storage": "Lokal depolama", "Aliyun OSS": "Aliyun OSS", "Amazon S3": "Amazon S3", - "Workflow": "İş Akışı", - "Execution history": "Yürütme Geçmişi", - "Trigger type": "Tetikleme türü", - "Description": "Açıklama", - "Status": "Durum", - "On": "Aç", - "Off": "Kapa", - "Version": "Sürüm", - "Copy to new version": "Yeni sürüme kopyala", - "Load failed": "Yükleme başarısız", - "Trigger": "Tetikle", - "Collection event": "Koleksiyon etkinliği", - "Trigger on": "Tetikleme açık", - "After record added": "Kayıt eklendikten sonra", - "After record updated": "Kayıt güncellendikten sonra", - "After record added or updated": "Kayıt eklendikten veya güncellendikten sonra", - "After record deleted": "Kayıt silindikten sonra", - "Changed fields": "Değiştirilen alanlar", - "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "Yalnızca seçilen alanlardan biri değiştiğinde tetiklenir. Seçili değilse, herhangi bir alan değiştiğinde tetikleneceği anlamına gelir. Kayıt eklendiğinde veya silindiğinde, herhangi bir alan değiştirilmiş olarak kabul edilir.", - "Only triggers when match conditions": "Yalnızca eşleşme koşulları olduğunda tetiklenir", - "Schedule event": "Etkinlik planla", - "Trigger mode": "Tetikleme modu", - "Based on certain date": "Belirli bir tarihe göre", - "Based on date field of collection": "Koleksiyonun tarih alanına göre", - "Starts on": "Başlangıç", - "Ends on": "Bitiş", - "Exactly at": "Tam zamanı", - "Repeat mode": "Tekrarlama modu", - "Repeat limit": "Tekrarlama limiti", - "No limit": "Limit yok", - "Seconds": "Saniye", - "Minutes": "Dakika", - "Hours": "Saat", - "Days": "Gün", - "Weeks": "Hafta", - "Months": "Ay", - "No repeat": "Tekrar yok", - "Every": "Her", - "By minute": "Dakikada", - "By hour": "Saatte", - "By day": "Günde", - "By week": "Haftada", - "By month": "Ayda", - "By field": "Alanda", - "By custom date": "Özel tarihe göre", - "Advanced": "Gelişmiş", - "Advanced type": "Gelişmiş", - "End": "Son", - "Trigger context": "Tetikleyici bağlamı", - "Node result": "Düğüm sonucu", - "Constant": "Devamlı", - "Boolean": "Boolean", - "String": "String", - "Comparison": "Karşılaştırma", - "Arithmetic calculation": "Aritmetik hesaplama", - "String operation": "String operation", - "On going": "Devam eden", - "Succeeded": "Başarılı", - "Failed": "Başarısız", - "Canceled": "İptal edilen", - "This node contains branches, deleting will also be preformed to them, are you sure?": "Bu düğüm başka içeriklerle bağlantı içeriyor, silme işlemini onaylarsanız o bağlantılarda silinecek, emin misiniz?", - "Control": "Kontrol", - "Collection operations": "Koleksiyon operasyonları", - "Node type": "Düğüm türü", - "Calculation": "Hesaplama", - "Configure calculation": "Hesaplamayı yapılandır", - "Calculation result": "Hesaplama sonucu", - "True": "Doğru", - "False": "Yanlış", - "Condition": "Koşul", - "Mode": "Tür", - "Continue when \"Yes\"": "\"Evet\" durumunda devam", - "Branch into \"Yes\" and \"No\"": "\"Evet\" ve \"Hayır\" olarak dallandırın", - "Conditions": "Koşullar", - "Parallel branch": "Paralel dal", - "All succeeded": "Hepsi başarılı", - "Any succeeded": "Herhangi biri başarılı", - "Continue after all branches succeeded": "Tüm dallar başarılı olduktan sonra devam et", - "Continue after any branch succeeded": "Herhangi bir dal başarılı olduktan sonra devam et", - "Create record": "Kayıt oluştur", - "Update record": "Kayıt güncelle", - "Query record": "Sorgu kaydı", - "Multiple records": "Birden çok kayıt", - "Please select collection first": "Lütfen önce koleksiyonu seçin", - "Only update records matching conditions": "Yalnızca koşullarla eşleşen kayıtları güncelleyin", - "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "Değer atanmamış alanlar varsayılan değere, varsayılan değeri olmayan alanlar ise null olarak ayarlanır.", - "Trigger in executed workflow cannot be modified": "Yürütülen iş akışındaki tetikleyici değiştirilemez", - "Node in executed workflow cannot be modified": "Yürütülen iş akışındaki düğüm değiştirilemez", "Unsaved changes": "Değişiklikler kaydedilmedi", "Are you sure you don't want to save?": "kaydetmek istemediğinizden emin misiniz??", "Dragging": "Sürükleme", diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index eff8bba0a7..91b12ab544 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -227,6 +227,7 @@ export default { "Sortable": "可排序", "Add filter": "添加筛选条件", "Add filter group": "添加筛选分组", + "Comparision": "值比较", "is": "等于", "is not": "不等于", "is variable": "为动态变量", @@ -525,136 +526,6 @@ export default { 'Bucket': '存储桶', 'Path': '路径(相对)', - // plugins/workflow - 'Workflow': '工作流', - 'Execution history': '执行历史', - 'Trigger type': '触发方式', - 'Description': '描述', - 'Status': '状态', - 'On': '启用', - 'Off': '停用', - 'Version': '版本', - 'Copy to new version': '复制到新版本', - - 'Loading': '加载中', - 'Load failed': '加载失败', - - 'Trigger': '触发器', - 'Trigger context': '触发数据', - 'Trigger data': '触发数据', - 'Trigger time': '触发时间', - 'Triggered at': '触发时间', - 'Collection event': '数据表事件', - 'Trigger on': '触发时机', - 'After record added': '新增数据后', - 'After record updated': '更新数据后', - 'After record added or updated': '新增或更新数据后', - 'After record deleted': '删除数据后', - 'Changed fields': '发生变动的字段', - 'Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.': '只有被选中的某个字段发生变动时才会触发。如果不选择,则表示任何字段变动时都会触发。新增或删除数据时,任意字段都被认为发生变动。', - 'Only triggers when match conditions': '满足以下条件才触发', - - 'Schedule event': '定时任务', - 'Trigger mode': '触发模式', - 'Based on certain date': '自定义时间', - 'Based on date field of collection': '根据数据表时间字段', - 'Starts on': '开始于', - 'Ends on': '结束于', - 'Exactly at': '当时', - 'Repeat mode': '重复模式', - 'Repeat limit': '重复次数', - 'No limit': '不限', - 'Seconds': '秒', - 'Minutes': '分钟', - 'Hours': '小时', - 'Days': '天', - 'Weeks': '周', - 'Months': '月', - - 'No repeat': '不重复', - 'Every': '每', - - 'By minute': '按分钟', - 'By hour': '按小时', - 'By day': '按天', - 'By week': '按周', - 'By month': '按月', - - 'By field': '数据表字段', - 'By custom date': '自定义时间', - - 'Advanced': '高级模式', - 'Advanced type': '高级类型', - - 'End': '结束', - - 'Node result': '节点数据', - 'Constant': '常量', - - 'Boolean': '逻辑值', - 'String': '字符串', - - 'Calculator': '运算', - 'Comparison': '值比较', - 'Arithmetic calculation': '算术运算', - 'String operation': '字符串', - - 'Executed at': '执行于', - - 'Queueing': '队列中', - 'On going': '进行中', - 'Succeeded': '成功', - 'Failed': '失败', - 'Pending': '等待处理', - 'Canceled': '已取消', - - 'This node contains branches, deleting will also be preformed to them, are you sure?': '节点包含分支,将同时删除其所有分支下的子节点,确定继续?', - - 'Control': '流程控制', - 'Collection operations': '数据表操作', - 'Extended': '扩展类型', - - 'Node type': '节点类型', - - 'Calculation': '运算', - 'Configure calculation': '配置运算', - 'Calculation result': '运算结果', - 'True': '真', - 'False': '假', - 'concat': '连接', - - 'Condition': '条件判断', - 'Mode': '模式', - 'Continue when "Yes"': '“是”则继续', - 'Branch into "Yes" and "No"': '“是”和“否”分别继续', - 'Conditions': '条件配置', - - 'Parallel branch': '分支', - 'Add branch': '增加分支', - 'All succeeded': '全部成功', - 'Any succeeded': '任意成功', - 'Any succeeded or failed': '任意成功或失败', - 'Continue after all branches succeeded': '全部分支都成功后才能继续', - 'Continue after any branch succeeded': '任意分支成功后就继续', - 'Continue after any branch succeeded, or exit after any branch failed': '任意分支成功继续,或失败后退出', - - 'Delay': '延时', - 'Duration': '时长', - 'End Status': '到时状态', - 'Select status': '选择状态', - 'Succeed and continue': '通过并继续', - 'Fail and exit': '失败并退出', - - 'Create record': '新增数据', - 'Update record': '更新数据', - 'Query record': '查询数据', - 'Multiple records': '多条数据', - 'Please select collection first': '请先选择数据表', - 'Only update records matching conditions': '只更新满足条件的数据', - 'Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.': '未被赋值的字段将被设置为默认值,没有默认值的设置为空值。', - 'Trigger in executed workflow cannot be modified': '已经执行过工作流的触发器不能被修改', - 'Node in executed workflow cannot be modified': '已经执行过工作流中的节点不能被修改', - 'Unsaved changes': '未保存修改', 'Are you sure you don\'t want to save?': '你确定不保存修改吗?', 'Dragging': '拖拽中', diff --git a/packages/core/client/src/pm/PluginManagerLink.tsx b/packages/core/client/src/pm/PluginManagerLink.tsx index 6e225ce044..538e3b76a8 100644 --- a/packages/core/client/src/pm/PluginManagerLink.tsx +++ b/packages/core/client/src/pm/PluginManagerLink.tsx @@ -63,7 +63,7 @@ export const SettingsCenterDropdown = () => { path: 'system-settings/system-settings', }, { - title: t('Workflow'), + title: t('workflow:Workflow'), path: 'workflow/workflows', }, // { diff --git a/packages/core/client/src/schema-component/antd/filter/FilterItem.tsx b/packages/core/client/src/schema-component/antd/filter/FilterItem.tsx index 4886e15fd6..4c52014019 100644 --- a/packages/core/client/src/schema-component/antd/filter/FilterItem.tsx +++ b/packages/core/client/src/schema-component/antd/filter/FilterItem.tsx @@ -40,7 +40,7 @@ export const FilterItem = observer((props: any) => { onChange={(value) => { setOperator(value); }} - placeholder={t('Comparison')} + placeholder={t('Comparision')} /> {!operator?.noValue && React.createElement(DynamicComponent, { diff --git a/packages/plugins/workflow/src/client/AddButton.tsx b/packages/plugins/workflow/src/client/AddButton.tsx index 5eb531fb0e..77b96d12d1 100644 --- a/packages/plugins/workflow/src/client/AddButton.tsx +++ b/packages/plugins/workflow/src/client/AddButton.tsx @@ -9,6 +9,7 @@ import { import { useFlowContext } from './FlowContext'; import { Instruction, instructions, Node } from './nodes'; import { addButtonClass } from './style'; +import { NAMESPACE } from './locale'; interface AddButtonProps { @@ -47,9 +48,9 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) { } const groups = [ - { value: 'control', name: '{{t("Control")}}' }, - { value: 'collection', name: '{{t("Collection operations")}}' }, - { value: 'extended', name: '{{t("Extended")}}' }, + { value: 'control', name: `{{t("Control", { ns: "${NAMESPACE}" })}}` }, + { value: 'collection', name: `{{t("Collection operations", { ns: "${NAMESPACE}" })}}` }, + { value: 'extended', name: `{{t("Extended types", { ns: "${NAMESPACE}" })}}` }, ]; const instructionList = (Array.from(instructions.getValues()) as Instruction[]); diff --git a/packages/plugins/workflow/src/client/ExecutionCanvas.tsx b/packages/plugins/workflow/src/client/ExecutionCanvas.tsx index 1c7695cfd8..322f9c2ebf 100644 --- a/packages/plugins/workflow/src/client/ExecutionCanvas.tsx +++ b/packages/plugins/workflow/src/client/ExecutionCanvas.tsx @@ -16,6 +16,7 @@ import { branchBlockClass, nodeCardClass, nodeMetaClass } from './style'; import { TriggerConfig } from './triggers'; import { Branch } from './Branch'; import { ExecutionStatusOptionsMap } from './constants'; +import { lang } from './locale'; @@ -41,20 +42,19 @@ function makeNodes(nodes, jobs = []): void { } export function ExecutionCanvas() { - const { t } = useTranslation(); const compile = useCompile(); - const { data, refresh, loading } = useResourceActionContext(); + const { data, loading } = useResourceActionContext(); const { setTitle } = useDocumentTitle(); useEffect(() => { const { workflow } = data?.data ?? {}; - setTitle(`${workflow?.title ? `${workflow.title} - ` : ''}${t('Execution history')}`); + setTitle(`${workflow?.title ? `${workflow.title} - ` : ''}${lang('Execution history')}`); }, [data?.data]); if (!data?.data) { if (loading) { - return
{t('Loading')}
+ return
{lang('Loading')}
} else { - return
{t('Load failed')}
; + return
{lang('Load failed')}
; } } @@ -80,7 +80,7 @@ export function ExecutionCanvas() {
- {t('Workflow')} + {lang('Workflow')} @@ -102,7 +102,7 @@ export function ExecutionCanvas() {
- {t('End')} + {lang('End')}
diff --git a/packages/plugins/workflow/src/client/ExecutionResourceProvider.tsx b/packages/plugins/workflow/src/client/ExecutionResourceProvider.tsx index aad16b6558..2894f4d22f 100644 --- a/packages/plugins/workflow/src/client/ExecutionResourceProvider.tsx +++ b/packages/plugins/workflow/src/client/ExecutionResourceProvider.tsx @@ -1,7 +1,7 @@ import React from "react"; import { ResourceActionProvider, useRecord } from "@nocobase/client"; -export const ExecutionResourceProvider = ({ request, ...others }) => { +export const ExecutionResourceProvider = ({ request, filter = {}, ...others }) => { const workflow = useRecord(); const props = { ...others, @@ -11,11 +11,10 @@ export const ExecutionResourceProvider = ({ request, ...others }) => { ...request?.params, filter: { ...(request?.params?.filter), - key: workflow.key + key: workflow.key, } } - }, - workflow + } }; return ( diff --git a/packages/plugins/workflow/src/client/WorkflowCanvas.tsx b/packages/plugins/workflow/src/client/WorkflowCanvas.tsx index 5ca2c9c6ab..eba6bcf647 100644 --- a/packages/plugins/workflow/src/client/WorkflowCanvas.tsx +++ b/packages/plugins/workflow/src/client/WorkflowCanvas.tsx @@ -1,12 +1,14 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { Link, useHistory } from 'react-router-dom'; import { Dropdown, Menu, Button, Tag, Switch, message } from 'antd'; -import { DownOutlined, RightOutlined } from '@ant-design/icons'; +import { DownOutlined, RightOutlined, EllipsisOutlined } from '@ant-design/icons'; import { cx } from '@emotion/css'; import { useTranslation } from 'react-i18next'; import classnames from 'classnames'; import { + ActionContext, + SchemaComponent, useDocumentTitle, useResourceActionContext, useResourceContext @@ -16,7 +18,11 @@ import { FlowContext } from './FlowContext'; import { branchBlockClass, nodeCardClass, nodeMetaClass, workflowVersionDropdownClass } from './style'; import { TriggerConfig } from './triggers'; import { Branch } from './Branch'; +import { executionCollection, executionSchema } from './schemas/executions'; +import { ExecutionLink } from './ExecutionLink'; +import { ExecutionResourceProvider } from './ExecutionResourceProvider'; +import { lang, NAMESPACE } from './locale'; @@ -35,18 +41,18 @@ function makeNodes(nodes): void { } export function WorkflowCanvas() { - const { t } = useTranslation(); const history = useHistory(); const { data, refresh, loading } = useResourceActionContext(); const { resource, targetKey } = useResourceContext(); const { setTitle } = useDocumentTitle(); + const [visible, setVisible] = useState(false); useEffect(() => { const { title } = data?.data ?? {}; - setTitle(`${t('Workflow')}${title ? `: ${title}` : ''}`); + setTitle(`${lang('Workflow')}${title ? `: ${title}` : ''}`); }, [data?.data]); if (!data?.data && !loading) { - return
{t('Load failed')}
; + return
{lang('Load failed')}
; } const { nodes = [], revisions = [], ...workflow } = data?.data ?? {}; @@ -77,11 +83,25 @@ export function WorkflowCanvas() { const { data: { data: revision } } = await resource.revision({ filterByTk: workflow[targetKey] }); - message.success(t('Operation succeeded')); + message.success(lang('Operation succeeded')); history.push(`${revision.id}`); } + async function onMenuCommand({ key }) { + switch (key) { + case 'history': + setVisible(true); + return; + case 'revision': + return onRevision(); + default: + break; + } + } + + const revisionable = workflow.executed && !revisions.find(item => !item.executed && new Date(item.createdAt) > new Date(workflow.createdAt)); + return ( - {t('Workflow')} + {lang('Workflow')} {workflow.title}
@@ -150,7 +188,7 @@ export function WorkflowCanvas() {
- {t('End')} + {lang('End')}
diff --git a/packages/plugins/workflow/src/client/WorkflowProvider.tsx b/packages/plugins/workflow/src/client/WorkflowProvider.tsx index 16da46904a..19323b5d9d 100644 --- a/packages/plugins/workflow/src/client/WorkflowProvider.tsx +++ b/packages/plugins/workflow/src/client/WorkflowProvider.tsx @@ -1,8 +1,17 @@ -import { PluginManagerContext, RouteSwitchContext, SettingsCenterProvider } from '@nocobase/client'; import React, { useContext } from 'react'; +import { PluginManagerContext, RouteSwitchContext, SettingsCenterProvider } from '@nocobase/client'; import { WorkflowPage } from './WorkflowPage'; import { WorkflowPane, WorkflowShortcut } from './WorkflowShortcut'; import { ExecutionPage } from './ExecutionPage'; +import { triggers } from './triggers'; +import { instructions } from './nodes'; +import { lang } from './locale'; + +export const WorkflowContext = React.createContext({}); + +export function useWorkflowContext() { + return useContext(WorkflowContext); +} export const WorkflowProvider = (props) => { const ctx = useContext(PluginManagerContext); @@ -21,10 +30,11 @@ export const WorkflowProvider = (props) => { settings={{ workflow: { icon: 'PartitionOutlined', - title: '{{t("Workflow")}}', + // title: `{{t("Workflow", { ns: "${NAMESPACE}" })}}`, + title: lang('Workflow'), tabs: { workflows: { - title: '{{t("Workflow")}}', + title: lang('Workflow'), component: WorkflowPane, }, }, @@ -35,12 +45,14 @@ export const WorkflowProvider = (props) => { value={{ components: { ...ctx?.components, - WorkflowShortcut, + // WorkflowShortcut, }, }} > - {props.children} + + {props.children} + diff --git a/packages/plugins/workflow/src/client/WorkflowShortcut.tsx b/packages/plugins/workflow/src/client/WorkflowShortcut.tsx index 5f8d8c4cb0..885393ae00 100644 --- a/packages/plugins/workflow/src/client/WorkflowShortcut.tsx +++ b/packages/plugins/workflow/src/client/WorkflowShortcut.tsx @@ -10,6 +10,7 @@ import { workflowSchema } from './schemas/workflows'; import { WorkflowLink } from './WorkflowLink'; import { ExecutionResourceProvider } from './ExecutionResourceProvider'; import { ExecutionLink } from './ExecutionLink'; +import { lang } from './locale'; @@ -29,12 +30,12 @@ export const WorkflowPane = () => { }; export const WorkflowShortcut = () => { - const { t } = useTranslation(); const history = useHistory(); return ( } - title={t('Workflow')} + title={lang('Workflow')} onClick={() => { history.push('/admin/settings/workflow/workflows'); }} diff --git a/packages/plugins/workflow/src/client/calculators.tsx b/packages/plugins/workflow/src/client/calculators.tsx index 4dc5d55492..d8a81f92fa 100644 --- a/packages/plugins/workflow/src/client/calculators.tsx +++ b/packages/plugins/workflow/src/client/calculators.tsx @@ -9,6 +9,7 @@ import { useFlowContext } from "./FlowContext"; import { triggers } from "./triggers"; import { useTranslation } from "react-i18next"; import { Registry } from "@nocobase/utils/client"; +import { lang, NAMESPACE, useWorkflowTranslation } from "./locale"; function NullRender() { return null; @@ -110,7 +111,7 @@ calculators.register('notEndsWith', { group: 'string' }); calculators.register('concat', { - name: '{{t("concat")}}', + name: `{{t("concat", { ns: "${NAMESPACE}" })}}`, type: 'string', group: 'string' }); @@ -118,19 +119,19 @@ calculators.register('concat', { const calculatorGroups = [ { value: 'boolean', - title: '{{t("Comparison")}}' + title: `{{t("Comparision", { ns: "${NAMESPACE}" })}}`, }, { value: 'number', - title: '{{t("Arithmetic calculation")}}' + title: `{{t("Arithmetic calculation", { ns: "${NAMESPACE}" })}}`, }, { value: 'string', - title: '{{t("String operation")}}' + title: `{{t("String operation", { ns: "${NAMESPACE}" })}}`, }, { value: 'date', - title: '{{t("Date")}}' + title: `{{t("Date", { ns: "${NAMESPACE}" })}}`, } ]; @@ -158,7 +159,7 @@ export const BaseTypeSet = new Set(['boolean', 'number', 'string', 'date']); const ConstantTypes = { string: { - title: '{{t("String")}}', + title: `{{t("String", { ns: "${NAMESPACE}" })}}`, value: 'string', component({ onChange, type, options, value }) { return ( @@ -184,7 +185,7 @@ const ConstantTypes = { default: 0 }, boolean: { - title: '{{t("Boolean")}}', + title: `{{t("Boolean", { ns: "${NAMESPACE}" })}}`, value: 'boolean', component({ onChange, type, options, value }) { const { t } = useTranslation(); @@ -194,8 +195,8 @@ const ConstantTypes = { onChange={v => onChange({ value: v, type, options })} placeholder={t('Select')} > - {t('True')} - {t('False')} + {lang('True')} + {lang('False')} ); }, @@ -213,7 +214,7 @@ const ConstantTypes = { export const VariableTypes = { constant: { - title: '{{t("Constant")}}', + title: `{{t("Constant", { ns: "${NAMESPACE}" })}}`, value: 'constant', options: Object.values(ConstantTypes).map(item => ({ value: item.value, @@ -241,7 +242,7 @@ export const VariableTypes = { } }, $jobsMapByNodeId: { - title: '{{t("Node result")}}', + title: `{{t("Node result", { ns: "${NAMESPACE}" })}}`, value: '$jobsMapByNodeId', options() { const node = useNodeContext(); @@ -296,7 +297,7 @@ export const VariableTypes = { } }, $context: { - title: '{{t("Trigger context")}}', + title: `{{t("Trigger context", { ns: "${NAMESPACE}" })}}`, value: '$context', component() { const { workflow } = useFlowContext(); @@ -382,7 +383,7 @@ export function Operand({ } export function Calculation({ calculator, operands = [], onChange }) { - const { t } = useTranslation(); + const { t } = useWorkflowTranslation(); const compile = useCompile(); return ( @@ -400,7 +401,7 @@ export function Calculation({ calculator, operands = [], onChange }) { onChange={v => onChange({ operands, calculator: v })} placeholder={t('Calculator')} > - {calculatorGroups.map(group => ( + {calculatorGroups.filter(group => Boolean(getGroupCalculators(group.value).length)).map(group => ( {getGroupCalculators(group.value).map(([value, { name }]) => ( {compile(name)} @@ -421,7 +422,7 @@ export function Calculation({ calculator, operands = [], onChange }) { export function VariableComponent({ value, onChange, renderSchemaComponent }) { const VTypes = { ...VariableTypes, constant: { - title: '{{t("Constant")}}', + title: `{{t("Constant", { ns: "${NAMESPACE}" })}}`, value: 'constant', options: undefined } diff --git a/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx b/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx index 979ed946e7..c35bba36fe 100644 --- a/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx +++ b/packages/plugins/workflow/src/client/components/CollectionFieldset.tsx @@ -7,6 +7,7 @@ import { css } from "@emotion/css"; import { CollectionField, CollectionProvider, SchemaComponent, useCollectionManager, useCompile } from "@nocobase/client"; import { Operand, parseStringValue, VariableTypes, VariableTypesContext } from "../calculators"; +import { lang, NAMESPACE } from "../locale"; function AssociationInput(props) { const { getCollectionFields } = useCollectionManager(); @@ -63,7 +64,7 @@ export default observer(({ value, onChange }: any) => { const VTypes = { ...(['linkTo', 'hasMany', 'belongsToMany'].includes(field.type) ? {} : VariableTypes), constant: { - title: '{{t("Constant")}}', + title: `{{t("Constant", { ns: "${NAMESPACE}" })}}`, value: 'constant', options: undefined } @@ -150,7 +151,7 @@ export default observer(({ value, onChange }: any) => { } ) - :

{t('Please select collection first')}

+ :

{lang('Please select collection first')}

} ); diff --git a/packages/plugins/workflow/src/client/components/Duration.tsx b/packages/plugins/workflow/src/client/components/Duration.tsx index a9be520ec1..972b7e9520 100644 --- a/packages/plugins/workflow/src/client/components/Duration.tsx +++ b/packages/plugins/workflow/src/client/components/Duration.tsx @@ -1,7 +1,7 @@ import React from "react"; import { InputNumber, Select } from "antd"; -import { useTranslation } from "react-i18next"; import { css } from "@emotion/css"; +import { lang } from "../locale"; const UnitOptions = [ { value: 1_000, label: 'Seconds' }, @@ -16,7 +16,6 @@ function getNumberOption(v) { } export default function ({ value = 60000, onChange }) { - const { t } = useTranslation(); const option = getNumberOption(value); const quantity = Math.round(value / option.value); @@ -28,7 +27,7 @@ export default function ({ value = 60000, onChange }) { onChange(Math.round(v * option.value))}/> diff --git a/packages/plugins/workflow/src/client/constants.tsx b/packages/plugins/workflow/src/client/constants.tsx index 30775e45eb..c6da8be171 100644 --- a/packages/plugins/workflow/src/client/constants.tsx +++ b/packages/plugins/workflow/src/client/constants.tsx @@ -5,6 +5,7 @@ import { CheckOutlined, ExclamationOutlined, } from '@ant-design/icons'; +import { NAMESPACE } from './locale'; export const EXECUTION_STATUS = { QUEUEING: null, @@ -15,11 +16,11 @@ export const EXECUTION_STATUS = { }; export const ExecutionStatusOptions = [ - { value: EXECUTION_STATUS.QUEUEING, label: '{{t("Queueing")}}', color: 'blue' }, - { value: EXECUTION_STATUS.STARTED, label: '{{t("On going")}}', color: 'gold' }, - { value: EXECUTION_STATUS.SUCCEEDED, label: '{{t("Succeeded")}}', color: 'green' }, - { value: EXECUTION_STATUS.FAILED, label: '{{t("Failed")}}', color: 'red' }, - { value: EXECUTION_STATUS.CANCELED, label: '{{t("Canceled")}}' }, + { value: EXECUTION_STATUS.QUEUEING, label: `{{t("Queueing", { ns: "${NAMESPACE}" })}}`, color: 'blue' }, + { value: EXECUTION_STATUS.STARTED, label: `{{t("On going", { ns: "${NAMESPACE}" })}}`, color: 'gold' }, + { value: EXECUTION_STATUS.SUCCEEDED, label: `{{t("Succeeded", { ns: "${NAMESPACE}" })}}`, color: 'green' }, + { value: EXECUTION_STATUS.FAILED, label: `{{t("Failed", { ns: "${NAMESPACE}" })}}`, color: 'red' }, + { value: EXECUTION_STATUS.CANCELED, label: `{{t("Canceled", { ns: "${NAMESPACE}" })}}` }, ]; export const ExecutionStatusOptionsMap = ExecutionStatusOptions.reduce((map, option) => Object.assign(map, { [option.value]: option }), {}); @@ -32,10 +33,10 @@ export const JOB_STATUS = { }; export const JobStatusOptions = [ - { value: JOB_STATUS.PENDING, label: '{{t("Pending")}}', color: '#d4c306', icon: }, - { value: JOB_STATUS.RESOLVED, label: '{{t("Succeeded")}}', color: '#67c068', icon: }, - { value: JOB_STATUS.REJECTED, label: '{{t("Failed")}}', color: '#f40', icon: }, - { value: JOB_STATUS.CANCELED, label: '{{t("Canceled")}}', color: '#f40', icon: } + { value: JOB_STATUS.PENDING, label: `{{t("Pending", { ns: "${NAMESPACE}" })}}`, color: '#d4c306', icon: }, + { value: JOB_STATUS.RESOLVED, label: `{{t("Succeeded", { ns: "${NAMESPACE}" })}}`, color: '#67c068', icon: }, + { value: JOB_STATUS.REJECTED, label: `{{t("Failed", { ns: "${NAMESPACE}" })}}`, color: '#f40', icon: }, + { value: JOB_STATUS.CANCELED, label: `{{t("Canceled", { ns: "${NAMESPACE}" })}}`, color: '#f40', icon: } ]; export const JobStatusOptionsMap = JobStatusOptions.reduce((map, option) => Object.assign(map, { [option.value]: option }), {}); diff --git a/packages/plugins/workflow/src/client/locale/en-US.ts b/packages/plugins/workflow/src/client/locale/en-US.ts new file mode 100644 index 0000000000..3fe40c935a --- /dev/null +++ b/packages/plugins/workflow/src/client/locale/en-US.ts @@ -0,0 +1,89 @@ +export default { + "Workflow": "Workflow", + "Execution history": "Execution history", + "Trigger type": "Trigger type", + "Description": "Description", + "Status": "Status", + "On": "On", + "Off": "Off", + "Version": "Version", + "Copy to new version": "Copy to new version", + "Load failed": "Load failed", + "Trigger": "Trigger", + "Collection event": "Collection event", + "Trigger on": "Trigger on", + "After record added": "After record added", + "After record updated": "After record updated", + "After record added or updated": "After record added or updated", + "After record deleted": "After record deleted", + "Changed fields": "Changed fields", + "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", + "Only triggers when match conditions": "Only triggers when match conditions", + "Schedule event": "Schedule event", + "Trigger mode": "Trigger mode", + "Based on certain date": "Based on certain date", + "Based on date field of collection": "Based on date field of collection", + "Starts on": "Starts on", + "Ends on": "Ends on", + "Exactly at": "Exactly at", + "Repeat mode": "Repeat mode", + "Repeat limit": "Repeat limit", + "No limit": "No limit", + "Seconds": "Seconds", + "Minutes": "Minutes", + "Hours": "Hours", + "Days": "Days", + "Weeks": "Weeks", + "Months": "Months", + "No repeat": "No repeat", + "Every": "Every", + "By minute": "By minute", + "By hour": "By hour", + "By day": "By day", + "By week": "By week", + "By month": "By month", + "By field": "By field", + "By custom date": "By custom date", + "Advanced": "Advanced", + "Advanced type": "Advanced", + "End": "End", + "Trigger context": "Trigger context", + "Node result": "Node result", + "Constant": "Constant", + "Boolean": "Boolean", + "String": "String", + "Arithmetic calculation": "Arithmetic calculation", + "String operation": "String operation", + "On going": "On going", + "Succeeded": "Succeeded", + "Failed": "Failed", + "Canceled": "Canceled", + "This node contains branches, deleting will also be preformed to them, are you sure?": "This node contains branches, deleting will also be preformed to them, are you sure?", + "Control": "Control", + "Collection operations": "Collection operations", + "Node type": "Node type", + "Calculation": "Calculation", + "Configure calculation": "Configure calculation", + "Calculation result": "Calculation result", + "True": "True", + "False": "False", + "Condition": "Condition", + "Mode": "Mode", + "Continue when \"Yes\"": "Continue when \"Yes\"", + "Branch into \"Yes\" and \"No\"": "Branch into \"Yes\" and \"No\"", + "Conditions": "Conditions", + "Parallel branch": "Parallel branch", + "All succeeded": "All succeeded", + "Any succeeded": "Any succeeded", + "Continue after all branches succeeded": "Continue after all branches succeeded", + "Continue after any branch succeeded": "Continue after any branch succeeded", + "Create record": "Create record", + "Update record": "Update record", + "Query record": "Query record", + "Multiple records": "Multiple records", + "Please select collection first": "Please select collection first", + "Only update records matching conditions": "Only update records matching conditions", + "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.", + "Trigger in executed workflow cannot be modified": "Trigger in executed workflow cannot be modified", + "Node in executed workflow cannot be modified": "Node in executed workflow cannot be modified", +}; diff --git a/packages/plugins/workflow/src/client/locale/index.ts b/packages/plugins/workflow/src/client/locale/index.ts new file mode 100644 index 0000000000..2cc84f0461 --- /dev/null +++ b/packages/plugins/workflow/src/client/locale/index.ts @@ -0,0 +1,24 @@ +import { useTranslation } from 'react-i18next'; +import { i18n } from '@nocobase/client'; + +import zhCN from './zh-CN'; +import enUS from './en-US'; +import jaJP from './ja-JP'; +import ruRU from './ru-RU'; +import trTR from './tr-TR'; + +export const NAMESPACE = 'workflow'; + +i18n.addResources('zh-CN', NAMESPACE, zhCN); +i18n.addResources('en-US', NAMESPACE, enUS); +i18n.addResources('ja-JP', NAMESPACE, jaJP); +i18n.addResources('ru-RU', NAMESPACE, ruRU); +i18n.addResources('tr-TR', NAMESPACE, trTR); + +export function lang(key: string) { + return i18n.t(key, { ns: NAMESPACE }); +} + +export function useWorkflowTranslation() { + return useTranslation(NAMESPACE); +} diff --git a/packages/plugins/workflow/src/client/locale/ja-JP.ts b/packages/plugins/workflow/src/client/locale/ja-JP.ts new file mode 100644 index 0000000000..1cccfc1784 --- /dev/null +++ b/packages/plugins/workflow/src/client/locale/ja-JP.ts @@ -0,0 +1,89 @@ +export default { + "Workflow": "ワークフロー", + "Execution history": "実行履歴", + "Trigger type": "トリガータイプ", + "Description": "説明", + "Status": "状態", + "On": "有効", + "Off": "無効", + "Version": "バージョン", + "Copy to new version": "新しいバージョンにコピー", + "Load failed": "読み込みに失敗しました", + "Trigger": "トリガー", + "Collection event": "コレクションイベント", + "Trigger on": "トリガータイミング", + "After record added": "レコードを追加した後", + "After record updated": "レコードを更新した後", + "After record added or updated": "レコードを追加もしくは更新した後", + "After record deleted": "レコードを削除した後", + "Changed fields": "フィールドが変更された時", + "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "選択したフィールドの 1 つが変更された場合にのみトリガーされます。 選択されていない場合は、フィールドが変更されたときにトリガーされることを意味します。 レコードが追加または削除されると、すべてのフィールドが変更されたと見なされます。", + "Only triggers when match conditions": "以下の条件を満たすと発動", + "Schedule event": "スケジュールイベント", + "Trigger mode": "トリガーモード", + "Based on certain date": "カスタム時間", + "Based on date field of collection": "コレクションのフィールド時間に基づく", + "Starts on": "開始", + "Ends on": "終了", + "Exactly at": "ちょうど", + "Repeat mode": "繰り返しパターン", + "Repeat limit": "繰り返し回数", + "No limit": "無制限", + "Seconds": "秒", + "Minutes": "分", + "Hours": "時", + "Days": "日", + "Weeks": "週", + "Months": "月", + "No repeat": "繰り返さない", + "Every": "毎", + "By minute": "分ごと", + "By hour": "時間ごと", + "By day": "日ごと", + "By week": "週ごと", + "By month": "月ごと", + "By field": "フィールドごと", + "By custom date": "カスタム時間", + "Advanced": "アドバンスド", + "Advanced type": "アドバンスタイプ", + "End": "終了", + "Trigger context": "トリガーフィールド", + "Node result": "ノードの結果", + "Constant": "定数", + "Boolean": "論理値", + "String": "文字列", + "Arithmetic calculation": "算術演算", + "String operation": "文字列操作", + "On going": "処理中", + "Succeeded": "成功", + "Failed": "失敗", + "Canceled": "取消", + "This node contains branches, deleting will also be preformed to them, are you sure?": "ノードにはブランチが含まれており、そのすべてのブランチの下にあるすべての子ノードが同時に削除されます。続行してもよろしいですか?", + "Control": "プロセス制御", + "Collection operations": "フィールド操作", + "Node type": "ノードタイプ", + "Calculation": "演算", + "Configure calculation": "演算設定", + "Calculation result": "演算結果", + "True": "真", + "False": "偽", + "Condition": "条件", + "Mode": "モデル", + "Continue when \"Yes\"": "「はい」の場合に続行", + "Branch into \"Yes\" and \"No\"": "「はい」と「いいえ」で分岐して続行", + "Conditions": "条件設定", + "Parallel branch": "分岐", + "All succeeded": "すべて成功", + "Any succeeded": "いずれかが成功", + "Continue after all branches succeeded": "すべての分岐が成功した後に続行", + "Continue after any branch succeeded": "いずれかの分岐が成功した後に続行", + "Create record": "レコード追加", + "Update record": "レコード更新", + "Query record": "クエリ レコード", + "Multiple records": "複数レコード", + "Please select collection first": "先にコレクションを選択してください", + "Only update records matching conditions": "条件を満たすレコードのみ更新", + "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "値が割り当てられていないフィールドはデフォルト値に設定され、デフォルト値がないフィールドは null に設定されます", + "Trigger in executed workflow cannot be modified": "すでにワークフローを実行したトリガーは変更できません", + "Node in executed workflow cannot be modified": "すでに実行されたワークフローのノードは変更できません", +}; diff --git a/packages/plugins/workflow/src/client/locale/ru-RU.ts b/packages/plugins/workflow/src/client/locale/ru-RU.ts new file mode 100644 index 0000000000..f209abe5ac --- /dev/null +++ b/packages/plugins/workflow/src/client/locale/ru-RU.ts @@ -0,0 +1,89 @@ +export default { + "Workflow": "Рабочий процесс", + "Execution history": "История запусков", + "Trigger type": "Тип триггера", + "Description": "Описание", + "Status": "Статус", + "On": "Вкл.", + "Off": "Выкл.", + "Version": "Версия", + "Copy to new version": "Скопировать в новую версию", + "Load failed": "Загрузка не удалась", + "Trigger": "Триггер", + "Collection event": "Событие коллекции", + "Trigger on": "Триггер на", + "After record added": "После добавления записи", + "After record updated": "После обновления записи", + "After record added or updated": "После добавления или обновления записи", + "After record deleted": "После удаления записи", + "Changed fields": "Измененные поля", + "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "Запускается только при изменении одного из выбранных полей. Если флажок не установлен, это означает, что он будет срабатывать при изменении любого поля. При добавлении или удалении записи любое поле считается измененным.", + "Only triggers when match conditions": "Срабатывает только при совпадении условий", + "Schedule event": "Событие по расписанию", + "Trigger mode": "Режим триггера", + "Based on certain date": "На основе определенной даты", + "Based on date field of collection": "На базе поля с датой в коллекции", + "Starts on": "Стартует с", + "Ends on": "Оканчивается в", + "Exactly at": "Ровно в", + "Repeat mode": "Режим повтора", + "Repeat limit": "Ограничение на повторы", + "No limit": "Нет ограничений", + "Seconds": "Секунды", + "Minutes": "Минуты", + "Hours": "Часы", + "Days": "Дни", + "Weeks": "Недели", + "Months": "Месяцы", + "No repeat": "Не повторять", + "Every": "Каждые", + "By minute": "По минутам", + "By hour": "По часам", + "By day": "По дням", + "By week": "По неделям", + "By month": "По месяцам", + "By field": "По полю", + "By custom date": "По пользовательской дате", + "Advanced": "Продвинутый", + "Advanced type": "Продвинутый", + "End": "Окончание", + "Trigger context": "Контекст триггера", + "Node result": "Результат Узла", + "Constant": "Константа", + "Boolean": "Логический", + "String": "Строка", + "Arithmetic calculation": "Арифметическое вычисление", + "String operation": "Операция со строкой", + "On going": "Непрерывный", + "Succeeded": "Успешный", + "Failed": "Неудачный", + "Canceled": "Прерванный", + "This node contains branches, deleting will also be preformed to them, are you sure?": "Этот узел содержит ветки, к ним тоже будет произведено удаление, вы уверены?", + "Control": "Управление", + "Collection operations": "Операции с Коллекцией", + "Node type": "Тип Узла", + "Calculation": "Вычисление", + "Configure calculation": "Настроить вычисление", + "Calculation result": "Результат вычисления", + "True": "Истина", + "False": "Ложь", + "Condition": "Условие", + "Mode": "Режим", + "Continue when \"Yes\"": "Продолжить когда \"Да\"", + "Branch into \"Yes\" and \"No\"": "Разветвление на \"Да\" and \"Нет\"", + "Conditions": "Условия", + "Parallel branch": "Параллельная ветвь", + "All succeeded": "Всё успешно", + "Any succeeded": "Что-то успешно", + "Continue after all branches succeeded": "Продолжать после успеха на всех ветвях", + "Continue after any branch succeeded": "Продолжать после успеха на любой из ветвей", + "Create record": "Создать запись", + "Update record": "Обновить запись", + "Query record": "Запрос записи", + "Multiple records": "Множество записей", + "Please select collection first": "Выберите сначала Коллекцию, пожалуйста", + "Only update records matching conditions": "Обновлять только записи, соответствующие условиям", + "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "Поля, которым не присвоено значение, будут установлены на значение по умолчанию, а поля, не имеющие значения по умолчанию, будут установлены на null.", + "Trigger in executed workflow cannot be modified": "Триггер в выполняемом рабочем процессе не может быть изменен", + "Node in executed workflow cannot be modified": "Узел в выполняемом рабочем процессе не может быть изменен", +}; diff --git a/packages/plugins/workflow/src/client/locale/tr-TR.ts b/packages/plugins/workflow/src/client/locale/tr-TR.ts new file mode 100644 index 0000000000..5ed2b6c1e3 --- /dev/null +++ b/packages/plugins/workflow/src/client/locale/tr-TR.ts @@ -0,0 +1,89 @@ +export default { + "Workflow": "İş Akışı", + "Execution history": "Yürütme Geçmişi", + "Trigger type": "Tetikleme türü", + "Description": "Açıklama", + "Status": "Durum", + "On": "Aç", + "Off": "Kapa", + "Version": "Sürüm", + "Copy to new version": "Yeni sürüme kopyala", + "Load failed": "Yükleme başarısız", + "Trigger": "Tetikle", + "Collection event": "Koleksiyon etkinliği", + "Trigger on": "Tetikleme açık", + "After record added": "Kayıt eklendikten sonra", + "After record updated": "Kayıt güncellendikten sonra", + "After record added or updated": "Kayıt eklendikten veya güncellendikten sonra", + "After record deleted": "Kayıt silindikten sonra", + "Changed fields": "Değiştirilen alanlar", + "Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.": "Yalnızca seçilen alanlardan biri değiştiğinde tetiklenir. Seçili değilse, herhangi bir alan değiştiğinde tetikleneceği anlamına gelir. Kayıt eklendiğinde veya silindiğinde, herhangi bir alan değiştirilmiş olarak kabul edilir.", + "Only triggers when match conditions": "Yalnızca eşleşme koşulları olduğunda tetiklenir", + "Schedule event": "Etkinlik planla", + "Trigger mode": "Tetikleme modu", + "Based on certain date": "Belirli bir tarihe göre", + "Based on date field of collection": "Koleksiyonun tarih alanına göre", + "Starts on": "Başlangıç", + "Ends on": "Bitiş", + "Exactly at": "Tam zamanı", + "Repeat mode": "Tekrarlama modu", + "Repeat limit": "Tekrarlama limiti", + "No limit": "Limit yok", + "Seconds": "Saniye", + "Minutes": "Dakika", + "Hours": "Saat", + "Days": "Gün", + "Weeks": "Hafta", + "Months": "Ay", + "No repeat": "Tekrar yok", + "Every": "Her", + "By minute": "Dakikada", + "By hour": "Saatte", + "By day": "Günde", + "By week": "Haftada", + "By month": "Ayda", + "By field": "Alanda", + "By custom date": "Özel tarihe göre", + "Advanced": "Gelişmiş", + "Advanced type": "Gelişmiş", + "End": "Son", + "Trigger context": "Tetikleyici bağlamı", + "Node result": "Düğüm sonucu", + "Constant": "Devamlı", + "Boolean": "Boolean", + "String": "String", + "Arithmetic calculation": "Aritmetik hesaplama", + "String operation": "String operation", + "On going": "Devam eden", + "Succeeded": "Başarılı", + "Failed": "Başarısız", + "Canceled": "İptal edilen", + "This node contains branches, deleting will also be preformed to them, are you sure?": "Bu düğüm başka içeriklerle bağlantı içeriyor, silme işlemini onaylarsanız o bağlantılarda silinecek, emin misiniz?", + "Control": "Kontrol", + "Collection operations": "Koleksiyon operasyonları", + "Node type": "Düğüm türü", + "Calculation": "Hesaplama", + "Configure calculation": "Hesaplamayı yapılandır", + "Calculation result": "Hesaplama sonucu", + "True": "Doğru", + "False": "Yanlış", + "Condition": "Koşul", + "Mode": "Tür", + "Continue when \"Yes\"": "\"Evet\" durumunda devam", + "Branch into \"Yes\" and \"No\"": "\"Evet\" ve \"Hayır\" olarak dallandırın", + "Conditions": "Koşullar", + "Parallel branch": "Paralel dal", + "All succeeded": "Hepsi başarılı", + "Any succeeded": "Herhangi biri başarılı", + "Continue after all branches succeeded": "Tüm dallar başarılı olduktan sonra devam et", + "Continue after any branch succeeded": "Herhangi bir dal başarılı olduktan sonra devam et", + "Create record": "Kayıt oluştur", + "Update record": "Kayıt güncelle", + "Query record": "Sorgu kaydı", + "Multiple records": "Birden çok kayıt", + "Please select collection first": "Lütfen önce koleksiyonu seçin", + "Only update records matching conditions": "Yalnızca koşullarla eşleşen kayıtları güncelleyin", + "Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.": "Değer atanmamış alanlar varsayılan değere, varsayılan değeri olmayan alanlar ise null olarak ayarlanır.", + "Trigger in executed workflow cannot be modified": "Yürütülen iş akışındaki tetikleyici değiştirilemez", + "Node in executed workflow cannot be modified": "Yürütülen iş akışındaki düğüm değiştirilemez", +}; diff --git a/packages/plugins/workflow/src/client/locale/zh-CN.ts b/packages/plugins/workflow/src/client/locale/zh-CN.ts new file mode 100644 index 0000000000..9bd2d20e73 --- /dev/null +++ b/packages/plugins/workflow/src/client/locale/zh-CN.ts @@ -0,0 +1,129 @@ +export default { + 'Workflow': '工作流', + 'Execution history': '执行历史', + 'Trigger type': '触发方式', + 'Description': '描述', + 'Status': '状态', + 'On': '启用', + 'Off': '停用', + 'Version': '版本', + 'Copy to new version': '复制到新版本', + + 'Loading': '加载中', + 'Load failed': '加载失败', + + 'Trigger': '触发器', + 'Trigger context': '触发数据', + 'Trigger data': '触发数据', + 'Trigger time': '触发时间', + 'Triggered at': '触发时间', + 'Collection event': '数据表事件', + 'Trigger on': '触发时机', + 'After record added': '新增数据后', + 'After record updated': '更新数据后', + 'After record added or updated': '新增或更新数据后', + 'After record deleted': '删除数据后', + 'Changed fields': '发生变动的字段', + 'Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.': '只有被选中的某个字段发生变动时才会触发。如果不选择,则表示任何字段变动时都会触发。新增或删除数据时,任意字段都被认为发生变动。', + 'Only triggers when match conditions': '满足以下条件才触发', + + 'Schedule event': '定时任务', + 'Trigger mode': '触发模式', + 'Based on certain date': '自定义时间', + 'Based on date field of collection': '根据数据表时间字段', + 'Starts on': '开始于', + 'Ends on': '结束于', + 'Exactly at': '当时', + 'Repeat mode': '重复模式', + 'Repeat limit': '重复次数', + 'No limit': '不限', + 'Seconds': '秒', + 'Minutes': '分钟', + 'Hours': '小时', + 'Days': '天', + 'Weeks': '周', + 'Months': '月', + + 'No repeat': '不重复', + 'Every': '每', + + 'By minute': '按分钟', + 'By hour': '按小时', + 'By day': '按天', + 'By week': '按周', + 'By month': '按月', + + 'By field': '数据表字段', + 'By custom date': '自定义时间', + + 'Advanced': '高级模式', + 'Advanced type': '高级类型', + + 'End': '结束', + + 'Node result': '节点数据', + 'Constant': '常量', + + 'Boolean': '逻辑值', + 'String': '字符串', + + 'Calculator': '运算', + 'Arithmetic calculation': '算术运算', + 'String operation': '字符串', + + 'Executed at': '执行于', + + 'Queueing': '队列中', + 'On going': '进行中', + 'Succeeded': '成功', + 'Failed': '失败', + 'Pending': '等待处理', + 'Canceled': '已取消', + + 'This node contains branches, deleting will also be preformed to them, are you sure?': '节点包含分支,将同时删除其所有分支下的子节点,确定继续?', + + 'Control': '流程控制', + 'Collection operations': '数据表操作', + 'Extended types': '扩展类型', + + 'Node type': '节点类型', + + 'Calculation': '运算', + 'Configure calculation': '配置运算', + 'Calculation result': '运算结果', + 'True': '真', + 'False': '假', + 'concat': '连接', + + 'Condition': '条件判断', + 'Mode': '模式', + 'Continue when "Yes"': '“是”则继续', + 'Branch into "Yes" and "No"': '“是”和“否”分别继续', + 'Conditions': '条件配置', + + 'Parallel branch': '分支', + 'Add branch': '增加分支', + 'All succeeded': '全部成功', + 'Any succeeded': '任意成功', + 'Any succeeded or failed': '任意成功或失败', + 'Continue after all branches succeeded': '全部分支都成功后才能继续', + 'Continue after any branch succeeded': '任意分支成功后就继续', + 'Continue after any branch succeeded, or exit after any branch failed': '任意分支成功继续,或失败后退出', + + 'Delay': '延时', + 'Duration': '时长', + 'End Status': '到时状态', + 'Select status': '选择状态', + 'Succeed and continue': '通过并继续', + 'Fail and exit': '失败并退出', + + 'Create record': '新增数据', + 'Update record': '更新数据', + 'Query record': '查询数据', + 'Multiple records': '多条数据', + 'Please select collection first': '请先选择数据表', + 'Only update records matching conditions': '只更新满足条件的数据', + 'Fields that are not assigned a value will be set to the default value, and those that do not have a default value are set to null.': '未被赋值的字段将被设置为默认值,没有默认值的设置为空值。', + 'Trigger in executed workflow cannot be modified': '已经执行过工作流的触发器不能被修改', + 'Node in executed workflow cannot be modified': '已经执行过工作流中的节点不能被修改', +}; diff --git a/packages/plugins/workflow/src/client/nodes/calculation.tsx b/packages/plugins/workflow/src/client/nodes/calculation.tsx index c2e2a1bc65..e682398e9f 100644 --- a/packages/plugins/workflow/src/client/nodes/calculation.tsx +++ b/packages/plugins/workflow/src/client/nodes/calculation.tsx @@ -3,15 +3,16 @@ import { css } from '@emotion/css'; import { useTranslation } from 'react-i18next'; import { Calculation } from '../calculators'; +import { NAMESPACE, useWorkflowTranslation } from '../locale'; export default { - title: '{{t("Calculation")}}', + title: `{{t("Calculation", { ns: "${NAMESPACE}" })}}`, type: 'calculation', group: 'control', fieldset: { 'config.calculation': { type: 'object', - title: '{{t("Configure calculation")}}', + title: `{{t("Configure calculation", { ns: "${NAMESPACE}" })}}`, name: 'config.calculation', required: true, 'x-decorator': 'FormItem', @@ -29,7 +30,7 @@ export default { } }, getter() { - const { t } = useTranslation(); + const { t } = useWorkflowTranslation(); return
{t('Calculation result')}
; } }; diff --git a/packages/plugins/workflow/src/client/nodes/condition.tsx b/packages/plugins/workflow/src/client/nodes/condition.tsx index 0a05556a9b..27fadb73f4 100644 --- a/packages/plugins/workflow/src/client/nodes/condition.tsx +++ b/packages/plugins/workflow/src/client/nodes/condition.tsx @@ -11,6 +11,7 @@ import { Branch } from "../Branch"; import { useFlowContext } from '../FlowContext'; import { branchBlockClass, nodeSubtreeClass } from "../style"; import { Calculation } from "../calculators"; +import { lang, NAMESPACE } from "../locale"; @@ -140,14 +141,14 @@ function CalculationConfig({ value, onChange }) { } export default { - title: '{{t("Condition")}}', + title: `{{t("Condition", { ns: "${NAMESPACE}" })}}`, type: 'condition', group: 'control', fieldset: { 'config.rejectOnFalse': { type: 'boolean', name: 'config.rejectOnFalse', - title: '{{t("Mode")}}', + title: `{{t("Mode", { ns: "${NAMESPACE}" })}}`, 'x-decorator': 'FormItem', 'x-component': 'Radio.Group', 'x-component-props': { @@ -156,18 +157,18 @@ export default { enum: [ { value: true, - label: i18n.t('Continue when "Yes"') + label: lang('Continue when "Yes"') }, { value: false, - label: i18n.t('Branch into "Yes" and "No"') + label: lang('Branch into "Yes" and "No"') } ], }, 'config.calculation': { type: 'string', name: 'config.calculation', - title: '{{t("Conditions")}}', + title: `{{t("Conditions", { ns: "${NAMESPACE}" })}}`, 'x-decorator': 'FormItem', 'x-component': 'CalculationConfig', } @@ -176,8 +177,8 @@ export default { }, options: [ - { label: i18n.t('Continue when "Yes"'), key: 'rejectOnFalse', value: { rejectOnFalse: true } }, - { label: i18n.t('Branch into "Yes" and "No"'), key: 'branch', value: { rejectOnFalse: false } } + { label: lang('Continue when "Yes"'), key: 'rejectOnFalse', value: { rejectOnFalse: true } }, + { label: lang('Branch into "Yes" and "No"'), key: 'branch', value: { rejectOnFalse: false } } ], render(data) { const { id, config: { rejectOnFalse } } = data; @@ -216,8 +217,8 @@ export default { } `} > - {i18n.t('No')} - {i18n.t('Yes')} + {lang('No')} + {lang('Yes')} )} diff --git a/packages/plugins/workflow/src/client/nodes/create.tsx b/packages/plugins/workflow/src/client/nodes/create.tsx index c662403fa5..e862a67223 100644 --- a/packages/plugins/workflow/src/client/nodes/create.tsx +++ b/packages/plugins/workflow/src/client/nodes/create.tsx @@ -5,11 +5,12 @@ import { collection, values } from '../schemas/collection'; import { useFlowContext } from '../FlowContext'; import CollectionFieldSelect from '../components/CollectionFieldSelect'; import CollectionFieldset from '../components/CollectionFieldset'; +import { NAMESPACE } from '../locale'; export default { - title: '{{t("Create record")}}', + title: `{{t("Create record", { ns: "${NAMESPACE}" })}}`, type: 'create', group: 'collection', fieldset: { diff --git a/packages/plugins/workflow/src/client/nodes/delay.tsx b/packages/plugins/workflow/src/client/nodes/delay.tsx index 9af8531909..55a7595878 100644 --- a/packages/plugins/workflow/src/client/nodes/delay.tsx +++ b/packages/plugins/workflow/src/client/nodes/delay.tsx @@ -1,14 +1,15 @@ import Duration from "../components/Duration"; +import { NAMESPACE } from "../locale"; export default { - title: '{{t("Delay")}}', + title: `{{t("Delay", { ns: "${NAMESPACE}" })}}`, type: 'delay', group: 'control', fieldset: { 'config.duration': { type: 'number', name: 'config.duration', - title: '{{t("Duration")}}', + title: `{{t("Duration", { ns: "${NAMESPACE}" })}}`, 'x-decorator': 'FormItem', 'x-component': 'Duration', default: 60000 @@ -16,15 +17,15 @@ export default { 'config.endStatus': { type: 'number', name: 'config.endStatus', - title: '{{t("End Status")}}', + title: `{{t("End Status", { ns: "${NAMESPACE}" })}}`, 'x-decorator': 'FormItem', 'x-component': 'Select', 'x-component-props': { - placeholder: '{{t("Select status")}}', + placeholder: `{{t("Select status", { ns: "${NAMESPACE}" })}}`, }, enum: [ - { label: '{{t("Succeed and continue")}}', value: 1 }, - { label: '{{t("Fail and exit")}}', value: -1 }, + { label: `{{t("Succeed and continue", { ns: "${NAMESPACE}" })}}`, value: 1 }, + { label: `{{t("Fail and exit", { ns: "${NAMESPACE}" })}}`, value: -1 }, ] } }, diff --git a/packages/plugins/workflow/src/client/nodes/index.tsx b/packages/plugins/workflow/src/client/nodes/index.tsx index 37ab8b77ac..1f59dc1c27 100644 --- a/packages/plugins/workflow/src/client/nodes/index.tsx +++ b/packages/plugins/workflow/src/client/nodes/index.tsx @@ -24,6 +24,7 @@ import create from './create'; import update from './update'; import destroy from './destroy'; import { JobStatusOptions, JobStatusOptionsMap } from '../constants'; +import { lang, NAMESPACE } from '../locale'; export interface Instruction { title: string; @@ -52,7 +53,6 @@ instructions.register('update', update); instructions.register('destroy', destroy); function useUpdateAction() { - const { t } = useTranslation(); const form = useForm(); const api = useAPIClient(); const ctx = useActionContext(); @@ -62,7 +62,7 @@ function useUpdateAction() { return { async run() { if (workflow.executed) { - message.error(t('Node in executed workflow cannot be modified')); + message.error(lang('Node in executed workflow cannot be modified')); return; } // TODO: how to do validation separately for each field? especially disabled for dynamic fields? @@ -87,7 +87,6 @@ export function useNodeContext() { } export function Node({ data }) { - const instruction = instructions.get(data.type); return ( @@ -147,8 +146,8 @@ export function RemoveButton() { const hasBranches = !nodes.find(item => item.upstream === current && item.branchIndex != null); const message = hasBranches - ? t('Are you sure you want to delete it?') - : t('This node contains branches, deleting will also be preformed to them, are you sure?'); + ? lang('Are you sure you want to delete it?') + : lang('This node contains branches, deleting will also be preformed to them, are you sure?'); Modal.confirm({ title: t('Delete'), @@ -171,7 +170,6 @@ export function RemoveButton() { } export function JobButton() { - const { t } = useTranslation(); const compile = useCompile(); const { execution } = useFlowContext(); const { id, type, title, job } = useNodeContext() ?? {}; @@ -229,7 +227,7 @@ export function JobButton() { properties: { status: { type: 'number', - title: '{{t("Status")}}', + title: `{{t("Status", { ns: "${NAMESPACE}" })}}`, 'x-decorator': 'FormItem', 'x-component': 'Select', enum: JobStatusOptions, @@ -237,7 +235,7 @@ export function JobButton() { }, updatedAt: { type: 'string', - title: '{{t("Executed at")}}', + title: `{{t("Executed at", { ns: "${NAMESPACE}" })}}`, 'x-decorator': 'FormItem', 'x-component': 'DatePicker', 'x-component-props': { @@ -247,7 +245,7 @@ export function JobButton() { }, result: { type: 'object', - title: '{{t("Node result")}}', + title: `{{t("Node result", { ns: "${NAMESPACE}" })}}`, 'x-decorator': 'FormItem', 'x-component': 'Input.JSON', 'x-component-props': { diff --git a/packages/plugins/workflow/src/client/nodes/parallel.tsx b/packages/plugins/workflow/src/client/nodes/parallel.tsx index c4d1c431a4..9db723c498 100644 --- a/packages/plugins/workflow/src/client/nodes/parallel.tsx +++ b/packages/plugins/workflow/src/client/nodes/parallel.tsx @@ -10,18 +10,19 @@ import { NodeDefaultView } from "."; import { Branch } from "../Branch"; import { useFlowContext } from '../FlowContext'; import { branchBlockClass, nodeSubtreeClass } from "../style"; +import { lang, NAMESPACE } from "../locale"; export default { - title: '{{t("Parallel branch")}}', + title: `{{t("Parallel branch", { ns: "${NAMESPACE}" })}}`, type: 'parallel', group: 'control', fieldset: { 'config.mode': { type: 'string', name: 'config.mode', - title: '{{t("Mode")}}', + title: `{{t("Mode", { ns: "${NAMESPACE}" })}}`, 'x-decorator': 'FormItem', 'x-component': 'Radio.Group', 'x-component-props': { @@ -31,10 +32,10 @@ export default { value: 'all', label: ( - {i18n.t('All succeeded')} + {lang('All succeeded')} ) }, @@ -42,10 +43,10 @@ export default { value: 'any', label: ( - {i18n.t('Any succeeded')} + {lang('Any succeeded')} ) }, @@ -53,10 +54,10 @@ export default { value: 'race', label: ( - {i18n.t('Any succeeded or failed')} + {lang('Any succeeded or failed')} ) }, @@ -69,7 +70,6 @@ export default { }, render(data) { const { id, config: { mode } } = data; - const { t } = useTranslation(); const { nodes } = useFlowContext(); const branches = nodes.reduce((result, node) => { if (node.upstreamId === id && node.branchIndex != null) { @@ -124,7 +124,7 @@ export default { height: 2em; `} > - +