Skip to content

Commit 1032ce6

Browse files
authored
refactor(migrations): improve button and card action migrations (#14215)
1 parent 2cbc95a commit 1032ce6

File tree

5 files changed

+130
-40
lines changed

5 files changed

+130
-40
lines changed

projects/igniteui-angular/migrations/migration-collection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@
176176
"version": "17.2.0",
177177
"description": "Updates Ignite UI for Angular from v17.1.x to v17.2.0",
178178
"factory": "./update-17_2_0"
179+
},
180+
"migration-36": {
181+
"version": "17.2.2",
182+
"description": "Updates Ignite UI for Angular from v17.2.0 to v17.2.2",
183+
"factory": "./update-17_2_2"
179184
}
180185
}
181186
}

projects/igniteui-angular/migrations/update-17_2_0/changes/inputs.json

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,6 @@
1818
"type": "component"
1919
}
2020
},
21-
{
22-
"name": "color",
23-
"remove": true,
24-
"owner": {
25-
"selector": "igxButton",
26-
"type": "directive"
27-
}
28-
},
29-
{
30-
"name": "background",
31-
"remove": true,
32-
"owner": {
33-
"selector": "igxButton",
34-
"type": "directive"
35-
}
36-
},
37-
{
38-
"name": "igxButtonColor",
39-
"remove": true,
40-
"owner": {
41-
"selector": "igxButton",
42-
"type": "directive"
43-
}
44-
},
45-
{
46-
"name": "igxButtonBackground",
47-
"remove": true,
48-
"owner": {
49-
"selector": "igxButton",
50-
"type": "directive"
51-
}
52-
},
5321
{
5422
"name": "type",
5523
"remove": true,
@@ -58,14 +26,6 @@
5826
"type": "component"
5927
}
6028
},
61-
{
62-
"name": "reverse",
63-
"remove": true,
64-
"owner": {
65-
"selector": "igx-card",
66-
"type": "component"
67-
}
68-
},
6929
{
7030
"name": "leftButtonColor",
7131
"remove": true,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "../../common/schema/binding.schema.json",
3+
"changes": [
4+
{
5+
"name": "igxButtonColor",
6+
"replaceWith": "style.--foreground",
7+
"owner": {
8+
"selector": "igxButton",
9+
"type": "directive"
10+
}
11+
},
12+
{
13+
"name": "igxButtonBackground",
14+
"replaceWith": "style.--background",
15+
"owner": {
16+
"selector": "igxButton",
17+
"type": "directive"
18+
}
19+
},
20+
{
21+
"name": "reverse",
22+
"remove": true,
23+
"owner": {
24+
"selector": "igx-card-actions",
25+
"type": "component"
26+
}
27+
}
28+
]
29+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import * as path from 'path';
2+
3+
import { EmptyTree } from '@angular-devkit/schematics';
4+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
5+
6+
const version = '17.2.2';
7+
8+
describe(`Update to ${version}`, () => {
9+
let appTree: UnitTestTree;
10+
const schematicRunner = new SchematicTestRunner('ig-migrate', path.join(__dirname, '../migration-collection.json'));
11+
12+
const configJson = {
13+
projects: {
14+
testProj: {
15+
root: '/',
16+
sourceRoot: '/testSrc'
17+
}
18+
},
19+
schematics: {
20+
'@schematics/angular:component': {
21+
prefix: 'appPrefix'
22+
}
23+
}
24+
};
25+
26+
beforeEach(() => {
27+
appTree = new UnitTestTree(new EmptyTree());
28+
appTree.create('/angular.json', JSON.stringify(configJson));
29+
});
30+
31+
const migrationName = 'migration-36';
32+
33+
it('should replace button property `igxButtonColor` with `style.--foreground`', async () => {
34+
appTree.create(`/testSrc/appPrefix/component/test.component.html`,
35+
`
36+
<button igxButton [igxButtonColor]="red"></button>
37+
`
38+
);
39+
40+
const tree = await schematicRunner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
41+
42+
expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')).toEqual(
43+
`
44+
<button igxButton [style.--foreground]="red"></button>
45+
`
46+
);
47+
});
48+
49+
it('should replace button property `igxButtonBackground` with `style.--background`', async () => {
50+
appTree.create(`/testSrc/appPrefix/component/test.component.html`,
51+
`
52+
<button igxButton [igxButtonBackground]="red"></button>
53+
`
54+
);
55+
56+
const tree = await schematicRunner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
57+
58+
expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')).toEqual(
59+
`
60+
<button igxButton [style.--background]="red"></button>
61+
`
62+
);
63+
});
64+
65+
it('should remove igx-card-actions property `reverse`', async () => {
66+
appTree.create(`/testSrc/appPrefix/component/test.component.html`,
67+
`
68+
<igx-card>
69+
<igx-card-actions [reverse]="true"></igx-card-actions>
70+
</igx-card>
71+
`
72+
);
73+
74+
const tree = await schematicRunner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
75+
76+
expect(tree.readContent('/testSrc/appPrefix/component/test.component.html')).toEqual(
77+
`
78+
<igx-card>
79+
<igx-card-actions></igx-card-actions>
80+
</igx-card>
81+
`
82+
);
83+
});
84+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Rule, SchematicContext, Tree } from "@angular-devkit/schematics";
2+
import { BoundPropertyObject, InputPropertyType, UpdateChanges } from "../common/UpdateChanges";
3+
4+
const version = "17.2.2";
5+
6+
export default (): Rule => async (host: Tree, context: SchematicContext) => {
7+
context.logger.info(
8+
`Applying migration for Ignite UI for Angular to version ${version}`,
9+
);
10+
const update = new UpdateChanges(__dirname, host, context);
11+
update.applyChanges();
12+
};

0 commit comments

Comments
 (0)