Skip to content

Commit 00a38e0

Browse files
committed
Change views as features change
Signed-off-by: worksofliam <[email protected]>
1 parent 4c2263b commit 00a38e0

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

src/IBMiDetail.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { commands } from "vscode";
12
import { getInstance } from "./base";
23
import { ServerComponent } from "./connection/serverComponent";
34

@@ -19,6 +20,7 @@ export class IBMiDetail {
1920

2021
setFeatureSupport(featureId: Db2FeatureIds, supported: boolean) {
2122
this.features[featureId] = supported;
23+
commands.executeCommand(`setContext`, `vscode-db2i:${featureId}Supported`, supported);
2224
}
2325

2426
getVersion() {
@@ -30,6 +32,12 @@ export class IBMiDetail {
3032
}
3133

3234
async fetchSystemInfo() {
35+
// Disable all features
36+
const features = Object.keys(featureRequirements) as Db2FeatureIds[];
37+
for (const featureId of features) {
38+
this.setFeatureSupport(featureId, false);
39+
}
40+
3341
const instance = getInstance();
3442
const content = instance.getContent();
3543

@@ -52,7 +60,6 @@ export class IBMiDetail {
5260
levelCheckFailed = true;
5361
}
5462

55-
const features = Object.keys(featureRequirements) as Db2FeatureIds[];
5663
for (const featureId of features) {
5764
const requiredLevelForFeature = featureRequirements[featureId][String(this.version)];
5865
const supported = requiredLevelForFeature && this.db2Level >= requiredLevelForFeature;

src/config.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export async function onConnectOrServerInstall(): Promise<boolean> {
3535
await ServerComponent.checkForUpdate();
3636

3737
updateStatusBar();
38-
toggleViews();
3938

4039
if (ServerComponent.isInstalled()) {
4140
JobManagerView.setVisible(true);
@@ -83,15 +82,6 @@ export function initConfig(context: ExtensionContext) {
8382
});
8483
}
8584

86-
export function toggleViews() {
87-
const features = osDetail.getFeatures();
88-
89-
const featureIds = Object.keys(features) as (keyof typeof features)[];
90-
for (const featureId of featureIds) {
91-
commands.executeCommand(`setContext`, `vscode-db2i:${featureId}Supported`, features[featureId]);
92-
}
93-
}
94-
9585
export async function askAboutNewJob(startup?: boolean): Promise<boolean> {
9686
const instance = getInstance();
9787
const connection = instance.getConnection();

src/views/jobManager/selfCodes/selfCodesResultsView.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Uri,
1010
Disposable
1111
} from "vscode";
12-
import { JobManager } from "../../../config";
12+
import { JobManager, osDetail } from "../../../config";
1313
import { SelfCodeNode, SelfIleStackFrame } from "./nodes";
1414
import { openExampleCommand } from "../../examples/exampleBrowser";
1515
import { SQLExample } from "../../examples";
@@ -94,15 +94,21 @@ export class selfCodesResultsView implements TreeDataProvider<any> {
9494
where user_name = current_user
9595
order by logged_time desc`;
9696

97-
const result = await selected.job.query<SelfCodeNode>(content).run(10000);
98-
if (result.success) {
99-
const data: SelfCodeNode[] = result.data.map((row) => ({
100-
...row,
101-
INITIAL_STACK: JSON.parse(row.INITIAL_STACK as unknown as string)
102-
}));
97+
try {
98+
const result = await selected.job.query<SelfCodeNode>(content).run(10000);
99+
if (result.success) {
100+
const data: SelfCodeNode[] = result.data.map((row) => ({
101+
...row,
102+
INITIAL_STACK: JSON.parse(row.INITIAL_STACK as unknown as string)
103+
}));
103104

104-
105-
return data;
105+
106+
return data;
107+
}
108+
} catch (e) {
109+
this.setRefreshEnabled(false);
110+
osDetail.setFeatureSupport(`SELF`, false);
111+
vscode.window.showErrorMessage(`An error occured fetching SELF code errors, and therefore will be disabled.`);
106112
}
107113
}
108114

0 commit comments

Comments
 (0)