All files / src/ui/flow zcl_abapgit_gui_page_flow.clas.abap

96.06% Statements 634/660
100% Branches 0/0
0% Functions 0/2
96.06% Lines 634/660

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 6611x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                           1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                           1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
CLASS zcl_abapgit_gui_page_flow DEFINITION
  PUBLIC
  INHERITING FROM zcl_abapgit_gui_component
  FINAL
  CREATE PRIVATE .
 
  PUBLIC SECTION.
 
    INTERFACES zif_abapgit_gui_event_handler .
    INTERFACES zif_abapgit_gui_renderable .
    INTERFACES zif_abapgit_gui_menu_provider .
 
    CLASS-METHODS create
      RETURNING
        VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable
      RAISING
        zcx_abapgit_exception .
    METHODS constructor
      RAISING
        zcx_abapgit_exception .
  PROTECTED SECTION.
  PRIVATE SECTION.
 
    CONSTANTS:
      BEGIN OF c_action,
        refresh             TYPE string VALUE 'refresh',
        consolidate         TYPE string VALUE 'consolicate',
        pull                TYPE string VALUE 'pull',
        stage               TYPE string VALUE 'stage',
        only_my_transports  TYPE string VALUE 'only_my_transports',
        hide_full_matches   TYPE string VALUE 'hide_full_matches',
        hide_matching_files TYPE string VALUE 'hide_matching_files',
      END OF c_action .
    DATA ms_information TYPE zif_abapgit_flow_logic=>ty_information .
    DATA ms_user_settings TYPE zif_abapgit_persist_user=>ty_flow_settings.
 
    METHODS refresh
      RAISING
        zcx_abapgit_exception .
    METHODS set_branch
      IMPORTING
        !iv_branch TYPE string
        !iv_key    TYPE zif_abapgit_persistence=>ty_value
      RAISING
        zcx_abapgit_exception .
 
    METHODS render_table
      IMPORTING
        !is_feature    TYPE zif_abapgit_flow_logic=>ty_feature
      RETURNING
        VALUE(ri_html) TYPE REF TO zif_abapgit_html .
 
    METHODS render_toolbar
      IMPORTING
        !iv_index      TYPE i
        !is_feature    TYPE zif_abapgit_flow_logic=>ty_feature
      RETURNING
        VALUE(ri_html) TYPE REF TO zif_abapgit_html
      RAISING
        zcx_abapgit_exception .
 
    METHODS call_diff
      IMPORTING
        !ii_event         TYPE REF TO zif_abapgit_gui_event
      RETURNING
        VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result
      RAISING
        zcx_abapgit_exception.
 
    METHODS call_stage
      IMPORTING
        !ii_event         TYPE REF TO zif_abapgit_gui_event
      RETURNING
        VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result
      RAISING
        zcx_abapgit_exception.
 
    METHODS call_pull
      IMPORTING
        !ii_event         TYPE REF TO zif_abapgit_gui_event
      RETURNING
        VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result
      RAISING
        zcx_abapgit_exception.
 
    METHODS call_consolidate
      RETURNING
        VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result
      RAISING
        zcx_abapgit_exception.
 
    METHODS render_user_settings
      RETURNING
        VALUE(ri_html) TYPE REF TO zif_abapgit_html
      RAISING
        zcx_abapgit_exception .
ENDCLASS.
 
 
 
