2019-09-17 04:25:12 -05:00
|
|
|
import React from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import tinycolor from 'tinycolor2';
|
2019-11-22 05:26:14 -06:00
|
|
|
import { css } from 'emotion';
|
2019-09-20 06:00:11 -05:00
|
|
|
import { CSSTransition } from 'react-transition-group';
|
2020-04-12 15:20:02 -05:00
|
|
|
import { useTheme, Tooltip, stylesFactory, selectThemeVariant, Icon } from '@grafana/ui';
|
2019-10-31 04:48:05 -05:00
|
|
|
import { GrafanaTheme } from '@grafana/data';
|
2019-09-17 04:25:12 -05:00
|
|
|
|
2019-11-22 05:26:14 -06:00
|
|
|
//Components
|
|
|
|
import { ResponsiveButton } from './ResponsiveButton';
|
|
|
|
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
2020-04-12 08:05:49 -05:00
|
|
|
const bgColor = selectThemeVariant({ light: theme.palette.gray5, dark: theme.palette.dark1 }, theme.type);
|
|
|
|
const orangeLighter = tinycolor(theme.palette.orangeDark)
|
2019-09-20 06:00:11 -05:00
|
|
|
.lighten(10)
|
|
|
|
.toString();
|
2020-04-12 08:05:49 -05:00
|
|
|
const pulseTextColor = tinycolor(theme.palette.orangeDark)
|
2019-09-20 06:00:11 -05:00
|
|
|
.desaturate(90)
|
|
|
|
.toString();
|
2019-09-17 04:25:12 -05:00
|
|
|
return {
|
|
|
|
noRightBorderStyle: css`
|
|
|
|
label: noRightBorderStyle;
|
|
|
|
border-right: 0;
|
|
|
|
`,
|
2019-09-20 06:00:11 -05:00
|
|
|
liveButton: css`
|
|
|
|
label: liveButton;
|
|
|
|
margin: 0;
|
|
|
|
`,
|
2019-09-17 04:25:12 -05:00
|
|
|
isLive: css`
|
|
|
|
label: isLive;
|
2020-04-12 08:05:49 -05:00
|
|
|
border-color: ${theme.palette.orangeDark};
|
|
|
|
color: ${theme.palette.orangeDark};
|
2019-09-17 04:25:12 -05:00
|
|
|
background: transparent;
|
|
|
|
&:focus {
|
2019-11-22 05:26:14 -06:00
|
|
|
background: transparent;
|
2020-04-12 08:05:49 -05:00
|
|
|
border-color: ${theme.palette.orangeDark};
|
|
|
|
color: ${theme.palette.orangeDark};
|
2019-09-17 04:25:12 -05:00
|
|
|
}
|
2019-11-22 05:26:14 -06:00
|
|
|
&:hover {
|
|
|
|
background-color: ${bgColor};
|
|
|
|
}
|
2019-09-17 04:25:12 -05:00
|
|
|
&:active,
|
|
|
|
&:hover {
|
|
|
|
border-color: ${orangeLighter};
|
|
|
|
color: ${orangeLighter};
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
isPaused: css`
|
|
|
|
label: isPaused;
|
2020-04-12 08:05:49 -05:00
|
|
|
border-color: ${theme.palette.orangeDark};
|
2019-09-17 04:25:12 -05:00
|
|
|
background: transparent;
|
2019-09-20 06:00:11 -05:00
|
|
|
animation: pulse 3s ease-out 0s infinite normal forwards;
|
2019-09-17 04:25:12 -05:00
|
|
|
&:focus {
|
2019-11-22 05:26:14 -06:00
|
|
|
background: transparent;
|
2020-04-12 08:05:49 -05:00
|
|
|
border-color: ${theme.palette.orangeDark};
|
2019-09-17 04:25:12 -05:00
|
|
|
}
|
2019-11-22 05:26:14 -06:00
|
|
|
&:hover {
|
|
|
|
background-color: ${bgColor};
|
|
|
|
}
|
2019-09-17 04:25:12 -05:00
|
|
|
&:active,
|
|
|
|
&:hover {
|
|
|
|
border-color: ${orangeLighter};
|
|
|
|
}
|
|
|
|
@keyframes pulse {
|
|
|
|
0% {
|
2019-09-20 06:00:11 -05:00
|
|
|
color: ${pulseTextColor};
|
2019-09-17 04:25:12 -05:00
|
|
|
}
|
|
|
|
50% {
|
2020-04-12 08:05:49 -05:00
|
|
|
color: ${theme.palette.orangeDark};
|
2019-09-17 04:25:12 -05:00
|
|
|
}
|
|
|
|
100% {
|
2019-09-20 06:00:11 -05:00
|
|
|
color: ${pulseTextColor};
|
2019-09-17 04:25:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2019-09-20 06:00:11 -05:00
|
|
|
stopButtonEnter: css`
|
|
|
|
label: stopButtonEnter;
|
|
|
|
width: 0;
|
|
|
|
opacity: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
`,
|
|
|
|
stopButtonEnterActive: css`
|
|
|
|
label: stopButtonEnterActive;
|
|
|
|
opacity: 1;
|
|
|
|
width: 32px;
|
|
|
|
`,
|
|
|
|
stopButtonExit: css`
|
|
|
|
label: stopButtonExit;
|
|
|
|
width: 32px;
|
|
|
|
opacity: 1;
|
|
|
|
overflow: hidden;
|
|
|
|
`,
|
|
|
|
stopButtonExitActive: css`
|
|
|
|
label: stopButtonExitActive;
|
|
|
|
opacity: 0;
|
|
|
|
width: 0;
|
|
|
|
`,
|
2019-09-17 04:25:12 -05:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2019-10-07 16:32:50 -05:00
|
|
|
const defaultLiveTooltip = () => {
|
|
|
|
return <>Live</>;
|
2019-10-07 16:30:07 -05:00
|
|
|
};
|
|
|
|
|
2019-09-17 04:25:12 -05:00
|
|
|
type LiveTailButtonProps = {
|
2019-10-10 15:16:04 -05:00
|
|
|
splitted: boolean;
|
2019-09-17 04:25:12 -05:00
|
|
|
start: () => void;
|
|
|
|
stop: () => void;
|
|
|
|
pause: () => void;
|
|
|
|
resume: () => void;
|
|
|
|
isLive: boolean;
|
|
|
|
isPaused: boolean;
|
|
|
|
};
|
|
|
|
export function LiveTailButton(props: LiveTailButtonProps) {
|
2019-10-10 15:16:04 -05:00
|
|
|
const { start, pause, resume, isLive, isPaused, stop, splitted } = props;
|
2019-09-17 04:25:12 -05:00
|
|
|
const theme = useTheme();
|
|
|
|
const styles = getStyles(theme);
|
|
|
|
|
|
|
|
const onClickMain = isLive ? (isPaused ? resume : pause) : start;
|
|
|
|
|
|
|
|
return (
|
2019-09-20 06:00:11 -05:00
|
|
|
<>
|
2019-10-07 16:32:50 -05:00
|
|
|
<Tooltip content={defaultLiveTooltip} placement="bottom">
|
2019-10-10 15:16:04 -05:00
|
|
|
<ResponsiveButton
|
|
|
|
splitted={splitted}
|
|
|
|
buttonClassName={classNames('btn navbar-button', styles.liveButton, {
|
2020-02-12 13:11:40 -06:00
|
|
|
[`btn--radius-right-0 explore-active-button ${styles.noRightBorderStyle}`]: isLive,
|
2019-10-07 16:30:07 -05:00
|
|
|
[styles.isLive]: isLive && !isPaused,
|
|
|
|
[styles.isPaused]: isLive && isPaused,
|
|
|
|
})}
|
@grafana/ui: Create Icon component and replace part of the icons (#23402)
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Resolve type errors resulted from merge
* Part2: Unicons implementation (#23266)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Icons update
* Add optional chaining to for isFontAwesome variable
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Part3: Unicons implementation (#23356)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Implment icons in Tabs
* Implement icons in search items and empty list
* Update buttons
* Update button-related snapshot tests
* Update icons in modals and page headers
* Create anfular wrapper and update all icons on search screen
* Update sizing, remove colors, update snapshot tests
* Remove color prop from icon, remove color implemetation in mono icons
* Remove color props from monochrome icons
* Complete update of icons for search screen
* Update icons for infor tooltips, playlist, permissions
* Support temporarly font awesome icons used in enterprise grafana
* Part1: Unicons implementation (#23197)
* Create a new Icon component
* Update icons in main sidebar
* Update icons in Useful links and in react components on main site
* Update icons in Useful links and in main top navigation
* Adjust sizing
* Update panel navigation and timepicker
* Update icons in Panel menu
* NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
* Update icons in add panel widget
* Resolve merge conflict
* Fix part of the test errors and type errors
* Fix storybook errors
* Update getAvailableIcons import in storybook knobs
* Fix import path
* Fix SyntaxError: Cannot use import statement outside a module in test environment error
* Remove dynamic imports
* Remove types as using @ts-ignore
* Update snapshot test
* Add @iconscout/react-unicons to the shouldExclude list as it is blundled with es2015 syntax
* Remove color prop from icon, remove color implemetation in mono icons
* Update navbar styling
* Move toPascalCase to utils/string
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Update icons in Explore
* Update icons in alerting
* Update + and x buttons
* Update icons in configurations and settings
* Update close icons
* Update icons in rich history
* Update alert messages
* Add optional chaining to for isFontAwesome variable
* Remove icon mock, set up jest.config
* Fix navbar plus icon
* Fir enable-bacground to enableBackgournd
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* Merge remote branch origin master to icons-unicons
* Revert "Merge remote branch origin master to icons-unicons"
This reverts commit 3f25d50a39a940883fefe73ce51219139c1ed37f.
* Size-up dashnav icons
* Fix alerting icons, panel headers, update tests
* Fix typecheck error
* Adjustments - add panel icon, spacing
* Set TerserPlugin sourceMap to false to prevent running out of memory when publishing storybook
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2020-04-08 07:33:31 -05:00
|
|
|
icon={!isLive ? 'play' : 'pause'}
|
|
|
|
iconClassName={isLive && 'icon-brand-gradient'}
|
2019-10-07 16:30:07 -05:00
|
|
|
onClick={onClickMain}
|
2019-10-10 15:16:04 -05:00
|
|
|
title={'\xa0Live'}
|
|
|
|
/>
|
2019-10-07 16:30:07 -05:00
|
|
|
</Tooltip>
|
2019-09-20 06:00:11 -05:00
|
|
|
<CSSTransition
|
|
|
|
mountOnEnter={true}
|
|
|
|
unmountOnExit={true}
|
2020-04-16 06:49:58 -05:00
|
|
|
timeout={100}
|
2019-09-20 06:00:11 -05:00
|
|
|
in={isLive}
|
|
|
|
classNames={{
|
|
|
|
enter: styles.stopButtonEnter,
|
|
|
|
enterActive: styles.stopButtonEnterActive,
|
|
|
|
exit: styles.stopButtonExit,
|
|
|
|
exitActive: styles.stopButtonExitActive,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div>
|
2019-11-22 05:26:14 -06:00
|
|
|
<button
|
2020-02-12 13:11:40 -06:00
|
|
|
className={`btn navbar-button navbar-button--attached explore-active-button ${styles.isLive}`}
|
2019-11-22 05:26:14 -06:00
|
|
|
onClick={stop}
|
|
|
|
>
|
2020-04-16 06:49:58 -05:00
|
|
|
<Icon className="icon-brand-gradient" name="square-shape" size="lg" type="mono" />
|
2019-09-20 06:00:11 -05:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</CSSTransition>
|
|
|
|
</>
|
2019-09-17 04:25:12 -05:00
|
|
|
);
|
|
|
|
}
|