refactor: icon to icons for lastupdated component (#15401)
* intial commit * fix test * Update superset-frontend/src/components/LastUpdated/index.tsx Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com> Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
This commit is contained in:
parent
a0179ac513
commit
076f774daf
|
|
@ -34,7 +34,7 @@ describe('LastUpdated', () => {
|
||||||
it('renders a refresh action', () => {
|
it('renders a refresh action', () => {
|
||||||
const mockAction = jest.fn();
|
const mockAction = jest.fn();
|
||||||
wrapper = mount(<LastUpdated updatedAt={updatedAt} update={mockAction} />);
|
wrapper = mount(<LastUpdated updatedAt={updatedAt} update={mockAction} />);
|
||||||
const props = wrapper.find('[data-test="refresh"]').first().props();
|
const props = wrapper.find('[aria-label="refresh"]').first().props();
|
||||||
if (props.onClick) {
|
if (props.onClick) {
|
||||||
props.onClick({} as React.MouseEvent);
|
props.onClick({} as React.MouseEvent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@
|
||||||
import React, { useEffect, useState, FunctionComponent } from 'react';
|
import React, { useEffect, useState, FunctionComponent } from 'react';
|
||||||
import moment, { Moment, MomentInput } from 'moment';
|
import moment, { Moment, MomentInput } from 'moment';
|
||||||
import { t, styled } from '@superset-ui/core';
|
import { t, styled } from '@superset-ui/core';
|
||||||
import Icon from 'src/components/Icon';
|
import Icons from 'src/components/Icons';
|
||||||
|
|
||||||
const REFRESH_INTERVAL = 60000; // every minute
|
const REFRESH_INTERVAL = 60000; // every minute
|
||||||
|
|
||||||
interface LastUpdatedProps {
|
interface LastUpdatedProps {
|
||||||
updatedAt: MomentInput;
|
updatedAt: MomentInput;
|
||||||
update?: React.MouseEventHandler<SVGSVGElement>;
|
update?: React.MouseEventHandler<HTMLSpanElement>;
|
||||||
}
|
}
|
||||||
moment.updateLocale('en', {
|
moment.updateLocale('en', {
|
||||||
calendar: {
|
calendar: {
|
||||||
|
|
@ -42,7 +42,7 @@ const TextStyles = styled.span`
|
||||||
color: ${({ theme }) => theme.colors.grayscale.base};
|
color: ${({ theme }) => theme.colors.grayscale.base};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Refresh = styled(Icon)`
|
const Refresh = styled(Icons.Refresh)`
|
||||||
color: ${({ theme }) => theme.colors.primary.base};
|
color: ${({ theme }) => theme.colors.primary.base};
|
||||||
width: auto;
|
width: auto;
|
||||||
height: ${({ theme }) => theme.gridUnit * 5}px;
|
height: ${({ theme }) => theme.gridUnit * 5}px;
|
||||||
|
|
@ -72,7 +72,7 @@ export const LastUpdated: FunctionComponent<LastUpdatedProps> = ({
|
||||||
return (
|
return (
|
||||||
<TextStyles>
|
<TextStyles>
|
||||||
{t('Last Updated %s', timeSince.isValid() ? timeSince.calendar() : '--')}
|
{t('Last Updated %s', timeSince.isValid() ? timeSince.calendar() : '--')}
|
||||||
{update && <Refresh name="refresh" onClick={update} />}
|
{update && <Refresh onClick={update} />}
|
||||||
</TextStyles>
|
</TextStyles>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue