This action appears only in the context menu, and context menus are inherently contextual: they should only show things relevant to what was right-clicked. Therefore it never makes sense to have disabled items in a context menu; they should be hidden instead.
This commit does that for the Undo action, only showing it in the context menu when it is contextually relevant.
The desktop context menu now has one less item in it by default. Obviously the undo action will appear when relevant, but at all other times it will be hidden, like so: