diff --git a/addon/exports/host-services.js b/addon/exports/host-services.js index f4420bc3..35738834 100644 --- a/addon/exports/host-services.js +++ b/addon/exports/host-services.js @@ -18,6 +18,7 @@ export const hostServices = [ 'fileQueue', 'sidebar', 'dashboard', + 'docs-panel', 'universe', 'universe/menu-service', 'universe/registry-service', diff --git a/addon/exports/services.js b/addon/exports/services.js index f5e6b264..2eb841ef 100644 --- a/addon/exports/services.js +++ b/addon/exports/services.js @@ -20,6 +20,7 @@ export const services = [ 'fileQueue', 'sidebar', 'dashboard', + 'docs-panel', 'universe', 'universe/menu-service', 'universe/registry-service', diff --git a/addon/library/subject-custom-fields.js b/addon/library/subject-custom-fields.js index ac8ddd2c..d1de2806 100644 --- a/addon/library/subject-custom-fields.js +++ b/addon/library/subject-custom-fields.js @@ -135,7 +135,7 @@ export default class SubjectCustomFields { // If `fieldFor` is provided then we are fetching custom fields for resource and not an instance of something // this means custom fields can be tied to individual resource instances OR tied to the schema of a resource kind - const fieldsQp = fieldFor ? { for: fieldFor } : { subject_uuid: subjectId }; + const fieldsQp = fieldFor ? { for: fieldFor, limit: -1 } : { subject_uuid: subjectId, limit: -1 }; const fields = await this.store.query('custom-field', fieldsQp); // retain on instance for getGroups/getFields() diff --git a/addon/serializers/application.js b/addon/serializers/application.js index f9e9f705..82e414e7 100644 --- a/addon/serializers/application.js +++ b/addon/serializers/application.js @@ -4,6 +4,8 @@ import { underscore } from '@ember/string'; import normalizePolymorphicTypeWithinHash from '../utils/serialize/normalize-polymorphic-type-within-hash'; export default class ApplicationSerializer extends RESTSerializer { + readOnlyAttributes = ['slug']; + /** * Default primary keys to uuid * @@ -32,6 +34,8 @@ export default class ApplicationSerializer extends RESTSerializer { serialize(snapshot) { const json = super.serialize(...arguments); + this.removeReadOnlyAttributes(json); + // for each relationship make sure the id is set snapshot.eachRelationship((key, relationship) => { const { kind } = relationship.meta; @@ -52,6 +56,14 @@ export default class ApplicationSerializer extends RESTSerializer { return json; } + removeReadOnlyAttributes(json = {}) { + this.readOnlyAttributes.forEach((attribute) => { + delete json[attribute]; + }); + + return json; + } + /** * Normalizes a part of the JSON payload returned by the server. * diff --git a/addon/services/chat.js b/addon/services/chat.js index b512506d..7f71beff 100644 --- a/addon/services/chat.js +++ b/addon/services/chat.js @@ -85,7 +85,7 @@ export default class ChatService extends Service.extend(Evented) { }, { normalizeToEmberData: true, - normalizeModelType: 'chatChannel', + normalizeModelType: 'chat_channel', } ) .then((chatChannelRecord) => { diff --git a/package.json b/package.json index 32b428c8..296204cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/ember-core", - "version": "0.3.21", + "version": "0.3.22", "description": "Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.", "keywords": [ "fleetbase-core", diff --git a/tests/unit/exports/services-test.js b/tests/unit/exports/services-test.js new file mode 100644 index 00000000..31d5d733 --- /dev/null +++ b/tests/unit/exports/services-test.js @@ -0,0 +1,10 @@ +import { module, test } from 'qunit'; +import { services } from '@fleetbase/ember-core/exports/services'; +import { hostServices } from '@fleetbase/ember-core/exports/host-services'; + +module('Unit | Exports | services', function () { + test('it exposes docs-panel to engines', function (assert) { + assert.ok(services.includes('docs-panel'), 'docs-panel is included in engine services'); + assert.ok(hostServices.includes('docs-panel'), 'docs-panel is included in host services'); + }); +}); diff --git a/tests/unit/serializers/application-test.js b/tests/unit/serializers/application-test.js index 166ea56d..ddbe47b6 100644 --- a/tests/unit/serializers/application-test.js +++ b/tests/unit/serializers/application-test.js @@ -20,4 +20,17 @@ module('Unit | Serializer | application', function (hooks) { assert.ok(serializedRecord); }); + + test('it removes read-only attributes from serialized payloads', function (assert) { + let store = this.owner.lookup('service:store'); + let serializer = store.serializerFor('application'); + let payload = { + name: 'Ron', + slug: '-1', + }; + + serializer.removeReadOnlyAttributes(payload); + + assert.deepEqual(payload, { name: 'Ron' }); + }); }); diff --git a/tests/unit/services/chat-test.js b/tests/unit/services/chat-test.js index 5346bc02..98906c77 100644 --- a/tests/unit/services/chat-test.js +++ b/tests/unit/services/chat-test.js @@ -24,7 +24,7 @@ module('Unit | Service | chat', function (hooks) { }); assert.deepEqual(options, { normalizeToEmberData: true, - normalizeModelType: 'chatChannel', + normalizeModelType: 'chat_channel', }); return Promise.resolve({ id: 'chat-1' });