From 45badeb527788c48250a38204fa62c84a841d2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hud=C3=A1k?= Date: Sat, 23 Jan 2021 09:56:15 +0100 Subject: [PATCH] Add refresh button to stage page (#4437) --- src/ui/zcl_abapgit_gui_page_stage.clas.abap | 50 +++++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/src/ui/zcl_abapgit_gui_page_stage.clas.abap b/src/ui/zcl_abapgit_gui_page_stage.clas.abap index 2b14686bc..42605ef79 100644 --- a/src/ui/zcl_abapgit_gui_page_stage.clas.abap +++ b/src/ui/zcl_abapgit_gui_page_stage.clas.abap @@ -7,9 +7,10 @@ CLASS zcl_abapgit_gui_page_stage DEFINITION INTERFACES zif_abapgit_gui_hotkeys. CONSTANTS: BEGIN OF c_action, - stage_all TYPE string VALUE 'stage_all', - stage_commit TYPE string VALUE 'stage_commit', - stage_filter TYPE string VALUE 'stage_filter', + stage_refresh TYPE string VALUE 'stage_refresh', + stage_all TYPE string VALUE 'stage_all', + stage_commit TYPE string VALUE 'stage_commit', + stage_filter TYPE string VALUE 'stage_filter', END OF c_action. METHODS: @@ -132,6 +133,8 @@ CLASS zcl_abapgit_gui_page_stage DEFINITION VALUE(ri_html) TYPE REF TO zif_abapgit_html RAISING zcx_abapgit_exception . + METHODS init_files + RAISING zcx_abapgit_exception. ENDCLASS. @@ -145,12 +148,17 @@ CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION. 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_typ = zif_abapgit_html=>c_action_type-onclick - iv_id = |patchBtn| ). + ro_menu->add( + iv_txt = 'Refresh' + iv_act = |{ c_action-stage_refresh }| + iv_opt = zif_abapgit_html=>c_html_opt-strong + )->add( + iv_txt = |Diff| + iv_act = |{ zif_abapgit_definitions=>c_action-go_diff }?key={ mo_repo->get_key( ) }| + )->add( + iv_txt = |Patch| + iv_typ = zif_abapgit_html=>c_action_type-onclick + iv_id = |patchBtn| ). ENDIF. ENDMETHOD. @@ -201,7 +209,6 @@ CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION. ms_control-page_title = 'Stage'. mo_repo = io_repo. - ms_files = zcl_abapgit_factory=>get_stage_logic( )->get( mo_repo ). mv_seed = iv_seed. IF mv_seed IS INITIAL. " Generate based on time unless obtained from diff page @@ -209,12 +216,9 @@ CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION. mv_seed = |stage{ lv_ts }|. ENDIF. + init_files( ). ms_control-page_menu = build_menu( ). - IF lines( ms_files-local ) = 0 AND lines( ms_files-remote ) = 0. - zcx_abapgit_exception=>raise( 'There are no changes that could be staged' ). - ENDIF. - ENDMETHOD. @@ -865,6 +869,11 @@ CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION. rs_handled-page = get_page_patch( lo_stage ). rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page. + WHEN c_action-stage_refresh. + mo_repo->refresh( abap_true ). + init_files( ). + rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render. + WHEN OTHERS. rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ). ENDCASE. @@ -887,5 +896,18 @@ CLASS zcl_abapgit_gui_page_stage IMPLEMENTATION. ls_hotkey_action-hotkey = |d|. INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. + ls_hotkey_action-description = |Refresh|. + ls_hotkey_action-action = c_action-stage_refresh. + ls_hotkey_action-hotkey = |r|. + INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions. + ENDMETHOD. + + METHOD init_files. + ms_files = zcl_abapgit_factory=>get_stage_logic( )->get( mo_repo ). + IF lines( ms_files-local ) = 0 AND lines( ms_files-remote ) = 0. + zcx_abapgit_exception=>raise( 'There are no changes that could be staged' ). + ENDIF. + ENDMETHOD. + ENDCLASS.