•  
      request #29602 Migrate pullrequest file-diffs to TypeScript
    Infos
    #29602
    Thomas Gorka (tgorka)
    2022-12-12 15:00
    2022-11-09 16:32
    31196
    Details
    Migrate pullrequest file-diffs to TypeScript

    The latest developments on pullrequests comments have brought us to change the way the side-by-side and the unified diffs are generated.

    We had to fix some issues, and having this complex feature written in Vanilla Javascript makes it really hard to debug them.

    The TypeScript parser will help us to spot clumsy things and make the whole feature more solid.

     

    The strategy is to migrate first files having no dependencies on codemirror, then migrate the ones having some.

    The first files that can be migrated with a certain ease are :

    1. code-collapse-service -> defines which sections of code can be folded (e.g untouched lines between two versions of a file) ✅
    2. side-by-side-line-grouper -> builds groups of lines by their states (added, deleted, untouched) ✅
    3. diff-mode-state -> tells if the diff is displayed in unified or side-by-side mode ✅
    4. inline-comments-positions -> only exports constants ✅

    Then we can migrate :

    1. side-by-side-scroll-synchronizer -> Uses codemirror Editor ✅
    2. side-by-side-widget-positionner -> Uses codemirror Handles ✅
    3. side-by-side-line-mapper -> Uses codemirror Handles and Editor ✅
    4. side-by-side-widget-finder -> Uses codemirror Widgets and Handles ✅
    5. side-by-side-line-height-equalizer -> Uses codemirror Editor, Handles and Widgets ✅
    6. side-by-side-comment-placeholder-builder -> Uses codemirror Editor, Handles and Widgets ✅

    Once all the files have been migrated to TypeScript, we'll have to extract some logic from side-by-side-component - which is not unit tested - and split it into smaller objects. To achieve that, we'll have first to:

    1. Migrate new-inline-comment-component to Hybrids + TypeScript ✅
    2. Extract the widgets creation part out of codemirror-helper-service (which is an angular.js service) ✅

    Then, we'll normally be able to extract and split the management of widgets in codemirrors from the master component.

    1. Insertion of comment and their placeholders on the opposite side ✅
    2. Insertion of the new-inline-comment-form and their placeholders on the opposide side ✅
    3. Insertion of code placeholders ✅

     

    [Bonus]

    We could also migrate the codemirror-helper-service out of angular, in a unit tested TypeScript object. ✅

     

    Pull Request
    Empty
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Empty
    Stage
    Empty
    Closed
    2022-12-12
    Attachments
    Empty
    References
    Referencing request #29602

    Git commit

    tuleap/tuleap/stable

    refactor: Migrate side-by-side-line-grouper to TypeScript 868aa37938
    refactor: Migrate diff-mode-state and inline-comment-positions to TypeScript b4c936dc13
    refactor: Migrate side-by-side-scroll-synchronizer to TypeScript 4174bd081e
    refactor: Use FileLine and GroupOfLines stubs in unit tests ec18116637
    refactor: Migrate side-by-side-line-mapper to TypeScript 6300f3fbfd
    refactor: Migrate side-by-side-widget-finder to TypeScript 1482294a1b
    refactor: Hybrids.js placeholder + stronger widgets types 2597a05455
    refactor: Migrate modes to TypeScript 9d12078fb0
    refactor: Introduce FileLineHandleStubs in unit tests 6b42710942
    refactor: Extract codemirrors init from lines-state 0055bd6ca6
    refactor: Migrate the file lines state + placeholders builders to TypeScript 73b48b173d
    refactor Migrate side-by-side-line-height-equalizer to TypeScript edc1da849c
    refactor: Migrate NewInlineCommentForm to Hybrids + TypeScript 8ea7659b01
    refactor: New inline comment saves itself e0a36beda2
    refactor: Extract widgets creation from Angular 313ee88cd8
    refactor: Extract widget management part from diff component 8ec96c23d4
    refactor: Extract NewInlineCommentFormWidget insertion part 935845d33b
    refactor: Extract code placeholders insertion 577e68db8a
    refactor: Drop has_initial_comment_placeholder property 085f642acc
    fix: Line number returned by gutterClick can be wrong 14ef77e15d
    refactor: Make user and current PR parameters of the controller 5f75eccd06
    refactor: Migrate codemirror-helper-service to TypeScript daebf3aab5
    refactor: Tidy up file-diff feature files c28941c0d2
    refactor: Use PascalCase to name files containing "class like" objects d05e373875

    Follow-ups

    User avatar
    Thomas Gorka (tgorka)2022-12-12 14:11
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gorka (tgorka)2022-11-30 12:04
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gorka (tgorka)2022-11-25 17:44
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gorka (tgorka)2022-11-24 13:37
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes
    User avatar
    Thomas Gorka (tgorka)2022-11-18 17:01
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes