Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Brunch was used to create the application skeleton for Ambari Web.
  • Brunch builds and deploys code automatically in the background as you modify the source files. This lets you break up the application into a number of JS files for code organization and reuse without worrying about development turnaround or runtime load performance.
  • Easily run unit tests
  • Run a Node.js-based web server with a single command so that you can easily run the application from the application root directory without any special configuration.

...

The above runs Ambari Web at localhost:3333. The login/password is admin/admin

  • Recommended IDE: PhpStorm

All front-end developers are highly recommended to use PhpStorm by JetBrains. JetBrains has kindly granted all contributors of Apache Ambari a free an open-source license for PhpStorm and IntelliJ (if you also need to do Java development - IntelliJ is a superset of PhpStorm, but PhpStorm is lighter so it is recommended if you are not modifying Java code).  You can also use Eclipse if that is your preference. 

  • IDE Plugins

Go to Preferences->Plugins->Browse repositories and install “Node.js” and “Handlebars” plugins.

...

  • We use 2 spaces instead of 4.
  • Variable Declarations:
    “It is preferred that each variable be given its own line and comment. They should be listed in alphabetical order.”
    Comment only where it makes sense. - No need to do alphabetical sorting.
  • “JavaScript does not have block scope, so defining variables in blocks can confuse programmers who are experienced with other C family languages. Define all variables at the top of the function.” - This does not need to be followed.

Unit

...

Tests

All patches must be accompanied by unit tests ensuring good coverage.  When unit tests are not applicable (e.g., stylistic or layout changes, etc.), you must explicitly state in the JIRA that unit tests are not applicable.

Unit tests are written using Mocha and run with the PhantomJS headless browser.
To set your environment up for unit testing, run:

...

Run unit tests via:

Code Block
cd ambari-web
# In terminal 1
brunch w -s # In different terminal
# In terminal 2
mocha-phantomjs public/test/test.html

...