How to use the umi.formatMessage function in umi

To help you get started, we’ve selected a few umi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / apisix-dashboard / web / src / components / Upstream / service.ts View on Github external
if (!hash_on) {
      return undefined;
    }

    if (hash_on !== 'consumer' && !key) {
      return undefined;
    }
  }

  if (pass_host === 'rewrite' && !upstream_host) {
    return undefined;
  }

  if (checks?.passive && !checks.active) {
    notification.error({
      message: formatMessage({id: 'component.upstream.other.health-check.invalid'}),
      description: formatMessage({id: 'component.upstream.other.health-check.passive-only'})
    })
    return undefined
  }

  /**
   * nodes will be [] or node list
   * when upstream_id === none, None === undefined
   */
  if (nodes) {
    // NOTE: https://github.com/ant-design/ant-design/issues/27396
    data.nodes = nodes?.map((item) => {
      return pick(item, ['host', 'port', 'weight']);
    });
    return data;
  }
github apache / apisix-dashboard / web / src / pages / User / components / LoginMethodPassword.tsx View on Github external
submit: async ({ username, password }) => {
    if (username !== '' && password !== '') {
      try {
        const result = await request('/user/login', {
          method: 'POST',
          requestType: 'json',
          data: {
            username,
            password,
          },
        });

        localStorage.setItem('token', result.data.token);
        return {
          status: true,
          message: formatMessage({ id: 'component.user.loginMethodPassword.success' }),
          data: [],
        };
      } catch (e) {
        // NOTE: API failed, using errorHandler
        return {
          status: false,
          message: '',
          data: [],
        };
      }
    } else {
      return {
        status: false,
        message: formatMessage({ id: 'component.user.loginMethodPassword.fieldInvalid' }),
        data: [],
      };
github apache / apisix-dashboard / web / src / components / Upstream / service.ts View on Github external
return undefined;
    }

    if (hash_on !== 'consumer' && !key) {
      return undefined;
    }
  }

  if (pass_host === 'rewrite' && !upstream_host) {
    return undefined;
  }

  if (checks?.passive && !checks.active) {
    notification.error({
      message: formatMessage({id: 'component.upstream.other.health-check.invalid'}),
      description: formatMessage({id: 'component.upstream.other.health-check.passive-only'})
    })
    return undefined
  }

  /**
   * nodes will be [] or node list
   * when upstream_id === none, None === undefined
   */
  if (nodes) {
    // NOTE: https://github.com/ant-design/ant-design/issues/27396
    data.nodes = nodes?.map((item) => {
      return pick(item, ['host', 'port', 'weight']);
    });
    return data;
  }
github apache / apisix-dashboard / web / src / global.tsx View on Github external
return true;
    };
    const key = `open${Date.now()}`;
    const btn = (
      <button type="primary"> {
          notification.close(key);
          reloadSW();
        }}
      &gt;
        {formatMessage({ id: 'app.pwa.serviceworker.updated.ok' })}
      </button>
    );
    notification.open({
      message: formatMessage({ id: 'app.pwa.serviceworker.updated' }),
      description: formatMessage({ id: 'app.pwa.serviceworker.updated.hint' }),
      btn,
      key,
      onClose: async () =&gt; {},
    });
  });
} else if ('serviceWorker' in navigator) {
github apache / apisix-dashboard / web / src / pages / User / components / LoginMethodPassword.tsx View on Github external
* See the License for the specific language governing permissions and
 * limitations under the License.
 */
import React from 'react';
import { Form, Input, Tooltip } from 'antd';
import type { FormInstance } from 'antd/lib/form';
import { UserOutlined, LockTwoTone } from '@ant-design/icons';
import { request, formatMessage } from 'umi';

import type { UserModule } from '@/pages/User/typing';

const formRef = React.createRef();

const LoginMethodPassword: UserModule.LoginMethod = {
  id: 'password',
  name: formatMessage({ id: 'component.user.loginMethodPassword' }),
  render: () =&gt; {
    return (
      <form name="control-ref">
        
          </form>
github apache / apisix-dashboard / web / src / components / PluginFlow / constants.ts View on Github external
findParent({ node }) {
      const bbox = node.getBBox()
      return this.getNodes().filter((item) =&gt; {
        const data = item.getData()
        if (data &amp;&amp; data.parent) {
          const targetBBox = item.getBBox()
          return bbox.isIntersectWithRect(targetBBox)
        }
        return false
      })
    },
  },
}

export const DEFAULT_STENCIL_OPINIONS: Partial = {
  title: formatMessage({ id: 'component.plugin-flow.text.nodes-area' }),
  stencilGraphWidth: DEFAULT_STENCIL_WIDTH,
  search: (cell, keyword) =&gt; {
    if (keyword) {
      return (cell as any).label?.indexOf(keyword) !== -1
    }
    return true
  },
  notFoundText: formatMessage({ id: 'component.plugin-flow.text.nodes.not-found' }),
  placeholder: formatMessage({ id: 'component.plugin-flow.text.search-nodes.placeholder' }),
  collapsable: true,
}

export const DEFAULT_SHAPE_RECT_OPINIONS = {
  inherit: 'rect',
  width: 80,
  height: 42,
github apache / apisix-dashboard / web / src / components / PluginFlow / constants.ts View on Github external
})
    },
  },
}

