Skip to content

Commit 2a40ced

Browse files
committed
fix bug with factory's config updating
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
1 parent 42f1619 commit 2a40ced

2 files changed

Lines changed: 36 additions & 26 deletions

File tree

dashboard/src/app/factories/factory-details/information-tab/factory-information/factory-information.controller.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,26 +144,29 @@ export class FactoryInformationController {
144144
* Update factory name.
145145
*
146146
* @param {string} name new factory name.
147-
* @raram {ng.IFormController} form
148147
*/
149-
updateName(name: string, form: ng.IFormController): void {
150-
if (form.$invalid) {
151-
return;
152-
}
153-
148+
updateFactoryName(name: string): void {
154149
this.copyOriginFactory.name = name;
150+
this.updateFactory();
151+
}
155152

156-
this.updateFactory(form);
153+
/**
154+
* Update workspace name.
155+
*
156+
* @param {string} name new workspace name.
157+
*/
158+
updateWorkspaceName(name: string): void {
159+
this.copyOriginFactory.workspace.name = name;
160+
this.updateFactory();
157161
}
158162

159163
/**
160-
* Update factory data.
161-
* @param {ng.IFormController} form
164+
* Save factory data.
162165
*/
163-
updateFactory(form: ng.IFormController): void {
166+
updateFactory(): void {
164167
this.factoryContent = this.$filter('json')(this.copyOriginFactory);
165168

166-
if (form.$invalid || !this.isFactoryChanged()) {
169+
if (this.factoryInformationForm.$invalid || !this.isFactoryChanged()) {
167170
return;
168171
}
169172

dashboard/src/app/factories/factory-details/information-tab/factory-information/factory-information.html

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@
1010
Red Hat, Inc. - initial API and implementation
1111
1212
-->
13-
<div class="factory-information" ng-if="factoryInformationController.copyOriginFactory">
13+
<div class="factory-information"
14+
ng-if="factoryInformationController.copyOriginFactory">
1415
<!-- Name -->
1516
<che-label-container che-label-name="Name">
1617
<div layout="column" class="factory-information-input">
17-
<ng-form name="factoryInformationForm">
18+
<ng-form name="factoryInformationController.factoryInformationForm">
1819
<che-input che-form="factoryInformationForm"
1920
che-name="name"
2021
che-place-holder="Name of the factory"
2122
aria-label="Name of the factory"
2223
ng-model="factoryInformationController.copyOriginFactory.name"
23-
ng-change="factoryInformationController.updateName($value, factoryInformationForm)"
24+
ng-change="factoryInformationController.updateFactoryName($value)"
25+
ng-model-options="{ allowInvalid: true }"
2426
ng-trim
2527
ng-minlength="3"
2628
ng-maxlength="20"
@@ -75,27 +77,31 @@
7577
<md-radio-button value="from-stack">Configure recipe from a stack</md-radio-button>
7678
</md-radio-group>
7779
<div ng-if="factoryInformationController.stackRecipeMode === 'from-stack'">
78-
<workspace-select-stack workspace-stack-on-change="factoryInformationController.onWorkspaceStackChanged(config, stackId)"
79-
workspace-name="factoryInformationController.workspaceName"
80-
environment-name="factoryInformationController.environmentName"
81-
workspace-imported-recipe="factoryInformationController.workspaceImportedRecipe"></workspace-select-stack>
82-
<che-button-primary che-button-title="Save" class="save-stack-button"
83-
ng-click="factoryInformationController.saveStack()"></che-button-primary>
80+
<ng-form name="factoryInformationController.factoryInformationForm">
81+
<workspace-select-stack workspace-stack-on-change="factoryInformationController.onWorkspaceStackChanged(config, stackId)"
82+
workspace-name="factoryInformationController.workspaceName"
83+
environment-name="factoryInformationController.environmentName"
84+
workspace-imported-recipe="factoryInformationController.workspaceImportedRecipe"></workspace-select-stack>
85+
<che-button-primary che-button-title="Save" class="save-stack-button"
86+
ng-click="factoryInformationController.saveStack()"></che-button-primary>
87+
</ng-form>
8488
</div>
8589
</che-label-container>
8690

8791
<che-label-container che-label-name="Workspace"
8892
che-label-description="A workspace contains projects and runtime environments.">
93+
8994
<!--Workspace name-->
9095
<che-label-container che-label-name="Name">
91-
<ng-form name="factoryInformationForm">
96+
<ng-form name="factoryInformationController.factoryInformationForm">
9297
<div class="factory-information-input">
9398
<che-input che-form="factoryInformationForm"
9499
che-name="name"
95100
che-place-holder="Name of the workspace"
96101
aria-label="Name of the workspace"
97102
ng-model="factoryInformationController.copyOriginFactory.workspace.name"
98-
ng-change="factoryInformationController.updateFactory(factoryInformationForm)"
103+
ng-change="factoryInformationController.updateWorkspaceName($value)"
104+
ng-model-options="{ allowInvalid: true }"
99105
required
100106
ng-minlength="3"
101107
ng-maxlength="20"
@@ -111,9 +117,10 @@
111117
</div>
112118
</ng-form>
113119
</che-label-container>
120+
114121
<!--Workspace RAM-->
115122
<che-label-container che-label-name="RAM">
116-
<ng-form name="factoryInformationForm">
123+
<ng-form name="factoryInformationController.factoryInformationForm">
117124
<div data-ng-repeat="(environmentKey, environmentValue) in factoryInformationController.copyOriginFactory.workspace.environments">
118125
<span ng-if="factoryInformationController.getObjectKeys(factoryInformationController.copyOriginFactory.workspace.environments).length > 1"
119126
class="workspace-environment-name">ENVIRONMENT: {{environmentKey}}</span>
@@ -124,7 +131,7 @@
124131
<span ng-if="factoryInformationController.getObjectKeys(environmentValue.machines).length > 1">MACHINE: {{machineKey}}</span>
125132
<che-workspace-ram-allocation-slider
126133
ng-model="machineValue.attributes.memoryLimitBytes"
127-
che-on-change="factoryInformationController.updateFactory(factoryInformationForm)"></che-workspace-ram-allocation-slider>
134+
che-on-change="factoryInformationController.updateFactory()"></che-workspace-ram-allocation-slider>
128135
</div>
129136
</div>
130137
</div>
@@ -137,7 +144,7 @@
137144
<che-label-container che-label-name="Configure Commands"
138145
che-label-description="Commands are processes that are invoked by users from a dropdown in the IDE.">
139146
<cdvy-factory-command cdvy-factory-object="factoryInformationController.copyOriginFactory"
140-
cdvy-on-change="factoryInformationController.updateFactory(factoryInformationForm)"></cdvy-factory-command>
147+
cdvy-on-change="factoryInformationController.updateFactory()"></cdvy-factory-command>
141148
</che-label-container>
142149

143150
<!-- Configure actions -->
@@ -152,7 +159,7 @@
152159
<cdvy-factory-action-box cdvy-lifecycle="onProjectsLoaded"
153160
cdvy-callback-controller="factoryInformationController"
154161
cdvy-factory-object="factoryInformationController.copyOriginFactory"
155-
cdvy-on-change="factoryInformationController.updateFactory(factoryInformationForm)"></cdvy-factory-action-box>
162+
cdvy-on-change="factoryInformationController.updateFactory()"></cdvy-factory-action-box>
156163
</che-label-container>
157164

158165
<!-- Configuration -->

0 commit comments

Comments
 (0)