12a69876c7
* first pass
* return list
* types and cleanup
* add to plugin page and add styles
* update comment
* update comment
* fix component path
* simplify error component
* simplify error struct
* fix tests
* don't export and fix string()
* update naming
* remove frontend
* introduce phantom loader
* track single error
* remove error from base
* remove unused struct
* remove unnecessary filter
* add errors endpoint
* Update set log to use id field
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
* skip adding BE plugins
* remove errs from plugin + ds list
* remove unnecessary fields
* add signature state to panels
* Fetch plugins errors
* grafana/ui component tweaks
* DS Picker - add unsigned badge
* VizPicker - add unsigned badge
* PluginSignatureBadge tweaks
* Plugins list - add signatures info box
* New datasource page - add signatures info box
* Plugin page - add signatures info box
* Fix test
* Do not show Core label in viz picker
* Update public/app/features/plugins/PluginsErrorsInfo.tsx
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
* Update public/app/features/plugins/PluginListPage.test.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/plugins/PluginListPage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Update public/app/features/datasources/NewDataSourcePage.tsx
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
* Review comments 1
* Review comments 2
* Update public/app/features/plugins/PluginsErrorsInfo.tsx
* Update public/app/features/plugins/PluginPage.tsx
* Prettier fix
* remove stale backend code
* Docs issues fix
Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
(cherry picked from commit 4468d41417)
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
91 lines
2.3 KiB
TypeScript
91 lines
2.3 KiB
TypeScript
import React, { HTMLAttributes } from 'react';
|
|
import { Icon } from '../Icon/Icon';
|
|
import { useTheme } from '../../themes/ThemeContext';
|
|
import { stylesFactory } from '../../themes/stylesFactory';
|
|
import { IconName } from '../../types';
|
|
import { Tooltip } from '../Tooltip/Tooltip';
|
|
import { getColorForTheme, GrafanaTheme } from '@grafana/data';
|
|
import tinycolor from 'tinycolor2';
|
|
import { css, cx } from 'emotion';
|
|
import { HorizontalGroup } from '../Layout/Layout';
|
|
|
|
export type BadgeColor = 'blue' | 'red' | 'green' | 'orange' | 'purple';
|
|
|
|
export interface BadgeProps extends HTMLAttributes<HTMLDivElement> {
|
|
text: string;
|
|
color: BadgeColor;
|
|
icon?: IconName;
|
|
tooltip?: string;
|
|
}
|
|
|
|
export const Badge = React.memo<BadgeProps>(({ icon, color, text, tooltip, className, ...otherProps }) => {
|
|
const theme = useTheme();
|
|
const styles = getStyles(theme, color);
|
|
const badge = (
|
|
<div className={cx(styles.wrapper, className)} {...otherProps}>
|
|
<HorizontalGroup align="center" spacing="xs">
|
|
{icon && <Icon name={icon} size="sm" />}
|
|
<span>{text}</span>
|
|
</HorizontalGroup>
|
|
</div>
|
|
);
|
|
|
|
return tooltip ? (
|
|
<Tooltip content={tooltip} placement="auto">
|
|
{badge}
|
|
</Tooltip>
|
|
) : (
|
|
badge
|
|
);
|
|
});
|
|
|
|
Badge.displayName = 'Badge';
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme, color: BadgeColor) => {
|
|
let sourceColor = getColorForTheme(color, theme);
|
|
let borderColor = '';
|
|
let bgColor = '';
|
|
let textColor = '';
|
|
|
|
if (theme.isDark) {
|
|
bgColor = tinycolor(sourceColor)
|
|
.darken(38)
|
|
.toString();
|
|
borderColor = tinycolor(sourceColor)
|
|
.darken(25)
|
|
.toString();
|
|
textColor = tinycolor(sourceColor)
|
|
.lighten(45)
|
|
.toString();
|
|
} else {
|
|
bgColor = tinycolor(sourceColor)
|
|
.lighten(30)
|
|
.toString();
|
|
borderColor = tinycolor(sourceColor)
|
|
.lighten(15)
|
|
.toString();
|
|
textColor = tinycolor(sourceColor)
|
|
.darken(40)
|
|
.toString();
|
|
}
|
|
|
|
return {
|
|
wrapper: css`
|
|
font-size: ${theme.typography.size.sm};
|
|
display: inline-flex;
|
|
padding: 1px 4px;
|
|
border-radius: 3px;
|
|
margin-top: 6px;
|
|
background: ${bgColor};
|
|
border: 1px solid ${borderColor};
|
|
color: ${textColor};
|
|
|
|
> span {
|
|
position: relative;
|
|
top: 1px;
|
|
margin-left: 2px;
|
|
}
|
|
`,
|
|
};
|
|
});
|