Skip to content

Commit

Permalink
fix link from tasks list to task type (#2769)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippotto authored Jun 19, 2018
1 parent 3b2c155 commit b5d8b9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/assets/javascripts/admin/tasktype/task_type_list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const { Search } = Input;

type Props = {
history: RouterHistory,
initialSearchValue?: string,
};

type State = {
Expand All @@ -41,6 +42,11 @@ class TaskTypeListView extends React.PureComponent<Props, State> {

componentWillMount() {
this.setState(persistence.load(this.props.history));
if (this.props.initialSearchValue && this.props.initialSearchValue !== "") {
this.setState({
searchQuery: this.props.initialSearchValue,
});
}
}

componentDidMount() {
Expand Down
5 changes: 4 additions & 1 deletion app/assets/javascripts/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ class ReactRouter extends React.Component<Props> {
<SecuredRoute
isAuthenticated={isAuthenticated}
path="/taskTypes"
component={TaskTypeListView}
render={({ location }: ContextRouter) => (
// Strip the leading # away. If there is no hash, "".slice(1) will evaluate to "", too.
<TaskTypeListView initialSearchValue={location.hash.slice(1)} />
)}
exact
/>
<SecuredRoute
Expand Down

0 comments on commit b5d8b9e

Please sign in to comment.