diff --git a/ui-v2/app/adapters/policy.js b/ui-v2/app/adapters/policy.js index ed5772878..f24ae8026 100644 --- a/ui-v2/app/adapters/policy.js +++ b/ui-v2/app/adapters/policy.js @@ -25,14 +25,24 @@ export default Adapter.extend({ return request` PUT /v1/acl/policy?${{ [API_DATACENTER_KEY]: data[DATACENTER_KEY] }} - ${serialized} + ${{ + Name: serialized.Name, + Description: serialized.Description, + Rules: serialized.Rules, + Datacenters: serialized.Datacenters, + }} `; }, requestForUpdateRecord: function(request, serialized, data) { return request` PUT /v1/acl/policy/${data[SLUG_KEY]}?${{ [API_DATACENTER_KEY]: data[DATACENTER_KEY] }} - ${serialized} + ${{ + Name: serialized.Name, + Description: serialized.Description, + Rules: serialized.Rules, + Datacenters: serialized.Datacenters, + }} `; }, requestForDeleteRecord: function(request, serialized, data) { diff --git a/ui-v2/app/models/policy.js b/ui-v2/app/models/policy.js index 9dfa92ed2..4c5bd2e25 100644 --- a/ui-v2/app/models/policy.js +++ b/ui-v2/app/models/policy.js @@ -1,11 +1,10 @@ import Model from 'ember-data/model'; import attr from 'ember-data/attr'; -import writable from 'consul-ui/utils/model/writable'; export const PRIMARY_KEY = 'uid'; export const SLUG_KEY = 'ID'; -const model = Model.extend({ +export default Model.extend({ [PRIMARY_KEY]: attr('string'), [SLUG_KEY]: attr('string'), Name: attr('string', { @@ -29,6 +28,3 @@ const model = Model.extend({ defaultValue: '', }), }); -// TODO: Remove this in favour of just specifying it in the Adapter -export const ATTRS = writable(model, ['Name', 'Description', 'Rules', 'Datacenters']); -export default model; diff --git a/ui-v2/app/models/token.js b/ui-v2/app/models/token.js index 32625eab2..e1de81735 100644 --- a/ui-v2/app/models/token.js +++ b/ui-v2/app/models/token.js @@ -1,11 +1,10 @@ import Model from 'ember-data/model'; import attr from 'ember-data/attr'; -import writable from 'consul-ui/utils/model/writable'; export const PRIMARY_KEY = 'uid'; export const SLUG_KEY = 'AccessorID'; -const model = Model.extend({ +export default Model.extend({ [PRIMARY_KEY]: attr('string'), [SLUG_KEY]: attr('string'), IDPName: attr('string'), @@ -43,19 +42,3 @@ const model = Model.extend({ CreateIndex: attr('number'), ModifyIndex: attr('number'), }); -// TODO: Remove this in favour of just specifying it in the Adapter -// Name and Rules is only for legacy tokens -export const ATTRS = writable(model, [ - 'Name', - 'Rules', - 'Type', - 'Local', - 'Description', - 'Policies', - 'Roles', - // SecretID isn't writable but we need it to identify an - // update via the old API, see TokenAdapter dataForRequest - 'SecretID', - 'AccessorID', -]); -export default model; diff --git a/ui-v2/app/serializers/policy.js b/ui-v2/app/serializers/policy.js index 3f0750116..aac641b81 100644 --- a/ui-v2/app/serializers/policy.js +++ b/ui-v2/app/serializers/policy.js @@ -1,8 +1,7 @@ import Serializer from './application'; -import { PRIMARY_KEY, SLUG_KEY, ATTRS } from 'consul-ui/models/policy'; +import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/policy'; export default Serializer.extend({ primaryKey: PRIMARY_KEY, slugKey: SLUG_KEY, - attrs: ATTRS, }); diff --git a/ui-v2/app/serializers/token.js b/ui-v2/app/serializers/token.js index cbd4785de..c12824efa 100644 --- a/ui-v2/app/serializers/token.js +++ b/ui-v2/app/serializers/token.js @@ -1,6 +1,6 @@ import Serializer from './application'; import { get } from '@ember/object'; -import { PRIMARY_KEY, SLUG_KEY, ATTRS } from 'consul-ui/models/token'; +import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/token'; import WithPolicies from 'consul-ui/mixins/policy/as-many'; import WithRoles from 'consul-ui/mixins/role/as-many'; @@ -8,7 +8,6 @@ import WithRoles from 'consul-ui/mixins/role/as-many'; export default Serializer.extend(WithPolicies, WithRoles, { primaryKey: PRIMARY_KEY, slugKey: SLUG_KEY, - attrs: ATTRS, serialize: function(snapshot, options) { let data = this._super(...arguments); // If a token has Rules, use the old API shape