2022-06-28 08:47:12 -05:00
|
|
|
import { css } from '@emotion/css';
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
2022-07-26 07:19:30 -05:00
|
|
|
import { Dropdown, FilterInput, Icon, Menu, MenuItem, Tooltip, useStyles2 } from '@grafana/ui';
|
2022-06-28 08:47:12 -05:00
|
|
|
import { contextSrv } from 'app/core/core';
|
|
|
|
|
|
|
|
import { TOP_BAR_LEVEL_HEIGHT } from './types';
|
|
|
|
|
|
|
|
export function TopSearchBar() {
|
|
|
|
const styles = useStyles2(getStyles);
|
|
|
|
|
|
|
|
return (
|
2022-08-16 09:09:22 -05:00
|
|
|
<div className={styles.container}>
|
|
|
|
<div className={styles.leftContent}>
|
|
|
|
<a className={styles.logo} href="/" title="Go to home">
|
|
|
|
<Icon name="grafana" size="xl" />
|
|
|
|
</a>
|
|
|
|
</div>
|
2022-06-28 08:47:12 -05:00
|
|
|
<div className={styles.searchWrapper}>
|
2022-08-16 09:09:22 -05:00
|
|
|
<FilterInput placeholder="Search grafana" value={''} onChange={() => {}} className={styles.searchInput} />
|
2022-06-28 08:47:12 -05:00
|
|
|
</div>
|
|
|
|
<div className={styles.actions}>
|
|
|
|
<Tooltip placement="bottom" content="Help menu (todo)">
|
|
|
|
<button className={styles.actionItem}>
|
|
|
|
<Icon name="question-circle" size="lg" />
|
|
|
|
</button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="bottom" content="Grafana news (todo)">
|
|
|
|
<button className={styles.actionItem}>
|
|
|
|
<Icon name="rss" size="lg" />
|
|
|
|
</button>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip placement="bottom" content="User profile (todo)">
|
2022-07-26 07:19:30 -05:00
|
|
|
<Dropdown overlay={ProfileMenu}>
|
|
|
|
<button className={styles.actionItem}>
|
|
|
|
<img src={contextSrv.user.gravatarUrl} />
|
|
|
|
</button>
|
|
|
|
</Dropdown>
|
2022-06-28 08:47:12 -05:00
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-07-26 07:19:30 -05:00
|
|
|
/**
|
|
|
|
* This is just temporary, needs syncing with the backend option like DisableSignoutMenu
|
|
|
|
*/
|
|
|
|
export function ProfileMenu() {
|
|
|
|
return (
|
|
|
|
<Menu>
|
|
|
|
<MenuItem url="profile" label="Your profile" />
|
|
|
|
<MenuItem url="profile/notifications" label="Your notifications" />
|
|
|
|
<MenuItem url="logout" label="Sign out" />
|
|
|
|
</Menu>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-06-28 08:47:12 -05:00
|
|
|
const getStyles = (theme: GrafanaTheme2) => {
|
|
|
|
return {
|
2022-08-16 09:09:22 -05:00
|
|
|
container: css({
|
2022-06-28 08:47:12 -05:00
|
|
|
height: TOP_BAR_LEVEL_HEIGHT,
|
2022-08-16 09:09:22 -05:00
|
|
|
display: 'grid',
|
|
|
|
gridTemplateColumns: '1fr 2fr 1fr',
|
2022-06-28 08:47:12 -05:00
|
|
|
padding: theme.spacing(0, 2),
|
|
|
|
alignItems: 'center',
|
|
|
|
border: `1px solid ${theme.colors.border.weak}`,
|
|
|
|
}),
|
2022-08-16 09:09:22 -05:00
|
|
|
leftContent: css({
|
|
|
|
display: 'flex',
|
|
|
|
}),
|
2022-06-28 08:47:12 -05:00
|
|
|
logo: css({
|
|
|
|
display: 'flex',
|
|
|
|
}),
|
|
|
|
searchWrapper: css({}),
|
|
|
|
searchInput: css({}),
|
|
|
|
actions: css({
|
|
|
|
display: 'flex',
|
|
|
|
gap: theme.spacing(1),
|
2022-08-16 09:09:22 -05:00
|
|
|
justifyContent: 'flex-end',
|
2022-06-28 08:47:12 -05:00
|
|
|
}),
|
|
|
|
actionItem: css({
|
|
|
|
display: 'flex',
|
|
|
|
flexGrow: 0,
|
|
|
|
border: 'none',
|
|
|
|
boxShadow: 'none',
|
|
|
|
background: 'none',
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
|
|
color: theme.colors.text.secondary,
|
|
|
|
'&:hover': {
|
|
|
|
background: theme.colors.background.secondary,
|
|
|
|
},
|
|
|
|
img: {
|
|
|
|
borderRadius: '50%',
|
|
|
|
width: '24px',
|
|
|
|
height: '24px',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
};
|