diff --git a/scm-ui-components/packages/ui-components/src/forms/FilterInput.js b/scm-ui-components/packages/ui-components/src/forms/FilterInput.js new file mode 100644 index 0000000000..8e41a177a7 --- /dev/null +++ b/scm-ui-components/packages/ui-components/src/forms/FilterInput.js @@ -0,0 +1,69 @@ +//@flow +import React from "react"; +import injectSheet from "react-jss"; +import classNames from "classnames"; +import { translate } from "react-i18next"; + +type Props = { + filter: string => void, + + // context props + classes: Object, + t: string => string +}; + +type State = { + value: string +}; + +const styles = { + inputField: { + float: "right", + marginTop: "1.25rem", + marginRight: "1.25rem" + }, + inputHeight: { + height: "2.5rem" + } +}; + +class FilterInput extends React.Component { + constructor(props) { + super(props); + this.state = { value: "" }; + } + + handleChange = event => { + this.setState({ value: event.target.value }); + }; + + handleSubmit = event => { + this.props.filter(this.state.value); + event.preventDefault(); + }; + + render() { + const { classes, t } = this.props; + return ( +
+
+ + + + +
+ + ); + } +} + +export default injectSheet(styles)(translate("commons")(FilterInput)); diff --git a/scm-ui-components/packages/ui-components/src/forms/index.js b/scm-ui-components/packages/ui-components/src/forms/index.js index ef4d7a1ae4..aed38d44bc 100644 --- a/scm-ui-components/packages/ui-components/src/forms/index.js +++ b/scm-ui-components/packages/ui-components/src/forms/index.js @@ -5,6 +5,7 @@ export { default as AutocompleteAddEntryToTableField } from "./AutocompleteAddEn export { default as MemberNameTable } from "./MemberNameTable.js"; export { default as Checkbox } from "./Checkbox.js"; export { default as Radio } from "./Radio.js"; +export { default as FilterInput } from "./FilterInput.js"; export { default as InputField } from "./InputField.js"; export { default as Select } from "./Select.js"; export { default as Textarea } from "./Textarea.js"; diff --git a/scm-ui-components/packages/ui-components/src/layout/Page.js b/scm-ui-components/packages/ui-components/src/layout/Page.js index 2f9add611c..c6f5d132a5 100644 --- a/scm-ui-components/packages/ui-components/src/layout/Page.js +++ b/scm-ui-components/packages/ui-components/src/layout/Page.js @@ -2,7 +2,6 @@ import * as React from "react"; import injectSheet from "react-jss"; import classNames from "classnames"; -import { translate } from "react-i18next"; import Loading from "./../Loading"; import ErrorNotification from "./../ErrorNotification"; import Title from "./Title"; @@ -10,10 +9,6 @@ import Subtitle from "./Subtitle"; import PageActions from "./PageActions"; import ErrorBoundary from "../ErrorBoundary"; -type State = { - value: string -}; - type Props = { title?: string, subtitle?: string, @@ -21,46 +16,19 @@ type Props = { error?: Error, showContentOnError?: boolean, children: React.Node, - filter: string => void, // context props - classes: Object, - t: string => string + classes: Object }; const styles = { actions: { display: "flex", justifyContent: "flex-end" - }, - inputField: { - float: "right", - marginTop: "1.25rem", - marginRight: "1.25rem" - }, - inputHeight: { - height: "2.5rem" - }, - button: { - float: "right", - marginTop: "1.25rem" } }; -class Page extends React.Component { - constructor(props) { - super(props); - this.state = { value: "" }; - } - - handleChange = event => { - this.setState({ value: event.target.value }); - }; - - handleSubmit = event => { - this.props.filter(this.state.value); - event.preventDefault(); - }; +class Page extends React.Component { render() { const { error } = this.props; @@ -78,7 +46,7 @@ class Page extends React.Component { } renderPageHeader() { - const { error, title, subtitle, children, classes, t } = this.props; + const { error, title, subtitle, children, classes } = this.props; let pageActions = null; let pageActionsExists = false; @@ -91,26 +59,7 @@ class Page extends React.Component { "column is-three-fifths is-mobile-action-spacing" )} > -
-
- - - - -
- -
- {child} -
+ {child} ); pageActionsExists = true; @@ -154,4 +103,4 @@ class Page extends React.Component { } } -export default injectSheet(styles)(translate("commons")(Page)); +export default injectSheet(styles)(Page);