From 57454f9aa96809a54259f31f6339e3ad147d7269 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 8 Mar 2019 08:10:34 +0100 Subject: [PATCH 1/4] adds option to request focus for a textarea --- .../packages/ui-components/src/forms/Textarea.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scm-ui-components/packages/ui-components/src/forms/Textarea.js b/scm-ui-components/packages/ui-components/src/forms/Textarea.js index 3db590122a..4ea3741a31 100644 --- a/scm-ui-components/packages/ui-components/src/forms/Textarea.js +++ b/scm-ui-components/packages/ui-components/src/forms/Textarea.js @@ -12,6 +12,7 @@ type Props = { label?: string, placeholder?: SelectItem[], value?: string, + autofocus?: boolean, onChange: (value: string, name?: string) => void, helpText?: string }; @@ -19,6 +20,12 @@ type Props = { class Textarea extends React.Component { field: ?HTMLTextAreaElement; + componentDidMount() { + if (this.props.autofocus && this.field) { + this.field.focus(); + } + } + handleInput = (event: SyntheticInputEvent) => { this.props.onChange(event.target.value, this.props.name); }; From b9b544b7f007560437d32de0a9719080a47d2677 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 8 Mar 2019 08:27:20 +0100 Subject: [PATCH 2/4] pass function to toggle collpase state to FileControlFactory --- .../packages/ui-components/src/repos/DiffFile.js | 8 +++++++- .../packages/ui-components/src/repos/DiffTypes.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/repos/DiffFile.js b/scm-ui-components/packages/ui-components/src/repos/DiffFile.js index 24aa407fb0..ccc07f2ea1 100644 --- a/scm-ui-components/packages/ui-components/src/repos/DiffFile.js +++ b/scm-ui-components/packages/ui-components/src/repos/DiffFile.js @@ -56,6 +56,12 @@ class DiffFile extends React.Component { })); }; + setCollapse = (collapsed: boolean) => { + this.setState({ + collapsed + }); + }; + createHunkHeader = (hunk: Hunk, i: number) => { const { classes } = this.props; if (i > 0) { @@ -166,7 +172,7 @@ class DiffFile extends React.Component { ); } - const fileControls = fileControlFactory ? fileControlFactory(file) : null; + const fileControls = fileControlFactory ? fileControlFactory(file, this.setCollapse) : null; return (
diff --git a/scm-ui-components/packages/ui-components/src/repos/DiffTypes.js b/scm-ui-components/packages/ui-components/src/repos/DiffTypes.js index f841de6e08..2b03f10e9f 100644 --- a/scm-ui-components/packages/ui-components/src/repos/DiffTypes.js +++ b/scm-ui-components/packages/ui-components/src/repos/DiffTypes.js @@ -42,7 +42,7 @@ export type BaseContext = { export type AnnotationFactoryContext = BaseContext; -export type FileAnnotationFactory = (file: File) => React.Node[]; +export type FileAnnotationFactory = (file: File, setCollapseState: (boolean) => void) => React.Node[]; // key = change id, value = react component export type AnnotationFactory = ( From 28778624b54b697285b4fa01509f5a296f212e10 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 8 Mar 2019 09:06:39 +0100 Subject: [PATCH 3/4] fixes wrong type definition --- .../packages/ui-components/src/repos/DiffTypes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/repos/DiffTypes.js b/scm-ui-components/packages/ui-components/src/repos/DiffTypes.js index 2b03f10e9f..74803e0a4e 100644 --- a/scm-ui-components/packages/ui-components/src/repos/DiffTypes.js +++ b/scm-ui-components/packages/ui-components/src/repos/DiffTypes.js @@ -42,7 +42,7 @@ export type BaseContext = { export type AnnotationFactoryContext = BaseContext; -export type FileAnnotationFactory = (file: File, setCollapseState: (boolean) => void) => React.Node[]; +export type FileAnnotationFactory = (file: File) => React.Node[]; // key = change id, value = react component export type AnnotationFactory = ( @@ -58,7 +58,7 @@ export type DiffEventContext = BaseContext & { export type DiffEventHandler = (context: DiffEventContext) => void; -export type FileControlFactory = (file: File) => ?React.Node; +export type FileControlFactory = (file: File, setCollapseState: (boolean) => void) => ?React.Node; export type DiffObjectProps = { sideBySide: boolean, From 67eed493b109edf7f53d56012ba62143aa23e5d4 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 8 Mar 2019 09:08:48 +0100 Subject: [PATCH 4/4] close branch feature/diff_annotations