1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

fix: missing feature toggle should pre-fill name

This commit is contained in:
Ivar Conradi Østhus 2020-02-12 22:10:43 +01:00
parent 00064644e5
commit a4961cc6d3
2 changed files with 15 additions and 3 deletions

View File

@ -4,14 +4,16 @@ import { connect } from 'react-redux';
import arrayMove from 'array-move';
import { createFeatureToggles, validateName } from './../../../store/feature-actions';
import AddFeatureComponent from './form-add-feature-component';
import { loadNameFromHash } from './util';
const defaultStrategy = { name: 'default' };
class WrapperComponent extends Component {
constructor() {
super();
constructor(props) {
super(props);
const name = loadNameFromHash();
this.state = {
featureToggle: { name: '', description: '', strategies: [], enabled: true },
featureToggle: { name, description: '', strategies: [], enabled: true },
errors: {},
dirty: false,
};

View File

@ -5,3 +5,13 @@ export const trim = value => {
return value;
}
};
export function loadNameFromHash() {
let field = '';
try {
[, field] = document.location.hash.match(/name=([a-z0-9-_.]+)/i);
} catch (e) {
// nothing
}
return field;
}