From da96f7de2363c130cc041da0f6dc5c6639c78b2c Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Sun, 16 Apr 2023 10:48:10 +0200 Subject: [PATCH] Improve "Advanced > Unit Tests" (#6213) --- .../lib/zcl_abapgit_gui_chunk_lib.clas.abap | 80 ++++++++++++++++--- .../zcl_abapgit_gui_page_repo_view.clas.abap | 58 +------------- .../zcl_abapgit_gui_page_runit.clas.abap | 18 +++-- src/ui/zabapgit_css_common.w3mi.data.css | 8 +- 4 files changed, 90 insertions(+), 74 deletions(-) diff --git a/src/ui/lib/zcl_abapgit_gui_chunk_lib.clas.abap b/src/ui/lib/zcl_abapgit_gui_chunk_lib.clas.abap index 2adaa372a..01794c326 100644 --- a/src/ui/lib/zcl_abapgit_gui_chunk_lib.clas.abap +++ b/src/ui/lib/zcl_abapgit_gui_chunk_lib.clas.abap @@ -94,9 +94,9 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION VALUE(ri_html) TYPE REF TO zif_abapgit_html . CLASS-METHODS render_repo_palette IMPORTING - iv_action TYPE string + iv_action TYPE string RETURNING - VALUE(ri_html) TYPE REF TO zif_abapgit_html + VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . CLASS-METHODS advanced_submenu @@ -131,10 +131,10 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION zcx_abapgit_exception . CLASS-METHODS render_repo_url IMPORTING - iv_url TYPE zif_abapgit_persistence=>ty_repo-url + iv_url TYPE zif_abapgit_persistence=>ty_repo-url iv_render_remote_edit_for_key TYPE zif_abapgit_persistence=>ty_repo-key OPTIONAL RETURNING - VALUE(ri_html) TYPE REF TO zif_abapgit_html + VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . CLASS-METHODS render_package_name @@ -167,7 +167,7 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION zcx_abapgit_exception . CLASS-METHODS render_sci_result IMPORTING - ii_html TYPE REF TO zif_abapgit_html + ii_html TYPE REF TO zif_abapgit_html iv_sci_result TYPE zif_abapgit_definitions=>ty_sci_result. CLASS-METHODS render_path @@ -181,7 +181,7 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION CLASS-METHODS render_timestamp IMPORTING - iv_timestamp TYPE timestampl + iv_timestamp TYPE timestampl RETURNING VALUE(rv_rendered) TYPE string. @@ -191,7 +191,7 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION iv_label TYPE string iv_value TYPE string OPTIONAL iv_max_length TYPE string OPTIONAL - iv_autofocus TYPE abap_bool DEFAULT abap_false + iv_autofocus TYPE abap_bool DEFAULT abap_false RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html. @@ -204,15 +204,27 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION CLASS-METHODS render_label_list IMPORTING - it_labels TYPE string_table - io_label_colors TYPE REF TO zcl_abapgit_string_map + it_labels TYPE string_table + io_label_colors TYPE REF TO zcl_abapgit_string_map iv_clickable_action TYPE string OPTIONAL RETURNING - VALUE(rv_html) TYPE string. + VALUE(rv_html) TYPE string. CLASS-METHODS render_help_hint IMPORTING iv_text_to_wrap TYPE string + RETURNING + VALUE(rv_html) TYPE string. + + CLASS-METHODS get_item_icon + IMPORTING + !is_item TYPE zif_abapgit_definitions=>ty_repo_item + RETURNING + VALUE(rv_html) TYPE string. + + CLASS-METHODS get_item_link + IMPORTING + !is_item TYPE zif_abapgit_definitions=>ty_repo_item RETURNING VALUE(rv_html) TYPE string. @@ -312,6 +324,50 @@ CLASS zcl_abapgit_gui_chunk_lib IMPLEMENTATION. ENDMETHOD. + METHOD get_item_icon. + + CASE is_item-obj_type. + WHEN 'PROG' OR 'CLAS' OR 'FUGR' OR 'INTF' OR 'TYPE'. + rv_html = zcl_abapgit_html=>icon( iv_name = 'file-code/darkgrey' + iv_hint = 'Code' ). + WHEN 'W3MI' OR 'W3HT' OR 'SFPF'. + rv_html = zcl_abapgit_html=>icon( iv_name = 'file-image/darkgrey' + iv_hint = 'Binary' ). + WHEN 'DEVC'. + rv_html = zcl_abapgit_html=>icon( iv_name = 'box/darkgrey' + iv_hint = 'Package' ). + WHEN ''. + rv_html = space. " no icon + WHEN OTHERS. + rv_html = zcl_abapgit_html=>icon( 'file-alt/darkgrey' ). + ENDCASE. + + IF is_item-is_dir = abap_true. + rv_html = zcl_abapgit_html=>icon( iv_name = 'folder/darkgrey' + iv_hint = 'Folder' ). + ENDIF. + + ENDMETHOD. + + + METHOD get_item_link. + + DATA lv_encode TYPE string. + DATA li_html TYPE REF TO zif_abapgit_html. + + CREATE OBJECT li_html TYPE zcl_abapgit_html. + + lv_encode = zcl_abapgit_html_action_utils=>jump_encode( + iv_obj_type = is_item-obj_type + iv_obj_name = is_item-obj_name ). + + rv_html = li_html->a( + iv_txt = |{ is_item-obj_name }| + iv_act = |{ zif_abapgit_definitions=>c_action-jump }?{ lv_encode }| ). + + ENDMETHOD. + + METHOD get_t100_text. MESSAGE ID iv_msgid TYPE 'S' NUMBER iv_msgno WITH '&1' '&2' '&3' '&4' INTO rv_text. @@ -1287,8 +1343,8 @@ CLASS zcl_abapgit_gui_chunk_lib IMPLEMENTATION. METHOD render_user_name. DATA: - lv_title TYPE string, - lv_jump TYPE string. + lv_title TYPE string, + lv_jump TYPE string. CREATE OBJECT ri_html TYPE zcl_abapgit_html. diff --git a/src/ui/pages/zcl_abapgit_gui_page_repo_view.clas.abap b/src/ui/pages/zcl_abapgit_gui_page_repo_view.clas.abap index 0a04f102c..f7e7ecf96 100644 --- a/src/ui/pages/zcl_abapgit_gui_page_repo_view.clas.abap +++ b/src/ui/pages/zcl_abapgit_gui_page_repo_view.clas.abap @@ -94,11 +94,6 @@ CLASS zcl_abapgit_gui_page_repo_view DEFINITION iv_is_object_row TYPE abap_bool DEFAULT abap_false RETURNING VALUE(rv_html) TYPE string . - METHODS get_item_icon - IMPORTING - !is_item TYPE zif_abapgit_definitions=>ty_repo_item - RETURNING - VALUE(rv_html) TYPE string . METHODS render_item_transport IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_repo_item @@ -111,11 +106,6 @@ CLASS zcl_abapgit_gui_page_repo_view DEFINITION VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . - METHODS build_obj_jump_link - IMPORTING - !is_item TYPE zif_abapgit_definitions=>ty_repo_item - RETURNING - VALUE(rv_html) TYPE string . METHODS build_dir_jump_link IMPORTING !iv_path TYPE string @@ -491,24 +481,6 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION. ENDMETHOD. - METHOD build_obj_jump_link. - - DATA lv_encode TYPE string. - DATA li_html TYPE REF TO zif_abapgit_html. - - CREATE OBJECT li_html TYPE zcl_abapgit_html. - - lv_encode = zcl_abapgit_html_action_utils=>jump_encode( - iv_obj_type = is_item-obj_type - iv_obj_name = is_item-obj_name ). - - rv_html = li_html->a( - iv_txt = |{ is_item-obj_name }| - iv_act = |{ zif_abapgit_definitions=>c_action-jump }?{ lv_encode }| ). - - ENDMETHOD. - - METHOD build_srcsystem_code. IF is_item-srcsystem IS NOT INITIAL AND is_item-srcsystem <> sy-sysid. @@ -672,32 +644,6 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION. ENDMETHOD. - METHOD get_item_icon. - - CASE is_item-obj_type. - WHEN 'PROG' OR 'CLAS' OR 'FUGR' OR 'INTF' OR 'TYPE'. - rv_html = zcl_abapgit_html=>icon( iv_name = 'file-code/darkgrey' - iv_hint = 'Code' ). - WHEN 'W3MI' OR 'W3HT' OR 'SFPF'. - rv_html = zcl_abapgit_html=>icon( iv_name = 'file-image/darkgrey' - iv_hint = 'Binary' ). - WHEN 'DEVC'. - rv_html = zcl_abapgit_html=>icon( iv_name = 'box/darkgrey' - iv_hint = 'Package' ). - WHEN ''. - rv_html = space. " no icon - WHEN OTHERS. - rv_html = zcl_abapgit_html=>icon( 'file-alt/darkgrey' ). - ENDCASE. - - IF is_item-is_dir = abap_true. - rv_html = zcl_abapgit_html=>icon( iv_name = 'folder/darkgrey' - iv_hint = 'Folder' ). - ENDIF. - - ENDMETHOD. - - METHOD is_repo_lang_logon_lang. rv_repo_lang_is_logon_lang = boolc( mo_repo->get_dot_abapgit( )->get_main_language( ) = sy-langu ). ENDMETHOD. @@ -870,13 +816,13 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION. && 'non-code and meta files' && '' ). ELSE. - ri_html->add( |{ get_item_icon( is_item ) }| ). + ri_html->add( |{ zcl_abapgit_gui_chunk_lib=>get_item_icon( is_item ) }| ). IF is_item-is_dir = abap_true. " Subdir lv_link = build_dir_jump_link( is_item-path ). ri_html->add( |{ lv_link }| ). ELSE. - lv_link = build_obj_jump_link( is_item ). + lv_link = zcl_abapgit_gui_chunk_lib=>get_item_link( is_item ). ri_html->add( |{ is_item-obj_type }| ). ri_html->add( |{ lv_link } { build_inactive_object_code( is_item ) } { build_srcsystem_code( is_item ) }| ). diff --git a/src/ui/pages/zcl_abapgit_gui_page_runit.clas.abap b/src/ui/pages/zcl_abapgit_gui_page_runit.clas.abap index ccf733f08..7ee86c4cd 100644 --- a/src/ui/pages/zcl_abapgit_gui_page_runit.clas.abap +++ b/src/ui/pages/zcl_abapgit_gui_page_runit.clas.abap @@ -160,6 +160,7 @@ CLASS zcl_abapgit_gui_page_runit IMPLEMENTATION. DATA lv_text TYPE string. DATA lv_count TYPE i. DATA lv_params TYPE string. + DATA ls_item TYPE zif_abapgit_definitions=>ty_repo_item. FIELD-SYMBOLS TYPE any. FIELD-SYMBOLS TYPE ANY TABLE. @@ -188,31 +189,38 @@ CLASS zcl_abapgit_gui_page_runit IMPLEMENTATION. ASSIGN COMPONENT 'ALERTS_BY_INDICIES' OF STRUCTURE TO . ASSIGN COMPONENT 'PROGRAMS' OF STRUCTURE TO . + ri_html->add( || ). + LOOP AT ASSIGNING . ASSIGN COMPONENT 'ALERTS' OF STRUCTURE TO . - LOOP AT ASSIGNING WHERE ('KIND = ''F'' OR KIND = ''S'''). " check level=F(ail?) instead? + LOOP AT ASSIGNING WHERE ('KIND = ''F'' OR KIND = ''S'' OR KIND = ''E'''). ASSIGN COMPONENT 'HEADER-PARAMS' OF STRUCTURE TO . LOOP AT INTO lv_params. lv_text = lv_params. ENDLOOP. - ri_html->add( |{ lv_text }
| ). + ri_html->add( |
| ). lv_count = lv_count + 1. ENDLOOP. ENDLOOP. + ri_html->add( '
{ lv_text }
' ). + ri_html->add( '
' ). ri_html->add( |Unit tests completed with { lv_count } errors ({ mv_summary })| ). ri_html->add( `
` ). - ri_html->add( |
| ). + ri_html->add( |
| ). LOOP AT ASSIGNING . + CLEAR ls_item. lv_program_ndx = sy-tabix. ASSIGN COMPONENT 'INFO-KEY-OBJ_TYPE' OF STRUCTURE TO . IF sy-subrc = 0. - ri_html->add( || ). + ls_item-obj_name = . + ri_html->add( || ). ELSE. * KEY field does not exist in 750 ASSIGN COMPONENT 'INFO-NAME' OF STRUCTURE TO . diff --git a/src/ui/zabapgit_css_common.w3mi.data.css b/src/ui/zabapgit_css_common.w3mi.data.css index d7181f966..f6270758d 100644 --- a/src/ui/zabapgit_css_common.w3mi.data.css +++ b/src/ui/zabapgit_css_common.w3mi.data.css @@ -1278,6 +1278,12 @@ table.settings_tab input { } settings_tab tr:first-child td { border-top: 0px; } +/* UNIT TESTS */ + +table.unit_tests { + line-height: 1.5; +} + /* DIALOGS */ .dialog { @@ -1491,4 +1497,4 @@ settings_tab tr:first-child td { border-top: 0px; } .toolbar-light a:first-child { padding-left: 0; border-left: none; -} +}
{ } | ). + ls_item-obj_type = . ASSIGN COMPONENT 'INFO-KEY-OBJ_NAME' OF STRUCTURE TO . - ri_html->add( |{ }
{ zcl_abapgit_gui_chunk_lib=>get_item_icon( ls_item ) } { ls_item-obj_type }| + && | { zcl_abapgit_gui_chunk_lib=>get_item_link( ls_item ) }