In case of JS we need to use the below code on ribbon button to show and hide based on access rights:
function canCurrentUserWrite(primaryControl) {
if (!primaryControl) return false;
var privileges = primaryControl.data.entity._privileges;
if (privileges && typeof privileges.canUpdate !== "undefined") {
return privileges.canUpdate;
}
return false;
}