mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +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() { | ||||
|     let field = ''; | ||||
|     try { | ||||
|         [, field] = document.location.hash.match(/name=([a-z0-9-_.]+)/i); | ||||
|     } catch (e) { | ||||
|         // nothing
 | ||||
|     } | ||||
|     return field; | ||||
| export function loadNameFromUrl() { | ||||
|     const params = new URLSearchParams(document.location.search); | ||||
|     return params.get('name') || ''; | ||||
| } | ||||
| 
 | ||||
| export const modalStyles = { | ||||
|  | ||||
| @ -77,7 +77,7 @@ exports[`renders correctly with one feature 1`] = ` | ||||
|           dateTime="2018-02-04T20:27:52.127Z" | ||||
|           title="2018-02-04T20:27:52.127Z" | ||||
|         > | ||||
|           3 years ago | ||||
|           4 years ago | ||||
|         </time> | ||||
|       </small> | ||||
|       <div> | ||||
| @ -178,7 +178,7 @@ exports[`renders correctly with one feature without permission 1`] = ` | ||||
|           dateTime="2018-02-04T20:27:52.127Z" | ||||
|           title="2018-02-04T20:27:52.127Z" | ||||
|         > | ||||
|           3 years ago | ||||
|           4 years ago | ||||
|         </time> | ||||
|       </small> | ||||
|       <div> | ||||
|  | ||||
| @ -6,7 +6,7 @@ import { | ||||
|     validateName, | ||||
| } from '../../../../store/feature-toggle/actions'; | ||||
| import CreateFeature from './CreateFeature'; | ||||
| import { loadNameFromHash, showPnpsFeedback } from '../../../common/util'; | ||||
| import { loadNameFromUrl, showPnpsFeedback } from '../../../common/util'; | ||||
| import { showFeedback } from '../../../../store/feedback/actions'; | ||||
| 
 | ||||
| const defaultStrategy = { | ||||
| @ -27,7 +27,7 @@ function resolveCurrentProjectId(settings) { | ||||
| class WrapperComponent extends Component { | ||||
|     constructor(props) { | ||||
|         super(); | ||||
|         const name = loadNameFromHash(); | ||||
|         const name = loadNameFromUrl(); | ||||
|         this.state = { | ||||
|             featureToggle: { | ||||
|                 name, | ||||
|  | ||||
| @ -9,7 +9,7 @@ import { | ||||
| } from '../../../store/strategy/actions'; | ||||
| 
 | ||||
| import CreateStrategy from './CreateStrategy'; | ||||
| import { loadNameFromHash } from '../../common/util'; | ||||
| import { loadNameFromUrl } from '../../common/util'; | ||||
| 
 | ||||
| const STRATEGY_EXIST_ERROR = 'Error: Strategy with name'; | ||||
| 
 | ||||
| @ -141,7 +141,7 @@ const mapStateToProps = (state, props) => { | ||||
|     return { | ||||
|         strategy: strategy | ||||
|             ? strategy | ||||
|             : { name: loadNameFromHash(), description: '', parameters: [] }, | ||||
|             : { name: loadNameFromUrl(), description: '', parameters: [] }, | ||||
|         editMode, | ||||
|     }; | ||||
| }; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user