Merge pull request #2574 from mabashian/2253-pendo-checkbox

Only show pendo checkbox on in license form if license is missing
This commit is contained in:
Michael Abashian 2018-07-19 16:43:24 -04:00 committed by GitHub
commit eb1c1acd5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 44 deletions

View File

@ -9,9 +9,9 @@ import {N_} from "../i18n";
export default
['Wait', '$state', '$scope', '$rootScope',
'ProcessErrors', 'CheckLicense', 'moment','$window',
'ConfigService', 'FeaturesService', 'pendoService', 'i18n', 'config', 'Rest', 'GetBasePath',
'ConfigService', 'FeaturesService', 'pendoService', 'i18n', 'config',
function(Wait, $state, $scope, $rootScope, ProcessErrors, CheckLicense, moment,
$window, ConfigService, FeaturesService, pendoService, i18n, config, Rest, GetBasePath) {
$window, ConfigService, FeaturesService, pendoService, i18n, config) {
const calcDaysRemaining = function(seconds) {
// calculate the number of days remaining on the license
@ -53,21 +53,9 @@ export default
$scope.time.expiresOn = calcExpiresOn($scope.license.license_info.license_date);
$scope.valid = CheckLicense.valid($scope.license.license_info);
$scope.compliant = $scope.license.license_info.compliant;
$scope.newLicense = {};
Rest.setUrl(`${GetBasePath('settings')}ui`);
Rest.get()
.then(({data}) => {
if (data.PENDO_TRACKING_STATE === 'off' && !$rootScope.licenseMissing) {
$scope.newLicense.pendo = false;
} else {
$scope.newLicense.pendo = true;
}
})
.catch(() => {
// default pendo tracking to true when settings is not accessible
$scope.newLicense.pendo = true;
});
$scope.newLicense = {
pendo: true
};
};
init(config);
@ -113,34 +101,33 @@ export default
.then(() => {
reset();
ConfigService.delete();
ConfigService.getConfig()
.then(function(config) {
delete($rootScope.features);
FeaturesService.get();
ConfigService.delete();
ConfigService.getConfig()
.then(function(config) {
delete($rootScope.features);
FeaturesService.get();
if ($scope.newLicense.pendo) {
pendoService.updatePendoTrackingState('detailed');
pendoService.issuePendoIdentity();
} else {
pendoService.updatePendoTrackingState('off');
}
if ($rootScope.licenseMissing === true) {
$state.go('dashboard', {
licenseMissing: false
if ($rootScope.licenseMissing === true) {
if ($scope.newLicense.pendo) {
pendoService.updatePendoTrackingState('detailed');
pendoService.issuePendoIdentity();
} else {
pendoService.updatePendoTrackingState('off');
}
$state.go('dashboard', {
licenseMissing: false
});
} else {
init(config);
$scope.success = true;
$rootScope.licenseMissing = false;
// for animation purposes
const successTimeout = setTimeout(function() {
$scope.success = false;
clearTimeout(successTimeout);
}, 4000);
}
});
} else {
init(config);
$scope.success = true;
$rootScope.licenseMissing = false;
// for animation purposes
const successTimeout = setTimeout(function() {
$scope.success = false;
clearTimeout(successTimeout);
}, 4000);
}
});
});
};
}];

View File

@ -122,7 +122,7 @@
</label>
</div>
</div>
<div class="form-group License-detailsGroup License-detailsGroup--withSeparator">
<div class="form-group License-detailsGroup License-detailsGroup--withSeparator" ng-if="licenseMissing">
<div class="checkbox">
<label class="License-details--label">
<input type="checkbox" ng-model="newLicense.pendo" ng-disabled="!user_is_superuser" required>