Skip to content

Commit 17aa7bb

Browse files
author
Oleksii Orel
committed
Merge pull request eclipse-che#617 from eclipse/CHE-212
Che 212 disable field auto completion after its adjustments
2 parents dc1eeb6 + ea2d61e commit 17aa7bb

4 files changed

Lines changed: 320 additions & 292 deletions

File tree

dashboard/src/app/projects/create-project/create-project.controller.js

Lines changed: 65 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -174,30 +174,12 @@ export class CreateProjectCtrl {
174174
}
175175
});
176176

177-
this.isChangeableName = true;
178-
this.isChangeableDescription = true;
179-
180-
$scope.$watch('createProjectCtrl.importProjectData.project.name', (newProjectName) => {
181-
182-
if (newProjectName === '') {
183-
return;
184-
}
185-
186-
if (!this.isChangeableName) {
187-
return;
188-
}
189-
this.projectName = newProjectName;
190-
});
191-
$scope.$watch('createProjectCtrl.importProjectData.project.description', (newProjectDescription) => {
192-
if (!this.isChangeableDescription) {
193-
return;
194-
}
195-
this.projectDescription = newProjectDescription;
196-
});
197-
198177
// channels on which we will subscribe on the workspace bus websocket
199178
this.listeningChannels = [];
200179

180+
this.projectName = null;
181+
this.projectDescription = null;
182+
this.defaultWorkspaceName = null;
201183
}
202184

203185

@@ -217,28 +199,6 @@ export class CreateProjectCtrl {
217199
};
218200
}
219201

