From dfbc34ebccf9fcc2bd93487aa66252ae07b0a112 Mon Sep 17 00:00:00 2001 From: olehp Date: Fri, 24 May 2024 16:52:03 +0300 Subject: [PATCH 1/4] Handle navigation --- .../Navigation/ScopeNavigation/HistoryManager.ts | 10 ++++++++++ src/components/Navigation/ScopeNavigation/index.tsx | 9 ++++++--- src/types.ts | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/Navigation/ScopeNavigation/HistoryManager.ts b/src/components/Navigation/ScopeNavigation/HistoryManager.ts index 4cf02c70..ccbf6082 100644 --- a/src/components/Navigation/ScopeNavigation/HistoryManager.ts +++ b/src/components/Navigation/ScopeNavigation/HistoryManager.ts @@ -32,6 +32,7 @@ export class HistoryManager { private current: Node | null = null; private itemsCount = 0; private currentIndex = -1; + private debug = false; constructor(data?: HistoryData) { if (data) { @@ -69,6 +70,8 @@ export class HistoryManager { } else { this.itemsCount++; } + + this.debug && console.log("History pushed: ", this.getHistoryData()); } canMoveBack() { @@ -85,6 +88,8 @@ export class HistoryManager { this.current = this.current.previous; this.currentIndex--; + + this.debug && console.log("History back: ", this.getHistoryData()); return this.getCurrent(); } @@ -102,6 +107,8 @@ export class HistoryManager { this.current = this.current.next; this.currentIndex++; + + this.debug && console.log("History forward: ", this.getHistoryData()); return this.getCurrent(); } @@ -117,6 +124,9 @@ export class HistoryManager { if (this.current) { this.current.value = { ...this.current.value, ...newValue }; } + + this.debug && + console.log("History current updated: ", this.getHistoryData()); } getHistoryData() { diff --git a/src/components/Navigation/ScopeNavigation/index.tsx b/src/components/Navigation/ScopeNavigation/index.tsx index a84cb56b..7fee032f 100644 --- a/src/components/Navigation/ScopeNavigation/index.tsx +++ b/src/components/Navigation/ScopeNavigation/index.tsx @@ -19,7 +19,8 @@ const changeScope = (scope: Scope | null) => { window.sendMessageToDigma({ action: globalActions.CHANGE_SCOPE, payload: { - span: scope?.span || null + span: scope?.span || null, + forceNavigation: true } }); }; @@ -92,13 +93,15 @@ export const ScopeNavigation = (props: ScopeNavigationProps) => { const handleViewChange = (data: unknown) => { const payload = data as SetViewsPayload; + const view = payload.views.find((x) => x.isSelected); + const viewId = [view?.id, view?.path].filter((x) => Boolean(x)).join("/"); + const currentStep = historyManager.getCurrent(); if (!payload.triggeredByJcef) { + historyManager.updateCurrent({ tabId: viewId }); return; } - const view = payload.views.find((x) => x.isSelected); - const viewId = [view?.id, view?.path].filter((x) => Boolean(x)).join("/"); if (view && currentStep && currentStep?.tabId !== viewId) { historyManager.push({ environment: environment, diff --git a/src/types.ts b/src/types.ts index 3068947b..ca4f48fd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -82,6 +82,7 @@ export interface ChangeScopePayload { span: { spanCodeObjectId: string; } | null; + forceNavigation?: boolean; } export interface ChangeViewPayload { From eef95861b27f43c8738c227235a90c57f45f95cf Mon Sep 17 00:00:00 2001 From: olehp Date: Fri, 24 May 2024 18:34:12 +0300 Subject: [PATCH 2/4] rename triggeredByJcef --- src/components/Navigation/ScopeNavigation/index.tsx | 2 +- src/components/Navigation/mockData.ts | 2 +- src/components/Navigation/types.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Navigation/ScopeNavigation/index.tsx b/src/components/Navigation/ScopeNavigation/index.tsx index 7fee032f..f8977861 100644 --- a/src/components/Navigation/ScopeNavigation/index.tsx +++ b/src/components/Navigation/ScopeNavigation/index.tsx @@ -97,7 +97,7 @@ export const ScopeNavigation = (props: ScopeNavigationProps) => { const viewId = [view?.id, view?.path].filter((x) => Boolean(x)).join("/"); const currentStep = historyManager.getCurrent(); - if (!payload.triggeredByJcef) { + if (!payload.createHistoryStep) { historyManager.updateCurrent({ tabId: viewId }); return; } diff --git a/src/components/Navigation/mockData.ts b/src/components/Navigation/mockData.ts index 84325ac9..7d7e843b 100644 --- a/src/components/Navigation/mockData.ts +++ b/src/components/Navigation/mockData.ts @@ -67,5 +67,5 @@ export const mockedViewsData: SetViewsPayload = { cardName: "tests" } ], - triggeredByJcef: false + createHistoryStep: false }; diff --git a/src/components/Navigation/types.ts b/src/components/Navigation/types.ts index 7f860390..31748368 100644 --- a/src/components/Navigation/types.ts +++ b/src/components/Navigation/types.ts @@ -34,7 +34,7 @@ export interface ChangeViewPayload { export interface SetViewsPayload { views: TabData[]; - triggeredByJcef: boolean; + createHistoryStep: boolean; } export interface AutoFixMissingDependencyPayload { From 38c70bc06faf443d3fa197dded8606e11e96d79b Mon Sep 17 00:00:00 2001 From: olehp Date: Fri, 24 May 2024 18:56:46 +0300 Subject: [PATCH 3/4] update logs --- src/api/index.ts | 11 +++++++---- .../Navigation/ScopeNavigation/HistoryManager.ts | 9 ++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 01b562ac..4b4ca92a 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -27,7 +27,7 @@ export const initializeDigmaMessageListener = ( export const sendMessage = ( message: DigmaOutgoingMessageData ): string | undefined => { - console.debug("Message to send:", message); + console.debug("Digma message to send:", message); switch (platform) { case "Web": @@ -36,7 +36,7 @@ export const sendMessage = ( case "VS Code": if (window.sendMessageToVSCode) { window.sendMessageToVSCode(message); - console.debug("Message has been sent to VS Code: ", message); + console.debug("Digma message has been sent to VS Code: ", message); } break; case "JetBrains": @@ -44,11 +44,14 @@ export const sendMessage = ( return window.cefQuery({ request: JSON.stringify(message), onSuccess: function (response) { - console.debug("cefQuery has been successfully sent: %s", response); + console.debug( + "Digma message cefQuery has been successfully sent: %s", + response + ); }, onFailure: function (error_code, error_message) { console.error( - "Failed to send cefQuery: %d, %s", + " Digma message failed to send cefQuery: %d, %s", error_code, error_message ); diff --git a/src/components/Navigation/ScopeNavigation/HistoryManager.ts b/src/components/Navigation/ScopeNavigation/HistoryManager.ts index ccbf6082..321997df 100644 --- a/src/components/Navigation/ScopeNavigation/HistoryManager.ts +++ b/src/components/Navigation/ScopeNavigation/HistoryManager.ts @@ -71,7 +71,7 @@ export class HistoryManager { this.itemsCount++; } - this.debug && console.log("History pushed: ", this.getHistoryData()); + console.debug("History: pushed: ", this.getHistoryData()); } canMoveBack() { @@ -89,7 +89,7 @@ export class HistoryManager { this.current = this.current.previous; this.currentIndex--; - this.debug && console.log("History back: ", this.getHistoryData()); + console.debug("History: back: ", this.getHistoryData()); return this.getCurrent(); } @@ -108,7 +108,7 @@ export class HistoryManager { this.current = this.current.next; this.currentIndex++; - this.debug && console.log("History forward: ", this.getHistoryData()); + console.debug("History: forward: ", this.getHistoryData()); return this.getCurrent(); } @@ -125,8 +125,7 @@ export class HistoryManager { this.current.value = { ...this.current.value, ...newValue }; } - this.debug && - console.log("History current updated: ", this.getHistoryData()); + console.debug("History: current updated: ", this.getHistoryData()); } getHistoryData() { From 08488b0c256652368b30221ad6b31fa1f9a6f85e Mon Sep 17 00:00:00 2001 From: olehp Date: Fri, 24 May 2024 19:06:14 +0300 Subject: [PATCH 4/4] revert --- .../Navigation/ScopeNavigation/HistoryManager.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/Navigation/ScopeNavigation/HistoryManager.ts b/src/components/Navigation/ScopeNavigation/HistoryManager.ts index 321997df..ccbf6082 100644 --- a/src/components/Navigation/ScopeNavigation/HistoryManager.ts +++ b/src/components/Navigation/ScopeNavigation/HistoryManager.ts @@ -71,7 +71,7 @@ export class HistoryManager { this.itemsCount++; } - console.debug("History: pushed: ", this.getHistoryData()); + this.debug && console.log("History pushed: ", this.getHistoryData()); } canMoveBack() { @@ -89,7 +89,7 @@ export class HistoryManager { this.current = this.current.previous; this.currentIndex--; - console.debug("History: back: ", this.getHistoryData()); + this.debug && console.log("History back: ", this.getHistoryData()); return this.getCurrent(); } @@ -108,7 +108,7 @@ export class HistoryManager { this.current = this.current.next; this.currentIndex++; - console.debug("History: forward: ", this.getHistoryData()); + this.debug && console.log("History forward: ", this.getHistoryData()); return this.getCurrent(); } @@ -125,7 +125,8 @@ export class HistoryManager { this.current.value = { ...this.current.value, ...newValue }; } - console.debug("History: current updated: ", this.getHistoryData()); + this.debug && + console.log("History current updated: ", this.getHistoryData()); } getHistoryData() {