Skip to content

Commit

Permalink
[#31] Remove jQuery
Browse files Browse the repository at this point in the history
* [x] Strip jQuery in ember-cli-build.js
* [x] Try to ember-data to use ember-fetch instead of $.ajax
* [x] app/adapters/application.js added the authorization: <bearer token> header to outgoing requests
* [x] ma-create-media guards against disabled button
* [x] updated dependencies
  • Loading branch information
0xadada committed Feb 14, 2018
1 parent 8118f9b commit c836951
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 25 deletions.
24 changes: 21 additions & 3 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import DS from 'ember-data';
import { get } from '@ember/object';
import { inject as service } from '@ember/service';
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
import JSONAPIAdapter from 'ember-data/adapters/json-api';
import config from 'mir/config/environment';

export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {
const TOKEN_KEY = 'session.session.authenticated.access_token';

export default JSONAPIAdapter.extend(AdapterFetch, DataAdapterMixin, {
session: service(),

/* Ember */
host: config.DS.host,
namespace: config.DS.namespace,

/* ember-simple-auth */
authorizer: 'authorizer:oauth2'
authorizer: 'authorizer:oauth2',

/* mir */
ajaxOptions() {
this._super(...arguments);
const options = this._super(...arguments) || {};
const token = get(this, TOKEN_KEY);
options.headers = options.headers || {};
options.headers['Content-Type'] = 'application/vnd.api+json';
options.headers['Authorization'] = `Bearer ${token}`;
return options;
}
});
3 changes: 2 additions & 1 deletion app/components/ma-create-media.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export default Component.extend({

actions: {
add(changeset) {
this._createMedia(changeset);
let isDisabled = get(this, 'isDisabled');
if (!isDisabled) this._createMedia(changeset);
}
}
});
5 changes: 4 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const VERSION = GETENVJSON().version;

module.exports = function(defaults) {
let app = new EmberApp(defaults, {
// Add options here
fingerprint: {
extensions: ['css', 'gif', 'js', 'jpg', 'png', 'map', 'svg']
},
Expand All @@ -30,6 +29,10 @@ module.exports = function(defaults) {

svgJar: {
sourceDirs: ['public/images']
},

vendorFiles: {
'jquery.js': null // removes jQuery from build
}
});

Expand Down
2 changes: 2 additions & 0 deletions mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ export default function() {
this.del('/medias/:id', (schema, request) => {
let media = schema.medias.find(request.params.id);
media.destroy();
// TODO: Hacks
return { data: null }; // i shouldn't have to return anything here
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"ember-resolver": "^4.5.0",
"ember-route-action-helper": "^2.0.6",
"ember-simple-auth": "^1.4.2",
"ember-source": "~3.0.0-beta.3",
"ember-source": "~3.0.0",
"ember-svg-jar": "^0.12.0",
"ember-test-component": "^0.2.1",
"eslint": "^4.17.0",
Expand Down
38 changes: 19 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2347,9 +2347,9 @@ columnify@~1.5.4:
strip-ansi "^3.0.0"
wcwidth "^1.0.0"

combined-stream@^1.0.5, combined-stream@~1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009"
combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818"
dependencies:
delayed-stream "~1.0.0"

Expand Down Expand Up @@ -3396,16 +3396,16 @@ ember-cli@~3.0.0-beta.1:
watch-detector "^0.1.0"
yam "0.0.22"

ember-cookies@^0.1.0:
version "0.1.3"
resolved "https://registry.yarnpkg.com/ember-cookies/-/ember-cookies-0.1.3.tgz#de4fc36752a0b0d8a17ef4644a3e03a10a6d1f05"
"ember-cookies@^0.1.0 || ^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/ember-cookies/-/ember-cookies-0.2.0.tgz#81195a31a36447240fb97af47d01ad582f747d47"
dependencies:
ember-cli-babel "^6.8.2"
ember-getowner-polyfill "^1.1.0 || ^2.0.0"

ember-data@^2.18.0:
version "2.18.0"
resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-2.18.0.tgz#8e374e540ea7c3b101983eb51cd0beedaa4d230d"
version "2.18.1"
resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-2.18.1.tgz#306d8fb272f113ab35db022f9a47a298720ba2dc"
dependencies:
amd-name-resolver "0.0.7"
babel-plugin-ember-modules-api-polyfill "^1.4.2"
Expand Down Expand Up @@ -3438,8 +3438,8 @@ ember-data@^2.18.0:
silent-error "^1.0.0"

ember-data@~3.0.0-beta.1:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-3.0.0.tgz#0401f02ab34e0183f77278b108c6c0564ec3e28d"
version "3.0.1"
resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-3.0.1.tgz#555bddde064c72ff9dde4ae4c8c635afe8158b8b"
dependencies:
amd-name-resolver "0.0.7"
babel-plugin-ember-modules-api-polyfill "^1.4.2"
Expand Down Expand Up @@ -3637,7 +3637,7 @@ ember-runtime-enumerable-includes-polyfill@^2.0.0:

ember-simple-auth@0xadada/ember-simple-auth#new-ember-qunit-release, ember-simple-auth@^1.4.2:
version "1.4.2"
resolved "https://codeload.github.com/0xadada/ember-simple-auth/tar.gz/872d97cd3f7b8d3b6a18c5f0607b2758b6a08cc0"
resolved "https://codeload.github.com/0xadada/ember-simple-auth/tar.gz/0638ea3c23e90882bde10119eebd36c8c495233e"
dependencies:
base-64 "^0.1.0"
broccoli-file-creator "^1.1.1"
Expand All @@ -3650,9 +3650,9 @@ ember-simple-auth@0xadada/ember-simple-auth#new-ember-qunit-release, ember-simpl
ember-getowner-polyfill "^1.1.0 || ^2.0.0"
silent-error "^1.0.0"

ember-source@~3.0.0-beta.3:
version "3.0.0-beta.6"
resolved "https://registry.yarnpkg.com/ember-source/-/ember-source-3.0.0-beta.6.tgz#e8042c1781de4f125993bb41b067cb32fc61c419"
ember-source@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ember-source/-/ember-source-3.0.0.tgz#51811cae98d2ceec53bcfbaa876d02b2b5b2159f"
dependencies:
broccoli-funnel "^2.0.1"
broccoli-merge-trees "^2.0.0"
Expand Down Expand Up @@ -4446,11 +4446,11 @@ form-data@~2.1.1:
mime-types "^2.1.12"

form-data@~2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.1.tgz#6fb94fbd71885306d73d15cc497fe4cc4ecd44bf"
version "2.3.2"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099"
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.5"
combined-stream "1.0.6"
mime-types "^2.1.12"

forwarded@~0.1.2:
Expand Down Expand Up @@ -8969,8 +8969,8 @@ source-map@~0.2.0:
amdefine ">=0.0.4"

sourcemap-validator@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/sourcemap-validator/-/sourcemap-validator-1.0.6.tgz#abd2f1ecdae6a3c46c2c96c5f256705b2147c9c0"
version "1.0.7"
resolved "https://registry.yarnpkg.com/sourcemap-validator/-/sourcemap-validator-1.0.7.tgz#d76aaadbe2c6ec269293b5f212100fad91eef260"
dependencies:
jsesc "~0.3.x"
lodash.foreach "~2.3.x"
Expand Down

0 comments on commit c836951

Please sign in to comment.