Skip to content

Commit

Permalink
Merge pull request #1297 from marmelab/angular-1.6
Browse files Browse the repository at this point in the history
[RFR] Angular 1.6
  • Loading branch information
jpetitcolas authored Jan 26, 2017
2 parents 9bb4473 + 98d7102 commit ed6a7a4
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 7 deletions.
31 changes: 31 additions & 0 deletions UPGRADE-1.0.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Upgrade to 1.0

## Angular 1.6
ng-admin is now ready for Angular 1.6 instead of 1.4, mainly for security reasons. We advice you to update your application too.

To do so, you can follow the Angular Migration Guide [from 1.4 to 1.5](https://docs.angularjs.org/guide/migration#migrating-from-1-4-to-1-5), then [from 1.5 to 1.6](https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6).

Here are the major changes we've faced:

The [default hash-prefix changed from `#/` to `#!/`](https://docs.angularjs.org/guide/migration#commit-aa077e8).
For ng-admin we choose to keep the old prefix in order to avoid major changes in production or tests.
You can do it too by adding a configuration block:

```js
$locationProvider.hashPrefix('');
```

- `$http` doesn't support its `.success` and `.error` functions anymore.

```diff
-$http.success(successFn).error(errorFn);
+$http.then(successFn, errorFn);
```

No more arrow functions on services and controllers.

```diff
-app.service(() => {
+app.service(function () {
/* service code */
});
```

## [BC Break] ng-admin now attaches to a named view

Ng-admin used to attach to the following element in your main `index.html`:
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
],
"dependencies": {
"admin-config": "~0.12.1",
"angular": "~1.4.8",
"angular": "~1.6.1",
"angular-numeraljs": "^1.1.6",
"angular-sanitize": "^1.3.15",
"angular-translate": "^2.11.0",
"angular-ui-bootstrap": "~1.2.1",
"angular-ui-codemirror": "jpetitcolas/ui-codemirror#di",
"angular-ui-router": "^0.2.14",
"angular-ui-router": "~0.4.0",
"bootstrap-sass": "^3.3.7",
"codemirror": "^5.2.0",
"core-js": "^0.6.1",
Expand All @@ -42,7 +42,7 @@
"ui-select": "0.18.1"
},
"devDependencies": {
"angular-mocks": "~1.4.8",
"angular-mocks": "~1.6.1",
"babel": "^6.5.2",
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
Expand All @@ -59,11 +59,13 @@
"html-loader": "^0.3.0",
"jasmine": "~2.4.1",
"jasmine-core": "~2.4.1",
"jasmine-spec-reporter": "^3.2.0",
"jshint-stylish": "~0.1.3",
"json-server": "~0.8.8",
"karma": "~0.13.21",
"karma-chrome-launcher": "~0.2.2",
"karma-jasmine": "~0.3.7",
"karma-mocha-reporter": "^2.2.1",
"karma-ng-html2js-preprocessor": "~0.2.1",
"karma-ng-scenario": "~0.1.0",
"karma-phantomjs-launcher": "~1.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/javascripts/ng-admin/Main/MainModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ MainModule.directive('maMenuBar', require('./component/directive/maMenuBar'));
MainModule.config(require('./config/http'));
MainModule.config(require('./config/routing'));
MainModule.config(require('./config/translate'));
MainModule.config(require('./config/location'));

MainModule.run(require('./run/HttpErrorHandler'));
MainModule.run(require('./run/Loader'));
10 changes: 10 additions & 0 deletions src/javascripts/ng-admin/Main/config/location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const location = ($locationProvider) => {
// Keep the start of all routes to #/ instead of #!/
// while updating to Angular 1.6
// @see https://docs.angularjs.org/guide/migration#commit-aa077e8
$locationProvider.hashPrefix('');
};

location.$inject = ['$locationProvider'];

export default location;
13 changes: 12 additions & 1 deletion src/javascripts/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@ module.exports = function (config) {
'test/function.bind.shim.js',
'test/unit/**/*.js'
],
plugins: ['karma-webpack', 'karma-jasmine', 'karma-chrome-launcher', 'karma-phantomjs-launcher'],
mochaReporter: {
showDiff: true,
ignoreSkipped: true,
},
reporters: ['mocha'],
plugins: [
'karma-webpack',
'karma-jasmine',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-mocha-reporter',
],
preprocessors: {
'ng-admin.js': 'webpack',
'test/**/*.js': 'webpack'
Expand Down
12 changes: 11 additions & 1 deletion src/javascripts/test/protractor.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*global browser*/
var jsonServer = require('json-server');
var path = require('path');
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;

var server = function() {
const server = jsonServer.create();
Expand All @@ -21,6 +22,14 @@ var beforeLaunch = function () {

var onPrepare = function () {
browser.executeScript('window.name = "NG_ENABLE_DEBUG_INFO"');
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: true
},
summary: {
displayDuration: false
}
}));
}

var afterLaunch = function () {
Expand Down Expand Up @@ -53,7 +62,8 @@ exports.config = {
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 360000
defaultTimeoutInterval: 360000,
print: () => {}, // Disable default reporter
},

beforeLaunch: beforeLaunch,
Expand Down
4 changes: 2 additions & 2 deletions src/javascripts/test/unit/Crud/field/maCheckboxFieldSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ describe('directive: checkbox-field', function () {
scope.value = true;
var element = $compile(directiveUsage)(scope);
scope.$digest();
expect(element.find('input').attr('checked')).toBeTruthy();
expect(element[0].querySelector(':checked')).toBeTruthy();
scope.value = false;
scope.$digest();
expect(element.find('input').attr('checked')).toBeFalsy();
expect(element[0].querySelector(':checked')).toBeFalsy();
});
});

0 comments on commit ed6a7a4

Please sign in to comment.