Add support for custom error messaging on license page

This commit is contained in:
mabashian
2019-08-30 10:08:13 -04:00
committed by Ryan Petrello
parent 53925f5e98
commit 38a7d62745
4 changed files with 19 additions and 13 deletions

View File

@@ -25,8 +25,8 @@ export default
.then((response) =>{ .then((response) =>{
return response.data; return response.data;
}) })
.catch(() => { .catch(({data}) => {
return $q.reject(); return $q.reject(data);
}); });
}, },

View File

@@ -124,8 +124,7 @@
} }
} }
.License-submit--success, .License-submit--failure{ .License-submit--success, .License-submit--failure {
line-height: 33px;
margin: 0; margin: 0;
} }
.License-file--container { .License-file--container {

View File

@@ -33,7 +33,10 @@ export default
const reset = function() { const reset = function() {
document.getElementById('License-form').reset(); document.getElementById('License-form').reset();
$scope.rhCreds = {}; $scope.newLicense.eula = undefined;
if (!$scope.licenseError) {
$scope.rhCreds = {};
}
}; };
const initVars = (config) => { const initVars = (config) => {
@@ -176,10 +179,10 @@ export default
}, 4000); }, 4000);
} }
}); });
}).catch(() => { }).catch((data) => {
Wait('stop'); Wait('stop');
reset(); reset();
$scope.licenseError = true; $scope.licenseError = data.error;
}); });
}; };
}]; }];

View File

@@ -167,19 +167,23 @@
</span> </span>
<div class="License-analyticsCheckboxGroup"> <div class="License-analyticsCheckboxGroup">
<div class="License-analyticsCheckbox checkbox"> <div class="License-analyticsCheckbox checkbox">
<input type="checkbox" ng-model="newLicense.pendo" ng-disabled="!user_is_superuser" required> <input type="checkbox" ng-model="newLicense.pendo" ng-disabled="!user_is_superuser">
<translate>User analytics: This data is used to enhance future releases of the Tower Software and help streamline customer experience and success.</translate> <translate>User analytics: This data is used to enhance future releases of the Tower Software and help streamline customer experience and success.</translate>
</div> </div>
<div class="License-analyticsCheckbox checkbox"> <div class="License-analyticsCheckbox checkbox">
<input type="checkbox" ng-model="newLicense.insights" ng-disabled="!user_is_superuser" required> <input type="checkbox" ng-model="newLicense.insights" ng-disabled="!user_is_superuser">
<translate>Automation analytics: This data is used to enhance future releases of the Tower Software and to provide Automation Insights to Tower subscribers.</translate> <translate>Automation analytics: This data is used to enhance future releases of the Tower Software and to provide Automation Insights to Tower subscribers.</translate>
</div> </div>
</div> </div>
</div> </div>
<div> <div style="display: flex;flex-direction: row;align-content:flex-end;">
<button ng-click="submit()" class="btn btn-success pull-right" ng-disabled="(!newLicense.file && (!rhCreds.username || !rhCreds.password)) || (newLicense.file && newLicense.file.license_key == null) || newLicense.eula == null || !user_is_superuser" translate>Submit</button> <div style="flex: 1">
<span ng-show="success == true" class="License-greenText License-submit--success pull-right" translate>Save successful!</span> <span ng-show="success == true" class="License-greenText License-submit--success pull-right" translate>Save successful!</span>
<span ng-show="licenseError == true" class="License-redText License-submit--failure pull-right" translate>Invalid License - Save unsuccessful</span> <span ng-show="licenseError" class="License-redText License-submit--failure pull-right" translate>Save unsuccessful - {{licenseError}}</span>
</div>
<div>
<button ng-click="submit()" class="btn btn-success pull-right" ng-disabled="(!newLicense.file && (!rhCreds.username || !rhCreds.password)) || (newLicense.file && newLicense.file.license_key == null) || newLicense.eula == null || !user_is_superuser" translate>Submit</button>
</div>
</div> </div>
</form> </form>
</div> </div>