-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: Move legacy ACLs, KVs and Intentions to use
form
functionality (#…
…4936) Change legacy acls, kvs and intentions to use `form`s
- Loading branch information
Showing
19 changed files
with
133 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
import Controller from '@ember/controller'; | ||
import { set } from '@ember/object'; | ||
import Changeset from 'ember-changeset'; | ||
import validations from 'consul-ui/validations/acl'; | ||
import lookupValidator from 'ember-changeset-validations'; | ||
import { inject as service } from '@ember/service'; | ||
import { get } from '@ember/object'; | ||
|
||
export default Controller.extend({ | ||
builder: service('form'), | ||
dom: service('dom'), | ||
init: function() { | ||
this._super(...arguments); | ||
this.form = get(this, 'builder').form('acl'); | ||
}, | ||
setProperties: function(model) { | ||
this.changeset = new Changeset(model.item, lookupValidator(validations), validations); | ||
this._super({ | ||
...model, | ||
...{ | ||
item: this.changeset, | ||
}, | ||
}); | ||
// essentially this replaces the data with changesets | ||
this._super( | ||
Object.keys(model).reduce((prev, key, i) => { | ||
switch (key) { | ||
case 'item': | ||
prev[key] = this.form.setData(prev[key]).getData(); | ||
break; | ||
} | ||
return prev; | ||
}, model) | ||
); | ||
}, | ||
actions: { | ||
change: function(e) { | ||
const target = e.target || { name: 'Rules', value: e }; | ||
switch (target.name) { | ||
case 'Type': | ||
set(this.changeset, target.name, target.value); | ||
break; | ||
case 'Rules': | ||
set(this, 'item.Rules', target.value); | ||
break; | ||
} | ||
change: function(e, value, item) { | ||
const event = get(this, 'dom').normalizeEvent(e, value); | ||
get(this, 'form').handleEvent(event); | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import validations from 'consul-ui/validations/acl'; | ||
import builderFactory from 'consul-ui/utils/form/builder'; | ||
const builder = builderFactory(); | ||
export default function(name = '', v = validations, form = builder) { | ||
return form(name, {}).setValidators(v); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import validations from 'consul-ui/validations/intention'; | ||
import builderFactory from 'consul-ui/utils/form/builder'; | ||
const builder = builderFactory(); | ||
export default function(name = '', v = validations, form = builder) { | ||
return form(name, {}).setValidators(v); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import validations from 'consul-ui/validations/kv'; | ||
import builderFactory from 'consul-ui/utils/form/builder'; | ||
const builder = builderFactory(); | ||
export default function(name = '', v = validations, form = builder) { | ||
return form(name, {}).setValidators(v); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters