@@ -13,9 +13,7 @@ angular.module("openshiftConsole")
13
13
QuotaService ,
14
14
SecurityCheckService ,
15
15
TaskList ,
16
- ProjectsService ,
17
- gettext ,
18
- gettextCatalog ) {
16
+ ProjectsService ) {
19
17
return {
20
18
restrict : "E" ,
21
19
scope : {
@@ -31,18 +29,10 @@ angular.module("openshiftConsole")
31
29
var getErrorDetails = $filter ( 'getErrorDetails' ) ;
32
30
TaskList . clear ( ) ;
33
31
34
- $scope . $on ( 'no-projects-cannot-create' , function ( ) {
35
- $scope . noProjectsCantCreate = true ;
36
- } ) ;
37
-
38
32
$scope . input = {
39
33
selectedProject : $scope . project
40
34
} ;
41
35
42
- $scope . $watch ( 'input.selectedProject.metadata.name' , function ( ) {
43
- $scope . projectNameTaken = false ;
44
- } ) ;
45
-
46
36
$scope . aceLoaded = function ( editor ) {
47
37
aceEditorSession = editor . getSession ( ) ;
48
38
aceEditorSession . setOption ( 'tabSize' , 2 ) ;
@@ -107,6 +97,17 @@ angular.module("openshiftConsole")
107
97
}
108
98
} ;
109
99
100
+ var createProjectIfNecessary = function ( ) {
101
+ if ( _ . has ( $scope . input . selectedProject , 'metadata.uid' ) ) {
102
+ return $q . when ( $scope . input . selectedProject ) ;
103
+ }
104
+
105
+ var newProjName = $scope . input . selectedProject . metadata . name ;
106
+ var newProjDisplayName = $scope . input . selectedProject . metadata . annotations [ 'new-display-name' ] ;
107
+ var newProjDesc = $filter ( 'description' ) ( $scope . input . selectedProject ) ;
108
+ return ProjectsService . create ( newProjName , newProjDisplayName , newProjDesc ) ;
109
+ } ;
110
+
110
111
$scope . create = function ( ) {
111
112
delete $scope . error ;
112
113
@@ -176,17 +177,14 @@ angular.module("openshiftConsole")
176
177
}
177
178
} ) ;
178
179
} , function ( e ) {
179
- if ( e . data . reason === 'AlreadyExists' ) {
180
- $scope . projectNameTaken = true ;
181
- } else {
182
- NotificationsService . addNotification ( {
183
- id : "import-create-project-error" ,
184
- type : "error" ,
185
- message : "An error occurred creating project." ,
186
- details : getErrorDetails ( e )
187
- } ) ;
188
- }
180
+ NotificationsService . addNotification ( {
181
+ id : "import-create-project-error" ,
182
+ type : "error" ,
183
+ message : "An error occurred creating project" ,
184
+ details : getErrorDetails ( e )
185
+ } ) ;
189
186
} ) ;
187
+
190
188
} ;
191
189
192
190
$scope . cancel = function ( ) {
@@ -288,21 +286,19 @@ angular.module("openshiftConsole")
288
286
if ( $scope . resourceKind === "Template" && $scope . templateOptions . process && ! $scope . errorOccurred ) {
289
287
if ( $scope . isDialog ) {
290
288
$scope . $emit ( 'fileImportedFromYAMLOrJSON' , {
291
- project : $scope . project ,
289
+ project : $scope . input . selectedProject ,
292
290
template : $scope . resource
293
291
} ) ;
294
292
}
295
293
else {
296
- namespace = ( $scope . templateOptions . add || $scope . updateResources . length > 0 ) ? $scope . project . metadata . name : "" ;
297
- path = Navigate . createFromTemplateURL ( $scope . resource , $scope . project . metadata . name , { namespace : namespace } ) ;
294
+ namespace = ( $scope . templateOptions . add || $scope . updateResources . length > 0 ) ? $scope . input . selectedProject . metadata . name : "" ;
295
+ path = Navigate . createFromTemplateURL ( $scope . resource , $scope . input . selectedProject . metadata . name , { namespace : namespace } ) ;
298
296
$location . url ( path ) ;
299
297
}
300
298
}
301
299
else if ( $scope . isDialog ) {
302
300
$scope . $emit ( 'fileImportedFromYAMLOrJSON' , {
303
- project : $scope . input . selectedProject ,
304
- resource : $scope . resource ,
305
- isList : $scope . isList
301
+ project : $scope . input . selectedProject
306
302
} ) ;
307
303
}
308
304
else {
@@ -405,9 +401,9 @@ angular.module("openshiftConsole")
405
401
var displayName = $filter ( 'displayName' ) ;
406
402
function createResourceList ( ) {
407
403
var titles = {
408
- started : gettextCatalog . getString ( gettext ( "Creating resources in project " ) ) + displayName ( $scope . input . selectedProject ) ,
409
- success : gettextCatalog . getString ( gettext ( "Creating resources in project " ) ) + displayName ( $scope . input . selectedProject ) ,
410
- failure : gettextCatalog . getString ( gettext ( "Failed to create some resources in project " ) ) + displayName ( $scope . input . selectedProject )
404
+ started : "Creating resources in project " + displayName ( $scope . input . selectedProject ) ,
405
+ success : "Creating resources in project " + displayName ( $scope . input . selectedProject ) ,
406
+ failure : "Failed to create some resources in project " + displayName ( $scope . input . selectedProject )
411
407
} ;
412
408
var helpLinks = { } ;
413
409
TaskList . add ( titles , helpLinks , $scope . input . selectedProject . metadata . name , function ( ) {
@@ -456,9 +452,9 @@ angular.module("openshiftConsole")
456
452
457
453
function updateResourceList ( ) {
458
454
var titles = {
459
- started : gettextCatalog . getString ( gettext ( "Updating resources in project " ) ) + displayName ( $scope . input . selectedProject ) ,
460
- success : gettextCatalog . getString ( gettext ( "Updated resources in project " ) ) + displayName ( $scope . input . selectedProject ) ,
461
- failure : gettextCatalog . getString ( gettext ( "Failed to update some resources in project " ) ) + displayName ( $scope . input . selectedProject )
455
+ started : "Updating resources in project " + displayName ( $scope . input . selectedProject ) ,
456
+ success : "Updated resources in project " + displayName ( $scope . input . selectedProject ) ,
457
+ failure : "Failed to update some resources in project " + displayName ( $scope . input . selectedProject )
462
458
} ;
463
459
var helpLinks = { } ;
464
460
TaskList . add ( titles , helpLinks , $scope . input . selectedProject . metadata . name , function ( ) {
0 commit comments