A U.S. federal judge has dismissed a case against former President Donald Trump for allegedly mishandling top secret documents after he left office.