220-
/**
221-
* Check changeable status for project name field
222-
*/
223-
checkChangeableNameStatus() {
224-
if ('config' === this.currentTab) {
225-
this.importProjectData.project.name = angular.copy(this.projectName);
226-
return;
227-
}
228-
this.isChangeableName = this.projectName === this.importProjectData.project.name;
229-
}
230-
231-
/**
232-
* Check changeable status for project description field
233-
*/
234-
checkChangeableDescriptionStatus() {
235-
if ('config' === this.currentTab) {
236-
this.importProjectData.project.description = angular.copy(this.projectDescription);
237-
return;
238-
}
239-
this.isChangeableDescription = this.projectDescription === this.importProjectData.project.description;
240-
}
241-
242202
/**
243203
* Fetching operation has been done, so get workspaces and websocket connection
244204
*/
@@ -291,8 +251,8 @@ export class CreateProjectCtrl {
291251
* @param gitHubRepository the repository selected
292252
*/
293253
selectGitHubRepository(gitHubRepository) {
294-
this.importProjectData.project.name = gitHubRepository.name;
295-
this.importProjectData.project.description = gitHubRepository.description;
254+
this.setProjectName(gitHubRepository.name);
255+
this.setProjectDescription(gitHubRepository.description);
296256
this.importProjectData.source.location = gitHubRepository.clone_url;
297257
}
298258

@@ -349,13 +309,9 @@ export class CreateProjectCtrl {
349309
} else if ('config' === tab) {
350310
this.importProjectData.project.type = 'blank';
351311
this.importProjectData.source.type = 'git';
352-
// set name and description from input fields into object
353-
if (!this.isChangeableDescription) {
354-
this.importProjectData.project.description = angular.copy(this.projectDescription);
355-
}
356-
if (!this.isChangeableName) {
357-
this.importProjectData.project.name = angular.copy(this.projectName);
358-
}
312+
//try to set default values
313+
this.setProjectDescription(this.importProjectData.project.description);
314+
this.setProjectName(this.importProjectData.project.name);
359315
this.refreshCM();
360316
}
361317
// github and samples tabs have broadcast selection events for isReady status
@@ -669,10 +625,10 @@ export class CreateProjectCtrl {
669625
this.$mdDialog.alert()
670626
.title('Workspace Connection Error')
671627
.content('It seems that your workspace is running, but we cannot connect your browser to it. This commonly happens when Che was' +
672-
' not configured properly. If your browser is connecting to workspaces running remotely, then you must start Che with the ' +
673-
'--remote:<ip-address> flag where the <ip-address> is the IP address of the node that is running your Docker workspaces.' +
674-
'Please restart Che with this flag. You can read about what this flag does and why it is essential at: ' +
675-
'https://eclipse-che.readme.io/docs/configuration#envrionment-variables')
628+
' not configured properly. If your browser is connecting to workspaces running remotely, then you must start Che with the ' +
629+
'--remote:<ip-address> flag where the <ip-address> is the IP address of the node that is running your Docker workspaces.' +
630+
'Please restart Che with this flag. You can read about what this flag does and why it is essential at: ' +
631+
'https://eclipse-che.readme.io/docs/configuration#envrionment-variables')
676632
.ariaLabel('Project creation')
677633
.ok('OK')
678634
);
@@ -728,15 +684,9 @@ export class CreateProjectCtrl {
728684
* Call the create operation that may create or import a project
729685
*/
730686
create() {
731-
732-
// set name and description for imported project
733-
if (!this.isChangeableDescription) {
734-
this.importProjectData.project.description = angular.copy(this.projectDescription);
735-
}
736-
if (!this.isChangeableName) {
737-
this.importProjectData.project.name = angular.copy(this.projectName);
738-
}
739-
this.createProjectSvc.setProject(this.importProjectData.project.name);
687+
this.importProjectData.project.description = this.projectDescription;
688+
this.importProjectData.project.name = this.projectName;
689+
this.createProjectSvc.setProject(this.projectName);
740690

741691
if (this.templatesChoice === 'templates-wizard') {
742692
this.createProjectSvc.setIDEAction('createProject:projectName=' + this.projectName);
@@ -816,7 +766,7 @@ export class CreateProjectCtrl {
816766
let bus = this.cheAPI.getWebsocket().getExistingBus(websocketStream);
817767

818768
// mode
819-
this.createProjectInWorkspace(this.workspaceSelected.id, this.importProjectData.project.name, this.importProjectData, bus);
769+
this.createProjectInWorkspace(this.workspaceSelected.id, this.projectName, this.importProjectData, bus);
820770
});
821771

822772
}, (error) => {
@@ -923,8 +873,7 @@ export class CreateProjectCtrl {
923873

924874
name = name + '-' + (('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4)); // jshint ignore:line
925875

926-
this.importProjectData.project.name = name;
927-
this.projectName = name;
876+
this.setProjectName(name);
928877
}
929878

930879
}
@@ -934,9 +883,9 @@ export class CreateProjectCtrl {
934883
*/
935884
generateWorkspaceName() {
936885
// starts with wksp
937-
var name = 'wksp';
938-
name = name + '-' + (('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4)); // jshint ignore:line
939-
this.workspaceName = name;
886+
let name = 'wksp';
887+
name += '-' + (('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4)); // jshint ignore:line
888+
this.setWorkspaceName(name);
940889
}
941890

942891
isImporting() {
@@ -1048,7 +997,7 @@ export class CreateProjectCtrl {
1048997
*/
1049998
cheStackLibraryWorkspaceSelecter(workspace) {
1050999
this.workspaceSelected = workspace;
1051-
this.workspaceName = workspace.config.name;
1000+
this.setWorkspaceName(workspace.config.name);
10521001
this.stackLibraryOption = 'existing-workspace';
10531002
let stack = null;
10541003
if (workspace.config.attributes && workspace.config.attributes.stackId) {
@@ -1117,4 +1066,48 @@ export class CreateProjectCtrl {
11171066
this.importProjectData.source.location = '';
11181067
}
11191068

1069+
/**
1070+
* Set workspace name
1071+
* @param name
1072+
*/
1073+
setWorkspaceName(name) {
1074+
if (!name) {
1075+
return;
1076+
}
1077+
if (!this.defaultWorkspaceName || this.defaultWorkspaceName === this.workspaceName) {
1078+
this.defaultWorkspaceName = name;
1079+
this.workspaceName = angular.copy(name);
1080+
}
1081+
}
1082+
1083+
/**
1084+
* Set project name
1085+
* @param name
1086+
*/
1087+
setProjectName(name) {
1088+
if (!name) {
1089+
return;
1090+
}
1091+
if (!this.defaultProjectName || this.defaultProjectName === this.projectName) {
1092+
this.defaultProjectName = name;
1093+
this.projectName = angular.copy(name);
1094+
}
1095+
this.importProjectData.project.name = this.projectName;
1096+
}
1097+
1098+
/**
1099+
* Set project description
1100+
* @param description
1101+
*/
1102+
setProjectDescription(description) {
1103+
if (!description) {
1104+
return;
1105+
}
1106+
if (!this.defaultProjectDescription || this.defaultProjectDescription === this.projectDescription) {
1107+
this.defaultProjectDescription = description;
1108+
this.projectDescription = angular.copy(description);
1109+
}
1110+
this.importProjectData.project.description = this.projectDescription;
1111+
}
1112+
11201113
}

0 commit comments

Comments
 (0)