Whereas Trump mayt be clueless about the Constitution, the idea of barring persons entry is nothing new and is permitted by The Constitution, as per Article I, section 8.
This was followed later by the Chinese Exclusion Act of 1882 (signed off on by President Chester A. Arthur).
Soon after in 1889, The Supreme Court ruled in favor of The power of exclusion and in the 1920s as xenophobia took off, immigration was tightly restricted for those attempting to come from southern and eastern Europe...to mainly curb Jewish infusion into the United States.
Then there was the 10 year Mexican exclusion from 1929 to 1939 and of course it's well known his the Japanese were prohibited entry into the United States, not to mention the forced interment of Japanese, Germans and Italians.
Fast forward to 1952. The Congress acted once more and added new force for them and additionally gave the President the power to block entry of people from any and all countries that the President believed "would be detrimental to the interests of the United States"
President Harry S Truman vetoed this act and stated:
Today we are "protecting" ourselves as we were in 1924, against being flooded by immigrants from Eastern Europe. This is fantastic... We do not need to be protected against immigrants from these countries - on the contrary, we want to stretch out a helping hand, to save those...
Anyway, President Truman's veto was overridden and Senator McCarren ( a Democrat from Nevada), said the reasoning was thus: "the solution of the problems of Europe and Asia will not come through a transplanting of those problems en masse to the United States"
So, the President has an ability to block anyone he darned well pleases, whether we the citizens like it or not.