Skip to content

Commit ed6a7a4

Browse files
authored
Merge pull request #1297 from marmelab/angular-1.6
[RFR] Angular 1.6
2 parents 9bb4473 + 98d7102 commit ed6a7a4

File tree

7 files changed

+72
-7
lines changed

7 files changed

+72
-7
lines changed

UPGRADE-1.0.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Upgrade to 1.0
22

3+
## Angular 1.6
4+
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.
5+
6+
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).
7+
8+
Here are the major changes we've faced:
9+
10+
The [default hash-prefix changed from `#/` to `#!/`](https://docs.angularjs.org/guide/migration#commit-aa077e8).
11+
For ng-admin we choose to keep the old prefix in order to avoid major changes in production or tests.
12+
You can do it too by adding a configuration block:
13+
14+
```js
15+
$locationProvider.hashPrefix('');
16+
```
17+
18+
- `$http` doesn't support its `.success` and `.error` functions anymore.
19+
20+
```diff
21+
-$http.success(successFn).error(errorFn);
22+
+$http.then(successFn, errorFn);
23+
```
24+
25+
No more arrow functions on services and controllers.
26+
27+
```diff
28+
-app.service(() => {
29+
+app.service(function () {
30+
/* service code */
31+
});
32+
```
33+
334
## [BC Break] ng-admin now attaches to a named view
435

536
Ng-admin used to attach to the following element in your main `index.html`:

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
],
1616
"dependencies": {
1717
"admin-config": "~0.12.1",
18-
"angular": "~1.4.8",
18+
"angular": "~1.6.1",
1919
"angular-numeraljs": "^1.1.6",
2020
"angular-sanitize": "^1.3.15",
2121
"angular-translate": "^2.11.0",
2222
"angular-ui-bootstrap": "~1.2.1",
2323
"angular-ui-codemirror": "jpetitcolas/ui-codemirror#di",
24-
"angular-ui-router": "^0.2.14",
24+
"angular-ui-router": "~0.4.0",
2525
"bootstrap-sass": "^3.3.7",
2626
"codemirror": "^5.2.0",
2727
"core-js": "^0.6.1",
@@ -42,7 +42,7 @@
4242
"ui-select": "0.18.1"
4343
},
4444
"devDependencies": {
45-
"angular-mocks": "~1.4.8",
45+
"angular-mocks": "~1.6.1",
4646
"babel": "^6.5.2",
4747
"babel-cli": "^6.14.0",
4848
"babel-core": "^6.14.0",
@@ -59,11 +59,13 @@
5959
"html-loader": "^0.3.0",
6060
"jasmine": "~2.4.1",
6161
"jasmine-core": "~2.4.1",
62+
"jasmine-spec-reporter": "^3.2.0",
6263
"jshint-stylish": "~0.1.3",
6364
"json-server": "~0.8.8",
6465
"karma": "~0.13.21",
6566
"karma-chrome-launcher": "~0.2.2",
6667
"karma-jasmine": "~0.3.7",
68+
"karma-mocha-reporter": "^2.2.1",
6769
"karma-ng-html2js-preprocessor": "~0.2.1",
6870
"karma-ng-scenario": "~0.1.0",
6971
"karma-phantomjs-launcher": "~1.0.0",

src/javascripts/ng-admin/Main/MainModule.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ MainModule.directive('maMenuBar', require('./component/directive/maMenuBar'));
1919
MainModule.config(require('./config/http'));
2020
MainModule.config(require('./config/routing'));
2121
MainModule.config(require('./config/translate'));
22+
MainModule.config(require('./config/location'));
2223

2324
MainModule.run(require('./run/HttpErrorHandler'));
2425
MainModule.run(require('./run/Loader'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const location = ($locationProvider) => {
2+
// Keep the start of all routes to #/ instead of #!/
3+
// while updating to Angular 1.6
4+
// @see https://docs.angularjs.org/guide/migration#commit-aa077e8
5+
$locationProvider.hashPrefix('');
6+
};
7+
8+
location.$inject = ['$locationProvider'];
9+
10+
export default location;

src/javascripts/test/karma.conf.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ module.exports = function (config) {
2323
'test/function.bind.shim.js',
2424
'test/unit/**/*.js'
2525
],
26-
plugins: ['karma-webpack', 'karma-jasmine', 'karma-chrome-launcher', 'karma-phantomjs-launcher'],
26+
mochaReporter: {
27+
showDiff: true,
28+
ignoreSkipped: true,
29+
},
30+
reporters: ['mocha'],
31+
plugins: [
32+
'karma-webpack',
33+
'karma-jasmine',
34+
'karma-chrome-launcher',
35+
'karma-phantomjs-launcher',
36+
'karma-mocha-reporter',
37+
],
2738
preprocessors: {
2839
'ng-admin.js': 'webpack',
2940
'test/**/*.js': 'webpack'

src/javascripts/test/protractor.conf.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*global browser*/
22
var jsonServer = require('json-server');
33
var path = require('path');
4+
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
45

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

2223
var onPrepare = function () {
2324
browser.executeScript('window.name = "NG_ENABLE_DEBUG_INFO"');
25+
jasmine.getEnv().addReporter(new SpecReporter({
26+
spec: {
27+
displayStacktrace: true
28+
},
29+
summary: {
30+
displayDuration: false
31+
}
32+
}));
2433
}
2534

2635
var afterLaunch = function () {
@@ -53,7 +62,8 @@ exports.config = {
5362
isVerbose: true,
5463
showColors: true,
5564
includeStackTrace: true,
56-
defaultTimeoutInterval: 360000
65+
defaultTimeoutInterval: 360000,
66+
print: () => {}, // Disable default reporter
5767
},
5868

5969
beforeLaunch: beforeLaunch,

src/javascripts/test/unit/Crud/field/maCheckboxFieldSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ describe('directive: checkbox-field', function () {
3636
scope.value = true;
3737
var element = $compile(directiveUsage)(scope);
3838
scope.$digest();
39-
expect(element.find('input').attr('checked')).toBeTruthy();
39+
expect(element[0].querySelector(':checked')).toBeTruthy();
4040
scope.value = false;
4141
scope.$digest();
42-
expect(element.find('input').attr('checked')).toBeFalsy();
42+
expect(element[0].querySelector(':checked')).toBeFalsy();
4343
});
4444
});

0 commit comments

Comments
 (0)