Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addon/exports/host-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const hostServices = [
'fileQueue',
'sidebar',
'dashboard',
'docs-panel',
'universe',
'universe/menu-service',
'universe/registry-service',
Expand Down
1 change: 1 addition & 0 deletions addon/exports/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const services = [
'fileQueue',
'sidebar',
'dashboard',
'docs-panel',
'universe',
'universe/menu-service',
'universe/registry-service',
Expand Down
2 changes: 1 addition & 1 deletion addon/library/subject-custom-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions addon/serializers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
Expand All @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion addon/services/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default class ChatService extends Service.extend(Evented) {
},
{
normalizeToEmberData: true,
normalizeModelType: 'chatChannel',
normalizeModelType: 'chat_channel',
}
)
.then((chatChannelRecord) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/exports/services-test.js
Original file line number Diff line number Diff line change
@@ -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');
});
});
13 changes: 13 additions & 0 deletions tests/unit/serializers/application-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
});
});
2 changes: 1 addition & 1 deletion tests/unit/services/chat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
Loading