Yes is compatible on the Edgrouter. Not tested on the Edgeswitch, but Ubiquiti is less problematic with third-party SFPs than others (e.g. Cisco). Keep in mind that if you use a BiDi SFP, the other side must not be the same SFP (here TP-Link TL-SM321A). If you have more than one single-mode fibre available, you can also use a standard duplex SFP.
According to the manufacturer, the following SFP+ modules are compatible: https://help.ui.com/hc... https://help.ui.com/hc... The TL-SM321B is not on the list - which doesn't necessarily mean that it doesn't work, but then there is probably no support from Ubiquiti if something doesn't work perfectly.