-
Notifications
You must be signed in to change notification settings - Fork 63
[EMB-170] Removing and refurbishing cruft #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EMB-170] Removing and refurbishing cruft #118
Conversation
07b5c72 to
538534e
Compare
binoculars
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+:100: for removing cruft. A few minor syntax suggestions.
app/adapters/osf-adapter.ts
Outdated
| * @uses GenericDataAdapterMixin | ||
| */ | ||
| export default class OsfAdapter extends JSONAPIAdapter.extend(GenericDataAdapterMixin, { | ||
| export default class OsfAdapter extends JSONAPIAdapter.extend(GenericDataAdapterMixin).extend({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double extend? I haven't seen it before. Maybe add a comment for why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, for some reason I thought that was required for typescript to get the types from the mixin properly, but that's not true. Reverting...
app/serializers/osf-serializer.ts
Outdated
| this.get('store').pushPayload(embeddedObj); | ||
|
|
||
| // Merge links on the embedded object with links on the relationship, so all returned links are available | ||
| const embeddedLinks = Object.assign( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use the object spread operator here.
app/serializers/osf-serializer.ts
Outdated
| // Construct a new relationship in JSON API format | ||
| if (Array.isArray(embeddedObj.data)) { | ||
| relationships[relName] = { | ||
| data: embeddedObj.data.map(o => ({ id: o.id, type: o.type })), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use destructuring and then take advantage of shorthand property names
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#Description
c9f2243 to
0958e16
Compare
0958e16 to
08485d9
Compare
jamescdavis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 this is really great!
| strict: 0, | ||
| indent: 0, | ||
| 'indent-legacy': 'error', | ||
| 'function-paren-newline': ['error', 'consistent'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| id: string, | ||
| snapshot: Snapshot, | ||
| requestType: string, | ||
| ): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay for readability
| $color-bg-blue-dark: #337ab7; | ||
| $color-bg-blue-light: #def; | ||
| $color-bg-red: #f00; | ||
| $color-bg-red: #a00; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this makes a11y happy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the deeper red is more friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH #f00 hurt my eyes :)
Purpose
Remove as much custom logic from our ember-data classes as possible, and clean up anything left.
Summary of Changes
usermodelSide Effects / Testing Notes
No visible changes, at most would require a regression test.
For future development, updating relationships works differently, since they can now be included in a normal POST/PATCH on an object. It should be a little less magic/opaque now.
node.save()Ticket
https://openscience.atlassian.net/browse/EMB-170
Reviewer Checklist
CHANGELOG.md