Skip to content

Commit

Permalink
Merge pull request #861 from digma-ai/feature/navigation-ui
Browse files Browse the repository at this point in the history
Feature/navigation UI
  • Loading branch information
kshmidt-digma committed May 24, 2024
2 parents dade36a + 08488b0 commit 927a9b2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
11 changes: 7 additions & 4 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const initializeDigmaMessageListener = (
export const sendMessage = <T>(
message: DigmaOutgoingMessageData<T>
): string | undefined => {
console.debug("Message to send:", message);
console.debug("Digma message to send:", message);

Check warning on line 30 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 30 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement

switch (platform) {
case "Web":
Expand All @@ -36,19 +36,22 @@ export const sendMessage = <T>(
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);

Check warning on line 39 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 39 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement
}
break;
case "JetBrains":
if (window.cefQuery) {
return window.cefQuery({
request: JSON.stringify(message),
onSuccess: function (response) {
console.debug("cefQuery has been successfully sent: %s", response);
console.debug(

Check warning on line 47 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 47 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement
"Digma message cefQuery has been successfully sent: %s",
response
);
},
onFailure: function (error_code, error_message) {
console.error(

Check warning on line 53 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 53 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement
"Failed to send cefQuery: %d, %s",
" Digma message failed to send cefQuery: %d, %s",
error_code,
error_message
);
Expand Down
10 changes: 10 additions & 0 deletions src/components/Navigation/ScopeNavigation/HistoryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class HistoryManager {
private current: Node<HistoryStep> | null = null;
private itemsCount = 0;
private currentIndex = -1;
private debug = false;

constructor(data?: HistoryData) {
if (data) {
Expand Down Expand Up @@ -69,6 +70,8 @@ export class HistoryManager {
} else {
this.itemsCount++;
}

this.debug && console.log("History pushed: ", this.getHistoryData());
}

canMoveBack() {
Expand All @@ -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();
}

Expand All @@ -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();
}

Expand All @@ -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() {
Expand Down
11 changes: 7 additions & 4 deletions src/components/Navigation/ScopeNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const changeScope = (scope: Scope | null) => {
window.sendMessageToDigma<ChangeScopePayload>({
action: globalActions.CHANGE_SCOPE,
payload: {
span: scope?.span || null
span: scope?.span || null,
forceNavigation: true
}
});
};
Expand Down Expand Up @@ -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) {
if (!payload.createHistoryStep) {
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,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ export const mockedViewsData: SetViewsPayload = {
cardName: "tests"
}
],
triggeredByJcef: false
createHistoryStep: false
};
2 changes: 1 addition & 1 deletion src/components/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface ChangeViewPayload {

export interface SetViewsPayload {
views: TabData[];
triggeredByJcef: boolean;
createHistoryStep: boolean;
}

export interface AutoFixMissingDependencyPayload {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export interface ChangeScopePayload {
span: {
spanCodeObjectId: string;
} | null;
forceNavigation?: boolean;
}

export interface ChangeViewPayload {
Expand Down

0 comments on commit 927a9b2

Please sign in to comment.