show GitHub star on navbar

This commit is contained in:
Rares Mardare 2022-08-18 16:14:15 +03:00
parent 0dbb93a903
commit 590650cd8f
8 changed files with 55 additions and 14 deletions

View file

@ -14,8 +14,8 @@ import { rootStore } from 'state';
import { useStore } from 'state/useStore';
import { useNavModel } from 'utils/hooks';
import './vars.css';
import './index.css';
import './style/vars.css';
import './style/index.css';
import { AppFeature } from './state/features';

View file

@ -111,15 +111,6 @@ const AlertTemplatesForm = (props: AlertTemplatesFormProps) => {
return groups;
}, [filteredTemplatesToRender]);
const handleChangeActiveTemplate = useCallback(
(templateName) => {
const template = groups[activeGroup].find((template: Template) => template.name === templateName);
setActiveTemplate(template);
},
[groups, activeGroup]
);
const getGroupByTemplateName = (templateName: string) => {
Object.values(groups).find((group) => {
const foundTemplate = group.find((obj: any) => {

View file

@ -0,0 +1,20 @@
:root {
--orange: #F5B73D;
}
.navbar-container {
display: flex;
align-items: center;
}
.navbar-star-icon {
fill: var(--orange);
}
.navbar-heading {
padding: 4px;
margin-left: 8px;
border: 1px solid var(--gray-9);
width: initial;
font-size: 12px;
}

View file

@ -0,0 +1,25 @@
import React from 'react';
import cn from 'classnames/bind';
import { Card, Icon } from '@grafana/ui';
import { APP_SUBTITLE } from 'utils/consts';
import styles from './NavBarSubtitle.module.css';
const cx = cn.bind(styles);
function NavBarSubtitle() {
return (
<div className={cx('navbar-container')}>
{APP_SUBTITLE}
<Card heading={undefined} className={cx('navbar-heading')}>
<a href="https://github.com/grafana/oncall">
<Icon name="star" className={cx('navbar-star-icon')} /> Star us on GitHub
</a>
</Card>
</div>
);
}
export default NavBarSubtitle;

View file

@ -33,3 +33,7 @@
white-space: nowrap;
}
}
.page-header__info-block {
flex-grow: 1; /* Stretch the navigation subtitle panel */
}

View file

@ -1,11 +1,12 @@
import { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { useMemo } from 'react';
import { AppRootProps, NavModelItem } from '@grafana/data';
import NavBarSubtitle from 'components/NavBar/NavBarSubtitle';
import { PageDefinition } from 'pages';
import { APP_TITLE, APP_SUBTITLE } from './consts';
import { APP_TITLE } from './consts';
type Args = {
meta: AppRootProps['meta'];
@ -54,7 +55,7 @@ export function useNavModel({ meta, pages, path, page, grafanaUser, enableLiveSe
const node = {
text: APP_TITLE,
img: meta.info.logos.large,
subTitle: APP_SUBTITLE,
subTitle: <NavBarSubtitle />,
url: path,
children: tabs,
};