1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix download all logs for pod with few containers (#7413)

* Use container name as downloaded file name

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Specify container to call for logs query

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Fixing tests

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

---------

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2023-03-27 12:22:37 +03:00 committed by GitHub
parent 8dc0177cb2
commit 7d71873135
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -190,12 +190,12 @@ describe("download logs options in logs dock tab", () => {
it("logs have been called with query", () => { it("logs have been called with query", () => {
expect(callForLogsMock).toHaveBeenCalledWith( expect(callForLogsMock).toHaveBeenCalledWith(
{ name: "dockerExporter", namespace: "default" }, { name: "dockerExporter", namespace: "default" },
{ "previous": true, "timestamps": false }, { "previous": true, "timestamps": false, container: "docker-exporter" },
); );
}); });
it("shows save dialog with proper attributes", async () => { it("shows save dialog with proper attributes", async () => {
expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "all-logs", "text/plain"); expect(openSaveFileDialogMock).toHaveBeenCalledWith("docker-exporter.log", "all-logs", "text/plain");
}); });
it("doesn't block download dropdown for interaction after click", async () => { it("doesn't block download dropdown for interaction after click", async () => {
@ -265,7 +265,7 @@ describe("download logs options in logs dock tab", () => {
it("logs have been called", () => { it("logs have been called", () => {
expect(callForLogsMock).toHaveBeenCalledWith( expect(callForLogsMock).toHaveBeenCalledWith(
{ name: "dockerExporter", namespace: "default" }, { name: "dockerExporter", namespace: "default" },
{ "previous": true, "timestamps": false }, { "previous": true, "timestamps": false, container: "docker-exporter" },
); );
}); });

View File

@ -25,7 +25,7 @@ const downloadAllLogsInjectable = getInjectable({
}); });
if (logs) { if (logs) {
openSaveFileDialog(`${params.name}.log`, logs, "text/plain"); openSaveFileDialog(`${query.container}.log`, logs, "text/plain");
} else { } else {
showErrorNotification("No logs to download"); showErrorNotification("No logs to download");
} }

View File

@ -101,7 +101,7 @@ export class LogTabViewModel {
if (pod && tabData) { if (pod && tabData) {
const params = { name: pod.getName(), namespace: pod.getNs() }; const params = { name: pod.getName(), namespace: pod.getNs() };
const query = { timestamps: tabData.showTimestamps, previous: tabData.showPrevious }; const query = { timestamps: tabData.showTimestamps, previous: tabData.showPrevious, container: tabData.selectedContainer };
return this.dependencies.downloadAllLogs(params, query); return this.dependencies.downloadAllLogs(params, query);
} }