diff --git a/web-console/src/components/refresh-button/refresh-button.tsx b/web-console/src/components/refresh-button/refresh-button.tsx index 681bd4225ec..04fe1609fd2 100644 --- a/web-console/src/components/refresh-button/refresh-button.tsx +++ b/web-console/src/components/refresh-button/refresh-button.tsx @@ -42,7 +42,7 @@ export const RefreshButton = React.memo(function RefreshButton(props: RefreshBut return ( - - - - + + + `; diff --git a/web-console/src/components/timed-button/timed-button.scss b/web-console/src/components/timed-button/timed-button.scss deleted file mode 100644 index f4d77005129..00000000000 --- a/web-console/src/components/timed-button/timed-button.scss +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -.timed-button { - padding: 10px 10px 5px 10px; -} diff --git a/web-console/src/components/timed-button/timed-button.spec.tsx b/web-console/src/components/timed-button/timed-button.spec.tsx index e5025fb7310..61c0ca54655 100644 --- a/web-console/src/components/timed-button/timed-button.spec.tsx +++ b/web-console/src/components/timed-button/timed-button.spec.tsx @@ -16,22 +16,22 @@ * limitations under the License. */ -import { render } from '@testing-library/react'; +import { shallow } from 'enzyme'; import React from 'react'; import { TimedButton } from './timed-button'; -describe('Timed button', () => { +describe('TimedButton', () => { it('matches snapshot', () => { - const timedButton = ( + const timedButton = shallow( null} - label={'label'} + label={'Select delay'} defaultDelay={1000} - /> + />, ); - const { container } = render(timedButton); - expect(container.firstChild).toMatchSnapshot(); + + expect(timedButton).toMatchSnapshot(); }); }); diff --git a/web-console/src/components/timed-button/timed-button.tsx b/web-console/src/components/timed-button/timed-button.tsx index 78a07652a0a..fe7a990843c 100644 --- a/web-console/src/components/timed-button/timed-button.tsx +++ b/web-console/src/components/timed-button/timed-button.tsx @@ -16,15 +16,21 @@ * limitations under the License. */ -import { Button, ButtonGroup, IButtonProps, Popover, Radio, RadioGroup } from '@blueprintjs/core'; +import { + Button, + ButtonGroup, + IButtonProps, + Menu, + MenuDivider, + MenuItem, + Popover, +} from '@blueprintjs/core'; import { IconNames } from '@blueprintjs/icons'; import React, { useState } from 'react'; import { useInterval } from '../../hooks'; import { localStorageGet, LocalStorageKeys, localStorageSet } from '../../utils'; -import './timed-button.scss'; - export interface DelayLabel { label: string; delay: number; @@ -51,7 +57,7 @@ export const TimedButton = React.memo(function TimedButton(props: TimedButtonPro ...other } = props; - const [delay, setDelay] = useState( + const [selectedDelay, setSelectedDelay] = useState( localStorageKey && localStorageGet(localStorageKey) ? Number(localStorageGet(localStorageKey)) : defaultDelay, @@ -59,31 +65,31 @@ export const TimedButton = React.memo(function TimedButton(props: TimedButtonPro useInterval(() => { onRefresh(true); - }, delay); + }, selectedDelay); - function handleSelection(e: any) { - const selectedDelay = Number(e.currentTarget.value); - setDelay(selectedDelay); + function handleSelection(delay: number) { + setSelectedDelay(delay); if (localStorageKey) { - localStorageSet(localStorageKey, String(selectedDelay)); + localStorageSet(localStorageKey, String(delay)); } } return ( - +