UI: Set the CODE view as the default view for editing KV's (#4651)

Sets the code toggle on the KV edit/create page to be on by default, we figured most people probably prefer this view.

Also, previously we forced the KV toggle back to a default setting for every
time you visited a KV form page. We've now changed this so that the KV code
toggle button acts as a 'global' toggle. So whatever you set it as will
be the same for every KV for the lifetime of your 'ember session'

If we are to keep this, then consider saving this into localStorage
settings or similar, added some thoughts in comments re: this as it's very likely
to happen.
This commit is contained in:
John Cowen 2018-09-13 09:09:30 +01:00 committed by GitHub
parent b8736e2b5c
commit 028875a732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -6,11 +6,14 @@ import Changeset from 'ember-changeset';
import validations from 'consul-ui/validations/kv';
import lookupValidator from 'ember-changeset-validations';
export default Controller.extend({
json: false,
json: true,
encoder: service('btoa'),
setProperties: function(model) {
// TODO: Potentially save whether json has been clicked to the model
set(this, 'json', false);
// TODO: Potentially save whether json has been clicked to the model,
// setting set(this, 'json', true) here will force the form to always default to code=on
// even if the user has selected code=off on another KV
// ideally we would save the value per KV, but I'd like to not do that on the model
// a set(this, 'json', valueFromSomeStorageJustForThisKV) would be added here
this.changeset = new Changeset(model.item, lookupValidator(validations), validations);
this._super({
...model,