Add query parameter to override Mirage scenario (#9380)

This commit is contained in:
Buck Doyle 2020-11-30 08:12:15 -06:00 committed by GitHub
parent 6334ad1b42
commit ba147a4fca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -30,6 +30,8 @@ You may need to reference the direct path to `ember`, typically in `./node_modul
The fake data in development is generated from a stable seed of 1. To generate different data, you can include a query parameter of `?faker-seed=2` or any other number in the URL. To turn off the seed and get different data with every load, use `?faker=seed=0`.
When running with Mirage, the default scenario is set in `config/environment.js` but can be overridden with a query parameter to any of the scenarios named in `mirage/scenarios/default.js` with something like `?mirage-scenario=emptyCluster`.
## Running / Development with Vagrant
All necessary tools for UI development are installed as part of the Vagrantfile. This is primarily to make it easy to build the UI from source while working on Nomad. Due to the filesystem requirements of [Broccoli](http://broccolijs.com/) (which powers Ember CLI), it is strongly discouraged to use Vagrant for developing changes to the UI.

View File

@ -18,7 +18,7 @@ const allScenarios = {
...topoScenarios,
};
const scenario = getConfigValue('mirageScenario', 'emptyCluster');
const scenario = getScenarioQueryParameter() || getConfigValue('mirageScenario', 'emptyCluster');
export default function(server) {
const activeScenario = allScenarios[scenario];
@ -169,4 +169,9 @@ function getConfigValue(variableName, defaultValue) {
);
return defaultValue;
}
function getScenarioQueryParameter() {
const params = new URLSearchParams(window.location.search);
return params.get('mirage-scenario');
}
/* eslint-enable */