in src/routes/Plugin/Discovery/ProxySelectorModal.js [63:122]
componentDidMount() {
const { isAdd, isSetConfig, discoveryType, data, pluginId, dispatch } =
this.props;
const { discoveryDicts } = this.state;
const { props } = this.props.data || {};
if (!isAdd || isSetConfig) {
this.setState({
configPropsJson:
isSetConfig === true ? {} : JSON.parse(data.discovery.props),
});
dispatch({
type: "discovery/saveGlobalType",
payload: {
chosenType: discoveryType,
},
});
} else {
let configProps = discoveryDicts.filter(
(item) => item.dictName === "zookeeper",
);
let propsEntries = JSON.parse(configProps[0]?.dictValue || "{}");
this.setState({ configPropsJson: propsEntries });
dispatch({
type: "discovery/saveGlobalType",
payload: {
chosenType: "",
},
});
}
let type = 1;
dispatch({
type: "pluginHandle/fetchByPluginId",
payload: {
pluginId,
type,
handle: Object.keys(props).length === 0 ? "" : props,
isHandleArray: false,
callBack: (pluginHandles) => {
if (Object.keys(pluginHandles).length > 0) {
const filteredArray = pluginHandles[0].filter(
(item) => item.field !== "discoveryHandler",
);
const handlerArray = pluginHandles[0].filter(
(item) => item.field === "discoveryHandler",
);
this.setState({ discoveryHandler: handlerArray });
pluginHandles[0] = filteredArray;
this.setState({ pluginHandleList: pluginHandles });
let defaultValue = handlerArray[0].defaultValue;
this.setState({ defaultValueList: defaultValue.split(",") });
}
},
},
});
}