@@ -125,6 +125,57 @@ angular.module('openshiftConsole')
125
125
return displayName ;
126
126
} ;
127
127
} )
128
+ . filter ( 'canI' , function ( AuthorizationService ) {
129
+ return function ( resource , verb ) {
130
+ return AuthorizationService . canI ( resource , verb ) ;
131
+ } ;
132
+ } )
133
+ . filter ( 'canIDoAny' , function ( canIFilter ) {
134
+ var resourceRulesMap = {
135
+ "buildConfig" : { "buildconfigs" : [ "delete" , "update" ] , "buildconfigs/instantiate" : [ "create" ] } ,
136
+ "build" : { "builds/clone" : [ "create" ] , "builds" : [ "create" , "update" ] } ,
137
+ "deploymentConfig" : { "horizontalpodautoscalers" : [ "create" , "update" ] , "deploymentconfigs" : [ "create" , "update" ] } ,
138
+ "deployment" : { "replicationcontrollers" : [ "update" , "delete" ] } ,
139
+ "imageStream" : { "imagestreams" : [ "update" , "delete" ] } ,
140
+ "persistentVolumeClaim" : { "persistentvolumeclaims" : [ "update" , "delete" ] } ,
141
+ "pod" : { "pods" : [ "update" , "delete" ] , "deploymentconfigs" : [ "update" ] } ,
142
+ "replicationController" : { "horizontalpodautoscalers" : [ "create" , "update" ] , "replicationcontrollers" : [ "create" , "update" ] } ,
143
+ "route" : { "routes" : [ "update" , "delete" ] } ,
144
+ "service" : { "services" : [ "update" , "create" , "delete" ] } ,
145
+ "project" : { 'projects' : [ 'delete' , 'update' ] } ,
146
+ "configmaps" : { "configmaps" : [ 'delete' , 'update' ] } ,
147
+ "endpoints" : { "endpoints" : [ 'delete' , 'update' ] } ,
148
+ "horizontalpodautoscalers" : { "horizontalpodautoscalers" : [ 'delete' , 'update' ] } ,
149
+ "jobs" : { "jobs" : [ 'delete' , 'update' ] }
150
+ }
151
+ return function ( resource ) {
152
+ var canIDoAny = false ;
153
+ _ . each ( resourceRulesMap [ resource ] , function ( verbs , resource ) {
154
+ _ . each ( verbs , function ( verb ) {
155
+ canIDoAny = canIFilter ( resource , verb ) ;
156
+ } ) ;
157
+ } ) ;
158
+ return canIDoAny ;
159
+ } ;
160
+ } )
161
+ . filter ( 'canIScale' , function ( canIFilter ) {
162
+ return function ( deploymentConfig ) {
163
+ var canIScale = false ;
164
+ if ( deploymentConfig ) {
165
+ canIScale = canIFilter ( "deploymentconfigs/scale" , "update" ) ;
166
+ } else {
167
+ canIScale = canIFilter ( "replicationcontrollers" , "update" ) ;
168
+ }
169
+ return canIScale ;
170
+ } ;
171
+ } )
172
+ // .filter('canInamespaced', function(AuthorizationService) {
173
+ // var canI = false;
174
+
175
+ // return function(resource, verb, namespace) {
176
+ // return AuthorizationService.canINamespaced(resource, verb, namespace);
177
+ // };
178
+ // })
128
179
. filter ( 'tags' , function ( annotationFilter ) {
129
180
return function ( resource , /* optional */ annotationKey ) {
130
181
annotationKey = annotationKey || "tags" ;
0 commit comments