Skip to content

Commit

Permalink
Fix zowe#3286
Browse files Browse the repository at this point in the history
Signed-off-by: JWaters02 <watersjoshua2002@gmail.com>
  • Loading branch information
JWaters02 committed Feb 6, 2025
1 parent eeeaf84 commit cc022f2
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen

- Fixed an issue where a TypeError occurred when applying VS Code proxy settings to an invalid session. [#3425](https://github.com/zowe/zowe-explorer-vscode/issues/3425)
- Fixed issue where the 'Delete' key binding for the USS tree returns a 'contextValue' error. [#2796](https://github.com/zowe/zowe-explorer-vscode/issues/2796)
- Fixed a bug where edit history does not show the correct information. [#3286](https://github.com/zowe/zowe-explorer-vscode/issues/3432)

## `3.1.0`

Expand Down
19 changes: 17 additions & 2 deletions packages/zowe-explorer/src/trees/shared/SharedHistoryView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class SharedHistoryView extends WebView {
}

protected async onDidReceiveMessage(message: any): Promise<void> {
ZoweLogger.trace("HistoryView.onDidReceiveMessage called.");
switch (message.command) {
case "refresh":
await this.refreshView(message);
Expand All @@ -59,7 +60,7 @@ export class SharedHistoryView extends WebView {
this.showError(message);
break;
case "update-selection":
this.updateSelection(message);
await this.updateSelection(message);
break;
case "add-item":
await this.addItem(message);
Expand Down Expand Up @@ -93,11 +94,23 @@ export class SharedHistoryView extends WebView {
}

private getTreeProvider(type: string): Definitions.TreeProvider {
ZoweLogger.trace("HistoryView.getTreeProvider called.");
return this.treeProviders[type === "jobs" ? "job" : type] as Definitions.TreeProvider;
}

private getHistoryData(type: string): Definitions.History {
ZoweLogger.trace("HistoryView.getHistoryData called.");
const treeProvider = this.treeProviders[type] as Definitions.TreeProvider;
if (!treeProvider) {
ZoweLogger.error(`No tree provider found for type: ${type}`);
return {
search: [],
sessions: [],
fileHistory: [],
favorites: [],
encodingHistory: [],
};
}
return {
search: treeProvider.getSearchHistory(),
sessions: treeProvider.getSessions(),
Expand All @@ -108,6 +121,7 @@ export class SharedHistoryView extends WebView {
}

private fetchEncodingHistory(): string[] {
ZoweLogger.trace("HistoryView.fetchEncodingHistory called.");
return ZoweLocalStorage.getValue<string[]>(Definitions.LocalStorageKey.ENCODING_HISTORY) ?? [];
}

Expand All @@ -116,9 +130,10 @@ export class SharedHistoryView extends WebView {
Gui.errorMessage(message.attrs.errorMsg);
}

private updateSelection(message): void {
private async updateSelection(message): Promise<void> {
ZoweLogger.trace("HistoryView.updateSelection called.");
this.currentSelection[message.attrs.type] = message.attrs.selection;
await this.refreshView(message);
}

private async addItem(message): Promise<void> {
Expand Down
12 changes: 10 additions & 2 deletions packages/zowe-explorer/src/webviews/src/edit-history/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import * as l10n from "@vscode/l10n";
export function App(): JSXInternal.Element {
const [timestamp, setTimestamp] = useState<Date | undefined>();
const [currentTab, setCurrentTab] = useState<{ [key: string]: string }>({});

useEffect(() => {
window.addEventListener("message", (event) => {
const handleMessage = (event: MessageEvent) => {
if (!isSecureOrigin(event.origin)) {
return;
}
Expand All @@ -41,9 +42,16 @@ export function App(): JSXInternal.Element {
contents: contents,
});
}
});
};

window.addEventListener("message", handleMessage);
PersistentVSCodeAPI.getVSCodeAPI().postMessage({ command: "ready" });
console.log("App.tsx: ready called");
PersistentVSCodeAPI.getVSCodeAPI().postMessage({ command: "GET_LOCALIZATION" });

return () => {
window.removeEventListener("message", handleMessage);
};
}, []);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import PersistentDataGridHeaders from "./PersistentDataGridHeaders";
import PersistentVSCodeAPI from "../../../PersistentVSCodeAPI";

export default function PersistentDataPanel({ type }: Readonly<{ type: Readonly<string> }>): JSXInternal.Element {
const [data, setData] = useState<{ [type: string]: { [property: string]: string[] } }>({ ds: {}, uss: {}, jobs: {} });
const [data, setData] = useState<{ [type: string]: { [property: string]: string[] } }>({ ds: {}, uss: {}, jobs: {}, cmds: {} });
const [selection, setSelection] = useState<{ [type: string]: string }>({ [type]: "search" });
const [persistentProp, setPersistentProp] = useState<string[]>([]);
const [selectedItems, setSelectedItems] = useState({});
Expand Down Expand Up @@ -51,11 +51,11 @@ export default function PersistentDataPanel({ type }: Readonly<{ type: Readonly<
};

useEffect(() => {
window.addEventListener("message", (event) => {
const handleMessage = (event: MessageEvent) => {
if (!isSecureOrigin(event.origin)) {
return;
}
if (event.data.ds && event.data.uss && event.data.jobs) {
if (event.data.ds && event.data.uss && event.data.jobs && event.data.cmds) {
setData(event.data);

if ("selection" in event.data) {
Expand All @@ -64,16 +64,20 @@ export default function PersistentDataPanel({ type }: Readonly<{ type: Readonly<
}));
}
}
});
}, []);
};

useEffect(() => {
setPersistentProp(() => data[type][selection[type]]);
}, [data]);
window.addEventListener("message", handleMessage);

return () => {
window.removeEventListener("message", handleMessage);
};
}, [type]);

useEffect(() => {
setPersistentProp(() => data[type][selection[type]]);
}, [selection]);
if (data[type] && selection[type]) {
setPersistentProp(() => data[type][selection[type]] || []);
}
}, [data, selection, type]);

if (type == "cmds") {
return (
Expand Down

0 comments on commit cc022f2

Please sign in to comment.