constructor()

in src/routes/Plugin/Common/Selector.js [80:129]


  constructor(props) {
    super(props);
    const { handle, pluginId } = props;
    let selectValue = `${props.type}` || null;
    let data = {};
    if (handle) {
      try {
        data = JSON.parse(handle);
      } catch (e) {
        // eslint-disable-next-line no-console
        console.error(e);
      }
    }

    const { divideUpstreams = [], gray = false, serviceId = "" } = data;
    const {
      discoveryUpstreams = [],
      isDiscovery,
      isAdd = true,
      discoveryConfig = {},
    } = this.props;

    if (isDivideUpstreamsRequiresForPlugin(pluginId)) {
      id = divideUpstreams.length;
    }

    this.state = {
      selectValue,
      gray,
      serviceId,
      divideUpstreams,
      visible: false,
      pluginHandleList: [],
      upstreams: discoveryUpstreams,
      recordCount: discoveryUpstreams ? discoveryUpstreams.length : 0,
      discoveryHandler: null,
      defaultValueList: null,
      configPropsJson: {},
      selectedDiscoveryValue: "local",
      showDiscoveryImportModal: false,
      importedDiscoveryId: "",
    };

    this.initSelectorCondition(props);

    if (isDiscovery && !isAdd) {
      this.state.configPropsJson = JSON.parse(discoveryConfig.props);
      this.state.selectedDiscoveryValue = discoveryConfig.discoveryType;
    }
  }