Repo view - show paths below object name (#5323)

* Repo view - show paths below object name

* rework table rows

* fix syntax

* remove old comment
This commit is contained in:
Frederik Hudák 2022-02-09 08:48:12 +01:00 committed by GitHub
parent 9ddad8b559
commit baa09083e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 89 additions and 55 deletions

View File

@ -292,33 +292,43 @@ table.repo_tab {
padding-top: 2px; padding-top: 2px;
padding-bottom: 2px; padding-bottom: 2px;
} }
.repo_tab td.icon { .repo_tab td.icon {
width: 1px; width: 1px;
text-align: center; text-align: center;
padding-left: 8px; padding-left: 8px;
padding-right: 4px; padding-right: 4px;
} }
.repo_tab td.icon:not(:first-child) {
width: 26px; .repo_tab td.transport {
width: 140px;
text-align: left; text-align: left;
} }
.repo_tab td.type { .repo_tab td.type {
width: 4em; width: 4em;
padding-left: 0.5em; padding-left: 0.5em;
} }
.repo_tab td.filename{
padding-left: 1em;
}
.repo_tab td.object { .repo_tab td.object {
padding-left: 0.5em; padding-left: 0.5em;
} }
.repo_tab td.files { .repo_tab td.files {
padding-left: 0.5em; padding-left: 0.5em;
line-height: 1.5; line-height: 1.5;
} }
.repo_tab td.cmd, .repo_tab th.cmd { .repo_tab td.cmd, .repo_tab th.cmd {
text-align: right; text-align: right;
padding-left: 0.5em; padding-left: 0.5em;
padding-right: 0.7em; padding-right: 0.7em;
min-width: 70px; min-width: 70px;
} }
.repo_tab th.cmd .icon{ .repo_tab th.cmd .icon{
padding-right: 8px; padding-right: 8px;
} }

View File

