Dialog windows open conditionally

This, migrated from `base.js`, has some changes.