Move all common functionality to modal component