@ -78,6 +78,11 @@ CLASS zcl_abapgit_gui_page_repo_view DEFINITION
!is_item TYPE zif_abapgit_definitions=>ty_repo_item !is_item TYPE zif_abapgit_definitions=>ty_repo_item
RETURNING RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html . VALUE(ri_html) TYPE REF TO zif_abapgit_html .
METHODS render_file_command
IMPORTING
!is_file TYPE zif_abapgit_definitions=>ty_repo_file
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html .
METHODS get_item_class METHODS get_item_class
IMPORTING IMPORTING
!is_item TYPE zif_abapgit_definitions=>ty_repo_item !is_item TYPE zif_abapgit_definitions=>ty_repo_item
@ -88,7 +93,7 @@ CLASS zcl_abapgit_gui_page_repo_view DEFINITION
!is_item TYPE zif_abapgit_definitions=>ty_repo_item !is_item TYPE zif_abapgit_definitions=>ty_repo_item
RETURNING RETURNING
VALUE(rv_html) TYPE string . VALUE(rv_html) TYPE string .
METHODS render_item_lock_column METHODS render_item_transport
IMPORTING IMPORTING
!is_item TYPE zif_abapgit_definitions=>ty_repo_item !is_item TYPE zif_abapgit_definitions=>ty_repo_item
RETURNING RETURNING
@ -237,7 +242,7 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
INSERT ls_sort INTO TABLE lt_sort. INSERT ls_sort INTO TABLE lt_sort.
ENDIF. ENDIF.
IF mv_order_by = 'PATH'. IF mv_order_by = 'TRANSPORT'.
ls_sort-name = 'OBJ_NAME'. ls_sort-name = 'OBJ_NAME'.
INSERT ls_sort INTO TABLE lt_sort. INSERT ls_sort INTO TABLE lt_sort.
ENDIF. ENDIF.
@ -249,7 +254,7 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
INSERT LINES OF lt_diff_items INTO TABLE ct_repo_items. INSERT LINES OF lt_diff_items INTO TABLE ct_repo_items.
INSERT LINES OF lt_code_items INTO TABLE ct_repo_items. INSERT LINES OF lt_code_items INTO TABLE ct_repo_items.
IF mv_order_by = 'PATH'. IF mv_order_by = 'TRANSPORT'.
LOOP AT ct_repo_items ASSIGNING <ls_repo_item>. LOOP AT ct_repo_items ASSIGNING <ls_repo_item>.
order_files( CHANGING ct_files = <ls_repo_item>-files ). order_files( CHANGING ct_files = <ls_repo_item>-files ).
ENDLOOP. ENDLOOP.
@ -773,7 +778,7 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
ls_sort-descending = mv_order_descending. ls_sort-descending = mv_order_descending.
ls_sort-astext = abap_true. ls_sort-astext = abap_true.
ls_sort-name = 'PATH'. ls_sort-name = 'TRANSPORT'.
INSERT ls_sort INTO TABLE lt_sort. INSERT ls_sort INTO TABLE lt_sort.
ls_sort-descending = mv_order_descending. ls_sort-descending = mv_order_descending.
@ -886,7 +891,7 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
ENDLOOP. ENDLOOP.
IF mv_changes_only = abap_true. IF mv_changes_only = abap_true.
ri_html->add( `<tfoot><tr><td colspan="5">` ). ri_html->add( `<tfoot><tr><td class="grey" colspan="5">` ).
ri_html->add( `(Only changes are shown. ` ). ri_html->add( `(Only changes are shown. ` ).
ri_html->add( ri_html->a( ri_html->add( ri_html->a(
iv_txt = |Show All| iv_txt = |Show All|
@ -965,29 +970,19 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
METHOD render_item. METHOD render_item.
DATA: lv_link TYPE string, DATA: lv_link TYPE string.
lv_colspan TYPE i.
CREATE OBJECT ri_html TYPE zcl_abapgit_html. CREATE OBJECT ri_html TYPE zcl_abapgit_html.
IF iv_render_transports = abap_false.
lv_colspan = 2.
ELSE.
lv_colspan = 3.
ENDIF.
ri_html->add( |<tr{ get_item_class( is_item ) }>| ). ri_html->add( |<tr{ get_item_class( is_item ) }>| ).
IF is_item-obj_name IS INITIAL AND is_item-is_dir = abap_false. IF is_item-obj_name IS INITIAL AND is_item-is_dir = abap_false.
ri_html->add( |<td colspan="{ lv_colspan }"></td>| ri_html->add( |<td colspan="2"></td>|
&& '<td class="object">' && '<td class="object">'
&& '<i class="grey">non-code and meta files</i>' && '<i class="grey">non-code and meta files</i>'
&& '</td>' ). && '</td>' ).
ELSE. ELSE.
ri_html->add( |<td class="icon">{ get_item_icon( is_item ) }</td>| ). ri_html->add( |<td class="icon">{ get_item_icon( is_item ) }</td>| ).
IF iv_render_transports = abap_true.
ri_html->add( render_item_lock_column( is_item ) ).
ENDIF.
IF is_item-is_dir = abap_true. " Subdir IF is_item-is_dir = abap_true. " Subdir
lv_link = build_dir_jump_link( is_item-path ). lv_link = build_dir_jump_link( is_item-path ).
@ -1004,10 +999,9 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
ri_html->add( render_item_changed_by( is_item ) ). ri_html->add( render_item_changed_by( is_item ) ).
ri_html->add( '</td>' ). ri_html->add( '</td>' ).
" Files IF iv_render_transports = abap_true.
ri_html->add( '<td class="files">' ). ri_html->add( render_item_transport( is_item ) ).
ri_html->add( render_item_files( is_item ) ). ENDIF.
ri_html->add( '</td>' ).
" Command " Command
ri_html->add( '<td class="cmd">' ). ri_html->add( '<td class="cmd">' ).
@ -1018,6 +1012,8 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
ri_html->add( '</tr>' ). ri_html->add( '</tr>' ).
ri_html->add( render_item_files( is_item ) ).
ENDMETHOD. ENDMETHOD.
@ -1041,7 +1037,6 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
CREATE OBJECT ri_html TYPE zcl_abapgit_html. CREATE OBJECT ri_html TYPE zcl_abapgit_html.
IF is_item-is_dir = abap_true. " Directory IF is_item-is_dir = abap_true. " Directory
ri_html->add( '<div>' ). ri_html->add( '<div>' ).
ri_html->add( |<span class="grey">{ is_item-changes } changes</span>| ). ri_html->add( |<span class="grey">{ is_item-changes } changes</span>| ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_item-lstate
@ -1049,7 +1044,6 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
ri_html->add( '</div>' ). ri_html->add( '</div>' ).
ELSEIF is_item-changes > 0. ELSEIF is_item-changes > 0.
IF mv_hide_files = abap_true AND is_item-obj_name IS NOT INITIAL. IF mv_hide_files = abap_true AND is_item-obj_name IS NOT INITIAL.
lv_difflink = zcl_abapgit_html_action_utils=>obj_encode( lv_difflink = zcl_abapgit_html_action_utils=>obj_encode(
@ -1063,30 +1057,34 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
iv_rstate = is_item-rstate ) ). iv_rstate = is_item-rstate ) ).
ri_html->add( '</div>' ). ri_html->add( '</div>' ).
ELSE.
LOOP AT is_item-files INTO ls_file.
ri_html->add( '<div>' ).
IF ls_file-is_changed = abap_true.
lv_difflink = zcl_abapgit_html_action_utils=>file_encode(
iv_key = mo_repo->get_key( )
ig_file = ls_file ).
ri_html->add_a( iv_txt = 'diff'
iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_difflink }| ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = ls_file-lstate
iv_rstate = ls_file-rstate ) ).
ELSE.
ri_html->add( '&nbsp;' ).
ENDIF.
ri_html->add( '</div>' ).
ENDLOOP.
ENDIF. ENDIF.
ENDIF. ENDIF.
ENDMETHOD. ENDMETHOD.
METHOD render_file_command.
DATA: lv_difflink TYPE string.
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
ri_html->add( '<div>' ).
IF is_file-is_changed = abap_true.
lv_difflink = zcl_abapgit_html_action_utils=>file_encode(
iv_key = mo_repo->get_key( )
ig_file = is_file ).
ri_html->add_a( iv_txt = 'diff'
iv_act = |{ zif_abapgit_definitions=>c_action-go_file_diff }?{ lv_difflink }| ).
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_item_state( iv_lstate = is_file-lstate
iv_rstate = is_file-rstate ) ).
ELSE.
ri_html->add( '&nbsp;' ).
ENDIF.
ri_html->add( '</div>' ).
ENDMETHOD.
METHOD render_item_files. METHOD render_item_files.
@ -1102,17 +1100,45 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
li_exit = zcl_abapgit_exit=>get_instance( ). li_exit = zcl_abapgit_exit=>get_instance( ).
LOOP AT is_item-files INTO ls_file. LOOP AT is_item-files INTO ls_file.
ri_html->add( |<tr{ get_item_class( is_item ) }>| ).
ri_html->add( |<td class="icon"></td>| ).
ri_html->add( |<td class="type"></td>| ).
ri_html->add( |<td class="filename darkgrey">| ).
IF mv_show_folders = abap_true. IF mv_show_folders = abap_true.
ri_html->add( |<div>{ li_exit->adjust_display_filename( ls_file-filename ) }</div>| ). ri_html->add( |<div>{ li_exit->adjust_display_filename( ls_file-filename ) }</div>| ).
ELSE. ELSE.
ri_html->add( |<div>{ li_exit->adjust_display_filename( ls_file-path && ls_file-filename ) }</div>| ). ri_html->add( |<div>{ li_exit->adjust_display_filename( ls_file-path && ls_file-filename ) }</div>| ).
ENDIF. ENDIF.
ri_html->add( |</td>| ).
" Changed by (not applicable to file)
ri_html->add( '<td class="user">' ).
ri_html->add( '</td>' ).
" Transport (not applicable to file)
IF mv_are_changes_recorded_in_tr = abap_true.
ri_html->add( `<td></td>` ).
ENDIF.
" Command
ri_html->add( '<td class="cmd">' ).
IF mo_repo->has_remote_source( ) = abap_true.
ri_html->add( render_file_command( ls_file ) ).
ENDIF.
ri_html->add( '</td>' ).
ri_html->add( '</tr>' ).
ENDLOOP. ENDLOOP.
ENDMETHOD. ENDMETHOD.
METHOD render_item_lock_column. METHOD render_item_transport.
DATA: DATA:
ls_item TYPE zif_abapgit_definitions=>ty_item, ls_item TYPE zif_abapgit_definitions=>ty_item,
@ -1120,17 +1146,15 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
CREATE OBJECT ri_html TYPE zcl_abapgit_html. CREATE OBJECT ri_html TYPE zcl_abapgit_html.
ri_html->add( '<td class="icon">' ). ri_html->add( '<td class="transport">' ).
ls_item-obj_type = is_item-obj_type. ls_item-obj_type = is_item-obj_type.
ls_item-obj_name = is_item-obj_name. ls_item-obj_name = is_item-obj_name.
TRY. TRY.
lv_transport = zcl_abapgit_factory=>get_cts_api( )->get_transport_for_object( ls_item ). lv_transport = zcl_abapgit_factory=>get_cts_api( )->get_transport_for_object( ls_item ).
IF lv_transport IS NOT INITIAL. IF lv_transport IS NOT INITIAL.
ri_html->add( zcl_abapgit_gui_chunk_lib=>render_transport( iv_transport = lv_transport ri_html->add( zcl_abapgit_gui_chunk_lib=>render_transport( iv_transport = lv_transport ) ).
iv_icon_only = abap_true ) ).
ENDIF. ENDIF.
CATCH zcx_abapgit_exception ##NO_HANDLER. CATCH zcx_abapgit_exception ##NO_HANDLER.
" Ignore errors related to object check when trying to get transport " Ignore errors related to object check when trying to get transport
@ -1150,10 +1174,8 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
CREATE OBJECT ri_html TYPE zcl_abapgit_html. CREATE OBJECT ri_html TYPE zcl_abapgit_html.
" icon
APPEND INITIAL LINE TO lt_col_spec. APPEND INITIAL LINE TO lt_col_spec.
IF mv_are_changes_recorded_in_tr = abap_true.
APPEND INITIAL LINE TO lt_col_spec.
ENDIF.
ls_col_spec-tech_name = 'OBJ_TYPE'. ls_col_spec-tech_name = 'OBJ_TYPE'.
ls_col_spec-display_name = 'Type'. ls_col_spec-display_name = 'Type'.
@ -1170,10 +1192,12 @@ CLASS zcl_abapgit_gui_page_repo_view IMPLEMENTATION.
ls_col_spec-allow_order_by = abap_true. ls_col_spec-allow_order_by = abap_true.
APPEND ls_col_spec TO lt_col_spec. APPEND ls_col_spec TO lt_col_spec.
ls_col_spec-tech_name = 'PATH'. IF mv_are_changes_recorded_in_tr = abap_true.
ls_col_spec-display_name = 'Path'. ls_col_spec-tech_name = 'TRANSPORT'.
ls_col_spec-allow_order_by = abap_true. ls_col_spec-display_name = 'Transport'.
APPEND ls_col_spec TO lt_col_spec. ls_col_spec-allow_order_by = abap_true.
APPEND ls_col_spec TO lt_col_spec.
ENDIF.
ls_col_spec-tech_name = 'LSTATE'. ls_col_spec-tech_name = 'LSTATE'.
ls_col_spec-display_name = 'Status'. ls_col_spec-display_name = 'Status'.