Refactor common function

Also allow glyphicons in modal action buttons