Files
incubator-seata/saga/seata-saga-statemachine-designer/ggeditor/components/Register/index.js
wangchunxiang c2453d6434 chore(project): 添加项目配置文件和忽略规则
- 添加 Babel 配置文件支持 ES6+ 语法转换
- 添加 ESLint 忽略规则和配置文件
- 添加 Git 忽略规则文件
- 添加 Travis CI 配置文件
- 添加 1.4.2 版本变更日志文件
- 添加 Helm 图表辅助模板文件
- 添加 Helm 忽略规则文件
2026-03-27 17:36:48 +08:00

58 lines
1.4 KiB
JavaScript

import React from 'react';
import Editor from '@components/Base/Editor';
import { upperFirst } from '@utils';
import withGGEditorContext from '@common/context/GGEditorContext/withGGEditorContext';
class Register extends React.Component {
static create = function (type) {
class TypedRegister extends Register {
constructor(props) {
super(props, type);
}
}
return withGGEditorContext(TypedRegister);
}
constructor(props, type) {
super(props);
this.type = type;
this.bindEvent();
}
bindEvent() {
const { type } = this;
const { onBeforeAddPage } = this.props;
onBeforeAddPage(({ className }) => {
let host = Editor[className];
let keys = ['name', 'config', 'extend'];
if (type === 'command') {
host = Editor;
}
if (type === 'behaviour') {
keys = ['name', 'behaviour', 'dependences'];
}
const args = keys.map(key => this.props[key]);
host[`register${upperFirst(type)}`](...args);
});
}
render() {
return null;
}
}
export const RegisterNode = Register.create('node');
export const RegisterEdge = Register.create('edge');
export const RegisterGroup = Register.create('group');
export const RegisterGuide = Register.create('guide');
export const RegisterCommand = Register.create('command');
export const RegisterBehaviour = Register.create('behaviour');