mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Patch for staged files only (#3730)
* Allow Hotkeys on helper object * Patch for staged files only * cleanup * fix linter * Fix: refresh on page patch keeps sel. files * Fix: Diff and Patch shd appear when only rem. Chg. * fix linter * clarify stage helper object in JS
This commit is contained in:
parent
17b6411cdb
commit
dfc19fe718
|
@ -319,6 +319,7 @@ RepoOverViewHelper.prototype.onPageLoad = function () {
|
|||
function StageHelper(params) {
|
||||
this.pageSeed = params.seed;
|
||||
this.formAction = params.formAction;
|
||||
this.patchAction = params.patchAction;
|
||||
this.user = params.user;
|
||||
this.selectedCount = 0;
|
||||
this.filteredCount = 0;
|
||||
|
@ -330,6 +331,7 @@ function StageHelper(params) {
|
|||
commitAllBtn: document.getElementById(params.ids.commitAllBtn),
|
||||
commitSelectedBtn: document.getElementById(params.ids.commitSelectedBtn),
|
||||
commitFilteredBtn: document.getElementById(params.ids.commitFilteredBtn),
|
||||
patchBtn: document.getElementById(params.ids.patchBtn),
|
||||
objectSearch: document.getElementById(params.ids.objectSearch),
|
||||
selectedCounter: null,
|
||||
filteredCounter: null,
|
||||
|
@ -393,6 +395,7 @@ StageHelper.prototype.setHooks = function() {
|
|||
this.dom.stageTab.onclick = this.onTableClick.bind(this);
|
||||
this.dom.commitSelectedBtn.onclick = this.submit.bind(this);
|
||||
this.dom.commitFilteredBtn.onclick = this.submitVisible.bind(this);
|
||||
this.dom.patchBtn.onclick = this.submitPatch.bind(this);
|
||||
this.dom.objectSearch.oninput = this.onFilter.bind(this);
|
||||
this.dom.objectSearch.onkeypress = this.onFilter.bind(this);
|
||||
window.onbeforeunload = this.onPageUnload.bind(this);
|
||||
|
@ -613,6 +616,10 @@ StageHelper.prototype.submitVisible = function () {
|
|||
submitSapeventForm(this.collectData(), this.formAction);
|
||||
};
|
||||
|
||||
StageHelper.prototype.submitPatch = function(){
|
||||
submitSapeventForm(this.collectData(), this.patchAction);
|
||||
};
|
||||
|
||||
// Extract data from the table
|
||||
StageHelper.prototype.collectData = function () {
|
||||
var data = {};
|
||||
|
@ -1288,12 +1295,21 @@ function Hotkeys(oKeyMap){
|
|||
// the hotkey execution
|
||||
this.oKeyMap[sKey] = function(oEvent) {
|
||||
|
||||
// gHelper is only valid for diff page
|
||||
var diffHelper = (window.gHelper || {});
|
||||
|
||||
// We have either a js function on this
|
||||
if (this[action]) {
|
||||
this[action].call(this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Or a method of the helper object for the diff page
|
||||
if (diffHelper[action]){
|
||||
diffHelper[action].call(diffHelper);
|
||||
return;
|
||||
}
|
||||
|
||||
// Or a global function
|
||||
if (window[action]) {
|
||||
window[action].call(this);
|
||||
|
|
|
@ -35,6 +35,7 @@ CLASS zcl_abapgit_gui_page_diff DEFINITION
|
|||
!iv_key TYPE zif_abapgit_persistence=>ty_repo-key
|
||||
!is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
||||
!is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
||||
!it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
|
||||
|
@ -68,6 +69,7 @@ CLASS zcl_abapgit_gui_page_diff DEFINITION
|
|||
IMPORTING
|
||||
is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
||||
is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
||||
it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL
|
||||
RAISING
|
||||
zcx_abapgit_exception,
|
||||
add_menu_begin
|
||||
|
@ -185,12 +187,17 @@ CLASS zcl_abapgit_gui_page_diff DEFINITION
|
|||
VALUE(ro_html) TYPE REF TO zcl_abapgit_html
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
METHODS filter_diff_by_files
|
||||
IMPORTING
|
||||
it_files TYPE zif_abapgit_definitions=>ty_stage_tt
|
||||
CHANGING
|
||||
ct_diff_files TYPE tt_file_diff.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
||||
CLASS zcl_abapgit_gui_page_diff IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD add_filter_sub_menu.
|
||||
|
@ -426,6 +433,7 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
|||
ENDLOOP.
|
||||
|
||||
ELSE. " Diff for the whole repo
|
||||
|
||||
SORT lt_status BY
|
||||
path ASCENDING
|
||||
filename ASCENDING.
|
||||
|
@ -437,6 +445,12 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
|||
|
||||
ENDIF.
|
||||
|
||||
filter_diff_by_files(
|
||||
EXPORTING
|
||||
it_files = it_files
|
||||
CHANGING
|
||||
ct_diff_files = mt_diff_files ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
|
@ -457,7 +471,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
|||
|
||||
calculate_diff(
|
||||
is_file = is_file
|
||||
is_object = is_object ).
|
||||
is_object = is_object
|
||||
it_files = it_files ).
|
||||
|
||||
IF lines( mt_diff_files ) = 0.
|
||||
zcx_abapgit_exception=>raise( 'PAGE_DIFF ERROR: No diff files found' ).
|
||||
|
@ -965,4 +980,26 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_DIFF IMPLEMENTATION.
|
|||
ENDCASE.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD filter_diff_by_files.
|
||||
|
||||
FIELD-SYMBOLS: <ls_diff_file> TYPE ty_file_diff.
|
||||
|
||||
IF lines( it_files ) = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
" Diff only for specified files
|
||||
LOOP AT ct_diff_files ASSIGNING <ls_diff_file>.
|
||||
|
||||
READ TABLE it_files TRANSPORTING NO FIELDS
|
||||
WITH KEY file-filename = <ls_diff_file>-filename.
|
||||
IF sy-subrc <> 0.
|
||||
DELETE TABLE ct_diff_files FROM <ls_diff_file>.
|
||||
ENDIF.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
|
@ -12,6 +12,7 @@ CLASS zcl_abapgit_gui_page_patch DEFINITION
|
|||
iv_key TYPE zif_abapgit_persistence=>ty_repo-key
|
||||
is_file TYPE zif_abapgit_definitions=>ty_file OPTIONAL
|
||||
is_object TYPE zif_abapgit_definitions=>ty_item OPTIONAL
|
||||
it_files TYPE zif_abapgit_definitions=>ty_stage_tt OPTIONAL
|
||||
iv_patch_mode TYPE abap_bool OPTIONAL
|
||||
RAISING
|
||||
zcx_abapgit_exception,
|
||||
|
@ -178,7 +179,7 @@ ENDCLASS.
|
|||
|
||||
|
||||
|
||||
CLASS ZCL_ABAPGIT_GUI_PAGE_PATCH IMPLEMENTATION.
|
||||
CLASS zcl_abapgit_gui_page_patch IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD add_menu_begin.
|
||||
|
@ -384,7 +385,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_PATCH IMPLEMENTATION.
|
|||
super->constructor(
|
||||
iv_key = iv_key
|
||||
is_file = is_file
|
||||
is_object = is_object ).
|
||||
is_object = is_object
|
||||
it_files = it_files ).
|
||||
|
||||
IF mo_repo->is_offline( ) = abap_true.
|
||||
zcx_abapgit_exception=>raise( |Can't patch offline repos| ).
|
||||
|
@ -504,7 +506,12 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_PATCH IMPLEMENTATION.
|
|||
METHOD refresh.
|
||||
|
||||
DATA:
|
||||
lt_diff_files_old TYPE tt_file_diff.
|
||||
lt_diff_files_old TYPE tt_file_diff,
|
||||
lt_files TYPE zif_abapgit_definitions=>ty_stage_tt,
|
||||
ls_file LIKE LINE OF lt_files.
|
||||
|
||||
FIELD-SYMBOLS: <ls_diff_file_old> TYPE zcl_abapgit_gui_page_diff=>ty_file_diff.
|
||||
|
||||
|
||||
lt_diff_files_old = mt_diff_files.
|
||||
|
||||
|
@ -517,7 +524,17 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_PATCH IMPLEMENTATION.
|
|||
refresh_local_object( iv_action ).
|
||||
ENDCASE.
|
||||
|
||||
calculate_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 lt_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 lt_files.
|
||||
ENDLOOP.
|
||||
|
||||
calculate_diff( it_files = lt_files ).
|
||||
restore_patch_flags( lt_diff_files_old ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
|
|
@ -87,7 +87,7 @@ CLASS zcl_abapgit_gui_page_stage DEFINITION
|
|||
RETURNING
|
||||
VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar .
|
||||
METHODS get_page_patch
|
||||
IMPORTING iv_getdata TYPE clike
|
||||
IMPORTING io_stage TYPE REF TO zcl_abapgit_stage
|
||||
RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable
|
||||
RAISING zcx_abapgit_exception.
|
||||
METHODS render_master_language_warning
|
||||
|
@ -115,12 +115,14 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
|||
|
||||
CREATE OBJECT ro_menu.
|
||||
|
||||
IF lines( ms_files-local ) > 0.
|
||||
IF lines( ms_files-local ) > 0
|
||||
OR lines( ms_files-remote ) > 0.
|
||||
ro_menu->add( iv_txt = |Diff|
|
||||
iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?key={ mo_repo->get_key( ) }| ).
|
||||
|
||||
ro_menu->add( iv_txt = |Patch|
|
||||
iv_act = |{ zif_abapgit_definitions=>c_action-go_patch }?key={ mo_repo->get_key( ) }| ).
|
||||
iv_typ = zif_abapgit_html=>c_action_type-onclick
|
||||
iv_id = |patchBtn| ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
@ -234,18 +236,20 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
|||
|
||||
METHOD get_page_patch.
|
||||
|
||||
DATA: lo_page TYPE REF TO zcl_abapgit_gui_page_patch,
|
||||
lv_key TYPE zif_abapgit_persistence=>ty_repo-key.
|
||||
DATA: lo_page TYPE REF TO zcl_abapgit_gui_page_patch,
|
||||
lv_key TYPE zif_abapgit_persistence=>ty_repo-key,
|
||||
lt_files TYPE zif_abapgit_definitions=>ty_stage_tt.
|
||||
|
||||
zcl_abapgit_html_action_utils=>file_obj_decode(
|
||||
EXPORTING
|
||||
iv_string = iv_getdata
|
||||
IMPORTING
|
||||
ev_key = lv_key ).
|
||||
lv_key = mo_repo->get_key( ).
|
||||
lt_files = io_stage->get_all( ).
|
||||
|
||||
DELETE lt_files WHERE method <> zif_abapgit_definitions=>c_method-add
|
||||
AND method <> zif_abapgit_definitions=>c_method-rm.
|
||||
|
||||
CREATE OBJECT lo_page
|
||||
EXPORTING
|
||||
iv_key = lv_key.
|
||||
iv_key = lv_key
|
||||
it_files = lt_files.
|
||||
|
||||
ri_page = lo_page.
|
||||
|
||||
|
@ -513,12 +517,14 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
|||
ro_html->add( | seed: "{ mv_seed }",| ). " Unique page id
|
||||
ro_html->add( | user: "{ to_lower( sy-uname ) }",| ).
|
||||
ro_html->add( ' formAction: "stage_commit",' ).
|
||||
ro_html->add( | patchAction: "{ zif_abapgit_definitions=>c_action-go_patch }",| ).
|
||||
|
||||
ro_html->add( ' ids: {' ).
|
||||
ro_html->add( ' stageTab: "stageTab",' ).
|
||||
ro_html->add( ' commitAllBtn: "commitAllButton",' ).
|
||||
ro_html->add( ' commitSelectedBtn: "commitSelectedButton",' ).
|
||||
ro_html->add( ' commitFilteredBtn: "commitFilteredButton",' ).
|
||||
ro_html->add( ' patchBtn: "patchBtn",' ).
|
||||
ro_html->add( ' objectSearch: "objectSearch",' ).
|
||||
ro_html->add( ' }' ).
|
||||
|
||||
|
@ -688,7 +694,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
|||
|
||||
WHEN zif_abapgit_definitions=>c_action-go_patch. " Go Patch page
|
||||
|
||||
ei_page = get_page_patch( iv_getdata ).
|
||||
lo_stage = stage_selected( it_postdata ).
|
||||
ei_page = get_page_patch( lo_stage ).
|
||||
ev_state = zcl_abapgit_gui=>c_event_state-new_page.
|
||||
|
||||
WHEN OTHERS.
|
||||
|
@ -711,7 +718,7 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_STAGE IMPLEMENTATION.
|
|||
|
||||
ls_hotkey_action-ui_component = 'Stage'.
|
||||
ls_hotkey_action-description = |Patch|.
|
||||
ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_patch.
|
||||
ls_hotkey_action-action = 'submitPatch'. " JS function in StageHelper
|
||||
ls_hotkey_action-hotkey = |p|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user