1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

pick up name from hash query when no input data

This commit is contained in:
sveisvei 2016-12-13 23:22:26 +01:00
parent 83a71902e9
commit 53909f9ca0
3 changed files with 21 additions and 6 deletions

View File

@ -5,7 +5,16 @@ import { createMapper, createActions } from '../input-helpers';
import FormComponent from './form';
const ID = 'add-feature-toggle';
const mapStateToProps = createMapper({ id: ID });
const mapStateToProps = createMapper({
id: ID,
getDefault () {
let name;
try {
[, name] = document.location.hash.match(/name=([a-z0-9-_]+)/i);
} catch (e) {}
return { name };
},
});
const prepare = (methods, dispatch) => {
methods.onSubmit = (input) => (
(e) => {

View File

@ -11,9 +11,6 @@ const prepare = (methods, dispatch) => {
methods.onSubmit = (input) => (
(e) => {
e.preventDefault();
// clean
const parameters = input.parameters
.filter((name) => !!name)
@ -56,4 +53,13 @@ const actions = createActions({
prepare,
});
export default connect(createMapper({ id: ID }), actions)(AddStrategy);
export default connect(createMapper({
id: ID,
getDefault () {
let name;
try {
[, name] = document.location.hash.match(/name=([a-z0-9-_]+)/i);
} catch (e) {}
return { name };
},
}), actions)(AddStrategy);

View File

@ -20,7 +20,7 @@ class StrategiesListComponent extends Component {
return (
<div>
<HeaderTitle title="Strategies"
actions={<IconButton mini raised name="add" onClick={() => this.context.router.push('/strategies/create')} title="Add new strategy" />} />
actions={<IconButton raised name="add" onClick={() => this.context.router.push('/strategies/create')} title="Add new strategy" />} />
<List>
{strategies.length > 0 ? strategies.map((strategy, i) => {
return (