Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: block oas until a4d is activated #6046

Open
wants to merge 2 commits into
base: feat/apex-oas
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 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)?$/"
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && sf:a4d_detected"
}
],
"explorer/context": [
{
"command": "sf.create.apex.action.class",
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && resourcePath =~ /classes/"
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && resourcePath =~ /classes/ && sf:a4d_detected"
}
],
"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/"
"when": "sf:project_opened && sf:has_target_org && resource =~ /.\\.(cls)?$/ && resourcePath =~ /classes/ && sf:a4d_detected"
}
]
},
Expand Down Expand Up @@ -372,6 +372,10 @@
{
"command": "sf.create.apex.action.class",
"title": "%create_openapi_doc_class%"
},
{
"command": "sf.a4d.notify.activated",
"title": "%a4d_notify_activated%"
}
],
"configuration": {
Expand Down
3 changes: 2 additions & 1 deletion packages/salesforcedx-vscode-apex/package.nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
"run_tests_title": "テストを実行",
"show_error_title": "エラーを表示",
"test_view_container_title": "テストビューア",
"test_view_name": "Apex テスト"
"test_view_name": "Apex テスト",
"a4d_notify_activated": "Agentforce for Developer is activated."
}
3 changes: 2 additions & 1 deletion packages/salesforcedx-vscode-apex/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
"run_tests_title": "Run Tests",
"show_error_title": "Display Error",
"test_view_container_title": "Test Viewer",
"test_view_name": "Apex Tests"
"test_view_name": "Apex Tests",
"a4d_notify_activated": "Agentforce for Developer is activated."
}
23 changes: 22 additions & 1 deletion packages/salesforcedx-vscode-apex/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ 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 @@ -175,6 +187,13 @@ const registerCommands = (): vscode.Disposable => {
'sf.launch.apex.replay.debugger.with.current.file',
launchApexReplayDebuggerWithCurrentFile
);
const notifyA4DExtensionActivated = vscode.commands.registerCommand('sf.notify.a4d.extension.activated', () =>
peternhale marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -198,7 +217,9 @@ const registerCommands = (): vscode.Disposable => {
apexTestSuiteAddCmd,
createApexActionFromMethodCmd,
createApexActionFromClassCmd,
launchApexReplayDebuggerWithCurrentFileCmd
launchApexReplayDebuggerWithCurrentFileCmd,
notifyA4DExtensionActivated,
notifyA4DExtensionDeactivated
);
};

Expand Down
Loading