CLASS ZCL_ABAPGIT_GUI_PAGE_FLOW IMPLEMENTATION.
 
 
  METHOD call_consolidate.
 
    DATA lt_repos        TYPE zcl_abapgit_flow_logic=>ty_repos_tt.
    DATA li_repo         LIKE LINE OF lt_repos.
 
    lt_repos = zcl_abapgit_flow_logic=>list_repos( abap_false ).
    IF lines( lt_repos ) <> 1.
      MESSAGE 'Todo, repository selection popup' TYPE 'S'.
    ELSE.
      READ TABLE lt_repos INTO li_repo INDEX 1.
      ASSERT sy-subrc = 0.
      rs_handled-page  = zcl_abapgit_gui_page_flowcons=>create( li_repo ).
      rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page.
    ENDIF.
 
  ENDMETHOD.
 
 
  METHOD call_diff.
 
    DATA lv_key         TYPE zif_abapgit_persistence=>ty_value.
    DATA lv_remote_sha1 TYPE zif_abapgit_git_definitions=>ty_sha1.
    DATA ls_file        TYPE zif_abapgit_git_definitions=>ty_file.
    DATA li_repo_online TYPE REF TO zif_abapgit_repo_online.
    DATA li_repo        TYPE REF TO zif_abapgit_repo.
    DATA lv_blob        TYPE xstring.
    DATA ls_local       TYPE zif_abapgit_git_definitions=>ty_file.
    DATA ls_remote      TYPE zif_abapgit_git_definitions=>ty_file.
    DATA lt_filter      TYPE zif_abapgit_definitions=>ty_tadir_tt.
    DATA lo_filter      TYPE REF TO zcl_abapgit_object_filter_obj.
    DATA lt_files_item  TYPE zif_abapgit_definitions=>ty_files_item_tt.
    DATA ls_file_item   LIKE LINE OF lt_files_item.
    DATA ls_item        TYPE zif_abapgit_definitions=>ty_item.
 
    FIELD-SYMBOLS <ls_filter> LIKE LINE OF lt_filter.
 
    lv_key = ii_event->query( )->get( 'KEY' ).
    li_repo_online ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ).
    li_repo ?= li_repo_online.
 
    lv_remote_sha1 = ii_event->query( )->get( 'REMOTE_SHA1' ).
 
    ls_file-path     = ii_event->query( )->get( 'PATH' ).
    ls_file-filename = ii_event->query( )->get( 'FILENAME' ). " unescape ?
 
    zcl_abapgit_filename_logic=>file_to_object(
      EXPORTING
        iv_filename = ls_file-filename
        iv_path     = ls_file-path
        iv_devclass = li_repo->get_package( )
        io_dot      = li_repo->get_dot_abapgit( )
      IMPORTING
        es_item     = ls_item ).
 
    APPEND INITIAL LINE TO lt_filter ASSIGNING <ls_filter>.
    <ls_filter>-object = ls_item-obj_type.
    <ls_filter>-obj_name = ls_item-obj_name.
    CREATE OBJECT lo_filter EXPORTING it_filter = lt_filter.
 
    lt_files_item = li_repo_online->zif_abapgit_repo~get_files_local_filtered( lo_filter ).
    READ TABLE lt_files_item INTO ls_file_item WITH KEY file-path = ls_file-path
      file-filename = ls_file-filename.
 
    lv_blob = zcl_abapgit_git_factory=>get_v2_porcelain( )->fetch_blob(
      iv_url  = li_repo_online->get_url( )
      iv_sha1 = lv_remote_sha1 ).
 
    ls_remote-path = ls_file-path.
    ls_remote-filename = ls_file-filename.
    ls_remote-sha1 = lv_remote_sha1.
    ls_remote-data = lv_blob.
 
    ls_local-path = ls_remote-path.
    ls_local-filename = ls_remote-filename.
    ls_local-sha1 = ls_file_item-file-sha1.
    ls_local-data = ls_file_item-file-data.
 
    rs_handled-page = zcl_abapgit_gui_page_diff_file=>create(
      iv_obj_type = ls_item-obj_type
      iv_obj_name = ls_item-obj_name
      is_local    = ls_local
      is_remote   = ls_remote ).
 
    rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark.
 
  ENDMETHOD.
 
 
  METHOD call_pull.
 
    DATA lv_key         TYPE zif_abapgit_persistence=>ty_value.
    DATA lv_branch      TYPE string.
    DATA lo_filter      TYPE REF TO lcl_filter.
    DATA lt_filter      TYPE zif_abapgit_definitions=>ty_tadir_tt.
    DATA lv_index       TYPE i.
    DATA li_repo_online TYPE REF TO zif_abapgit_repo_online.
    DATA ls_feature     LIKE LINE OF ms_information-features.
 
    FIELD-SYMBOLS <ls_object> LIKE LINE OF ls_feature-changed_objects.
    FIELD-SYMBOLS <ls_filter> LIKE LINE OF lt_filter.
 
    lv_key = ii_event->query( )->get( 'KEY' ).
    lv_index = ii_event->query( )->get( 'INDEX' ).
    lv_branch = ii_event->query( )->get( 'BRANCH' ).
    li_repo_online ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ).
 
    READ TABLE ms_information-features INTO ls_feature INDEX lv_index.
    ASSERT sy-subrc = 0.
 
    LOOP AT ls_feature-changed_objects ASSIGNING <ls_object>.
      APPEND INITIAL LINE TO lt_filter ASSIGNING <ls_filter>.
      <ls_filter>-object = <ls_object>-obj_type.
      <ls_filter>-obj_name = <ls_object>-obj_name.
    ENDLOOP.
    CREATE OBJECT lo_filter EXPORTING it_filter = lt_filter.
 
    set_branch(
          iv_branch = lv_branch
          iv_key    = lv_key ).
 
    rs_handled-page = zcl_abapgit_gui_page_pull=>create(
          ii_repo       = li_repo_online
          iv_trkorr     = ls_feature-transport-trkorr
          ii_obj_filter = lo_filter ).
 
    rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page.
 
    refresh( ).
 
  ENDMETHOD.
 
 
  METHOD call_stage.
 
    DATA lv_key          TYPE zif_abapgit_persistence=>ty_value.
    DATA lv_branch       TYPE string.
    DATA lo_filter       TYPE REF TO lcl_filter.
    DATA lt_filter       TYPE zif_abapgit_definitions=>ty_tadir_tt.
    DATA lv_index        TYPE i.
    DATA li_repo_online  TYPE REF TO zif_abapgit_repo_online.
    DATA ls_feature      LIKE LINE OF ms_information-features.
 
    FIELD-SYMBOLS <ls_object> LIKE LINE OF ls_feature-changed_objects.
    FIELD-SYMBOLS <ls_filter> LIKE LINE OF lt_filter.
 
    lv_key = ii_event->query( )->get( 'KEY' ).
    lv_index = ii_event->query( )->get( 'INDEX' ).
    lv_branch = ii_event->query( )->get( 'BRANCH' ).
    li_repo_online ?= zcl_abapgit_repo_srv=>get_instance( )->get( lv_key ).
 
    READ TABLE ms_information-features INTO ls_feature INDEX lv_index.
    ASSERT sy-subrc = 0.
 
    LOOP AT ls_feature-changed_objects ASSIGNING <ls_object>.
      APPEND INITIAL LINE TO lt_filter ASSIGNING <ls_filter>.
      <ls_filter>-object = <ls_object>-obj_type.
      <ls_filter>-obj_name = <ls_object>-obj_name.
    ENDLOOP.
    CREATE OBJECT lo_filter EXPORTING it_filter = lt_filter.
 
    set_branch(
      iv_branch = lv_branch
      iv_key    = lv_key ).
 
    rs_handled-page = zcl_abapgit_gui_page_stage=>create(
      ii_force_refresh = abap_false
      ii_repo_online   = li_repo_online
      ii_obj_filter    = lo_filter ).
 
    rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page_w_bookmark.
 
    refresh( ).
 
  ENDMETHOD.
 
 
  METHOD constructor.
    super->constructor( ).
    ms_user_settings = zcl_abapgit_persist_factory=>get_user( )->get_flow_settings( ).
  ENDMETHOD.
 
 
  METHOD create.
 
    DATA lo_component TYPE REF TO zcl_abapgit_gui_page_flow.
 
    CREATE OBJECT lo_component.
 
    ri_page = zcl_abapgit_gui_page_hoc=>create(
      iv_page_title         = 'Flow'
      ii_page_menu_provider = lo_component
      ii_child_component    = lo_component ).
 
  ENDMETHOD.
 
 
  METHOD refresh.

    DATA ls_feature LIKE LINE OF ms_information-features.
    DATA li_repo  TYPE REF TO zif_abapgit_repo.


    LOOP AT ms_information-features INTO ls_feature.
      li_repo = zcl_abapgit_repo_srv=>get_instance( )->get( ls_feature-repo-key ).
      li_repo->refresh( ).
    ENDLOOP.

    CLEAR ms_information.

  ENDMETHOD.
 
 
  METHOD render_table.
 
    DATA ls_path_name LIKE LINE OF is_feature-changed_files.
    DATA lv_status    TYPE string.
    DATA lv_branch    TYPE string.
    DATA lv_param     TYPE string.
 
 
    CREATE OBJECT ri_html TYPE zcl_abapgit_html.
 
    ri_html->add( |<table>| ).
    ri_html->add( |<tr><td><u>Filename</u></td><td><u>Remote</u></td><td><u>Local</u></td><td></td></tr>| ).
 
    lv_branch = is_feature-branch-display_name.
    IF lv_branch IS INITIAL.
      lv_branch = 'main'.
    ENDIF.
 
    LOOP AT is_feature-changed_files INTO ls_path_name.
      IF ls_path_name-remote_sha1 = ls_path_name-local_sha1.
        IF ms_user_settings-hide_matching_files = abap_true.
          CONTINUE.
        ENDIF.
        lv_status = 'Match'.
      ELSEIF ls_path_name-remote_sha1 IS NOT INITIAL
          AND ls_path_name-local_sha1 IS NOT INITIAL.
