fix: interval is blocked for custom time selection (#2146)

* fix: interval is blocked for custom time selection

* fix: custom is updated

* chore: selectedTime is updated in hidden logic
This commit is contained in:
Palash Gupta 2023-01-30 19:27:13 +05:30 committed by GitHub
parent af272a368b
commit 3115b32dcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -37,8 +37,11 @@ function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {
const { pathname } = useLocation();
const isDisabled = useMemo(
() => disabled || globalTime.isAutoRefreshDisabled,
[globalTime.isAutoRefreshDisabled, disabled],
() =>
disabled ||
globalTime.isAutoRefreshDisabled ||
globalTime.selectedTime === 'custom',
[globalTime.isAutoRefreshDisabled, disabled, globalTime.selectedTime],
);
const localStorageData = JSON.parse(get(DASHBOARD_TIME_IN_DURATION) || '{}');
@ -132,6 +135,11 @@ function AutoRefresh({ disabled = false }: AutoRefreshProps): JSX.Element {
[localStorageData, pathname],
);
if (globalTime.selectedTime === 'custom') {
// eslint-disable-next-line react/jsx-no-useless-fragment
return <></>;
}
return (
<Popover
placement="bottomLeft"

View File

@ -88,6 +88,14 @@ function DateTimeSelection({
return timeInterval;
};
useEffect(() => {
if (selectedTime === 'custom') {
setRefreshButtonHidden(true);
} else {
setRefreshButtonHidden(false);
}
}, [selectedTime]);
const getDefaultTime = (pathName: string): Time => {
const defaultSelectedOption = getDefaultOption(pathName);