Merge pull request #2286 from overleaf/jel-institution-email-primary-tooltip

Tooltip for "Make Primary" for SSO emails

GitOrigin-RevId: 443cd032d4275ba486a632e92104299997c71bbc
This commit is contained in:
Eric Mc Sween 2019-10-28 10:05:29 -04:00 committed by sharelatex
parent 9afb911b89
commit 44ba0895fe
2 changed files with 32 additions and 12 deletions

View file

@ -1,6 +1,17 @@
mixin aboutInstitutionLink() mixin aboutInstitutionLink()
a(href="/") #{translate("find_out_more_about_institution_login")}. a(href="/") #{translate("find_out_more_about_institution_login")}.
mixin btnMakePrimaryDisabled(tooltip)
div(
tooltip=tooltip
tooltip-enable="!ui.isMakingRequest"
ng-if="!userEmail.default && (!userEmail.confirmedAt || ui.isMakingRequest) && !institutionAlreadyLinked(userEmail)"
)
button.btn.btn-sm.btn-success.affiliations-table-inline-action(
disabled
type="button"
) #{translate("make_primary")}
form.row( form.row(
ng-controller="UserAffiliationsController" ng-controller="UserAffiliationsController"
name="affiliationsForm" name="affiliationsForm"
@ -73,15 +84,10 @@ form.row(
td.affiliations-table-inline-actions td.affiliations-table-inline-actions
// Disabled buttons don't work with tooltips, due to pointer-events: none, // Disabled buttons don't work with tooltips, due to pointer-events: none,
// so create a wrapper for the tooltip // so create a wrapper for the tooltip
div.affiliations-table-inline-action-disabled-wrapper( .affiliations-table-inline-action-disabled-wrapper(ng-if="showInstitutionTooltip(userEmail)")
tooltip=translate("please_confirm_your_email_before_making_it_default") +btnMakePrimaryDisabled("Please confirm your email by linking to your institutional account before making it the primary email.")
tooltip-enable="!ui.isMakingRequest" .affiliations-table-inline-action-disabled-wrapper(ng-if="!showInstitutionTooltip(userEmail)")
ng-if="!userEmail.default && (!userEmail.confirmedAt || ui.isMakingRequest) && !institutionAlreadyLinked(userEmail)" +btnMakePrimaryDisabled(translate("please_confirm_your_email_before_making_it_default"))
)
button.btn.btn-sm.btn-success.affiliations-table-inline-action(
disabled
type="button"
) #{translate("make_primary")}
button.btn.btn-sm.btn-success.affiliations-table-inline-action( button.btn.btn-sm.btn-success.affiliations-table-inline-action(
tooltip=translate("make_email_primary_description") tooltip=translate("make_email_primary_description")
ng-if="!userEmail.default && (userEmail.confirmedAt && !ui.isMakingRequest)" ng-if="!userEmail.default && (userEmail.confirmedAt && !ui.isMakingRequest)"

View file

@ -30,15 +30,29 @@ define(['base'], App =>
} }
$scope.hasSamlBeta = ExposedSettings.hasSamlBeta $scope.hasSamlBeta = ExposedSettings.hasSamlBeta
$scope.hasSamlFeature = ExposedSettings.hasSamlFeature $scope.hasSamlFeature = ExposedSettings.hasSamlFeature
$scope.canUseSamlFeature = $scope.hasSamlFeature || $scope.hasSamlBeta
$scope.samlInitPath = ExposedSettings.samlInitPath $scope.samlInitPath = ExposedSettings.samlInitPath
$scope.showInstitutionTooltip = emailData => {
if (!emailData.affiliation || !$scope.canUseSamlFeature) {
return false
}
if (
emailData.affiliation.institution &&
emailData.affiliation.institution.ssoEnabled
) {
return true
}
return false
}
$scope.shouldShowRolesAndAddEmailButton = () => { $scope.shouldShowRolesAndAddEmailButton = () => {
const newAffiliation = $scope.newAffiliation const newAffiliation = $scope.newAffiliation
const hasSamlFeature = $scope.hasSamlFeature || $scope.hasSamlBeta
return ( return (
!newAffiliation || !newAffiliation ||
(newAffiliation && !newAffiliation.university) || (newAffiliation && !newAffiliation.university) ||
(!hasSamlFeature && newAffiliation && newAffiliation.university) || (!$scope.canUseSamlFeature &&
(hasSamlFeature && newAffiliation &&
newAffiliation.university) ||
($scope.canUseSamlFeature &&
newAffiliation && newAffiliation &&
newAffiliation.university && newAffiliation.university &&
!newAffiliation.university.ssoEnabled) !newAffiliation.university.ssoEnabled)