export const DEFAULT_STENCIL_OPINIONS: Partial = {
  title: formatMessage({ id: 'component.plugin-flow.text.nodes-area' }),
  stencilGraphWidth: DEFAULT_STENCIL_WIDTH,
  search: (cell, keyword) =&gt; {
    if (keyword) {
      return (cell as any).label?.indexOf(keyword) !== -1
    }
    return true
  },
  notFoundText: formatMessage({ id: 'component.plugin-flow.text.nodes.not-found' }),
  placeholder: formatMessage({ id: 'component.plugin-flow.text.search-nodes.placeholder' }),
  collapsable: true,
}

export const DEFAULT_SHAPE_RECT_OPINIONS = {
  inherit: 'rect',
  width: 80,
  height: 42,
  attrs: {
    body: {
      stroke: '#5F95FF',
      strokeWidth: 1,
      fill: 'rgba(95,149,255,0.05)',
    },
    fo: {
      refWidth: '100%',
      refHeight: '100%',
github apache / apisix-dashboard / web / src / global.tsx View on Github external
};
    const key = `open${Date.now()}`;
    const btn = (
      <button type="primary"> {
          notification.close(key);
          reloadSW();
        }}
      &gt;
        {formatMessage({ id: 'app.pwa.serviceworker.updated.ok' })}
      </button>
    );
    notification.open({
      message: formatMessage({ id: 'app.pwa.serviceworker.updated' }),
      description: formatMessage({ id: 'app.pwa.serviceworker.updated.hint' }),
      btn,
      key,
      onClose: async () =&gt; {},
    });
  });
} else if ('serviceWorker' in navigator) {
github apache / apisix-dashboard / web / src / components / PluginFlow / constants.ts View on Github external
return false
      })
    },
  },
}

export const DEFAULT_STENCIL_OPINIONS: Partial = {
  title: formatMessage({ id: 'component.plugin-flow.text.nodes-area' }),
  stencilGraphWidth: DEFAULT_STENCIL_WIDTH,
  search: (cell, keyword) =&gt; {
    if (keyword) {
      return (cell as any).label?.indexOf(keyword) !== -1
    }
    return true
  },
  notFoundText: formatMessage({ id: 'component.plugin-flow.text.nodes.not-found' }),
  placeholder: formatMessage({ id: 'component.plugin-flow.text.search-nodes.placeholder' }),
  collapsable: true,
}

export const DEFAULT_SHAPE_RECT_OPINIONS = {
  inherit: 'rect',
  width: 80,
  height: 42,
  attrs: {
    body: {
      stroke: '#5F95FF',
      strokeWidth: 1,
      fill: 'rgba(95,149,255,0.05)',
    },
    fo: {
      refWidth: '100%',
github apache / apisix-dashboard / web / src / global.tsx View on Github external
window.addEventListener('sw.offline', () => {
    message.warning(formatMessage({ id: 'app.pwa.offline' }));
  });