fleet/frontend/components/forms/LicenseForm/LicenseForm.jsx
Mike Stone e565e03130 License features (#1134)
* API client to create and get an app license

* Fixes unhandled promise rejection errors in redux config

* License Page and Form

* Adds getLicense action

* Adds License key area to App Settings Form

* Use license.token instead of license.license

* Implement API client

* Adds key icon to License Form

* Adds License Success component

* Render License Success on License Page when there is a license

* Adds persistent flash actions and reducer to redux

* Adds nag message middleware

* Moves FlashMessage component to flash_message directory

* Adds Persistent Flash component

* Renders Persistent Flash component from Core Layout

* Adds Kyle's styles

* Change license validation message

* Finishing touches for app config form license area

* Handle revoked licenses

* License Page hits setup endpoint

* Display server errors on license form

* Changes 0 allowed hosts to unlimited

* Trims JWT token before sending to the server

* GET setup page after submitting license
2017-02-09 22:16:51 -05:00

64 lines
2.2 KiB
JavaScript

import React, { Component, PropTypes } from 'react';
import Button from 'components/buttons/Button';
import Form from 'components/forms/Form';
import formFieldInterface from 'interfaces/form_field';
import InputField from 'components/forms/fields/InputField';
import validate from 'components/forms/LicenseForm/validate';
import freeTrial from '../../../../assets/images/sign-up-pencil.svg';
import key from '../../../../assets/images/key.svg';
const fields = ['license'];
const baseClass = 'license-form';
class LicenseForm extends Component {
static propTypes = {
baseError: PropTypes.string,
fields: PropTypes.shape({
license: formFieldInterface.isRequired,
}).isRequired,
handleSubmit: PropTypes.func.isRequired,
};
render () {
const { baseError, fields: formFields, handleSubmit } = this.props;
return (
<form className={baseClass} onSubmit={handleSubmit}>
<div className={`${baseClass}__container`}>
<h2>
<img alt="Kolide License" className={`${baseClass}__key-img`} src={key} />
Kolide License
</h2>
{baseError && <div className="form__base-error">{baseError}</div>}
<InputField
{...formFields.license}
hint={<p className={`${baseClass}__help-text`}>Found under <a href="https://www.kolide.co/account">Account Settings</a> at Kolide.co</p>}
inputClassName={`${baseClass}__input`}
label="Enter License File"
type="textarea"
/>
<Button block className={`${baseClass}__upload-btn`} type="submit">
UPLOAD LICENSE
</Button>
<p className="form-field__label">Don&apos;t have a license?</p>
<p className={`${baseClass}__free-trial-text`}>Start a free trial of Kolide today!</p>
<a
className={`${baseClass}__free-trial-btn button button--unstyled`}
href="https://www.kolide.co/register"
>
<img
alt="Free trial"
src={freeTrial}
className={`${baseClass}__free-trial-img`}
/>
<span>Sign up for Free Kolide Trial</span>
</a>
</div>
</form>
);
}
}
export default Form(LicenseForm, { fields, validate });