Skip to content

Commit

Permalink
Merge pull request #420 from SanjulaGanepola/feature/merlin-context-v…
Browse files Browse the repository at this point in the history
…alue

Add merlin context value
  • Loading branch information
edmundreinhardt authored Mar 26, 2024
2 parents 0d8d233 + d1908a9 commit 10c5ca3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@
},
{
"command": "vscode-ibmi-projectexplorer.uploadAndReplace",
"when": "view == projectExplorer && viewItem =~ /^member*/",
"when": "view == projectExplorer && viewItem =~ /^member*/ && !vscode-ibmi-projectexplorer:isInMerlin",
"group": "5_transfer@1"
},
{
Expand Down
21 changes: 21 additions & 0 deletions src/contextValueManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* (c) Copyright IBM Corp. 2023
*/

import { commands } from "vscode";
import { EnvironmentManager } from "./environmentManager";

/**
* Represents a manager for the custom context values used by the extension.
*/
export namespace ContextValueManager {
/**
* Initialize the custom context values.
*/
export async function initialize() {
const isInMerlin = EnvironmentManager.isInMerlin();
if (isInMerlin) {
await commands.executeCommand('setContext', 'vscode-ibmi-projectexplorer:isInMerlin', isInMerlin);
}
}
}
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { IBMiProjectExplorer } from './ibmiProjectExplorer';
import { initialise } from './testing';
import { ProjectFileWatcher } from './fileWatcher';
import { ConfigurationManager } from './configurationManager';
import { ContextValueManager } from './contextValueManager';

export async function activate(context: ExtensionContext): Promise<IBMiProjectExplorer> {
console.log(l10n.t('Congratulations, your extension "vscode-ibmi-projectexplorer" is now active!'));
Expand All @@ -24,6 +25,9 @@ export async function activate(context: ExtensionContext): Promise<IBMiProjectEx
// Initialize configuration manager
ConfigurationManager.initialize(context);

// Initialize context value manager
await ContextValueManager.initialize();

// Setup tree views
const projectExplorer = new ProjectExplorer(context);
const projectExplorerTreeView = window.createTreeView(`projectExplorer`, { treeDataProvider: projectExplorer, showCollapseAll: true });
Expand Down
8 changes: 3 additions & 5 deletions src/views/projectExplorer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1170,11 +1170,9 @@ export default class ProjectExplorer implements TreeDataProvider<ProjectExplorer
await commands.executeCommand(`workbench.action.addRootFolder`);
}
}),
commands.registerCommand(`vscode-ibmi-projectexplorer.openConnectionBrowser`, async (element: ErrorItem) => {
if (element) {
const isInMerlin = EnvironmentManager.isInMerlin();
await commands.executeCommand(isInMerlin ? `ibmideveloper.connectionBrowser.focus` : `connectionBrowser.focus`);
}
commands.registerCommand(`vscode-ibmi-projectexplorer.openConnectionBrowser`, async (element?: ErrorItem) => {
const isInMerlin = EnvironmentManager.isInMerlin();
await commands.executeCommand(isInMerlin ? `ibmideveloper.connectionBrowser.focus` : `connectionBrowser.focus`);
}),
commands.registerCommand(`vscode-ibmi-projectexplorer.setDeployLocation`, async (element: ErrorItem | WorkspaceFolder) => {
const workspaceFolder = element instanceof ErrorItem ? element.workspaceFolder : element;
Expand Down

0 comments on commit 10c5ca3

Please sign in to comment.