mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 04:08:27 +08:00
UI repo over view page refactoring (#5789)
* improvements in abapgit_html * linter fix * repo over code styling * repo overview refactoring part 1 * move universal cod to chunks * cleanup new code temporarily * more clean ups * ui_component register_hotkeys helper * move relevant hotkeys to repo overview * forgotten part * move event handling to repo over * reuse td * move render_repo_url to chunks * minor * linter fix * new > create Co-authored-by: Lars Hvam <larshp@hotmail.com> Co-authored-by: Marc Bernard <59966492+mbtools@users.noreply.github.com>
This commit is contained in:
parent
3e4e631cdb
commit
3ecf82777c
|
@ -63,6 +63,7 @@ span.separator {
|
|||
.center { text-align:center; }
|
||||
.paddings { padding: 0.5em 0.5em; }
|
||||
.pad-sides { padding-left: 0.3em; padding-right: 0.3em; }
|
||||
.pad-1em { padding: 1em 1em; }
|
||||
.margin-v5 { margin-top: 0.5em; margin-bottom: 0.5em; }
|
||||
.margin-v1 { margin-top: 1em; margin-bottom: 1em; }
|
||||
.indent5em { padding-left: 0.5em; }
|
||||
|
@ -1338,4 +1339,17 @@ settings_tab tr:first-child td { border-top: 0px; }
|
|||
|
||||
.sticky_full_width + .not_sticky {
|
||||
padding-top: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Light toolbar or blocks with separators */
|
||||
.toolbar-light a {
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
border-left: 1px solid;
|
||||
border-left-color: #ccc;
|
||||
}
|
||||
|
||||
.toolbar-light a:first-child {
|
||||
padding-left: 0;
|
||||
border-left: none;
|
||||
}
|
||||
|
|
|
@ -129,6 +129,14 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION
|
|||
VALUE(ri_html) TYPE REF TO zif_abapgit_html
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS render_repo_url
|
||||
IMPORTING
|
||||
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
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
CLASS-METHODS render_package_name
|
||||
IMPORTING
|
||||
!iv_package TYPE devclass
|
||||
|
@ -162,7 +170,6 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION
|
|||
ii_html TYPE REF TO zif_abapgit_html
|
||||
iv_sci_result TYPE zif_abapgit_definitions=>ty_sci_result.
|
||||
|
||||
|
||||
CLASS-METHODS render_path
|
||||
IMPORTING
|
||||
!iv_path TYPE string
|
||||
|
@ -171,6 +178,30 @@ CLASS zcl_abapgit_gui_chunk_lib DEFINITION
|
|||
VALUE(ri_html) TYPE REF TO zif_abapgit_html
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
|
||||
CLASS-METHODS render_timestamp
|
||||
IMPORTING
|
||||
iv_timestamp TYPE timestampl
|
||||
RETURNING
|
||||
VALUE(rv_rendered) TYPE string.
|
||||
|
||||
CLASS-METHODS render_text_input
|
||||
IMPORTING
|
||||
iv_name TYPE string
|
||||
iv_label TYPE string
|
||||
iv_value TYPE string OPTIONAL
|
||||
iv_max_length TYPE string OPTIONAL
|
||||
iv_autofocus TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING
|
||||
VALUE(ri_html) TYPE REF TO zif_abapgit_html.
|
||||
|
||||
CLASS-METHODS shorten_repo_url
|
||||
IMPORTING
|
||||
iv_full_url TYPE string
|
||||
iv_max_length TYPE i DEFAULT 60
|
||||
RETURNING
|
||||
VALUE(rv_shortened) TYPE string.
|
||||
|
||||
PROTECTED SECTION.
|
||||
|
||||
CLASS-METHODS render_repo_top_commit_hash
|
||||
|
@ -198,7 +229,7 @@ ENDCLASS.
|
|||
|
||||
|
||||
|
||||
CLASS zcl_abapgit_gui_chunk_lib IMPLEMENTATION.
|
||||
CLASS ZCL_ABAPGIT_GUI_CHUNK_LIB IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD advanced_submenu.
|
||||
|
@ -1026,6 +1057,26 @@ CLASS zcl_abapgit_gui_chunk_lib IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD render_repo_url.
|
||||
|
||||
ri_html = zcl_abapgit_html=>create( )->add_a(
|
||||
iv_txt = shorten_repo_url( iv_url )
|
||||
iv_title = iv_url
|
||||
iv_act = |{ zif_abapgit_definitions=>c_action-url }?url={ iv_url }| ).
|
||||
|
||||
IF iv_render_remote_edit_for_key IS NOT INITIAL.
|
||||
ri_html->add_a(
|
||||
iv_txt = ri_html->icon(
|
||||
iv_name = 'edit-solid'
|
||||
iv_class = 'pad-sides'
|
||||
iv_hint = 'Change remote' )
|
||||
iv_act = |{ zif_abapgit_definitions=>c_action-repo_remote_settings }?key={ iv_render_remote_edit_for_key }|
|
||||
iv_class = |remote_repo| ).
|
||||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD render_sci_result.
|
||||
|
||||
DATA lv_icon TYPE string.
|
||||
|
@ -1048,6 +1099,45 @@ CLASS zcl_abapgit_gui_chunk_lib IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD render_text_input.
|
||||
|
||||
DATA lv_attrs TYPE string.
|
||||
|
||||
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
|
||||
|
||||
IF iv_value IS NOT INITIAL.
|
||||
lv_attrs = | value="{ iv_value }"|.
|
||||
ENDIF.
|
||||
|
||||
IF iv_max_length IS NOT INITIAL.
|
||||
lv_attrs = lv_attrs && | maxlength="{ iv_max_length }"|.
|
||||
ENDIF.
|
||||
|
||||
IF iv_autofocus = abap_true.
|
||||
lv_attrs = lv_attrs && | autofocus|.
|
||||
ENDIF.
|
||||
|
||||
ri_html->add( |<label for="{ iv_name }">{ iv_label }</label>| ).
|
||||
ri_html->add( |<input id="{ iv_name }" name="{ iv_name }" type="text"{ lv_attrs }>| ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD render_timestamp.
|
||||
|
||||
DATA lv_date TYPE d.
|
||||
DATA lv_time TYPE t.
|
||||
|
||||
CONVERT TIME STAMP iv_timestamp
|
||||
TIME ZONE gv_time_zone
|
||||
INTO DATE lv_date
|
||||
TIME lv_time.
|
||||
|
||||
rv_rendered = |{ lv_date DATE = USER } { lv_time TIME = USER }|.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD render_transport.
|
||||
|
||||
DATA:
|
||||
|
@ -1192,4 +1282,24 @@ CLASS zcl_abapgit_gui_chunk_lib IMPLEMENTATION.
|
|||
iv_cur = boolc( iv_act = zif_abapgit_definitions=>c_action-go_settings_personal ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD shorten_repo_url.
|
||||
DATA lv_new_length TYPE i.
|
||||
DATA lv_length_to_truncate_to TYPE i.
|
||||
|
||||
rv_shortened = iv_full_url.
|
||||
|
||||
REPLACE FIRST OCCURRENCE OF 'https://' IN rv_shortened WITH ''.
|
||||
REPLACE FIRST OCCURRENCE OF 'http://' IN rv_shortened WITH ''.
|
||||
IF rv_shortened CP '*.git'.
|
||||
lv_new_length = strlen( rv_shortened ) - 4.
|
||||
rv_shortened = rv_shortened(lv_new_length).
|
||||
ENDIF.
|
||||
|
||||
IF strlen( rv_shortened ) > iv_max_length.
|
||||
lv_length_to_truncate_to = iv_max_length - 3.
|
||||
rv_shortened = rv_shortened(lv_length_to_truncate_to) && `...`.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
|
|
@ -23,6 +23,11 @@ CLASS zcl_abapgit_gui_component DEFINITION
|
|||
VALUE(ri_gui_services) TYPE REF TO zif_abapgit_gui_services
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
METHODS register_hotkeys
|
||||
IMPORTING
|
||||
ii_hotkey_provider TYPE REF TO zif_abapgit_gui_hotkeys OPTIONAL
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mi_gui_services TYPE REF TO zif_abapgit_gui_services.
|
||||
|
@ -46,4 +51,23 @@ CLASS ZCL_ABAPGIT_GUI_COMPONENT IMPLEMENTATION.
|
|||
iv_collection = c_html_parts-scripts
|
||||
ii_part = ii_part ).
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD register_hotkeys.
|
||||
|
||||
DATA li_hotkey_provider TYPE REF TO zif_abapgit_gui_hotkeys.
|
||||
|
||||
IF ii_hotkey_provider IS BOUND.
|
||||
li_hotkey_provider = ii_hotkey_provider.
|
||||
ELSE.
|
||||
TRY.
|
||||
li_hotkey_provider ?= me.
|
||||
CATCH cx_root.
|
||||
RETURN.
|
||||
ENDTRY.
|
||||
ENDIF.
|
||||
|
||||
gui_services( )->get_hotkeys_ctl( )->register_hotkeys( li_hotkey_provider->get_hotkey_actions( ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
|
|
@ -7,8 +7,10 @@ CLASS zcl_abapgit_gui_page_main DEFINITION
|
|||
INTERFACES: zif_abapgit_gui_hotkeys.
|
||||
METHODS:
|
||||
constructor
|
||||
IMPORTING iv_only_favorites TYPE abap_bool
|
||||
RAISING zcx_abapgit_exception,
|
||||
IMPORTING
|
||||
iv_only_favorites TYPE abap_bool
|
||||
RAISING
|
||||
zcx_abapgit_exception,
|
||||
zif_abapgit_gui_event_handler~on_event REDEFINITION.
|
||||
|
||||
|
||||
|
@ -19,19 +21,14 @@ CLASS zcl_abapgit_gui_page_main DEFINITION
|
|||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
BEGIN OF c_actions,
|
||||
show TYPE string VALUE 'show' ##NO_TEXT,
|
||||
overview TYPE string VALUE 'overview',
|
||||
select TYPE string VALUE 'select',
|
||||
apply_filter TYPE string VALUE 'apply_filter',
|
||||
abapgit_home TYPE string VALUE 'abapgit_home',
|
||||
END OF c_actions.
|
||||
|
||||
DATA: mo_repo_overview TYPE REF TO zcl_abapgit_gui_page_repo_over,
|
||||
mv_repo_key TYPE zif_abapgit_persistence=>ty_value,
|
||||
mv_only_favorites TYPE abap_bool.
|
||||
DATA mo_repo_overview TYPE REF TO zcl_abapgit_gui_page_repo_over.
|
||||
|
||||
METHODS build_main_menu
|
||||
RETURNING VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar.
|
||||
RETURNING
|
||||
VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
@ -66,87 +63,35 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_MAIN IMPLEMENTATION.
|
|||
|
||||
|
||||
METHOD constructor.
|
||||
|
||||
super->constructor( ).
|
||||
ms_control-page_menu = build_main_menu( ).
|
||||
ms_control-page_title = 'Repository List'.
|
||||
mv_only_favorites = iv_only_favorites.
|
||||
|
||||
CREATE OBJECT mo_repo_overview
|
||||
EXPORTING
|
||||
iv_only_favorites = iv_only_favorites.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD render_content.
|
||||
|
||||
register_hotkeys( ).
|
||||
|
||||
CREATE OBJECT ri_html TYPE zcl_abapgit_html.
|
||||
|
||||
gui_services( )->get_hotkeys_ctl( )->register_hotkeys( zif_abapgit_gui_hotkeys~get_hotkey_actions( ) ).
|
||||
|
||||
IF mo_repo_overview IS INITIAL OR mo_repo_overview->mv_only_favorites <> mv_only_favorites.
|
||||
CREATE OBJECT mo_repo_overview EXPORTING iv_only_favorites = mv_only_favorites.
|
||||
ENDIF.
|
||||
|
||||
ri_html->add( mo_repo_overview->zif_abapgit_gui_renderable~render( ) ).
|
||||
|
||||
register_deferred_script( zcl_abapgit_gui_chunk_lib=>render_repo_palette( c_actions-select ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD zif_abapgit_gui_event_handler~on_event.
|
||||
|
||||
DATA: lv_key TYPE zif_abapgit_persistence=>ty_value.
|
||||
|
||||
lv_key = ii_event->query( )->get( 'KEY' ).
|
||||
|
||||
CASE ii_event->mv_action.
|
||||
WHEN c_actions-abapgit_home.
|
||||
CLEAR mv_repo_key.
|
||||
rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
|
||||
WHEN c_actions-select.
|
||||
|
||||
zcl_abapgit_persistence_user=>get_instance( )->set_repo_show( lv_key ).
|
||||
|
||||
TRY.
|
||||
zcl_abapgit_repo_srv=>get_instance( )->get( lv_key )->refresh( ).
|
||||
CATCH zcx_abapgit_exception ##NO_HANDLER.
|
||||
ENDTRY.
|
||||
|
||||
mv_repo_key = lv_key.
|
||||
CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_repo_view
|
||||
EXPORTING
|
||||
iv_key = lv_key.
|
||||
rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page.
|
||||
|
||||
WHEN zif_abapgit_definitions=>c_action-change_order_by.
|
||||
|
||||
mo_repo_overview->set_order_by( ii_event->query( )->get( 'ORDERBY' ) ).
|
||||
rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
|
||||
|
||||
WHEN zif_abapgit_definitions=>c_action-toggle_favorites.
|
||||
|
||||
mv_only_favorites = ii_event->query( )->get( 'FAVORITES' ).
|
||||
rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
|
||||
|
||||
WHEN zif_abapgit_definitions=>c_action-direction.
|
||||
|
||||
mo_repo_overview->set_order_direction(
|
||||
boolc( ii_event->query( )->get( 'DIRECTION' ) = 'DESCENDING' ) ).
|
||||
rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
|
||||
|
||||
WHEN c_actions-apply_filter.
|
||||
|
||||
mo_repo_overview->set_filter( ii_event->mt_postdata ).
|
||||
rs_handled-state = zcl_abapgit_gui=>c_event_state-re_render.
|
||||
|
||||
WHEN zif_abapgit_definitions=>c_action-go_patch.
|
||||
|
||||
CREATE OBJECT rs_handled-page TYPE zcl_abapgit_gui_page_patch
|
||||
EXPORTING
|
||||
iv_key = lv_key.
|
||||
rs_handled-state = zcl_abapgit_gui=>c_event_state-new_page.
|
||||
|
||||
WHEN OTHERS.
|
||||
|
||||
rs_handled = super->zif_abapgit_gui_event_handler~on_event( ii_event ).
|
||||
|
||||
ENDCASE.
|
||||
|
||||
ENDMETHOD.
|
||||
|
@ -154,7 +99,7 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_MAIN IMPLEMENTATION.
|
|||
|
||||
METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions.
|
||||
|
||||
DATA: ls_hotkey_action LIKE LINE OF rt_hotkey_actions.
|
||||
DATA ls_hotkey_action LIKE LINE OF rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-ui_component = 'Main'.
|
||||
|
||||
|
@ -173,46 +118,5 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_MAIN IMPLEMENTATION.
|
|||
ls_hotkey_action-hotkey = |o|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Stage|.
|
||||
ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_stage.
|
||||
ls_hotkey_action-hotkey = |s|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Diff|.
|
||||
ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_repo_diff.
|
||||
ls_hotkey_action-hotkey = |d|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Check|.
|
||||
ls_hotkey_action-action = zif_abapgit_definitions=>c_action-repo_code_inspector.
|
||||
ls_hotkey_action-hotkey = |c|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Pull|.
|
||||
ls_hotkey_action-action = zif_abapgit_definitions=>c_action-git_reset.
|
||||
ls_hotkey_action-hotkey = |p|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Patch|.
|
||||
ls_hotkey_action-action = zif_abapgit_definitions=>c_action-go_patch.
|
||||
ls_hotkey_action-hotkey = |p|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
" registered/handled in js
|
||||
ls_hotkey_action-description = |Previous Repository|.
|
||||
ls_hotkey_action-action = `#`.
|
||||
ls_hotkey_action-hotkey = |4|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Next Repository|.
|
||||
ls_hotkey_action-action = `##`.
|
||||
ls_hotkey_action-hotkey = |6|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Open Repository|.
|
||||
ls_hotkey_action-action = `###`.
|
||||
ls_hotkey_action-hotkey = |Enter|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user