<commit_before>import React, { Children } from 'react';
import PropTypes from 'prop-types';
import { getContext } from 'recompose';
import { createComponent } from 'olymp-fela';
import { Link } from 'olymp-router';
import { Modal } from 'olymp-ui';
import Form from 'olymp-ui/form';
import { notification } from 'antd';

const def = getContext({
  theme: PropTypes.object,
})(
  ({
    showLogo,
    isOpen,
    title,
    pathname,
    onCancel,
    onOk,
    cancelText,
    okText,
    loading,
    saving,
    version,
    ...props
  }) => {
    let links = null;
    const theme = props.theme.get();
    const children = Children.toArray(props.children).filter(child => {
      if (child.type && child.type === def.Links) {
        links = child;
        return false;
      }

      return true;
    });

    return (
      <Modal
        showLogo={showLogo !== false}
        isOpen={isOpen}
        title={title}
        onCancel={onCancel}
        maskClosable={false}
        loading={loading}
        noPortal
      >
        <Form>{children}</Form>
        <Modal.Footer>
          <Modal.Button onClick={onCancel}>
            {cancelText || 'Abbruch'}
          </Modal.Button>
          {onOk && (
            <Modal.Button type="primary" onClick={onOk} loading={saving}>
              {okText || title}
            </Modal.Button>
          )}
        </Modal.Footer>
        <Modal.Copyright>
          {links && <def.Links>{links}</def.Links>}
          <Link to={{ pathname, query: { register: null, login: undefined } }}>
            {theme.copyright || 'made with ❤ by olymp'}
          </Link>
        </Modal.Copyright>
      </Modal>
    );
  },
);
def.Links = createComponent(
  ({ theme }) => ({
    textAlign: 'center',
    '& a': {
      display: 'inline-block',
      minWidth: 200,
      paddingBottom: theme.space2,
      color: 'white',
      opacity: 0.3,
      onHover: {
        opacity: 1,
      },
    },
  }),
  'div',
);

export default def;

export const onError = err => {
  let description;
  if (err && err.message) {
    description = err.message;
  } else if (err && typeof err === 'object') {
    description = Object.keys(err)
      .map(key => err[key].errors.map(e => e.message).join('\n'))
      .join('\n');
  }
  notification.error({
    message: 'Fehler',
    description,
  });
};

export const onSuccess = (message, description) => {
  notification.success({
    message,
    description,
  });
};

export const layout = { labelCol: { span: 7 }, wrapperCol: { span: 17 } };

export const onEnterFocus = ref => e => {
  if (e.key === 'Enter') {
    return ref() && ref().refs && ref().refs.input.focus();
  }
  return false;<commit_msg>change notification => message<commit_after>import React, { Children } from 'react';
import PropTypes from 'prop-types';
import { getContext } from 'recompose';
import { createComponent } from 'olymp-fela';
import { Link } from 'olymp-router';
import { Modal } from 'olymp-ui';
import Form from 'olymp-ui/form';
import { message } from 'antd';

const def = getContext({
  theme: PropTypes.object,
})(
  ({
    showLogo,
    isOpen,
    title,
    pathname,
    onCancel,
    onOk,
    cancelText,
    okText,
    loading,
    saving,
    version,
    ...props
  }) => {
    let links = null;
    const theme = props.theme.get();
    const children = Children.toArray(props.children).filter(child => {
      if (child.type && child.type === def.Links) {
        links = child;
        return false;
      }

      return true;
    });

    return (
      <Modal
        showLogo={showLogo !== false}
        isOpen={isOpen}
        title={title}
        onCancel={onCancel}
        maskClosable={false}
        loading={loading}
        noPortal
      >
        <Form>{children}</Form>
        <Modal.Footer>
          <Modal.Button onClick={onCancel}>
            {cancelText || 'Abbruch'}
          </Modal.Button>
          {onOk && (
            <Modal.Button type="primary" onClick={onOk} loading={saving}>
              {okText || title}
            </Modal.Button>
          )}
        </Modal.Footer>
        <Modal.Copyright>
          {links && <def.Links>{links}</def.Links>}
          <Link to={{ pathname, query: { register: null, login: undefined } }}>
            {theme.copyright || 'made with ❤ by olymp'}
          </Link>
        </Modal.Copyright>
      </Modal>
    );
  },
);
def.Links = createComponent(
  ({ theme }) => ({
    textAlign: 'center',
    '& a': {
      display: 'inline-block',
      minWidth: 200,
      paddingBottom: theme.space2,
      color: 'white',
      opacity: 0.3,
      onHover: {
        opacity: 1,
      },
    },
  }),
  'div',
);

export default def;

export const onError = err => {
  let description;
  if (err && err.message) {
    description = err.message;
  } else if (err && typeof err === 'object') {
    description = Object.keys(err)
      .map(key => err[key].errors.map(e => e.message).join('\n'))
      .join('\n');
  }
  message.error(description);
};

export const onSuccess = (message, description) => {
  message.success(description);
};

export const layout = { labelCol: { span: 7 }, wrapperCol: { span: 17 } };

export const onEnterFocus = ref => e => {
  if (e.key === 'Enter') {
    return ref() && ref().refs && ref().refs.input.focus();
  }
  return false;
{'fraction_non_alphanumeric': 0.1617205108940646, 'fraction_numerical': 0.003756574004507889, 'mean_word_length': 2.1905332534451767, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '898080', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1672, 'n_words': 388}