factor out logic to open panel