show loading when performing actions

This also moves the loading logic into a utils so it can be used in other places besides modals.