mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Drop waiting state on network or other error
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
a7d7fa9c9a
commit
c0d254a71e
@ -6,13 +6,12 @@
|
|||||||
import styles from "./download-logs-dropdown.module.scss";
|
import styles from "./download-logs-dropdown.module.scss";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { cssNames } from "../../../utils";
|
|
||||||
import { Icon } from "../../icon";
|
import { Icon } from "../../icon";
|
||||||
import { Menu, MenuItem } from "../../menu";
|
import { Menu, MenuItem } from "../../menu";
|
||||||
|
|
||||||
interface DownloadLogsDropdownProps {
|
interface DownloadLogsDropdownProps {
|
||||||
downloadVisibleLogs: () => Promise<boolean>
|
downloadVisibleLogs: () => Promise<any>
|
||||||
downloadAllLogs: () => Promise<boolean>
|
downloadAllLogs: () => Promise<any>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DownloadLogsDropdown({ downloadAllLogs, downloadVisibleLogs }: DownloadLogsDropdownProps) {
|
export function DownloadLogsDropdown({ downloadAllLogs, downloadVisibleLogs }: DownloadLogsDropdownProps) {
|
||||||
@ -23,10 +22,13 @@ export function DownloadLogsDropdown({ downloadAllLogs, downloadVisibleLogs }: D
|
|||||||
setOpened(!opened);
|
setOpened(!opened);
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadLogs = async (download: () => Promise<boolean>) => {
|
const downloadLogs = async (download: () => Promise<void>) => {
|
||||||
setWaiting(true);
|
setWaiting(true);
|
||||||
await download();
|
try {
|
||||||
setWaiting(false);
|
await download();
|
||||||
|
} finally {
|
||||||
|
setWaiting(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -34,7 +36,8 @@ export function DownloadLogsDropdown({ downloadAllLogs, downloadVisibleLogs }: D
|
|||||||
<button
|
<button
|
||||||
data-testid="download-logs-dropdown"
|
data-testid="download-logs-dropdown"
|
||||||
id="download-logs-dropdown"
|
id="download-logs-dropdown"
|
||||||
className={cssNames(styles.dropdown, { [styles.waiting]: waiting })}
|
className={styles.dropdown}
|
||||||
|
disabled={waiting}
|
||||||
>
|
>
|
||||||
Download
|
Download
|
||||||
<Icon material="arrow_drop_down" smallest/>
|
<Icon material="arrow_drop_down" smallest/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user