From 702c67f3781bdd327f3c23d676a9e0922b02775f Mon Sep 17 00:00:00 2001 From: Bohdan Date: Wed, 1 Mar 2017 15:07:39 +0200 Subject: [PATCH 1/2] news_announcement Initial commit of news announcement feature. --- src/zabapgit.prog.abap | 1 + src/zabapgit_css_common.w3mi.data.css | 47 +++ src/zabapgit_html_chunks.prog.abap | 63 +++- src/zabapgit_js_common.w3mi.data.js | 10 + src/zabapgit_news.prog.abap | 400 ++++++++++++++++++++++++++ src/zabapgit_news.prog.xml | 23 ++ src/zabapgit_page_main.prog.abap | 20 ++ 7 files changed, 558 insertions(+), 6 deletions(-) create mode 100644 src/zabapgit_news.prog.abap create mode 100644 src/zabapgit_news.prog.xml diff --git a/src/zabapgit.prog.abap b/src/zabapgit.prog.abap index 55725524a..532981413 100644 --- a/src/zabapgit.prog.abap +++ b/src/zabapgit.prog.abap @@ -53,6 +53,7 @@ INCLUDE zabapgit_folder_logic. INCLUDE zabapgit_stage. INCLUDE zabapgit_git_helpers. INCLUDE zabapgit_repo. +INCLUDE zabapgit_news. INCLUDE zabapgit_stage_logic. INCLUDE zabapgit_2fa. INCLUDE zabapgit_http. diff --git a/src/zabapgit_css_common.w3mi.data.css b/src/zabapgit_css_common.w3mi.data.css index 31365ec0b..4dc2aae0a 100644 --- a/src/zabapgit_css_common.w3mi.data.css +++ b/src/zabapgit_css_common.w3mi.data.css @@ -700,3 +700,50 @@ div.tutorial h2 { font-size: 14pt; color: #404040; } + +/* News Announcement */ +.change-log { + position: absolute; + z-index: 99 !important; + top: 50%; + left: 50%; + width: 40em; + margin-top: -12em; + margin-left: -20em; + border: 1px solid #ccc; + background-color: white; + padding: 0.5em; +} + +.change-log .change-log-title { + color: #888888; + font-weight: bold; + font-size: 16px; + padding-top: 4px; + padding-bottom: 4px; +} + +.change-log .attention { + background-color: #ff9800; + color: white; + opacity: 0.83; + padding: 10px; +} + +.change-log li { + margin: 4px; + padding-left: 10px; + font-size: 15px; + list-style-type: none; +} + +.change-log p.versionHeader { + font-size: 16px; + color: #888888; + font-weight: bold; + text-align: left; + padding-top: 8px; + padding-bottom: 8px; + border-bottom: 1px #ddd solid; + margin: 4px; +} \ No newline at end of file diff --git a/src/zabapgit_html_chunks.prog.abap b/src/zabapgit_html_chunks.prog.abap index de94e6cca..03385b8ff 100644 --- a/src/zabapgit_html_chunks.prog.abap +++ b/src/zabapgit_html_chunks.prog.abap @@ -7,9 +7,9 @@ CLASS lcl_gui_chunk_lib DEFINITION FINAL. PUBLIC SECTION. CLASS-METHODS render_error - IMPORTING ix_error TYPE REF TO lcx_exception OPTIONAL - iv_error TYPE string OPTIONAL - RETURNING VALUE(ro_html) TYPE REF TO lcl_html. + IMPORTING ix_error TYPE REF TO lcx_exception OPTIONAL + iv_error TYPE string OPTIONAL + RETURNING VALUE(ro_html) TYPE REF TO lcl_html. CLASS-METHODS render_repo_top IMPORTING io_repo TYPE REF TO lcl_repo @@ -17,13 +17,15 @@ CLASS lcl_gui_chunk_lib DEFINITION FINAL. iv_show_branch TYPE abap_bool DEFAULT abap_true iv_interactive_branch TYPE abap_bool DEFAULT abap_false iv_branch TYPE string OPTIONAL + iv_has_news TYPE abap_bool OPTIONAL + iv_has_important_news TYPE abap_bool OPTIONAL RETURNING VALUE(ro_html) TYPE REF TO lcl_html RAISING lcx_exception. CLASS-METHODS render_item_state - IMPORTING iv1 TYPE char1 - iv2 TYPE char1 - RETURNING VALUE(rv_html) TYPE string. + IMPORTING iv1 TYPE char1 + iv2 TYPE char1 + RETURNING VALUE(rv_html) TYPE string. CLASS-METHODS render_branch_span IMPORTING iv_branch TYPE string @@ -36,6 +38,13 @@ CLASS lcl_gui_chunk_lib DEFINITION FINAL. RETURNING VALUE(ro_html) TYPE REF TO lcl_html RAISING lcx_exception. + CLASS-METHODS render_news_pop_up + IMPORTING + it_log TYPE lcl_news=>tt_log + iv_has_important TYPE abap_bool + RETURNING VALUE(ro_html) TYPE REF TO lcl_html + RAISING lcx_exception. + ENDCLASS. "lcl_gui_chunk_lib CLASS lcl_gui_chunk_lib IMPLEMENTATION. @@ -72,6 +81,12 @@ CLASS lcl_gui_chunk_lib IMPLEMENTATION. ro_html->add( '' ). + IF iv_has_news = abap_true. + ro_html->add_a( iv_act = 'displayLog()' + iv_typ = gc_action_type-onclick + iv_txt = lcl_html=>icon( iv_name = 'book/dark' ) ). + ENDIF. + IF abap_true = lcl_app=>user( )->is_favorite_repo( io_repo->get_key( ) ). lv_icon = 'star/blue' ##NO_TEXT. ELSE. @@ -215,4 +230,40 @@ CLASS lcl_gui_chunk_lib IMPLEMENTATION. ro_html->add( '' ). ENDMETHOD. "render_js_error_stub + METHOD render_news_pop_up. + + CREATE OBJECT ro_html. + + FIELD-SYMBOLS: LIKE LINE OF it_log. + + ro_html->add( '
' ). + + ro_html->add( '' ). + ro_html->add( '' ). + ro_html->add( '' ). + ro_html->add( '
' ). + ro_html->add( 'Announcement of the latest changes' ). + ro_html->add( '' ). + ro_html->add( 'close' ). + ro_html->add( '
' ). + + IF iv_has_important = abap_true. + ro_html->add( '
' + && '!!! Some changes mentioned in this announcement might be critical !!! ' + && '
' ). + ENDIF. + + " Generate changelog table + LOOP AT it_log ASSIGNING . + IF -header = 'X'. + ro_html->add( '

' && -text && '

' ). + ELSE. + ro_html->add( '
  • ' && -text && '
  • ' ). + ENDIF. + ENDLOOP. + + ro_html->add( '
    ' ). + + ENDMETHOD. "render_news_pop_up + ENDCLASS. "lcl_gui_chunk_lib diff --git a/src/zabapgit_js_common.w3mi.data.js b/src/zabapgit_js_common.w3mi.data.js index f37db91d9..d043ce10d 100644 --- a/src/zabapgit_js_common.w3mi.data.js +++ b/src/zabapgit_js_common.w3mi.data.js @@ -363,3 +363,13 @@ StageHelper.prototype.iterateStageTab = function (changeMode, cb /*, ...*/) { window.scrollTo(0, scrollOffset); } } + +/********************************************************** + * Other functions + **********************************************************/ + +// News announcement +function displayLog() { + var div = document.getElementById("changeLog"); + div.style.display = (div.style.display)?'':'none'; +} \ No newline at end of file diff --git a/src/zabapgit_news.prog.abap b/src/zabapgit_news.prog.abap new file mode 100644 index 000000000..7fac27453 --- /dev/null +++ b/src/zabapgit_news.prog.abap @@ -0,0 +1,400 @@ +*&---------------------------------------------------------------------* +*& Include ZABAPGIT_NEWS +*&---------------------------------------------------------------------* +CLASS ltcl_news DEFINITION DEFERRED. + +*&---------------------------------------------------------------------* +*& Class lcl_news +*&---------------------------------------------------------------------* +* Class responsible for preparation of data for news announcements +*----------------------------------------------------------------------* +CLASS lcl_news DEFINITION FRIENDS ltcl_news. + + PUBLIC SECTION. + TYPES: + BEGIN OF ty_log, + version TYPE string, + header TYPE abap_bool, + important TYPE abap_bool, + text TYPE string, + END OF ty_log, + tt_log TYPE STANDARD TABLE OF ty_log WITH DEFAULT KEY. + + CONSTANTS: + mc_log_file_path TYPE string VALUE '/', + mc_log_file_name TYPE string VALUE 'changelog.txt'. + + CLASS-METHODS create + IMPORTING io_repo TYPE REF TO lcl_repo + RETURNING VALUE(ro_instance) TYPE REF TO lcl_news. + + METHODS: + constructor + IMPORTING iv_rawdata TYPE xstring + iv_version TYPE string, + has_news + RETURNING value(rv_boolean) TYPE abap_bool, + get_log + RETURNING value(rt_log) TYPE tt_log, + has_important_news + RETURNING value(rv_boolean) TYPE abap_bool. + + PRIVATE SECTION. + DATA mt_log TYPE tt_log. + + CLASS-METHODS: + split_string + IMPORTING iv_string TYPE string + RETURNING value(rt_lines) TYPE string_table, + + convert_version_to_numeric + IMPORTING iv_version TYPE string + RETURNING value(rv_version) TYPE i, + + parse_data + IMPORTING it_lines TYPE string_table + iv_version TYPE string + RETURNING value(rt_log) TYPE tt_log, + + compare_versions + IMPORTING iv_a TYPE string + iv_b TYPE string + RETURNING value(rv_result) TYPE i. + +ENDCLASS. "lcl_news + +*----------------------------------------------------------------------* +* CLASS lcl_news IMPLEMENTATION +*----------------------------------------------------------------------* +* +*----------------------------------------------------------------------* +CLASS lcl_news IMPLEMENTATION. + + METHOD constructor. + DATA: + lt_lines TYPE string_table, + lv_string TYPE string. + + lv_string = lcl_convert=>xstring_to_string_utf8( iv_rawdata ). + lt_lines = lcl_news=>split_string( lv_string ). + mt_log = lcl_news=>parse_data( it_lines = lt_lines iv_version = iv_version ). + + ENDMETHOD. "constructor + + METHOD create. + + DATA: + lt_remote TYPE ty_files_tt, + lo_repo_online TYPE REF TO lcl_repo_online. + + FIELD-SYMBOLS LIKE LINE OF lt_remote. + + IF io_repo->is_offline( ) = abap_false. + lo_repo_online ?= io_repo. + + " News announcement temporary restricted to abapGit only + IF lo_repo_online->get_url( ) CS '/abapGit.git'. + lt_remote = io_repo->get_files_remote( ). + + READ TABLE lt_remote ASSIGNING WITH KEY path = mc_log_file_path + filename = mc_log_file_name. + IF sy-subrc = 0. + CREATE OBJECT ro_instance EXPORTING + iv_rawdata = -data + iv_version = gc_abap_version. + ENDIF. + ENDIF. + ENDIF. + + ENDMETHOD. "create + + METHOD split_string. + + DATA ls_line LIKE LINE OF rt_lines. + + FIND FIRST OCCURRENCE OF cl_abap_char_utilities=>cr_lf IN iv_string. + + " Convert string into table depending on separator type CR_LF vs. LF + IF sy-subrc = 0. + SPLIT iv_string AT cl_abap_char_utilities=>cr_lf INTO TABLE rt_lines. + ELSE. + SPLIT iv_string AT cl_abap_char_utilities=>newline INTO TABLE rt_lines. + ENDIF. + + ENDMETHOD. "split_string + + METHOD parse_data. + + CONSTANTS: + lc_changelog_version TYPE string + VALUE '^\d{4}-\d{2}-\d{2}\s+v(\d{1,3}\.\d{1,3}\.\d{1,3})\s*$', + lc_internal_version TYPE string + VALUE '^v?(\d{1,3}\.\d{1,3}\.\d{1,3})\s*$'. + + DATA: + lv_first_version_found TYPE abap_bool, + lv_version TYPE string, + lv_current_version TYPE string, + ls_log LIKE LINE OF rt_log. + + FIELD-SYMBOLS: LIKE LINE OF it_lines. + + " Internal program version should be in format "vXXX.XXX.XXX" + FIND FIRST OCCURRENCE OF REGEX lc_internal_version IN iv_version SUBMATCHES lv_current_version. + + IF sy-subrc IS NOT INITIAL. + RETURN. " Internal format of program version is not correct. TODO implement error message + ENDIF. + + LOOP AT it_lines ASSIGNING . + CLEAR: lv_version, ls_log-text, ls_log-important, ls_log-header. + + IF IS INITIAL OR CO ' -='. " Skip empty and technical lines + CONTINUE. + ENDIF. + + " Check if line is a header line + FIND FIRST OCCURRENCE OF REGEX lc_changelog_version IN SUBMATCHES lv_version. + + " Skip entries before first version found + IF lv_first_version_found = abap_false. + IF sy-subrc IS NOT INITIAL. + CONTINUE. + ELSE. + lv_first_version_found = abap_true. + ENDIF. + ENDIF. + + "Skip everything below current version + IF lv_version IS NOT INITIAL + AND lcl_news=>compare_versions( iv_a = lv_version iv_b = lv_current_version ) < 1. + EXIT. + ENDIF. + + " Populate log + IF lv_version IS NOT INITIAL. " Version header + ls_log-version = lv_version. " ... stays for all subsequent non-version lines + ls_log-header = abap_true. + ELSE. " Version line item + FIND FIRST OCCURRENCE OF REGEX '^\s*!' IN . + IF sy-subrc IS INITIAL. + ls_log-important = abap_true. " Change is important + ENDIF. + ENDIF. + + ls_log-text = . + + APPEND ls_log TO rt_log. + ENDLOOP. + + ENDMETHOD. "parse_data + + METHOD has_news. + + rv_boolean = boolc( lines( mt_log ) > 0 ). + + ENDMETHOD. "has_news + + METHOD get_log. + + rt_log = me->mt_log. + + ENDMETHOD. "get_log + + METHOD has_important_news. + + READ TABLE mt_log WITH KEY important = abap_true TRANSPORTING NO FIELDS. + + rv_boolean = boolc( sy-subrc IS INITIAL ). + + ENDMETHOD. "has_important_news + + METHOD compare_versions. + + DATA: + lv_version_a TYPE i, + lv_version_b TYPE i. + + " Convert versions to numeric + lv_version_a = lcl_news=>convert_version_to_numeric( iv_a ). + lv_version_b = lcl_news=>convert_version_to_numeric( iv_b ). + + " Compare versions + IF lv_version_a > lv_version_b. + rv_result = 1. + ELSEIF lv_version_a < lv_version_b. + rv_result = -1. + ELSE. + rv_result = 0. + ENDIF. + + ENDMETHOD. "compare_versions + + METHOD convert_version_to_numeric. + + DATA: lv_major TYPE numc4, + lv_minor TYPE numc4, + lv_release TYPE numc4. + + SPLIT iv_version AT '.' INTO lv_major lv_minor lv_release. + + " Calculated value of version number + rv_version = lv_major * 1000000 + lv_minor * 1000 + lv_release. + + ENDMETHOD. "convert_version_to_numeric + +ENDCLASS. "lcl_news + +*----------------------------------------------------------------------* +* CLASS ltcl_news DEFINITION +*----------------------------------------------------------------------* +* Definition of test class for news announcement +*----------------------------------------------------------------------* +CLASS ltcl_news DEFINITION FINAL + FOR TESTING RISK LEVEL HARMLESS DURATION SHORT. + + PRIVATE SECTION. + + METHODS: + split_string FOR TESTING, + convert_version_to_numeric FOR TESTING, + compare_versions FOR TESTING, + parse_data FOR TESTING. + +ENDCLASS. "ltcl_news DEFINITION + +*----------------------------------------------------------------------* +* CLASS ltcl_news IMPLEMENTATION +*----------------------------------------------------------------------* +* Implementation of test class for news announcement +*----------------------------------------------------------------------* +CLASS ltcl_news IMPLEMENTATION. + + METHOD split_string. + + DATA: lt_act TYPE string_table, + lt_exp TYPE string_table. + + APPEND 'ABC' TO lt_exp. + APPEND '123' TO lt_exp. + + " Case 1. String separated by CRLF + lt_act = lcl_news=>split_string( 'ABC' && cl_abap_char_utilities=>cr_lf && '123' ). + + cl_abap_unit_assert=>assert_equals( exp = lt_exp + act = lt_act + msg = ' Error during string split: CRLF' ). + + CLEAR: lt_act. + + " Case 2. String separated by LF + lt_act = lcl_news=>split_string( 'ABC' && cl_abap_char_utilities=>newline && '123' ). + + cl_abap_unit_assert=>assert_equals( exp = lt_exp + act = lt_act + msg = ' Error during string split: LF' ). + + ENDMETHOD. "split_string. + + METHOD convert_version_to_numeric. + + DATA: lv_version_exp TYPE i VALUE 1023010, + lv_version_act TYPE i. + + lv_version_act = lcl_news=>convert_version_to_numeric( '1.23.10' ). + + cl_abap_unit_assert=>assert_equals( exp = lv_version_exp + act = lv_version_act + msg = ' Error during conversion of version to numeric value' ). + + ENDMETHOD. "convert_version_to_numeric + + METHOD compare_versions. + + DATA lv_result TYPE i. + + " Case 1: version A > version B + lv_result = lcl_news=>compare_versions( iv_a = '1.28.10' iv_b = '1.23.10' ). + + cl_abap_unit_assert=>assert_equals( exp = 1 + act = lv_result + msg = ' Error during comparison of versions. Case: A > B' ). + + CLEAR: lv_result. + + " Case 2: version A < version B + lv_result = lcl_news=>compare_versions( iv_a = '1.28.10' iv_b = '2.23.10' ). + + cl_abap_unit_assert=>assert_equals( exp = -1 + act = lv_result + msg = ' Error during comparison of versions. Case: A < B' ). + + CLEAR: lv_result. + + " Case 3: version A = version B + lv_result = lcl_news=>compare_versions( iv_a = '1.28.10' iv_b = '1.28.10' ). + + cl_abap_unit_assert=>assert_equals( exp = 0 + act = lv_result + msg = ' Error during comparison of versions. Case: A = B' ). + + ENDMETHOD. "compare_versions + + DEFINE _add_news_log_entry. + CLEAR: ls_log. + ls_log-version = &1. + ls_log-header = &2. + ls_log-important = &3. + ls_log-text = &4. + APPEND ls_log TO lt_log_exp. + END-OF-DEFINITION. + + METHOD parse_data. + + DATA: + lt_log_exp TYPE lcl_news=>tt_log, + lt_log_act TYPE lcl_news=>tt_log, + ls_log LIKE LINE OF lt_log_exp, + lt_lines TYPE string_table. + + " Generate test data + APPEND '======' TO lt_lines. + APPEND '------' TO lt_lines. + APPEND ' ' TO lt_lines. + APPEND 'abapGit changelog' TO lt_lines. + APPEND '2017-02-13 v1.28.0' TO lt_lines. + APPEND '------------------' TO lt_lines. + APPEND '+ Staging page redesigned' TO lt_lines. + APPEND '! Support for core data services' TO lt_lines. + APPEND ' ' TO lt_lines. + APPEND '2017-01-25 v1.27.0' TO lt_lines. + APPEND '------------------' TO lt_lines. + APPEND '+ Two factor authentication with github.com' TO lt_lines. + APPEND '2017-01-25 v1.26.0' TO lt_lines. + + " Generate expected results + _add_news_log_entry '1.28.0' 'X' '' '2017-02-13 v1.28.0'. + _add_news_log_entry '1.28.0' '' '' '+ Staging page redesigned'. + _add_news_log_entry '1.28.0' '' 'X' '! Support for core data services'. + _add_news_log_entry '1.27.0' 'X' '' '2017-01-25 v1.27.0'. + _add_news_log_entry '1.27.0' '' '' '+ Two factor authentication with github.com'. + + " Case 1. Test parsing of data + lt_log_act = lcl_news=>parse_data( it_lines = lt_lines iv_version = '1.26.01' ). + + cl_abap_unit_assert=>assert_equals( exp = lt_log_exp + act = lt_log_act + msg = ' Error during parsing: Case 1.' ). + + CLEAR: lt_log_act, lt_log_exp. + + " Case 2. Negative test - format of version is not correct + lt_log_act = lcl_news=>parse_data( it_lines = lt_lines iv_version = 'version.1.27.00' ). + + cl_abap_unit_assert=>assert_equals( exp = lt_log_exp + act = lt_log_act + msg = ' Error during parsing: Case 2.' ). + + ENDMETHOD. "parse_data + +ENDCLASS. "ltcl_news IMPLEMENTATION diff --git a/src/zabapgit_news.prog.xml b/src/zabapgit_news.prog.xml new file mode 100644 index 000000000..753deeb21 --- /dev/null +++ b/src/zabapgit_news.prog.xml @@ -0,0 +1,23 @@ + + + + + + ZABAPGIT_NEWS + A + X + I + K + E + X + + + + R + Include ZABAPGIT_NEWS + 21 + + + + + diff --git a/src/zabapgit_page_main.prog.abap b/src/zabapgit_page_main.prog.abap index 63adfaad4..ab3a39186 100644 --- a/src/zabapgit_page_main.prog.abap +++ b/src/zabapgit_page_main.prog.abap @@ -307,11 +307,31 @@ CLASS lcl_gui_page_main IMPLEMENTATION. METHOD render_repo. + DATA: + lo_news TYPE REF TO lcl_news, + lv_has_news TYPE abap_bool VALUE abap_false. + CREATE OBJECT ro_html. + lo_news = lcl_news=>create( io_repo ). + + IF lo_news IS BOUND. + lv_has_news = lo_news->has_news( ). + ENDIF. + ro_html->add( |
    | ). ro_html->add( lcl_gui_chunk_lib=>render_repo_top( io_repo = io_repo + iv_has_news = lv_has_news iv_interactive_branch = abap_true ) ). + + IF lv_has_news = abap_true. + ro_html->add( lcl_gui_chunk_lib=>render_news_pop_up( + it_log = lo_news->get_log( ) + iv_has_important = lo_news->has_important_news( ) + ) + ). + ENDIF. + ro_html->add( mo_repo_content->render( ) ). ro_html->add( '
    ' ). From 2f680d80a783f36940a25bfb04b1c324f3d1512c Mon Sep 17 00:00:00 2001 From: Bohdan Date: Thu, 2 Mar 2017 11:48:54 +0200 Subject: [PATCH 2/2] fixing of issues, small renamings --- src/zabapgit_css_common.w3mi.data.css | 17 +++++----- src/zabapgit_html_chunks.prog.abap | 48 ++++++++++++++++----------- src/zabapgit_js_common.w3mi.data.js | 6 ++-- src/zabapgit_news.prog.abap | 8 ++--- src/zabapgit_page_main.prog.abap | 18 ++-------- 5 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/zabapgit_css_common.w3mi.data.css b/src/zabapgit_css_common.w3mi.data.css index 4dc2aae0a..fdf25d19e 100644 --- a/src/zabapgit_css_common.w3mi.data.css +++ b/src/zabapgit_css_common.w3mi.data.css @@ -702,9 +702,9 @@ div.tutorial h2 { } /* News Announcement */ -.change-log { +.news { position: absolute; - z-index: 99 !important; + z-index: 99; top: 50%; left: 50%; width: 40em; @@ -715,7 +715,7 @@ div.tutorial h2 { padding: 0.5em; } -.change-log .change-log-title { +.news .title { color: #888888; font-weight: bold; font-size: 16px; @@ -723,21 +723,20 @@ div.tutorial h2 { padding-bottom: 4px; } -.change-log .attention { +.news .attention { background-color: #ff9800; - color: white; - opacity: 0.83; + color: white; padding: 10px; } -.change-log li { +.news li { margin: 4px; padding-left: 10px; font-size: 15px; list-style-type: none; } -.change-log p.versionHeader { +.news p.versionHeader { font-size: 16px; color: #888888; font-weight: bold; @@ -746,4 +745,4 @@ div.tutorial h2 { padding-bottom: 8px; border-bottom: 1px #ddd solid; margin: 4px; -} \ No newline at end of file +} diff --git a/src/zabapgit_html_chunks.prog.abap b/src/zabapgit_html_chunks.prog.abap index 03385b8ff..5db3a7f55 100644 --- a/src/zabapgit_html_chunks.prog.abap +++ b/src/zabapgit_html_chunks.prog.abap @@ -17,8 +17,7 @@ CLASS lcl_gui_chunk_lib DEFINITION FINAL. iv_show_branch TYPE abap_bool DEFAULT abap_true iv_interactive_branch TYPE abap_bool DEFAULT abap_false iv_branch TYPE string OPTIONAL - iv_has_news TYPE abap_bool OPTIONAL - iv_has_important_news TYPE abap_bool OPTIONAL + io_news TYPE REF TO lcl_news OPTIONAL RETURNING VALUE(ro_html) TYPE REF TO lcl_html RAISING lcx_exception. @@ -38,10 +37,9 @@ CLASS lcl_gui_chunk_lib DEFINITION FINAL. RETURNING VALUE(ro_html) TYPE REF TO lcl_html RAISING lcx_exception. - CLASS-METHODS render_news_pop_up + CLASS-METHODS render_news IMPORTING - it_log TYPE lcl_news=>tt_log - iv_has_important TYPE abap_bool + io_news TYPE REF TO lcl_news RETURNING VALUE(ro_html) TYPE REF TO lcl_html RAISING lcx_exception. @@ -81,10 +79,10 @@ CLASS lcl_gui_chunk_lib IMPLEMENTATION. ro_html->add( '' ). - IF iv_has_news = abap_true. - ro_html->add_a( iv_act = 'displayLog()' + IF io_news IS BOUND AND io_news->has_news( ) = abap_true. + ro_html->add_a( iv_act = 'displayNews()' iv_typ = gc_action_type-onclick - iv_txt = lcl_html=>icon( iv_name = 'book/dark' ) ). + iv_txt = lcl_html=>icon( iv_name = 'history/dark' ) ). ENDIF. IF abap_true = lcl_app=>user( )->is_favorite_repo( io_repo->get_key( ) ). @@ -230,40 +228,50 @@ CLASS lcl_gui_chunk_lib IMPLEMENTATION. ro_html->add( '' ). ENDMETHOD. "render_js_error_stub - METHOD render_news_pop_up. + METHOD render_news. + + DATA lt_log TYPE lcl_news=>tt_log. CREATE OBJECT ro_html. - FIELD-SYMBOLS: LIKE LINE OF it_log. + IF io_news IS NOT BOUND. + RETURN. + ELSEIF io_news->has_news( ) = abap_true. + lt_log = io_news->get_log( ). + ELSE. + RETURN. + ENDIF. - ro_html->add( '
    ' ). + FIELD-SYMBOLS: LIKE LINE OF lt_log. + + ro_html->add( '
    ' ). ro_html->add( '' ). - ro_html->add( '' ). ro_html->add( '' ). ro_html->add( '
    ' ). + ro_html->add( '' ). ro_html->add( 'Announcement of the latest changes' ). ro_html->add( '' ). - ro_html->add( 'close' ). + ro_html->add( 'close' ). ro_html->add( '
    ' ). - IF iv_has_important = abap_true. + IF io_news->has_important_news( ) = abap_true. ro_html->add( '
    ' - && '!!! Some changes mentioned in this announcement might be critical !!! ' + && 'Some changes mentioned in this announcement might be critical !' && '
    ' ). ENDIF. - " Generate changelog table - LOOP AT it_log ASSIGNING . + " Generate news + LOOP AT lt_log ASSIGNING . IF -header = 'X'. - ro_html->add( '

    ' && -text && '

    ' ). + ro_html->add( |

    { -text }

    | ). ELSE. - ro_html->add( '
  • ' && -text && '
  • ' ). + ro_html->add( |
  • { -text }
  • | ). ENDIF. ENDLOOP. ro_html->add( '
    ' ). - ENDMETHOD. "render_news_pop_up + ENDMETHOD. "render_news ENDCLASS. "lcl_gui_chunk_lib diff --git a/src/zabapgit_js_common.w3mi.data.js b/src/zabapgit_js_common.w3mi.data.js index d043ce10d..46b48237f 100644 --- a/src/zabapgit_js_common.w3mi.data.js +++ b/src/zabapgit_js_common.w3mi.data.js @@ -369,7 +369,7 @@ StageHelper.prototype.iterateStageTab = function (changeMode, cb /*, ...*/) { **********************************************************/ // News announcement -function displayLog() { - var div = document.getElementById("changeLog"); +function displayNews() { + var div = document.getElementById("news"); div.style.display = (div.style.display)?'':'none'; -} \ No newline at end of file +} diff --git a/src/zabapgit_news.prog.abap b/src/zabapgit_news.prog.abap index 7fac27453..bed394801 100644 --- a/src/zabapgit_news.prog.abap +++ b/src/zabapgit_news.prog.abap @@ -21,8 +21,8 @@ CLASS lcl_news DEFINITION FRIENDS ltcl_news. tt_log TYPE STANDARD TABLE OF ty_log WITH DEFAULT KEY. CONSTANTS: - mc_log_file_path TYPE string VALUE '/', - mc_log_file_name TYPE string VALUE 'changelog.txt'. + c_log_filename TYPE string VALUE '/', + c_log_path TYPE string VALUE 'changelog.txt'. CLASS-METHODS create IMPORTING io_repo TYPE REF TO lcl_repo @@ -96,8 +96,8 @@ CLASS lcl_news IMPLEMENTATION. IF lo_repo_online->get_url( ) CS '/abapGit.git'. lt_remote = io_repo->get_files_remote( ). - READ TABLE lt_remote ASSIGNING WITH KEY path = mc_log_file_path - filename = mc_log_file_name. + READ TABLE lt_remote ASSIGNING WITH KEY path = c_log_filename + filename = c_log_path. IF sy-subrc = 0. CREATE OBJECT ro_instance EXPORTING iv_rawdata = -data diff --git a/src/zabapgit_page_main.prog.abap b/src/zabapgit_page_main.prog.abap index ab3a39186..ff85159e7 100644 --- a/src/zabapgit_page_main.prog.abap +++ b/src/zabapgit_page_main.prog.abap @@ -307,30 +307,18 @@ CLASS lcl_gui_page_main IMPLEMENTATION. METHOD render_repo. - DATA: - lo_news TYPE REF TO lcl_news, - lv_has_news TYPE abap_bool VALUE abap_false. + DATA lo_news TYPE REF TO lcl_news. CREATE OBJECT ro_html. lo_news = lcl_news=>create( io_repo ). - IF lo_news IS BOUND. - lv_has_news = lo_news->has_news( ). - ENDIF. - ro_html->add( |
    | ). ro_html->add( lcl_gui_chunk_lib=>render_repo_top( io_repo = io_repo - iv_has_news = lv_has_news + io_news = lo_news iv_interactive_branch = abap_true ) ). - IF lv_has_news = abap_true. - ro_html->add( lcl_gui_chunk_lib=>render_news_pop_up( - it_log = lo_news->get_log( ) - iv_has_important = lo_news->has_important_news( ) - ) - ). - ENDIF. + ro_html->add( lcl_gui_chunk_lib=>render_news( io_news = lo_news ) ). ro_html->add( mo_repo_content->render( ) ). ro_html->add( '
    ' ).