Diff and Patch Pages Update (#5056)

* Diff and Patch Pages Update

- Fix refresh of a single file on diff page (it was displaying all diffs afterwards)
- Add some hotkey assignments
- Replace "Refresh" after filename with icon

normal:

hover:

* Local refresh on patch page

* Update zcl_abapgit_gui_page_patch.clas.abap

* Patch page: Add js for refresh all hotkey

Co-authored-by: Christian Günter <christianguenter@googlemail.com>
This commit is contained in:
Marc Bernard 2021-10-27 01:28:17 -04:00 committed by GitHub
parent 2a27d34c08
commit 679f2050b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 54 deletions

View File

@ -1730,7 +1730,8 @@ Patch.prototype.ID = {
Patch.prototype.ACTION = {
PATCH_STAGE: "patch_stage",
REFRESH_LOCAL: "refresh_local"
REFRESH_LOCAL: "refresh_local",
REFRESH_ALL: "refresh_all"
};
Patch.prototype.escape = function(sFileName){
@ -1877,6 +1878,10 @@ Patch.prototype.registerStagePatch = function registerStagePatch(){
this.submitPatch(this.ACTION.REFRESH_LOCAL);
}.bind(this));
window.refreshAll = memoizeScrollPosition(function(){
this.submitPatch(this.ACTION.REFRESH_ALL);
}.bind(this));
};
Patch.prototype.submitPatch = function(action) {

View File

@ -148,9 +148,9 @@ CLASS zcl_abapgit_gui_page_diff DEFINITION
VALUE(rv_is_refrseh) TYPE abap_bool.
METHODS modify_files_before_diff_calc
IMPORTING
it_diff_files_old TYPE ty_file_diffs
CHANGING
ct_files TYPE zif_abapgit_definitions=>ty_stage_tt.
!it_diff_files_old TYPE ty_file_diffs
RETURNING
VALUE(rt_files) TYPE zif_abapgit_definitions=>ty_stage_tt.
METHODS render_content
REDEFINITION .
@ -625,6 +625,20 @@ CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION.
METHOD modify_files_before_diff_calc.
DATA ls_file LIKE LINE OF rt_files.
FIELD-SYMBOLS <ls_diff_file_old> TYPE ty_file_diff.
" We need to supply files again in calculate_diff. Because
" we only want to refresh the visible files. Otherwise all
" diff files would appear.
" Which is not wanted when we previously only selected particular files.
LOOP AT it_diff_files_old ASSIGNING <ls_diff_file_old>.
CLEAR ls_file.
MOVE-CORRESPONDING <ls_diff_file_old> TO ls_file-file.
INSERT ls_file INTO TABLE rt_files.
ENDLOOP.
ENDMETHOD.
@ -666,11 +680,7 @@ CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION.
refresh_local_object( iv_action ).
ENDCASE.
modify_files_before_diff_calc(
EXPORTING
it_diff_files_old = lt_diff_files_old
CHANGING
ct_files = lt_files ).
lt_files = modify_files_before_diff_calc( lt_diff_files_old ).
calculate_diff( it_files = lt_files ).
@ -879,24 +889,19 @@ CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION.
METHOD render_diff_head_after_state.
DATA: lv_act_id TYPE string.
IF is_diff-fstate = c_fstate-both AND mv_unified = abap_true.
ii_html->add( '<span class="attention pad-sides">Attention: Unified mode'
&& ' highlighting for MM assumes local file is newer ! </span>' ).
ENDIF.
IF is_diff-obj_type IS NOT INITIAL AND is_diff-obj_name IS NOT INITIAL.
lv_act_id = |{ c_actions-refresh_local_object }_{ is_diff-obj_type }_{ is_diff-obj_name }|.
ii_html->add_a(
iv_txt = |Refresh|
iv_typ = zif_abapgit_html=>c_action_type-sapevent
iv_act = lv_act_id
iv_id = lv_act_id
iv_title = |Local refresh of this object| ).
ii_html->add( '<span class="repo_name">' ).
ii_html->add_a( iv_txt = ii_html->icon( iv_name = 'redo-alt-solid'
iv_class = 'pad-sides'
iv_hint = 'Local refresh of this object' )
iv_act = |{ c_actions-refresh_local_object }_{ is_diff-obj_type }_{ is_diff-obj_name }|
iv_class = |url| ).
ii_html->add( '</span>' ).
ENDIF.
ENDMETHOD.
@ -1216,6 +1221,20 @@ CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION.
ls_hotkey_action-hotkey = |r|.
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
ENDMETHOD.
ls_hotkey_action-description = |Refresh all|.
ls_hotkey_action-action = c_actions-refresh_all.
ls_hotkey_action-hotkey = |a|.
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
ls_hotkey_action-description = |Toogle split/unified|.
ls_hotkey_action-action = c_actions-toggle_unified.
ls_hotkey_action-hotkey = |u|.
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
ls_hotkey_action-description = |Toogle hidden characters|.
ls_hotkey_action-action = c_actions-toggle_hidden_chars.
ls_hotkey_action-hotkey = |h|.
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
ENDMETHOD.
ENDCLASS.

View File

@ -39,8 +39,7 @@ CLASS zcl_abapgit_gui_page_patch DEFINITION
render_diff_head_after_state REDEFINITION,
insert_nav REDEFINITION,
render_line_split_row REDEFINITION,
refresh REDEFINITION,
modify_files_before_diff_calc REDEFINITION.
refresh REDEFINITION.
PRIVATE SECTION.
@ -424,26 +423,6 @@ CLASS zcl_abapgit_gui_page_patch IMPLEMENTATION.
ENDMETHOD.
METHOD modify_files_before_diff_calc.
DATA: ls_file LIKE LINE OF ct_files.
FIELD-SYMBOLS: <ls_diff_file_old> TYPE zcl_abapgit_gui_page_diff=>ty_file_diff.
" We need to supply files again in calculate_diff. Because
" we only want to refresh the visible files. Otherwise all
" diff files would appear.
" Which is not wanted when we previously only selected particular files.
LOOP AT it_diff_files_old ASSIGNING <ls_diff_file_old>.
CLEAR: ls_file.
MOVE-CORRESPONDING <ls_diff_file_old> TO ls_file-file.
INSERT ls_file INTO TABLE ct_files.
ENDLOOP.
ENDMETHOD.
METHOD refresh.
DATA: lt_diff_files_old TYPE ty_file_diffs.
@ -491,17 +470,19 @@ CLASS zcl_abapgit_gui_page_patch IMPLEMENTATION.
DATA: lv_act_id TYPE string.
lv_act_id = |{ c_actions-refresh_local_object }_{ is_diff-obj_type }_{ is_diff-obj_name }|.
IF is_diff-obj_type IS NOT INITIAL AND is_diff-obj_name IS NOT INITIAL.
lv_act_id = |{ c_actions-refresh_local_object }_{ is_diff-obj_type }_{ is_diff-obj_name }|.
ii_html->add_a(
iv_txt = |Refresh|
iv_typ = zif_abapgit_html=>c_action_type-dummy
iv_act = lv_act_id
iv_id = lv_act_id
iv_title = |Local refresh of this object| ).
" Dummy link is handled in JS (based on ID)
ii_html->add( '<span class="repo_name">' ).
ii_html->add_a( iv_txt = ii_html->icon( iv_name = 'redo-alt-solid'
iv_class = 'pad-sides'
iv_hint = 'Local refresh of this object' )
iv_id = lv_act_id
iv_act = lv_act_id
iv_typ = zif_abapgit_html=>c_action_type-dummy
iv_class = |url| ).
ii_html->add( '</span>' ).
ENDIF.
ENDMETHOD.
@ -686,5 +667,10 @@ CLASS zcl_abapgit_gui_page_patch IMPLEMENTATION.
ls_hotkey_action-hotkey = |r|.
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
ls_hotkey_action-description = |Refresh all|.
ls_hotkey_action-action = |refreshAll|.
ls_hotkey_action-hotkey = |a|.
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
ENDMETHOD.
ENDCLASS.