Skip to content

Commit 3d2b7fa

Browse files
authored
Merge pull request #216 from digma-ai/feature/fix-menu-stacking-context
Feature/fix menu stacking context
2 parents 08ca9d5 + 424db1c commit 3d2b7fa

File tree

10 files changed

+95
-99
lines changed

10 files changed

+95
-99
lines changed

src/services/analyticsProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ export class AnalyticsProvider
468468
InsightType: insightType,
469469
Time: time,
470470
},
471+
false,
471472
);
472473
return response;
473474
}

src/views-ui/codeAnalytics/main.scss

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ vscode-panel-view {
7171

7272
.list-item-body {
7373
margin-top: 5px;
74-
z-index: 2;
7574
}
7675

7776
.list-item-buttons {
@@ -94,15 +93,11 @@ vscode-panel-view {
9493
.list-item-menu {
9594
padding: 0;
9695
margin: 0;
96+
width: 8px;
9797
}
9898

99-
.list-item-menu-item {
100-
padding: 4px;
101-
margin: 0;
102-
}
103-
104-
ul.list-item-menu {
105-
li.list-item-menu {
99+
.sf-menu {
100+
li {
106101
right: 0;
107102
min-width: unset;
108103
font-family: var(--font-family);
@@ -116,21 +111,21 @@ ul.list-item-menu {
116111
cursor: pointer;
117112
}
118113

119-
// li {
120-
// color: var(--button-secondary-foreground);
121-
// background: var(--button-secondary-background);
122-
// }
123-
124-
ul {
125-
left: unset;
126-
right: 0;
127-
min-width: unset;
128-
z-index: 100;
129-
130-
li {
131-
color: var(--button-secondary-foreground);
132-
background: var(--button-secondary-background);
133-
}
114+
li {
115+
color: var(--button-secondary-foreground);
116+
background: var(--button-secondary-background);
117+
padding: 4px 8px;
118+
}
119+
}
120+
121+
ul {
122+
left: unset;
123+
right: 0;
124+
min-width: unset;
125+
126+
li, li:hover {
127+
color: var(--button-secondary-foreground);
128+
background: var(--button-secondary-background);
134129
}
135130
}
136131
}

src/views-ui/codeAnalytics/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ window.addEventListener("load", () =>
127127
function initListItemMenus(){
128128
const menus: any = $('.list-item-menu');
129129
menus.superfish({
130-
delay: 10000,
130+
delay: 3000,
131131
cssArrows: false,
132132
});
133133
}
@@ -225,6 +225,9 @@ window.addEventListener("load", () =>
225225
$timeInfo
226226
.find('.list-item-time-info-message')
227227
.text('Applying the new time filter. Wait a few minutes and then refresh.');
228+
$timeInfo
229+
.find('.custom-start-date-refresh-link')
230+
.show();
228231
$timeInfo.show();
229232
publish(new UiMessage.Notify.SetInsightCustomStartTime(codeObjectId, insightType, new Date()));
230233
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export interface Action {
2+
}

src/views/codeAnalytics/InsightListView/ItemRender/insightTemplateHtml.ts

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export class InsightTemplateHtml
4444

4545
const { insight } = this.data;
4646

47-
let startTime = '';
48-
let formattedStartTime = '';
49-
let hasCustomTime = false;
47+
let timeInfoHtml = '';
5048

5149
const menuItems = [];
5250
if((<CodeObjectInsight>insight)?.prefixedCodeObjectId) {
@@ -60,10 +58,23 @@ export class InsightTemplateHtml
6058

6159
console.log('insight', codeObjectId, insightType, customStartTime);
6260

63-
startTime = actualStartTime?.format('L') || '';
64-
formattedStartTime = actualStartTime?.fromNow() || formattedStartTime;
65-
hasCustomTime = !!customStartTime;
61+
const startTime = actualStartTime?.format('L') || '';
62+
const formattedStartTime = actualStartTime?.fromNow() || '';
63+
const identicalStartTimes = actualStartTime?.valueOf() === customStartTime?.valueOf();
6664

65+
const timeInfoVisibilityClass = !!customStartTime ? '' : 'hidden';
66+
const refreshButtonVisibilityClass = identicalStartTimes ? 'hidden' : '';
67+
const timeInfoMessage = identicalStartTimes
68+
? `Age of data: ${formattedStartTime}`
69+
: `Applying the new time filter. Wait a few minutes and then refresh.`;
70+
71+
timeInfoHtml = `
72+
<div class="list-item-time-info ${timeInfoVisibilityClass}">
73+
<span class="list-item-time-info-message" title="${startTime}">${timeInfoMessage}</span>
74+
<a href="#" class="custom-start-date-refresh-link ${refreshButtonVisibilityClass}">Refresh</a>
75+
</div>
76+
`;
77+
6778
menuItems.push(`
6879
<li
6980
class="list-item-menu-item custom-start-date-recalculate-link"
@@ -77,36 +88,18 @@ export class InsightTemplateHtml
7788

7889
const threeDotImageUri = this._viewUris.image('three-dots.svg');
7990

80-
// let menuHtml = menuItems?.length > 0
81-
// ? `<ul class="list-item-menu sf-menu sf-js-enabled">
82-
// <li class="list-item-menu">
83-
// <img class="list-item-icon" src="${threeDotImageUri}" height="15">
84-
// <ul>
85-
// ${menuItems.join("")}
86-
// </ul>
87-
// </li>
88-
// </ul>`
89-
// : ``;
90-
let menuHtml = menuItems?.length > 0
91-
? `<div
92-
class="list-item-icon custom-start-date-recalculate-link codicon codicon-calendar"
93-
src="${threeDotImageUri}"
94-
title="Recalculate\n\nClick to recalculate this insight only using new data"
95-
height="15"
96-
></div>`
91+
const menuItemsHtml = menuItems.length > 0
92+
? `<li class="list-item-menu">
93+
<img class="list-item-icon" src="${threeDotImageUri}" height="15">
94+
<ul>
95+
${menuItems.join("")}
96+
</ul>
97+
</li>`
9798
: ``;
98-
// const menuItemsHtml = menuItems.length > 0
99-
// ? `<li class="list-item-menu-item">
100-
// <img class="list-item-icon" src="${threeDotImageUri}" height="15">
101-
// <ul>
102-
// ${menuItems.join("")}
103-
// </ul>
104-
// </li>`
105-
// : ``;
106-
// const menuHtml = `
107-
// <ul class="list-item-menu sf-menu sf-js-enabled">
108-
// ${menuItemsHtml}
109-
// </ul>`;
99+
const menuHtml = `
100+
<ul class="list-item-menu sf-menu sf-js-enabled">
101+
${menuItemsHtml}
102+
</ul>`;
110103

111104
let title = "";
112105
let tooltip = "";
@@ -118,14 +111,6 @@ export class InsightTemplateHtml
118111
tooltip = (<ITitle>this.data.title).tooltip;
119112
}
120113

121-
const timeInfoVisibilityClass = hasCustomTime ? '' : 'hidden';
122-
const timeInfoHtml = `
123-
<div class="list-item-time-info ${timeInfoVisibilityClass}">
124-
<span class="list-item-time-info-message" title="${startTime}">Age of data: ${formattedStartTime}</span>
125-
<a href="#" class="custom-start-date-refresh-link">Refresh</a>
126-
</div>
127-
`;
128-
129114
const html = /*html*/`
130115
<div class="list-item insight">
131116
<div class="list-item-top-area">
@@ -134,8 +119,8 @@ export class InsightTemplateHtml
134119
${timeInfoHtml}
135120
${descriptionHtml}
136121
</div>
137-
${menuHtml}
138122
${iconHtml}
123+
${menuHtml}
139124
</div>
140125
${bodyHtml}
141126
${buttonsHtml}

src/views/codeAnalytics/codeAnalyticsView.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { DigmaCommands } from "../../commands";
3333
import { EnvSelectStatusBar } from "./StatusBar/envSelectStatusBar";
3434
import { AnalyticsCodeLens } from "../../analyticsCodeLens";
3535
import { CodeObjectInfo, MinimalCodeObjectInfo, EmptyCodeObjectInfo } from "../../services/codeObject";
36-
import { HandleDigmaBackendExceptions } from "../utils/handleDigmaBackendExceptions";
36+
import { Action } from "./InsightListView/Actions/Action";
3737
//import { DigmaFileDecorator } from "../../decorators/fileDecorator";
3838

3939

@@ -144,6 +144,7 @@ class CodeAnalyticsViewProvider implements vscode.WebviewViewProvider,vscode.Dis
144144
private _currentCodeObject?: CodeObjectInfo;
145145
private _disposables: vscode.Disposable[] = [];
146146
private _webviewViewProvider: WebviewViewProvider;
147+
private _actions: Action[] = [];
147148
constructor(
148149
extensionUri: vscode.Uri,
149150
private _analyticsProvider: AnalyticsProvider,
@@ -184,8 +185,6 @@ class CodeAnalyticsViewProvider implements vscode.WebviewViewProvider,vscode.Dis
184185
this._channel.consume(UiMessage.Notify.OpenHistogramPanel, this.onOpenHistogramRequested.bind(this));
185186
this._channel.consume(UiMessage.Notify.OpenTracePanel, this.onOpenTracePanel.bind(this));
186187

187-
this._channel.consume(UiMessage.Notify.SetInsightCustomStartTime, this.onSetInsightCustomStartTime.bind(this));
188-
189188
const listViewItemsCreator = new InsightListViewItemsCreator();
190189
listViewItemsCreator.setUknownTemplate(new UnknownInsightInsight(this._webViewUris));
191190
listViewItemsCreator.add("HotSpot", new HotspotListViewItemsCreator(this._webViewUris));
@@ -502,22 +501,4 @@ class CodeAnalyticsViewProvider implements vscode.WebviewViewProvider,vscode.Dis
502501
</body>
503502
</html>`;
504503
}
505-
506-
public async onSetInsightCustomStartTime(event: UiMessage.Notify.SetInsightCustomStartTime) {
507-
if (event.codeObjectId && event.insightType && event.time) {
508-
try {
509-
await this._analyticsProvider.setInsightCustomStartTime(
510-
event.codeObjectId,
511-
event.insightType,
512-
event.time,
513-
);
514-
}
515-
catch(e) {
516-
let html = new HandleDigmaBackendExceptions(this._webViewUris).getExceptionMessageHtml(e);
517-
// this.updateListView(html);
518-
console.log(html);
519-
return;
520-
}
521-
}
522-
}
523504
}

src/views/codeAnalytics/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ICodeAnalyticsViewTab extends Disposable
1414
onDectivate(): void ;
1515
onRefreshRequested(codeObject: CodeObjectInfo):void;
1616
onUpdated(codeObject: CodeObjectInfo): void ;
17+
showError(error: any): void;
1718
}
1819

1920

src/views/codeAnalytics/errorsViewTab.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ export class ErrorsViewTab implements ICodeAnalyticsViewTab {
114114
<div id="error-list" class="list"></div>
115115
</div>`;
116116
}
117+
118+
public showError(error: any): void {
119+
let html = new HandleDigmaBackendExceptions(this._webViewUris).getExceptionMessageHtml(error);
120+
this._channel.publish(new UiMessage.Set.ErrorsList(html));
121+
}
122+
117123
private refreshCodeObjectLabel(codeObject: CodeObjectInfo)
118124
{
119125
let html = HtmlHelper.getCodeObjectLabel(this._webViewUris, codeObject.displayName);
@@ -160,8 +166,7 @@ export class ErrorsViewTab implements ICodeAnalyticsViewTab {
160166
return;
161167
}
162168

163-
let html = new HandleDigmaBackendExceptions(this._webViewUris).getExceptionMessageHtml(e);
164-
this._channel.publish(new UiMessage.Set.ErrorsList(html));
169+
this.showError(e);
165170
return;
166171
}
167172

src/views/codeAnalytics/insightsViewTab.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export class InsightsViewTab implements ICodeAnalyticsViewTab
3636
private _viewUris: WebViewUris,
3737
private _noCodeObjectsMessage: NoCodeObjectMessage,
3838
private _workspaceState: WorkspaceState,
39-
private _noEnvironmentSelectedMessage: NoEnvironmentSelectedMessage) { }
39+
private _noEnvironmentSelectedMessage: NoEnvironmentSelectedMessage,
40+
) {
41+
this._channel.consume(UiMessage.Notify.SetInsightCustomStartTime, this.onSetInsightCustomStartTime.bind(this));
42+
}
4043

4144

4245
onRefreshRequested(codeObject: CodeObjectInfo): void {
@@ -123,12 +126,10 @@ export class InsightsViewTab implements ICodeAnalyticsViewTab
123126
}
124127
catch(e)
125128
{
126-
127-
let html = new HandleDigmaBackendExceptions(this._viewUris).getExceptionMessageHtml(e);
128-
this.updateListView(html);
129+
this.showError(e);
129130
return;
130-
131131
}
132+
132133
try{
133134

134135
let groupItems = await new CodeObjectGroupDiscovery(this._groupViewItemCreator).getGroups(usageResults.codeObjectStatuses);
@@ -201,7 +202,10 @@ export class InsightsViewTab implements ICodeAnalyticsViewTab
201202
this._channel?.publish(new UiMessage.Set.InsightsList(html));
202203
}
203204

204-
205+
public showError(error: any): void {
206+
let html = new HandleDigmaBackendExceptions(this._viewUris).getExceptionMessageHtml(error);
207+
this.updateListView(html);
208+
}
205209

206210
public getHtml(): string {
207211
return /*html*/`
@@ -213,4 +217,19 @@ export class InsightsViewTab implements ICodeAnalyticsViewTab
213217
214218
`;
215219
}
220+
221+
private async onSetInsightCustomStartTime(event: UiMessage.Notify.SetInsightCustomStartTime) {
222+
if (event.codeObjectId && event.insightType && event.time) {
223+
try {
224+
await this._analyticsProvider.setInsightCustomStartTime(
225+
event.codeObjectId,
226+
event.insightType,
227+
event.time,
228+
);
229+
}
230+
catch(error) {
231+
this.showError(error);
232+
}
233+
}
234+
}
216235
}

src/views/codeAnalytics/summaryViewTab.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ export class UsagesViewTab implements ICodeAnalyticsViewTab
4949
usageResults = await this._analyticsProvider.getUsageStatus([]);
5050
}
5151
catch(e){
52-
let html = new HandleDigmaBackendExceptions(this._webViewUris).getExceptionMessageHtml(e);
53-
this.updateListView(html);
52+
this.showError(e);
5453
return;
5554
}
5655

@@ -96,4 +95,9 @@ export class UsagesViewTab implements ICodeAnalyticsViewTab
9695
// </div>
9796
// </div>`;
9897
}
98+
99+
public showError(error: any): void {
100+
let html = new HandleDigmaBackendExceptions(this._webViewUris).getExceptionMessageHtml(error);
101+
this.updateListView(html);
102+
}
99103
}

0 commit comments

Comments
 (0)