Move some duplicate logic into a base view.