Skip to content

Commit

Permalink
Merge pull request #165 from Accenture/bug/114-incorrect-behaviour-wh…
Browse files Browse the repository at this point in the history
…en-trying-to-retrievedeploy-when-single-child-folders-are-compressed

deactivate Compact Folders fix code
  • Loading branch information
anasilva105 authored Apr 30, 2024
2 parents 60142d0 + 3ef0b42 commit c9bf736
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/devtools/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ async function initDevToolsExtension(): Promise<void>{

editorDependencies.activateExtensionDependencies(mainConfig.extensionsDependencies);

// Deactivates Compact folders for command right execution
editorDependencies.deactivateCompactFolders();

// activate the status bar
devtoolsContainers.activateStatusBar();

Expand Down
19 changes: 15 additions & 4 deletions src/editor/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ async function activateExtensionDependencies(dependencies: string | string[]){

if(missingExtDependencies.length){

const suggestRecommendedExtensions: string | boolean =
editorWorkspace.handleWorkspaceConfiguration("recommendExtensions", true).get();
const workspaceConfiguration = editorWorkspace.handleWorkspaceConfiguration("sfmc-devtools-vscode", "Global");
const suggestRecommendedExtensions: boolean =
Boolean(workspaceConfiguration.get("recommendExtensions", true));

if(suggestRecommendedExtensions){
const message: string = "There are some recommended extensions that can enhance your usage of SFMC DevTools. Would you like to install them?";
Expand All @@ -34,15 +35,25 @@ async function activateExtensionDependencies(dependencies: string | string[]){
);
});
}else if(selectedOption === RecommendedExtensionsInputOptions.DONT_ASK_AGAIN){
editorWorkspace.handleWorkspaceConfiguration("recommendExtensions", false).set();
workspaceConfiguration.set("recommendExtensions", false);
}
}
}
}
}

function deactivateCompactFolders(){
const workspaceConfiguration = editorWorkspace.handleWorkspaceConfiguration("explorer", "Workspace");
const isCompactFoldersEnabled: boolean = Boolean(workspaceConfiguration.get("compactFolders", true));
if(isCompactFoldersEnabled){
// Disable Compact Folders
workspaceConfiguration.set("compactFolders", false);
}
}

const editorDependencies = {
activateExtensionDependencies
activateExtensionDependencies,
deactivateCompactFolders
};

export { editorDependencies };
10 changes: 6 additions & 4 deletions src/editor/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { workspace, Uri, TextDocument, WorkspaceFolder, FileType, FileStat, WorkspaceConfiguration, ConfigurationTarget } from "vscode";
import { editorCommands } from "./commands";

type WorkspaceConfigurationTarget = "Global" | "Workspace" | "WorkspaceFolder";

function getWorkspaceURI(): Uri {
const wsFolder: readonly WorkspaceFolder[] | undefined = workspace.workspaceFolders;
if(wsFolder){
Expand Down Expand Up @@ -53,12 +55,12 @@ async function isFile(file: string | Uri){
return fileType.toLowerCase() === "file";
}

function handleWorkspaceConfiguration(key: string, value: string | boolean){
const workspaceConfiguration: WorkspaceConfiguration = workspace.getConfiguration("sfmc-devtools-vscode");
function handleWorkspaceConfiguration(section: string, target: WorkspaceConfigurationTarget){
const workspaceConfiguration: WorkspaceConfiguration = workspace.getConfiguration(section);
if(workspaceConfiguration){
return {
get: () => workspaceConfiguration.get(key, value),
set: () => workspaceConfiguration.update(key, value, ConfigurationTarget.Global)
get: (key: string, value: string | boolean) => workspaceConfiguration.get(key, value),
set: (key: string, value: string | boolean) => workspaceConfiguration.update(key, value, ConfigurationTarget[target])
};
}
throw new Error("Failed to handle Workspace Configuration.");
Expand Down

0 comments on commit c9bf736

Please sign in to comment.