2018-02-05 17:12:47 +02:00
|
|
|
import React from 'react';
|
|
|
|
import { Field } from 'redux-form';
|
|
|
|
import Flex from 'styled-flex-component';
|
|
|
|
import { Margin } from 'styled-components-spacing';
|
|
|
|
|
2018-04-12 12:53:00 +03:00
|
|
|
import { Button, FormGroup, Input, FormLabel } from 'joyent-ui-toolkit';
|
2018-02-05 17:12:47 +02:00
|
|
|
|
|
|
|
export const Toolbar = ({
|
|
|
|
searchable = true,
|
|
|
|
searchLabel = 'Filter',
|
|
|
|
searchPlaceholder = '',
|
|
|
|
action = false,
|
|
|
|
actionLabel = '',
|
|
|
|
actionable = false,
|
|
|
|
onActionClick
|
|
|
|
}) => (
|
2018-04-12 12:53:00 +03:00
|
|
|
<Flex justifyBetween alignEnd>
|
2018-02-05 17:12:47 +02:00
|
|
|
<FormGroup name="filter" field={Field}>
|
|
|
|
<FormLabel>{searchLabel}</FormLabel>
|
|
|
|
<Margin top={0.5}>
|
|
|
|
<Input placeholder={searchPlaceholder} disabled={!searchable} />
|
|
|
|
</Margin>
|
|
|
|
</FormGroup>
|
|
|
|
{action ? (
|
|
|
|
<FormGroup right>
|
|
|
|
<Button
|
2018-02-14 22:30:25 +02:00
|
|
|
type="button"
|
2018-02-05 17:12:47 +02:00
|
|
|
disabled={!actionable}
|
|
|
|
onClick={onActionClick}
|
|
|
|
icon
|
|
|
|
fluid
|
|
|
|
>
|
|
|
|
{actionLabel}
|
|
|
|
</Button>
|
|
|
|
</FormGroup>
|
|
|
|
) : null}
|
|
|
|
</Flex>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default ({ handleSubmit, ...rest }) => (
|
|
|
|
<form onSubmit={handleSubmit}>
|
|
|
|
<Toolbar {...rest} />
|
|
|
|
</form>
|
|
|
|
);
|