Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Update rails to version 7.0 #201

Conversation

syphax-bouazzouni
Copy link
Contributor

@syphax-bouazzouni syphax-bouazzouni commented May 31, 2022

Prerequisites

Changes

  • Done rails app:update (a7132a9)
  • Fix the conflicts with rails app:update changes
  • install jsbundling-rails with the esbuild option (1f56d3c)
  • install stimulus js (e7002ec)
  • update the Gemfile to be sync to the rails 7 one (6cc4604)
  • Adapt the new js bundling to work with our old system which was the asset pipeline (a7132a9) (see the details below)
  • Use the JS compressor (87e809e)
  • Use the new SASS compiler (a36924c)

How the new asset pipeline works

The significant change of the rails version is better handling of the javascript and allowing us to use the modern js (ECMAScript 2021). To make this possible this new version comes with esbuild for bundling our js code and stimulus js framework to organize it (and replace all where we can jquery) (see details here #151).

However, our old code will not work directly with this new system. So for some time, I propose to work in a transitional state where our old code will work in parallel with the modern one. The old code will still be in app/assets/javascripts and the modern one will be in the new folder app/javascript

It works like so :

  1. The modern js in app/javascript is compiled and bundled to the app/assets/builds as a regular JS code file.
  2. The bundled modern js code in app/assets/builds will then be added to the existing asset pipeline that we had before in app/assets/javascripts.

What we need to do next (for the js part of our frontend):

  1. Migrate incrementally the old code to the modern JS,
  2. Use package.json to set our dependencies and yarn to install it:
    currently we are using app/assets/javascripts/vendor.js to define our dependencies and the folder vendor/assets/javascripts to store their source code. But nowadays the best is to use a package manager (in our case yarn) to handle it for us. We have also to remove the direct include of dependencies from CDN like those in the `app/views/layouts/_header.html.erb' file :
      <%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js" %>
      <%= javascript_include_tag "//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js" %>
      <%= javascript_include_tag "//unpkg.com/split.js/dist/split.min.js" %>
  3. in the browse page, replace angular.js because it's deprecated and used nowhere else
  4. Think of a better way to handle the app state, and no more use Jquery.data()
      <script>
        jQuery(document).data({bp: {config: <%=bp_config_json.html_safe%>, user: <%=(session[:user] || {}).to_hash.to_json.html_safe%>}});
        jQuery(document).data().bp.ontology = <%=@ontology.to_json.html_safe%> || {};
        jQuery(document).data().bp.submission_latest = <%=@submission_latest.to_json.html_safe%> || {};
        jQuery(document).data().bp.ontolobridge_ontologies = <%=$NEW_TERM_REQUEST_ONTOLOGIES.to_json.html_safe%> || [];
        jQuery(document).data().bp.ont_viewer = {};
        jQuery(document).data().bp.ont_chart = {};
      </script>
  5. Remove the js.erb files because it's no more supported by the this new system (esbuild)
  6. Include and compile the js code after the page load. It will make the page load more fastly and not wait to load all the js code to begin to show the page.

image

@syphax-bouazzouni syphax-bouazzouni changed the title update rails to version 7.0 Refactor: Update rails to version 7.0 Sep 21, 2022
@jvendetti jvendetti self-assigned this Dec 10, 2022
syphax-bouazzouni referenced this pull request in ontoportal/ontoportal_web_ui Mar 24, 2023
* create chips component file

* Add a function to turn spaces into underscores

* Create chips component design file

* CSS for the chips component

* Add recaptcha tags

* Change the meaningless argument "text" by "name" & "value"

* Use the chips component on the feedback page

* Add a component folder for component styles in the styelsheets folder

* Remove chips component style from feedback page css file
syphax-bouazzouni referenced this pull request in ontoportal/ontoportal_web_ui Mar 24, 2023
* merge to "development"

* refactoring

* unsubscribe feat

* remove no more used code

* remove submissions.js.erb

* add unsubscribe

* add and use Loader view component

* [ontoportal-bot] Gemfile.lock update

* Update users_controller.rb

* add tests && refacto

* add switch input view component

* extract submission save and update concerns

* update latest_submission_attributes helper name

* update turbo alerts helpers to have custom id

* update submission from to use SwitchComponent and move out hidden_field

* update admin metadata section style& add show all submissions  switch

* update curator result to implement submissions & show edit_metadata_btn

* update the edit action to add error handling and remove useless code

* add submission inline editable attribute views and action

* update metadata bulk edit form to use turbo modal

* update curator result table style and attribute_inline_editable partial

* update curator "update" to use a concern & handle multiple submissions

* add route to ontologies_metadata_curator#show_metadata_by_ontology

* add ontology_submission_id_label and ontology_and_submission_id helpers

* add tests and refacto

* fix empty chosen not sent in the request

* fix response_success? test when response.status is string

* fix submission form show_sections  value

* on submission save/update permit arrays of hash or values

* Update users_controller.rb

* Update Dockerfile

* fix empty scheme ids show

* fix turbo frame error catching by preventing event

* se turbo config method to use Alertify.confirm

* add remove turbo_stream helper

* update admin submission delete to handle turbo_stream

* make submission edit action use submission Id

* add edit and delete actions to ontology submissions table

* fix response_errors to use response body

* [ontoportal-bot] Gemfile.lock update

* [ontoportal-bot] Gemfile.lock update

* fix a typo in ontologies_metadata_curator

* [ontoportal-bot] Gemfile.lock update

* [ontoportal-bot] Gemfile.lock update

* Revert "Merge branch 'fix/docker' into fix/add-to-our-mailing-list"

This reverts commit 55d8627, reversing
changes made to a0352e8.

* remove duplicated code

* remove unused submission_attributes helper

* update submission_editable_properties  to use equivalent_properties

* display equivalent attributes on display_submission_attributes

* replace equivalent arguments, with equivalent_properties helper

* use equivalent_properties in the metadata curator result

* use the same submission_editable_properties in the curator

* display attrbiute_inline for equivalent_properties

* usen CGI.escape for escaping URIs

* [ontoportal-bot] Gemfile.lock update

* use Chosen for no multiple  select also

* make the select component select an empty value by default

* permit submission array and hash attributes

* add a turbo_frame_tag for format section in the submission form

* remove docker-entrypoint-web file

* disable  workers and threads defaults

* [ontoportal-bot] Gemfile.lock update

* Update docker-compose.yml

* [ontoportal-bot] Gemfile.lock update

* [ontoportal-bot] Gemfile.lock update

* fix escaping URIs issue

* add less to the Dockerfile used by binding.pry

* [ontoportal-bot] Gemfile.lock update

* Add check icon

* Add unescape() function

* [ontoportal-bot] Gemfile.lock update

* [ontoportal-bot] Gemfile.lock update

* Update the design of the feedback page

* catch send exceptions for submission attributes

* make form_group_component asterik configurable

* use the required option from form_group_attribute

* don't collapse sections if new submission

* disable submission form filters if  new submission or error state

* show only required properties if new submissions

* disable filter if create or update submission action

* show backend errors in the submission form

* add ID column for submissions table  if ontology admin

* change submission+ontology ID label to use # instead of / as joiner

* [ontoportal-bot] Gemfile.lock update

* [ontoportal-bot] Gemfile.lock update

* Extract popup message

Extract the popup we're using to show success messages ... to make it reusable

* Update application.css.scss.erb

* delete replacable classes by bootstrap

* Update feedback.html.haml

* Add tags field

* Create notifier.rb

* Add tags (checks)

* Replace fixed colors by variables

* Change the name to card_message

* Update and rename popup_message.scss to card_message.scss

* Update and rename popup_message_component.rb to card_message_component.rb

* Rename the message card component

* Delete app/components/popup_message_component directory

* Update card_message.scss

* Update card_message_component.rb

* Update card_message_component.html.haml

* set ontology viewer section frame target to  top

* disable turbo cache on browser back

* fix ontology_picker_advanced that didn't work on browser back

* Add OntologySubscribeButton component

* move external stimulus controller to application.js

* add subscribe_button helper

* use the subscribe_button component in the user page

* remove old subscribe_ontology_button helper

* remove old subscribeToNotes js code

* remove the bp_ontology_viewer.js file

* remove duplicate code in _submissions.html.haml to toggle the table

* use turbo modal instead of jquery facebox to show the fair score details

* wrap the fair score details pop view in a turbo_frame

* Extract note table line and use turbo modal to show details

* wrap note detail view in a modal turbo_frame

* extract notes table partial

* re-use the notes table partial in the ontology and concept notes views

* add the new_comment action and view

* add new proposal action and view

* add new reply action and view

* update the notes creation action to render streams

* add notes destroy action if portal admin

* add helpers for add_comment, add_proposal and add_reply buttons

* make render_alerts_container use a custom id

* extract reply list and show partials from the thread view

* remove no more used JS code in bp_notes.js

* add route  get 'ontologies/:ontology/notes'

* remove the layout from the notes virtual_show response

* remove the relative link to edit submission

* Feature: Update login page design (#142)

* add new login style

* import the new login style

* update login template

* put colors variables in one globale file

* convert login file from .erb to .haml

* Remove the replaceable classes by bootstrap classes & use css variables instead of fixed values

* import variables file

* Update application.css.scss.erb

* Update application.css.scss.erb

* Update application.css.scss.erb

* Update and rename variables_stage.scss to variables.scss.erb

* Update bioportal.scss

* Update login.scss

* Rename variables.scss.erb to theme-variables.scss.erb

* Update application.css.scss.erb

---------

Co-authored-by: Syphax Bouazzouni <[email protected]>

* Feature: Update lost password page design (#143)

* update login page design

* update the design of lost password page

* update sucess message for password reset

* Update index.html.erb

* Delete login.scss

* Update index.html.erb

* upload arrow-back.svg

* Update lostpassword.scss

* Extract the svg to a file, and convert the file from .erb to .haml

* Use the message card component

* replace fixed colors by variables

* Update lostpassword.scss

* Update lost_password_success.html.haml

* Update lost_password_success.html.haml

* Update lost_password_success.html.haml

---------

Co-authored-by: Syphax Bouazzouni <[email protected]>

* [ontoportal-bot] Gemfile.lock update

* Fix: add user to mailing list on signup (#148)

* update (un)subscribe ui

* Refactor confirmation message and update UI

* Create Sympa mailer with registration and unregistration methods

* Fix subscription logic and add environment example for mailing list

* protect routes

* [ontoportal-bot] Gemfile.lock update

* remove the old reference to subscribe_notes_controller

* Create green-check.svg

* Create red-warning.svg

* Update card_message_component.rb

* Update card_message_component.html.haml

* Update home_controller.rb

* Update feedback.html.haml

* Update and rename feedback_complete.html.erb to feedback_complete.html.haml

* Revert "Add tags field"

This reverts commit 989902d.

* update feedback in the right notifier.rb in mailers not models

* fix feedback popup if location is empty

* remove the old feedback.html.erb file

* remove the auto close of the popup after a timeout

* move the feedback views to home/feedback folder

* reset the portal font

* [ontoportal-bot] Gemfile.lock update

* remove the auto close of the popup after a timeout

* move the feedback views to home/feedback folder

* update switch component to have a boolean version for submissions form

* fix input attribute of type uri getting only the first letter (e.g h)

* don't use response_error? in the admin controller

* update $DATA_CATALOG_VALUES variables values

* update how data_catalog is found

* add display=all parameter to access concept json link

* show ontology pull url in summary page if ontology admin

* remove the option None for all the submission from select attribute

* extract ontology_restricted? helper

* remove unused code in the  ontology 'show' action

* remove no more needed code in the ontology 'summary' action

* add submission index action

* move partial 'submission' to a turbo_frame

* use @submission_latest instead of @Submissions.first to get the latest

* add submission index action route

* don't show Download latest version if no submission latest

* [ontoportal-bot] Gemfile.lock update

* add newrelic configs for ui app

* remove unused stages

* fix typo issue of writing '=' in the statement end where it's not needed

* Remove no title value of the message card component  (#197)

* Feature: Add Newrelic configuration file  (#198)

* [ontoportal-bot] Gemfile.lock update

* add newrelic configs for ui app

* remove unused stages

* fix typo issue of writing '=' in the statement end where it's not needed

---------

Co-authored-by: OntoPortal Bot <[email protected]>
Co-authored-by: HADDAD Zineddine <[email protected]>

* [ontoportal-bot] Gemfile.lock update

* install newrelic_rpm also in :appliance stage

* Revert "Merge pull request #119 from ontoportal-lirmm/fix/browse-search-length-problem"

This reverts commit 0ad14c3.

* extract metadata table row partial

* make the bulk update refresh the table in the background

* remove the single update option in the bulk popup

* add a help text for the bulk edit button

* fix ontology advancer filter not working in admin because to triggered

* update submission_properties list to include them all

* [ontoportal-bot] Gemfile.lock update

* Feature: Update the style of the mailing list section in the account page  (#202)

* Feature: Extract chips component (#181)

* create chips component file

* Add a function to turn spaces into underscores

* Create chips component design file

* CSS for the chips component

* Change the meaningless argument "text" by "name" & "value"

* Add a component folder for component styles in the styelsheets folder

* Feature: Feedback page uses chips component (#201)

* create chips component file

* Add a function to turn spaces into underscores

* Create chips component design file

* CSS for the chips component

* Add recaptcha tags

* Change the meaningless argument "text" by "name" & "value"

* Use the chips component on the feedback page

* Add a component folder for component styles in the styelsheets folder

* Remove chips component style from feedback page css file

* Feature: Update register template  (#144)

* update login page design

* update the design of lost password page

* update sucess message for password reset

* update register page design

* Delete login.scss

* Delete lostpassword.scss

* Update index.html.erb

* Delete lost_password_success.html.erb

* Update index.html.erb

* Update lost_password.html.erb

* Update routes.rb

* Update index.html.erb

* Update register.scss

* Delete _form.html.erb

* Update _form.html.haml

* Update login_controller.rb

* Add code to remove auto added arrows from number_text_field

* Add the two fields (OrcidID & github)

* Add subscription to mailing list

* Update index.html.erb

* Update _form.html.haml

* Add captacha tag

* Update _form.html.haml

* Add github icon

* Add orcide icon

* Fix recaptacha tags (add "=")

* replace "ORCIDE" by "ORCID"

* Change ORCID ID  input type from 'number' to ‘text’

* Extract orcidId & githubId from URLs

* Extract arrow-back.svg file

* Fix extract id from link

* Resolve conflicts with developement branch

* remove import browse

---------

Co-authored-by: Syphax bouazzouni <[email protected]>

* convert the feedback file from erb to haml

---------

Co-authored-by: HADDAD Zineddine <[email protected]>
Co-authored-by: OntoPortal Bot <[email protected]>
Co-authored-by: Bilelkihal <[email protected]>
@jvendetti jvendetti mentioned this pull request Nov 30, 2023
@jvendetti
Copy link
Member

Thanks for the pull request @syphax-bouazzouni. I had a need to break the upgrade into a couple of smaller chunks in our production environment. I'd like to close this request now unless you have objections?

In terms of the future work that you detailed in "What we need to do next (for the js part of our frontend)", I'd prefer to enter a handful of issues so that we can track each of the points separately. Objections?

@syphax-bouazzouni
Copy link
Contributor Author

Thanks for the pull request @syphax-bouazzouni. I had a need to break the upgrade into a couple of smaller chunks in our production environment. I'd like to close this request now unless you have objections?

In terms of the future work that you detailed in "What we need to do next (for the js part of our frontend)", I'd prefer to enter a handful of issues so that we can track each of the points separately. Objections?

Hello 👋 , Yes fine by me. I saw your release, good work on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants