Repository navigation
feat: sbb-angular auto migration setup - #606
DavideMininni-Fincons wants to merge 78 commits into
Conversation
jeripeierSBB
left a comment
There was a problem hiding this comment.
Amazing work! I think we can merge it and then continue with smaller PRs.
| import { MigrationScope } from '../../utils.cjs'; | ||
| import { CommentMigration, createCommentMigrationRule } from '../migrations/comment-migration.cjs'; | ||
|
|
||
| const COMMENTS: CommentMigration[] = [ |
There was a problem hiding this comment.
this could be transferred into a menu and a button inside the header to open it?
There was a problem hiding this comment.
I would prefer to add just the comment;
even if it can be migrated to a header-button, its properties and behavior cannot easily be migrated with a solution which covers 100% of cases (eg. displayName and username, the change when menu opens, the menu events and so on).
jeripeierSBB
left a comment
There was a problem hiding this comment.
Create framework you created. In my opinion we can merge the state.
| const comments: CommentMigration[] = [ | ||
| { | ||
| selector: 'sbb-usermenu', | ||
| message: `FIXME: this component has no direct counterpart in lyne-angular; you can replace it with a 'sbb-header-button' adapting its properties.`, |
There was a problem hiding this comment.
This comment should not prevent any merge now. In case we want to change anything we could do it in a follow up PR.
I think if we know that a component is used very often (like the usermenu) and there is a (almost) deterministic path to migrate, we should try to do it. I think this kind of components make it hard for consumers and also AI to migrate because they need to understand exactly how the two worlds work. If we provide a starting point, they could be much faster understanding and adapting it.
Maybe you did try already much more :), but nevertheless I try with a simple idea:
before
<sbb-usermenu
[userName]="userName"
[displayName]="displayName"
(loginRequest)="login()"
[menu]="menu"
>
</sbb-usermenu>after
<sbb-header-button
iconName="user-small"
(click)="displayName ? null : login()"
[sbbMenu]="displayName ? menu : null"
>
@if(displayName) {
{{ displayName }}
} @else {
Login
}
</sbb-header-button>
<!-- [userName]="userName" should be included in the sbb-menu --> In the comment it could be helpful to link an example (which we have, but without the login mechanism and only in lyne-elements): https://lyne-elements.app.sbb.ch/?path=/story/elements-header--with-user-menu. Probably it would be worth to create a full example (with login and logout functions) in lyne-angular, as this is used in almost every application.
Setup for the automatic migration from
sbb-angulartolyne-angular.The migration is executed launching
ng generate @sbb-esta/lyne-angular:migrate-legacy;--projectparameter can be used to migrate a specific project in a multi-project workspace;--moduleparameter can be used to launch a module specific migration.The setup includes customizable rules for:
defaultValuecombined withreplaceWith;If a custom rule is needed, it can be simply added in the migration chain.
The configured theme is already available for specific theme-dependent migrations.
Check
src/angular/schematics/migrate-legacy/README.mdfor technical details.Button module migration is included too.