Skip to content

Commit 5e029af

Browse files
committed
fixed issue when no env selected
1 parent 4ec9821 commit 5e029af

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export async function activate(context: vscode.ExtensionContext)
4242
workspaceState.setEnvironment(firstEnv);
4343
}
4444
}
45+
4546
context.subscriptions.push(new AnaliticsCodeLens(documentInfoProvider));
4647
//context.subscriptions.push(new ContextView(analyticsProvider, context.extensionUri));
4748
context.subscriptions.push(new MethodCallErrorTooltip(documentInfoProvider, codeInspector));
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { AnalyticsProvider, UsageStatusResults } from "../../../services/analyticsProvider";
2+
import { DocumentInfo } from "../../../services/documentInfoProvider";
3+
import { WorkspaceState } from "../../../state";
4+
import { WebViewUris } from "../../webViewUtils";
5+
import { CodeObjectGroupEnvironments } from "../CodeObjectGroups/CodeObjectGroupEnvUsage";
6+
import { HtmlHelper } from "../common";
7+
8+
export class NoEnvironmentSelectedMessage{
9+
10+
constructor(private _analyticsProvider: AnalyticsProvider,
11+
private _viewUris: WebViewUris,
12+
private _workspaceState: WorkspaceState){
13+
14+
}
15+
public async showNoEnvironmentSelectedMessage( usageStatuses: UsageStatusResults){
16+
17+
let html=new CodeObjectGroupEnvironments(this._viewUris, this._workspaceState).getUsageHtml(undefined,undefined,usageStatuses);;
18+
19+
html += /*html*/ `
20+
${HtmlHelper.getInfoMessage("No deployment environment is currently selected, please click on any of the environment links above.")}`;
21+
22+
return html;
23+
24+
}
25+
}

src/views/codeAnalytics/CodeObjectGroups/CodeObjectGroupEnvUsage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CodeObjectUsageStatus, EnvironmentUsageStatus, UsageStatusResults } from "../../../services/analyticsProvider";
1+
import { AnalyticsProvider, CodeObjectUsageStatus, EnvironmentUsageStatus, UsageStatusResults } from "../../../services/analyticsProvider";
22
import { Settings } from "../../../settings";
33
import { WebViewUris } from "../../webViewUtils";
44
import * as os from 'os';

src/views/codeAnalytics/codeAnalyticsView.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { Console } from "console";
2828
import { HistogramPanel } from "./Histogram/histogramPanel";
2929
import { TracePanel } from "./Traces/tracePanel";
3030
import { WorkspaceState } from "../../state";
31+
import { NoEnvironmentSelectedMessage } from "./AdminInsights/noEnvironmentSelectedMessage";
3132

3233
export class CodeAnalyticsView implements vscode.Disposable
3334
{
@@ -167,8 +168,10 @@ class CodeAnalyticsViewProvider implements vscode.WebviewViewProvider,vscode.Dis
167168

168169

169170
let noCodeObjectMessage = new NoCodeObjectMessage(_analyticsProvider,this._webViewUris, this._workspaceState);
171+
let noEnvironmentSelectedMessage = new NoEnvironmentSelectedMessage(_analyticsProvider,this._webViewUris, this._workspaceState);
172+
170173
const tabsList = [
171-
new InsightsViewTab(this._channel, this._analyticsProvider,groupItemViewCreator, listViewItemsCreator, _documentInfoProvider, this._webViewUris,noCodeObjectMessage, this._workspaceState),
174+
new InsightsViewTab(this._channel, this._analyticsProvider,groupItemViewCreator, listViewItemsCreator, _documentInfoProvider, this._webViewUris,noCodeObjectMessage, this._workspaceState, noEnvironmentSelectedMessage),
172175
new ErrorsViewTab(this._channel, this._analyticsProvider, this._documentInfoProvider, editorHelper, errorFlowParamDecorator, this._overlay, this._webviewViewProvider, this._webViewUris,noCodeObjectMessage, groupItemViewCreator, this._workspaceState),
173176
new UsagesViewTab(this._channel, this._webViewUris, this._analyticsProvider, globalInsightItemrCreator, this._workspaceState)
174177
];

src/views/codeAnalytics/insightsViewTab.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { CodeObjectGroupEnvironments } from "./CodeObjectGroups/CodeObjectGroupE
1919
import { NoCodeObjectMessage } from "./AdminInsights/noCodeObjectMessage";
2020
import { HandleDigmaBackendExceptions } from "../utils/handleDigmaBackendExceptions";
2121
import { WorkspaceState } from "../../state";
22+
import { NoEnvironmentSelectedMessage } from "./AdminInsights/noEnvironmentSelectedMessage";
2223

2324

2425

@@ -33,7 +34,8 @@ export class InsightsViewTab implements ICodeAnalyticsViewTab
3334
private _documentInfoProvider: DocumentInfoProvider,
3435
private _viewUris: WebViewUris,
3536
private _noCodeObjectsMessage: NoCodeObjectMessage,
36-
private _workspaceState: WorkspaceState) { }
37+
private _workspaceState: WorkspaceState,
38+
private _noEnvironmentSelectedMessage: NoEnvironmentSelectedMessage) { }
3739

3840

3941
onRefreshRequested(codeObject: CodeObjectInfo): void {
@@ -74,6 +76,7 @@ export class InsightsViewTab implements ICodeAnalyticsViewTab
7476
this._viewedCodeObjectId=undefined;
7577
return;
7678
}
79+
7780
const methodInfo = docInfo.methods.single(x => x.id == codeObject.id);
7881
const codeObjectsIds = [methodInfo.idWithType]
7982
.concat(methodInfo.relatedCodeObjects.map(r => r.idWithType));
@@ -88,6 +91,14 @@ export class InsightsViewTab implements ICodeAnalyticsViewTab
8891
}
8992

9093
usageResults = await this._analyticsProvider.getUsageStatus(codeObjectsIds);
94+
if (!this._workspaceState.environment &&
95+
(usageResults.codeObjectStatuses.length>0 || usageResults.environmentStatuses.length>0) ){
96+
let html = await this._noEnvironmentSelectedMessage.showNoEnvironmentSelectedMessage(usageResults);
97+
this.updateListView(html);
98+
this.updateSpanListView("");
99+
this._viewedCodeObjectId=undefined;
100+
return;
101+
}
91102

92103
}
93104
catch(e)

0 commit comments

Comments
 (0)