mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
Load name from url (#323)
* fix: changed loadNameFromHash to loadNameFromUrl Co-authored-by: Shane A. Stillwell <shane@northernv.com>
This commit is contained in:
parent
1dbf74f6d8
commit
cad5e1a01b
@ -85,14 +85,9 @@ export function updateWeight(variants, totalWeight) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadNameFromHash() {
|
export function loadNameFromUrl() {
|
||||||
let field = '';
|
const params = new URLSearchParams(document.location.search);
|
||||||
try {
|
return params.get('name') || '';
|
||||||
[, field] = document.location.hash.match(/name=([a-z0-9-_.]+)/i);
|
|
||||||
} catch (e) {
|
|
||||||
// nothing
|
|
||||||
}
|
|
||||||
return field;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const modalStyles = {
|
export const modalStyles = {
|
||||||
|
@ -77,7 +77,7 @@ exports[`renders correctly with one feature 1`] = `
|
|||||||
dateTime="2018-02-04T20:27:52.127Z"
|
dateTime="2018-02-04T20:27:52.127Z"
|
||||||
title="2018-02-04T20:27:52.127Z"
|
title="2018-02-04T20:27:52.127Z"
|
||||||
>
|
>
|
||||||
3 years ago
|
4 years ago
|
||||||
</time>
|
</time>
|
||||||
</small>
|
</small>
|
||||||
<div>
|
<div>
|
||||||
@ -178,7 +178,7 @@ exports[`renders correctly with one feature without permission 1`] = `
|
|||||||
dateTime="2018-02-04T20:27:52.127Z"
|
dateTime="2018-02-04T20:27:52.127Z"
|
||||||
title="2018-02-04T20:27:52.127Z"
|
title="2018-02-04T20:27:52.127Z"
|
||||||
>
|
>
|
||||||
3 years ago
|
4 years ago
|
||||||
</time>
|
</time>
|
||||||
</small>
|
</small>
|
||||||
<div>
|
<div>
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
validateName,
|
validateName,
|
||||||
} from '../../../../store/feature-toggle/actions';
|
} from '../../../../store/feature-toggle/actions';
|
||||||
import CreateFeature from './CreateFeature';
|
import CreateFeature from './CreateFeature';
|
||||||
import { loadNameFromHash, showPnpsFeedback } from '../../../common/util';
|
import { loadNameFromUrl, showPnpsFeedback } from '../../../common/util';
|
||||||
import { showFeedback } from '../../../../store/feedback/actions';
|
import { showFeedback } from '../../../../store/feedback/actions';
|
||||||
|
|
||||||
const defaultStrategy = {
|
const defaultStrategy = {
|
||||||
@ -27,7 +27,7 @@ function resolveCurrentProjectId(settings) {
|
|||||||
class WrapperComponent extends Component {
|
class WrapperComponent extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super();
|
super();
|
||||||
const name = loadNameFromHash();
|
const name = loadNameFromUrl();
|
||||||
this.state = {
|
this.state = {
|
||||||
featureToggle: {
|
featureToggle: {
|
||||||
name,
|
name,
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
} from '../../../store/strategy/actions';
|
} from '../../../store/strategy/actions';
|
||||||
|
|
||||||
import CreateStrategy from './CreateStrategy';
|
import CreateStrategy from './CreateStrategy';
|
||||||
import { loadNameFromHash } from '../../common/util';
|
import { loadNameFromUrl } from '../../common/util';
|
||||||
|
|
||||||
const STRATEGY_EXIST_ERROR = 'Error: Strategy with name';
|
const STRATEGY_EXIST_ERROR = 'Error: Strategy with name';
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ const mapStateToProps = (state, props) => {
|
|||||||
return {
|
return {
|
||||||
strategy: strategy
|
strategy: strategy
|
||||||
? strategy
|
? strategy
|
||||||
: { name: loadNameFromHash(), description: '', parameters: [] },
|
: { name: loadNameFromUrl(), description: '', parameters: [] },
|
||||||
editMode,
|
editMode,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user