Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: vitaliy-guliy <[email protected]>
  • Loading branch information
vitaliy-guliy committed Dec 30, 2024
1 parent ede7683 commit 5d51a86
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions code/extensions/che-remote/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@ async function updateDevfile(cheApi: any): Promise<boolean> {
} = cheApi.getDevfileService();
const devWorkspaceGenerator = new DevWorkspaceGenerator();

await new Promise(resolve => setTimeout(resolve, 500));

let devfilePath = await selectDevfile();
await new Promise(resolve => setTimeout(resolve, 500));

if (`${process.env.PROJECTS_ROOT!}/*` === devfilePath) {
const uri = await vscode.window.showOpenDialog({
canSelectFolders: false
Expand All @@ -180,8 +176,6 @@ async function updateDevfile(cheApi: any): Promise<boolean> {
return false;
}

await new Promise(resolve => setTimeout(resolve, 500));

const action = await vscode.window.showInformationMessage(
'Workspace restart', {
modal: true, detail: `Your workspace will be restarted from ${devfilePath}. This action is not revertable.`
Expand Down Expand Up @@ -237,20 +231,15 @@ async function updateDevfile(cheApi: any): Promise<boolean> {
}

try {
const action = await vscode.window.showInformationMessage('Do you want to copy attributes from existing to a new devfile?', {
modal: true
}, 'Copy', 'Skip');
console.log(`> action [${action}]`);
// keep spec.template.attributes
if (!devfileContext.devWorkspace.spec!.template!.attributes) {
devfileContext.devWorkspace.spec!.template!.attributes = {};
}

if ('Copy' === action) {
// keep spec.template.attributes
if (!devfileContext.devWorkspace.spec!.template!.attributes) {
devfileContext.devWorkspace.spec!.template!.attributes = flattenedDevfile.attributes;
for (const key of Object.keys(flattenedDevfile.attributes)) {
if (flattenedDevfile.attributes[key]) {
devfileContext.devWorkspace.spec!.template!.attributes[key] = flattenedDevfile.attributes[key];
}
} else if (action === 'Skip') {
// do nothing
} else if (action === undefined) {
return false;
}
} catch (error) {
await vscode.window.showErrorMessage(`Failed to update DevWorkspace attributes. ${error}`);
Expand All @@ -269,8 +258,9 @@ async function updateDevfile(cheApi: any): Promise<boolean> {
}

try {
const action = await vscode.window.showInformationMessage('Apply changes?', {
modal: true
const action = await vscode.window.showInformationMessage('The new devfile has been written to \'/projects/new-devfile.yaml\'', {
modal: true,
detail: 'Apply changes?'
}, 'Apply');
if (action !== 'Apply') {
return false;
Expand Down

0 comments on commit 5d51a86

Please sign in to comment.