mirror of https://github.com/portainer/portainer
feat(oauth): update configuration override UX
parent
4a5fa211a7
commit
6711e6c969
|
@ -11,6 +11,7 @@ angular.module('portainer.extensions.oauth')
|
||||||
this.$onInit = onInit;
|
this.$onInit = onInit;
|
||||||
this.onSelectProvider = onSelectProvider;
|
this.onSelectProvider = onSelectProvider;
|
||||||
this.onMicrosoftTenantIDChange = onMicrosoftTenantIDChange;
|
this.onMicrosoftTenantIDChange = onMicrosoftTenantIDChange;
|
||||||
|
this.resetProviderConfiguration = resetProviderConfiguration;
|
||||||
|
|
||||||
function onMicrosoftTenantIDChange() {
|
function onMicrosoftTenantIDChange() {
|
||||||
var tenantID = ctrl.state.microsoftTenantID;
|
var tenantID = ctrl.state.microsoftTenantID;
|
||||||
|
@ -20,13 +21,25 @@ angular.module('portainer.extensions.oauth')
|
||||||
ctrl.settings.ResourceURI = _.replace('https://graph.windows.net/TENANT_ID/me?api-version=2013-11-08', 'TENANT_ID', tenantID);
|
ctrl.settings.ResourceURI = _.replace('https://graph.windows.net/TENANT_ID/me?api-version=2013-11-08', 'TENANT_ID', tenantID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetProviderConfiguration() {
|
||||||
|
ctrl.settings.AuthorizationURI = ctrl.state.provider.authUrl;
|
||||||
|
ctrl.settings.AccessTokenURI = ctrl.state.provider.accessTokenUrl;
|
||||||
|
ctrl.settings.ResourceURI = ctrl.state.provider.resourceUrl;
|
||||||
|
ctrl.settings.UserIdentifier = ctrl.state.provider.userIdentifier;
|
||||||
|
ctrl.settings.Scopes = ctrl.state.provider.scopes;
|
||||||
|
|
||||||
|
if (ctrl.state.provider.name === 'microsoft' && ctrl.state.microsoftTenantID !== '') {
|
||||||
|
onMicrosoftTenantIDChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onSelectProvider(provider) {
|
function onSelectProvider(provider) {
|
||||||
ctrl.state.provider = provider;
|
ctrl.state.provider = provider;
|
||||||
ctrl.settings.AuthorizationURI = provider.authUrl;
|
ctrl.settings.AuthorizationURI = ctrl.settings.AuthorizationURI === '' ? provider.authUrl : ctrl.settings.AuthorizationURI;
|
||||||
ctrl.settings.AccessTokenURI = provider.accessTokenUrl;
|
ctrl.settings.AccessTokenURI = ctrl.settings.AccessTokenURI === '' ? provider.accessTokenUrl : ctrl.settings.AccessTokenURI;
|
||||||
ctrl.settings.ResourceURI = provider.resourceUrl;
|
ctrl.settings.ResourceURI = ctrl.settings.ResourceURI === '' ? provider.resourceUrl : ctrl.settings.ResourceURI;
|
||||||
ctrl.settings.UserIdentifier = provider.userIdentifier;
|
ctrl.settings.UserIdentifier = ctrl.settings.UserIdentifier === '' ? provider.userIdentifier : ctrl.settings.UserIdentifier;
|
||||||
ctrl.settings.Scopes = provider.scopes;
|
ctrl.settings.Scopes = ctrl.settings.Scopes === '' ? provider.scopes : ctrl.settings.Scopes;
|
||||||
|
|
||||||
if (provider.name === 'microsoft' && ctrl.state.microsoftTenantID !== '') {
|
if (provider.name === 'microsoft' && ctrl.state.microsoftTenantID !== '') {
|
||||||
onMicrosoftTenantIDChange();
|
onMicrosoftTenantIDChange();
|
||||||
|
|
|
@ -205,9 +205,9 @@
|
||||||
<div class="form-group" ng-if="$ctrl.state.provider.name != 'custom'">
|
<div class="form-group" ng-if="$ctrl.state.provider.name != 'custom'">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<a class="small interactive" ng-if="!$ctrl.state.overrideConfiguration" ng-click="$ctrl.state.overrideConfiguration = true;">
|
<a class="small interactive" ng-if="!$ctrl.state.overrideConfiguration" ng-click="$ctrl.state.overrideConfiguration = true;">
|
||||||
<i class="fa fa-wrench space-right" aria-hidden="true"></i> Override configuration
|
<i class="fa fa-wrench space-right" aria-hidden="true"></i> Override default configuration
|
||||||
</a>
|
</a>
|
||||||
<a class="small interactive" ng-if="$ctrl.state.overrideConfiguration" ng-click="$ctrl.state.overrideConfiguration = false;">
|
<a class="small interactive" ng-if="$ctrl.state.overrideConfiguration" ng-click="$ctrl.state.overrideConfiguration = false; $ctrl.resetProviderConfiguration()">
|
||||||
<i class="fa fa-cogs space-right" aria-hidden="true"></i> Use default configuration
|
<i class="fa fa-cogs space-right" aria-hidden="true"></i> Use default configuration
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue