<commit_before>// This file is part of Indico.
// Copyright (C) 2002 - 2019 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.

import React from 'react';
import {Form as FinalForm} from 'react-final-form';
import {Divider, Form, Message} from 'semantic-ui-react';
import {FinalSubmitButton, FinalTextArea} from 'indico/react/forms';
import {Translate} from 'indico/react/i18n';

import './ChangesConfirmation.module.scss';

export default function ChangesConfirmation() {
  const confirmChanges = formData => {
    console.log(formData);
  };

  return (
    <div>
      <Divider />
      <FinalForm onSubmit={confirmChanges}>
        {fprops => (
          <Form onSubmit={fprops.handleSubmit}>
            <Message
              info
              size="tiny"
              icon="exclamation circle"
              header={Translate.string('Confirmation required')}
              content={
                <p>
                  <Translate>
                    Editor uploaded changes to your paper. Please download the updated files and
                    verify their changes. If you reject them, you can upload a new version
                    afterwards.
                  </Translate>
                </p>
              }
            />
            <FinalTextArea
              name="comment"
              placeholder={Translate.string('You can leave a comment if you wish')}
            />
            <Form.Group inline styleName="submit-buttons">
              <FinalSubmitButton
                label={Translate.string('Accept')}
                color="green"
                icon="check"
                onClick={() => {
                  fprops.form.change('action', 'accept');
                }}
                disabledUntilChange={false}
              />
              <FinalSubmitButton
                label={Translate.string('Reject')}
                color="red"
                icon="times"
                onClick={() => {
                  fprops.form.change('action', 'reject');
                }}
                disabledUntilChange={false}
              />
            </Form.Group>
          </Form>
        )}
      </FinalForm>
    </div>
  );
}<commit_msg>Show correct button as loading when confirming changes<commit_after>// This file is part of Indico.
// Copyright (C) 2002 - 2019 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.

import React from 'react';
import {Field, Form as FinalForm} from 'react-final-form';
import {Divider, Form, Message} from 'semantic-ui-react';
import {FinalSubmitButton, FinalTextArea} from 'indico/react/forms';
import {Translate} from 'indico/react/i18n';

import './ChangesConfirmation.module.scss';

export default function ChangesConfirmation() {
  const confirmChanges = formData => {
    console.log(formData);
  };

  return (
    <div>
      <Divider />
      <FinalForm onSubmit={confirmChanges} initialValues={{comment: ''}} subscription={{}}>
        {fprops => (
          <Form onSubmit={fprops.handleSubmit}>
            <Message
              info
              size="tiny"
              icon="exclamation circle"
              header={Translate.string('Confirmation required')}
              content={
                <p>
                  <Translate>
                    Editor uploaded changes to your paper. Please download the updated files and
                    verify their changes. If you reject them, you can upload a new version
                    afterwards.
                  </Translate>
                </p>
              }
            />
            <FinalTextArea
              name="comment"
              placeholder={Translate.string('You can leave a comment if you wish')}
            />
            <Form.Group inline styleName="submit-buttons">
              <Field name="action" subscription={{value: true}}>
                {({input: {value: currentAction}}) => (
                  <>
                    <FinalSubmitButton
                      label={Translate.string('Accept')}
                      color="green"
                      icon="check"
                      onClick={() => {
                        fprops.form.change('action', 'accept');
                      }}
                      disabledUntilChange={false}
                      activeSubmitButton={currentAction === 'accept'}
                    />
                    <FinalSubmitButton
                      label={Translate.string('Reject')}
                      color="red"
                      icon="times"
                      onClick={() => {
                        fprops.form.change('action', 'reject');
                      }}
                      disabledUntilChange={false}
                      activeSubmitButton={currentAction === 'reject'}
                    />
                  </>
                )}
              </Field>
            </Form.Group>
          </Form>
        )}
      </FinalForm>
    </div>
  );
}
{'fraction_non_alphanumeric': 0.10914396887159533, 'fraction_numerical': 0.0038910505836575876, 'mean_word_length': 1.4515975202670481, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7253545', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1198, 'n_words': 324}