2017-12-21 02:12:42 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { Field } from 'redux-form';
|
2018-02-01 17:33:58 +02:00
|
|
|
import Flex from 'styled-flex-component';
|
2018-01-25 17:44:03 +02:00
|
|
|
import { Margin } from 'styled-components-spacing';
|
2018-03-16 21:49:10 +02:00
|
|
|
import { Link } from 'react-router-dom';
|
2018-01-08 17:13:05 +02:00
|
|
|
import remcalc from 'remcalc';
|
2017-12-21 02:12:42 +02:00
|
|
|
|
|
|
|
import {
|
|
|
|
FormGroup,
|
|
|
|
Input,
|
|
|
|
FormLabel,
|
2018-01-08 17:13:05 +02:00
|
|
|
Button,
|
|
|
|
Divider
|
2017-12-21 02:12:42 +02:00
|
|
|
} from 'joyent-ui-toolkit';
|
|
|
|
|
|
|
|
export const Toolbar = ({
|
|
|
|
searchLabel = 'Filter',
|
|
|
|
searchPlaceholder = '',
|
|
|
|
searchable = true,
|
|
|
|
actionLabel = 'Create',
|
|
|
|
actionable = true,
|
2018-03-16 21:49:10 +02:00
|
|
|
onActionClick,
|
|
|
|
actionTo
|
2017-12-21 02:12:42 +02:00
|
|
|
}) => (
|
2018-02-01 17:33:58 +02:00
|
|
|
<Flex justifyBetween>
|
|
|
|
<FormGroup name="filter" field={Field}>
|
|
|
|
<FormLabel>{searchLabel}</FormLabel>
|
|
|
|
<Margin top={0.5}>
|
|
|
|
<Input placeholder={searchPlaceholder} disabled={!searchable} />
|
|
|
|
</Margin>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup right>
|
|
|
|
<Divider height={remcalc(21)} transparent />
|
|
|
|
<Button
|
2018-03-16 21:49:10 +02:00
|
|
|
type={actionTo || onActionClick ? 'button' : 'submit'}
|
2018-02-01 17:33:58 +02:00
|
|
|
disabled={!actionable}
|
2018-03-16 21:49:10 +02:00
|
|
|
component={actionTo ? Link : undefined}
|
|
|
|
to={actionTo}
|
2018-02-01 17:33:58 +02:00
|
|
|
onClick={onActionClick}
|
|
|
|
icon
|
|
|
|
fluid
|
|
|
|
>
|
|
|
|
{actionLabel}
|
|
|
|
</Button>
|
|
|
|
</FormGroup>
|
|
|
|
</Flex>
|
2017-12-21 02:12:42 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
export default ({ handleSubmit, ...rest }) => (
|
|
|
|
<form onSubmit={handleSubmit}>
|
|
|
|
<Toolbar {...rest} />
|
2018-01-08 17:13:05 +02:00
|
|
|
<Divider height={remcalc(20)} transparent />
|
2017-12-21 02:12:42 +02:00
|
|
|
</form>
|
|
|
|
);
|