render()

in src/components/GlobalHeader/index.js [262:378]


  render() {
    const {
      onLogout,
      form: { getFieldDecorator, resetFields, validateFields, getFieldValue },
      dispatch,
      loading,
      namespaces,
      currentNamespaceId,
      location: { pathname },
    } = this.props;
    const { popup, userName, visible } = this.state;
    const showNamespaces = !~[
      "/config/dict",
      "/config/namespace",
      "/config/pluginhandle",
      "/config/plugin",
      "/system/resource",
      "/system/role",
      "/system/manage",
    ].indexOf(pathname);
    const menu = (
      <Menu>
        <Menu.Item
          key="1"
          onClick={() => {
            this.setState({ visible: true });
          }}
        >
          <Icon type="form" />{" "}
          {getIntlContent("SHENYU.GLOBALHEADER.CHANGE.PASSWORD")}
        </Menu.Item>
        <Menu.Item key="0" onClick={onLogout}>
          <Icon type="logout" /> {getIntlContent("SHENYU.GLOBALHEADER.LOGOUT")}
        </Menu.Item>
      </Menu>
    );
    const importMenu = (
      <Menu>
        {this.checkAuth("system:manager:exportConfig") && (
          <Menu.Item key="2" onClick={this.exportConfigClick}>
            <Icon type="export" /> {getIntlContent("SHENYU.COMMON.EXPORT")}
          </Menu.Item>
        )}
        {this.checkAuth("system:manager:importConfig") && (
          <Menu.Item key="3" onClick={this.importConfigClick}>
            <Icon type="import" /> {getIntlContent("SHENYU.COMMON.IMPORT")}
          </Menu.Item>
        )}
      </Menu>
    );
    return (
      <div className={styles.header}>
        <span className={styles.text}>
          Apache ShenYu Gateway Management System
        </span>
        <div>
          {showNamespaces && (
            <div className={styles.item}>
              <Dropdown
                placement="bottomCenter"
                overlay={
                  <Menu onClick={this.handleNamespacesValueChange}>
                    {namespaces.map((namespace) => {
                      let isCurrentNamespace =
                        currentNamespaceId === namespace.namespaceId;
                      return (
                        <Menu.Item
                          key={namespace.namespaceId}
                          disabled={isCurrentNamespace}
                        >
                          <span>{namespace.name}</span>
                        </Menu.Item>
                      );
                    })}
                  </Menu>
                }
              >
                <Button>
                  <a
                    className="ant-dropdown-link"
                    style={{ fontWeight: "bold" }}
                    onClick={(e) => e.preventDefault()}
                  >
                    {`${getIntlContent("SHENYU.SYSTEM.NAMESPACE")} / ${namespaces.find((namespace) => currentNamespaceId === namespace.namespaceId)?.name} `}
                  </a>
                  <Icon type="down" />
                </Button>
              </Dropdown>
            </div>
          )}
          {(this.checkAuth("system:manager:importConfig") ||
            this.checkAuth("system:manager:exportConfig")) && (
            <div className={styles.item}>
              <Dropdown overlay={importMenu}>
                <Button>
                  <Icon type="import" />{" "}
                  {getIntlContent("SHENYU.COMMON.IMPORT_EXPORT")}
                </Button>
              </Dropdown>
            </div>
          )}
          <div className={styles.item}>
            <Dropdown placement="bottomCenter" overlay={this.state.help}>
              <Button>
                <Icon type="question-circle" />
              </Button>
            </Dropdown>
          </div>
          <div className={styles.item}>
            <Dropdown placement="bottomCenter" overlay={this.state.menu}>
              <Button>
                <TranslationOutlined />
              </Button>
            </Dropdown>
          </div>
          <div className={`${styles.item} ${styles.right}`}>
            <Dropdown.Button overlay={menu} icon={<Icon type="user" />}>