Skip to content

Commit

Permalink
feat: use a4d isenabled context value
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxuanzhangsfdx committed Feb 1, 2025
1 parent 6495a13 commit bb275bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
6 changes: 3 additions & 3 deletions packages/salesforcedx-vscode-apex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@
},
{
"command": "sf.create.apex.action.class",
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && sf:a4d_detected"
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && salesforcedx-einstein-gpt.isEnabled"
}
],
"explorer/context": [
{
"command": "sf.create.apex.action.class",
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && resourcePath =~ /classes/ && sf:a4d_detected"
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && resourcePath =~ /classes/ && salesforcedx-einstein-gpt.isEnabled"
}
],
"view/title": [
Expand Down Expand Up @@ -260,7 +260,7 @@
},
{
"command": "sf.create.apex.action.class",
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && resourcePath =~ /classes/ && sf:a4d_detected"
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && resourcePath =~ /classes/ && salesforcedx-einstein-gpt.isEnabled"
}
]
},
Expand Down
23 changes: 1 addition & 22 deletions packages/salesforcedx-vscode-apex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ import { ApexTestRunner, TestRunType } from './views/testRunner';
const metadataOrchestrator = new MetadataOrchestrator();
export const apexActionController = new ApexActionController(metadataOrchestrator);

const onA4DExtensionActivated = () => {
setA4dActivatedContext(true);
};

const onA4DExtensionDeactivated = () => {
setA4dActivatedContext(false);
};

const setA4dActivatedContext = (val: boolean) => {
vscode.commands.executeCommand('setContext', 'sf:a4d_detected', val);
};

export const activate = async (extensionContext: vscode.ExtensionContext) => {
const telemetryService = await getTelemetryService();
if (!telemetryService) {
Expand Down Expand Up @@ -187,13 +175,6 @@ const registerCommands = (): vscode.Disposable => {
'sf.launch.apex.replay.debugger.with.current.file',
launchApexReplayDebuggerWithCurrentFile
);
const notifyA4DExtensionActivated = vscode.commands.registerCommand('sf.notify.a4d.extension.activated', () =>
onA4DExtensionActivated()
); // the command is only used by the a4d extension to notify us that it has been activated

const notifyA4DExtensionDeactivated = vscode.commands.registerCommand('sf.notify.a4d.extension.deactivated', () =>
onA4DExtensionDeactivated()
); // the command is only used by the a4d extension to notify us that it has been deactivated

return vscode.Disposable.from(
anonApexDebugDelegateCmd,
Expand All @@ -217,9 +198,7 @@ const registerCommands = (): vscode.Disposable => {
apexTestSuiteAddCmd,
createApexActionFromMethodCmd,
createApexActionFromClassCmd,
launchApexReplayDebuggerWithCurrentFileCmd,
notifyA4DExtensionActivated,
notifyA4DExtensionDeactivated
launchApexReplayDebuggerWithCurrentFileCmd
);
};

Expand Down

0 comments on commit bb275bb

Please sign in to comment.