Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Commit

Permalink
feat(api): Context-path can be changed by primary_owner or administra…
Browse files Browse the repository at this point in the history
…tor only (#204)

Ref: gravitee-io/issues#203
  • Loading branch information
brasseld authored and NicolasGeraud committed Sep 1, 2016
1 parent 25f3561 commit dfb69cc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/api/admin/general/apiGeneral.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/
class ApiAdminController {
constructor(ApiService, NotificationService, $scope, $mdDialog, $mdEditDialog, $rootScope, resolvedApi, base64, $state) {
constructor(ApiService, NotificationService, UserService, $scope, $mdDialog, $mdEditDialog, $rootScope, resolvedApi, base64, $state) {
'ngInject';
this.ApiService = ApiService;
this.NotificationService = NotificationService;
this.UserService = UserService;
this.$scope = $scope;
this.$rootScope = $rootScope;
this.$mdEditDialog = $mdEditDialog;
Expand Down Expand Up @@ -80,6 +81,9 @@ class ApiAdminController {
}
}

// Context-path editable
this.contextPathEditable = (this.api.permission === 'primary_owner') || this.UserService.isUserInRoles(['ADMIN']);

var self = this;
this.$scope.$on("apiChangeSucceed", function () {
self.initialApi = _.cloneDeep(self.$scope.$parent.apiCtrl.api);
Expand Down
4 changes: 3 additions & 1 deletion src/app/api/admin/general/apiGeneral.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
<div layout-gt-sm="row">
<md-input-container class="md-block" flex-gt-sm>
<label>Gateway context path *</label>
<input ng-model="generalCtrl.api.proxy.context_path" type="text" ng-pattern="/^\/[\/.a-zA-Z0-9-]+$/" required>
<input ng-model="generalCtrl.api.proxy.context_path" type="text"
ng-pattern="/^\/[\/.a-zA-Z0-9-]+$/" ng-disabled="!generalCtrl.contextPathEditable"
required>
</md-input-container>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ function DialogApiPermissionsHelpController($scope, $mdDialog) {
"user": false,
"owner": true,
"primary_owner": true
},{
"action": "Change context-path",
"anyone": false,
"user": false,
"owner": false,
"primary_owner": true
},
{
"action": "Delete API",
Expand Down

0 comments on commit dfb69cc

Please sign in to comment.