Binderhub: Refactor index.js megafile into mutliple files

Created on 25 Jan 2019  路  2Comments  路  Source: jupyterhub/binderhub

To aid with our conversion to React and to ease front-end development on Binder (https://github.com/jupyterhub/binderhub/issues/774), we'll need to refactor the index.js mega file into multiple files with discrete functions. The goal here is to move all the functions into files that will roughly map to React components or library functions in the future.

Steps

  1. Pick one of the tasks in the checklist below.
  2. Move the function/functions into a new file within the src directory.
  3. Add any helper functions or adjust function definitions/body to make it easy for the relocated functions to work independently of jQuery.
  4. Export the necessary and functions and use them in index.js.

Tips

  • Where possible, opt for passing a value into a function as a parameter instead of extracting it within the function body using jQuery selectors.
  • When possible, use functions that are part of standard JS instead of jQuery.
  • If possible, address some of the FIXMEs left in the code if they are small and isolated.
  • Make sure that all functions and variables are in camelCase, the JavaScript function naming convention.

Checklist

Here's a checklist of the functions/components that need to be moved out into separate files. This list isn't complete yet but is enough to get the ball rolling.

  • [x] Move Image class into image.js (https://github.com/jupyterhub/binderhub/pull/776)
  • [ ] Move setUpLog into log.js
  • [ ] Move updateUrls and v2url to url.js
  • [ ] Move getBuildFormValues to form.js. The function should take the jQuery form element as a parameter and extract the individual form fields from the children within.
  • [ ] Move constants in constants.js, export each individually, and import them where needed
  • [x] Move markdownBade and rstBadge functions into badge.js (https://github.com/jupyterhub/binderhub/pull/778)
  • [x] Move getPathType and updatePathText to path.js. (https://github.com/jupyterhub/binderhub/pull/778)
  • [ ] Move updateRepoText to repo.js

cc: @yuvipanda @choldgraf @betatim

Most helpful comment

To be clear - this is before any reactification (reacting? reaction?) happens, right?

Yep. No React-ification. Just moving and refactoring things so it is easier to Reactify down the line.

All 2 comments

To be clear - this is before any reactification (reacting? reaction?) happens, right?

I am so happy we are finally doing this!

To be clear - this is before any reactification (reacting? reaction?) happens, right?

Yep. No React-ification. Just moving and refactoring things so it is easier to Reactify down the line.

Was this page helpful?
0 / 5 - 0 ratings