* todo: file added or removed
        ASSERT is_feature-repo-key IS NOT INITIAL.
        lv_param = zcl_abapgit_html_action_utils=>file_encode(
          iv_key   = is_feature-repo-key
          ig_file  = ls_path_name
          iv_extra = lv_branch ).
        lv_status = ri_html->a(
          iv_txt = 'Diff'
          iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{
            lv_param }&remote_sha1={ ls_path_name-remote_sha1 }| ).
      ENDIF.
 
      ri_html->add( |<tr><td><tt>{ ls_path_name-path }{ ls_path_name-filename }</tt></td><td>{
        ls_path_name-remote_sha1(7) }</td><td>{
        ls_path_name-local_sha1(7) }</td><td>{ lv_status }</td></tr>| ).
    ENDLOOP.
    ri_html->add( |</table>| ).
 
  ENDMETHOD.
 
 
  METHOD render_toolbar.
 
    DATA lo_toolbar TYPE REF TO zcl_abapgit_html_toolbar.
    DATA lv_extra   TYPE string.
    DATA li_repo    TYPE REF TO zif_abapgit_repo.
    DATA lv_opt     TYPE c LENGTH 1.
 
 
    CREATE OBJECT ri_html TYPE zcl_abapgit_html.
    CREATE OBJECT lo_toolbar EXPORTING iv_id = 'toolbar-flow'.
 
    li_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( is_feature-repo-key ).
    IF li_repo->get_local_settings( )-write_protected = abap_true.
      lv_opt = zif_abapgit_html=>c_html_opt-crossout.
    ELSE.
      lv_opt = zif_abapgit_html=>c_html_opt-strong.
    ENDIF.
 
    IF is_feature-full_match = abap_false AND is_feature-branch-display_name IS NOT INITIAL.
      lv_extra = |?index={ iv_index }&key={ is_feature-repo-key }&branch={ is_feature-branch-display_name }|.
      lo_toolbar->add( iv_txt = 'Pull'
                       iv_act = |{ c_action-pull }{ lv_extra }|
                       iv_opt = lv_opt ).
      IF is_feature-transport-trkorr IS NOT INITIAL.
* its only remote, so there is no changes to stage
        lo_toolbar->add( iv_txt = 'Stage'
                         iv_act = |{ c_action-stage }{ lv_extra }|
                         iv_opt = zif_abapgit_html=>c_html_opt-strong ).
      ENDIF.
    ENDIF.
 
    zcl_abapgit_flow_exit=>get_instance( )->toolbar_extras(
      io_toolbar = lo_toolbar
      iv_index   = iv_index
      is_feature = is_feature ).
 
    ri_html->add( lo_toolbar->render( ) ).
 
  ENDMETHOD.
 
 
  METHOD set_branch.

    DATA lv_branch TYPE string.
    DATA li_repo_online TYPE REF TO zif_abapgit_repo_online.

    IF iv_branch IS NOT INITIAL.
      lv_branch = zif_abapgit_git_definitions=>c_git_branch-heads_prefix && iv_branch.
      li_repo_online ?= zcl_abapgit_repo_srv=>get_instance( )->get( iv_key ).
      IF li_repo_online->get_selected_branch( ) <> lv_branch.
        li_repo_online->select_branch( lv_branch ).
      ENDIF.
    ENDIF.

  ENDMETHOD.
 
 
  METHOD zif_abapgit_gui_event_handler~on_event.
 
    DATA ls_event_result TYPE zif_abapgit_flow_exit=>ty_event_result.
 
 
    CASE ii_event->mv_action.
      WHEN c_action-only_my_transports.
        ms_user_settings-only_my_transports = boolc( ms_user_settings-only_my_transports <> abap_true ).
        zcl_abapgit_persist_factory=>get_user( )->set_flow_settings( ms_user_settings ).
        rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
      WHEN c_action-hide_full_matches.
        ms_user_settings-hide_full_matches = boolc( ms_user_settings-hide_full_matches <> abap_true ).
        zcl_abapgit_persist_factory=>get_user( )->set_flow_settings( ms_user_settings ).
        rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
      WHEN c_action-hide_matching_files.
        ms_user_settings-hide_matching_files = boolc( ms_user_settings-hide_matching_files <> abap_true ).
        zcl_abapgit_persist_factory=>get_user( )->set_flow_settings( ms_user_settings ).
        rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
      WHEN c_action-refresh.
        refresh( ).
        rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
      WHEN c_action-consolidate.
        rs_handled = call_consolidate( ).
      WHEN zif_abapgit_definitions=>c_action-go_file_diff.
        rs_handled = call_diff( ii_event ).
      WHEN c_action-stage.
        rs_handled = call_stage( ii_event ).
      WHEN c_action-pull.
        rs_handled = call_pull( ii_event ).
      WHEN OTHERS.
        ls_event_result = zcl_abapgit_flow_exit=>get_instance( )->on_event(
         ii_event    = ii_event
         it_features = ms_information-features ).
 
        rs_handled = ls_event_result-handled.
 
        IF ls_event_result-refresh = abap_true.
          refresh( ).
        ENDIF.
    ENDCASE.
 
  ENDMETHOD.
 
 
  METHOD zif_abapgit_gui_menu_provider~get_menu.
 
    ro_toolbar = zcl_abapgit_html_toolbar=>create( 'toolbar-flow' ).
 
    ro_toolbar->add(
      iv_txt = 'Refresh'
      iv_act = c_action-refresh ).
 
    ro_toolbar->add(
      iv_txt = 'Consolidate'
      iv_act = c_action-consolidate ).
 
    ro_toolbar->add(
      iv_txt = zcl_abapgit_gui_buttons=>repo_list( )
      iv_act = zif_abapgit_definitions=>c_action-abapgit_home ).
 
    ro_toolbar->add(
      iv_txt = 'Back'
      iv_act = zif_abapgit_definitions=>c_action-go_back ).
 
  ENDMETHOD.
 
  METHOD render_user_settings.
 
    DATA lv_icon_class TYPE string.
 
    CREATE OBJECT ri_html TYPE zcl_abapgit_html.
    ri_html->add( '<span class="toolbar-light pad-sides">' ).
 
    IF ms_user_settings-only_my_transports = abap_true.
      lv_icon_class = `blue`.
    ELSE.
      lv_icon_class = `grey`.
    ENDIF.
    ri_html->add( ri_html->a(
      iv_txt   = |<i id="icon-filter-favorite" class="icon icon-check { lv_icon_class }"></i> Only my transports|
      iv_class = 'command'
      iv_act   = |{ c_action-only_my_transports }| ) ).
 
    IF ms_user_settings-hide_full_matches = abap_true.
      lv_icon_class = `blue`.
    ELSE.
      lv_icon_class = `grey`.
    ENDIF.
    ri_html->add( ri_html->a(
      iv_txt   = |<i id="icon-filter-favorite" class="icon icon-check { lv_icon_class }"></i> Hide full matches|
      iv_class = 'command'
      iv_act   = |{ c_action-hide_full_matches }| ) ).
 
    IF ms_user_settings-hide_matching_files = abap_true.
      lv_icon_class = `blue`.
    ELSE.
      lv_icon_class = `grey`.
    ENDIF.
    ri_html->add( ri_html->a(
      iv_txt   = |<i id="icon-filter-favorite" class="icon icon-check { lv_icon_class }"></i> Hide matching files|
      iv_class = 'command'
      iv_act   = |{ c_action-hide_matching_files }| ) ).
 
    ri_html->add( '</span>' ).
 
  ENDMETHOD.
 
  METHOD zif_abapgit_gui_renderable~render.
 
    DATA ls_feature LIKE LINE OF ms_information-features.
    DATA lv_index TYPE i.
    DATA lv_rendered TYPE abap_bool.
    DATA lo_timer TYPE REF TO zcl_abapgit_timer.
    DATA lt_my_transports TYPE zif_abapgit_cts_api=>ty_trkorr_tt.
    DATA lv_warning LIKE LINE OF ms_information-warnings.
 
 
    lo_timer = zcl_abapgit_timer=>create( )->start( ).
 
    register_handlers( ).
    CREATE OBJECT ri_html TYPE zcl_abapgit_html.
    ri_html->add( '<div class="repo-overview">' ).
 
    IF ms_information IS INITIAL.
      ms_information = zcl_abapgit_flow_logic=>get( ).
    ENDIF.
 
    ri_html->add( render_user_settings( ) ).
 
    ri_html->add( '<br>' ).
    ri_html->add( '<br>' ).
 
    IF lines( ms_information-warnings ) > 0.
      LOOP AT ms_information-warnings INTO lv_warning.
        ri_html->add( zcl_abapgit_gui_chunk_lib=>render_warning_banner( lv_warning ) ).
      ENDLOOP.
      ri_html->add( '<br>' ).
    ENDIF.
 
    IF ms_user_settings-only_my_transports = abap_true.
      lt_my_transports = zcl_abapgit_factory=>get_cts_api( )->list_open_requests_by_user( sy-uname ).
    ENDIF.
 
    LOOP AT ms_information-features INTO ls_feature.
      lv_index = sy-tabix.
 
      IF ms_user_settings-hide_full_matches = abap_true
          AND ls_feature-full_match = abap_true.
        CONTINUE.
      ENDIF.
 
      IF ms_user_settings-only_my_transports = abap_true AND ls_feature-transport-trkorr IS NOT INITIAL.
        READ TABLE lt_my_transports WITH KEY table_line = ls_feature-transport-trkorr TRANSPORTING NO FIELDS.
        IF sy-subrc <> 0.
          CONTINUE.
        ENDIF.
      ENDIF.
 
      IF lines( ls_feature-changed_files ) = 0.
