Skip to content

Commit d9c4592

Browse files
vrubezhnydatho7561
authored andcommitted
Force refresh App explorer on create project...
...when new project name is the same as the one set in the current-context. The steps to reproduce: - On Openshift cluster: create a project giving it some name - assert that the project is successfully created, the App Explorer is refreshed automatically and the new project is lister in the App Explorer tree - Delete the project - Assert that the project is successfully deleted, the App Explorer is refreshed automatically and the deleted projectbow is marked as "Missing ptoject: in the App Explorer - Click on the "Missing project" tree item to "Create new or set Active project" - Chose "Create new project" and type exactly the same name as it was used to create the project tne the beginning - Assert that the project is successfully created - FAIL: Assert the App Explorer is refreshed automatically and tthe new project is listed in the App Explorer Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
1 parent 4218e28 commit d9c4592

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/openshift/project.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Odo } from '../odo/odoWrapper';
1111
import { Progress } from '../util/progress';
1212
import { VsCommandError, vsCommand } from '../vscommand';
1313
import OpenShiftItem from './openshiftItem';
14+
import { KubeConfigUtils } from '../util/kubeUtils';
1415

1516
export class Project extends OpenShiftItem {
1617

@@ -51,7 +52,19 @@ export class Project extends OpenShiftItem {
5152
if (!projectName) return null;
5253
projectName = projectName.trim();
5354
return Project.odo.createProject(projectName)
54-
.then(() => `Project '${projectName}' successfully created`)
55+
.then(() => {
56+
const kcu = new KubeConfigUtils();
57+
const currentContext = kcu.findContext(kcu.currentContext);
58+
if (currentContext && projectName === currentContext.namespace) {
59+
// We have to force refresh on App Explorer in case of the new project name
60+
// is the same as the one set in current context (active project) because,
61+
// in case they are equal, the kube config will not be changed by `odo creare project`,
62+
// so the App Explorer will not be automatcally refreshed whle it really needs to be
63+
// refreshed
64+
OpenShiftExplorer.getInstance().refresh();
65+
}
66+
return `Project '${projectName}' successfully created`;
67+
})
5568
.catch((error) => Promise.reject(new VsCommandError(`Failed to create Project with error '${error}'`, 'Failed to create Project')));
5669
}
5770

0 commit comments

Comments
 (0)