* no changes, eg. only files outside of starting folder changed
        CONTINUE.
      ENDIF.
      lv_rendered = abap_true.
 
      ri_html->add( '<b><font size="+2">' && ls_feature-repo-name ).
      IF ls_feature-branch-display_name IS NOT INITIAL.
        ri_html->add( | - | ).
        ri_html->add_icon( 'code-branch' ).
        ri_html->add( ls_feature-branch-display_name ).
      ENDIF.
      IF ls_feature-transport-trkorr IS NOT INITIAL.
        ri_html->add( | - | ).
        ri_html->add_icon( 'truck-solid' ).
        ri_html->add( |<tt>{ ls_feature-transport-trkorr }</tt>| ).
      ENDIF.
      ri_html->add( |</font></b><br>| ).
 
      IF ls_feature-branch-display_name IS INITIAL.
        ri_html->add( |No branch found, comparing with <tt>main</tt>| ).
      ELSEIF ls_feature-pr IS NOT INITIAL.
        ri_html->add_a(
          iv_txt   = ls_feature-pr-title
          iv_act   = |{ zif_abapgit_definitions=>c_action-url }?url={ ls_feature-pr-url }|
          iv_class = |url| ).
 
        IF ls_feature-pr-draft = abap_true.
          ri_html->add( 'DRAFT' ).
        ENDIF.
      ELSE.
        ri_html->add( |No PR found| ).
      ENDIF.
      ri_html->add( |<br>| ).
 
      IF ls_feature-transport IS NOT INITIAL.
        ri_html->add( |<tt>{ ls_feature-transport-trkorr }</tt> - { ls_feature-transport-title }<br>| ).
      ELSE.
        ri_html->add( |No corresponding transport found<br>| ).
      ENDIF.
 
      IF ls_feature-branch IS NOT INITIAL AND ls_feature-branch-up_to_date = abap_false.
        ri_html->add( '<b>Branch not up to date</b><br><br>' ).
        CONTINUE.
      ENDIF.
 
      ri_html->add( render_toolbar(
        iv_index   = lv_index
        is_feature = ls_feature ) ).
 
      IF ls_feature-full_match = abap_true.
        ri_html->add( |Full Match, {
          lines( ls_feature-changed_files ) } files, {
          lines( ls_feature-changed_objects ) } objects<br>| ).
      ELSE.
        ri_html->add( render_table( ls_feature ) ).
      ENDIF.
 
* todo      LOOP AT ls_feature-changed_objects INTO ls_item.
* todo       ri_html->add( |<tt><small>{ ls_item-obj_type } { ls_item-obj_name }</small></tt><br>| ).
* todo     ENDLOOP.
 
      ri_html->add( '<br>' ).
    ENDLOOP.
 
    IF lines( ms_information-features ) = 0 OR lv_rendered = abap_false.
      ri_html->add( 'Empty, repositories must be favorite + flow enabled<br><br>' ).
 
      ri_html->add( 'Or nothing in progress<br><br>' ).
 
      ri_html->add_a(
        iv_txt   = 'abapGit flow documentation'
        iv_act   = |{ zif_abapgit_definitions=>c_action-url
          }?url=https://docs.abapgit.org/user-guide/reference/flow.html|
        iv_class = |url| ).
    ELSE.
      ri_html->add( |<small>{ lines( ms_information-features ) } features in { lo_timer->end( ) }</small>| ).
    ENDIF.
 
    ri_html->add( '</div>' ).
 
  ENDMETHOD.
ENDCLASS.