mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Bookmarks: Add empty state to page (#92693)
This commit is contained in:
parent
6ab120a448
commit
bdb1c7ee63
@ -1,8 +1,9 @@
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
|
|
||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2, NavModelItem } from '@grafana/data';
|
||||||
import { useStyles2 } from '@grafana/ui';
|
import { EmptyState, useStyles2 } from '@grafana/ui';
|
||||||
import { Page } from 'app/core/components/Page/Page';
|
import { Page } from 'app/core/components/Page/Page';
|
||||||
|
import { t, Trans } from 'app/core/internationalization';
|
||||||
import { useSelector } from 'app/types';
|
import { useSelector } from 'app/types';
|
||||||
|
|
||||||
import { usePinnedItems } from '../AppChrome/MegaMenu/hooks';
|
import { usePinnedItems } from '../AppChrome/MegaMenu/hooks';
|
||||||
@ -14,15 +15,29 @@ export function BookmarksPage() {
|
|||||||
const pinnedItems = usePinnedItems();
|
const pinnedItems = usePinnedItems();
|
||||||
const navTree = useSelector((state) => state.navBarTree);
|
const navTree = useSelector((state) => state.navBarTree);
|
||||||
|
|
||||||
|
const validItems = pinnedItems.reduce((acc: NavModelItem[], url) => {
|
||||||
|
const item = findByUrl(navTree, url);
|
||||||
|
if (item) {
|
||||||
|
acc.push(item);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page navId="bookmarks">
|
<Page navId="bookmarks">
|
||||||
<Page.Contents>
|
<Page.Contents>
|
||||||
|
{validItems.length === 0 ? (
|
||||||
|
<EmptyState
|
||||||
|
variant="call-to-action"
|
||||||
|
message={t('bookmarks-page.empty.message', 'It looks like you haven’t created any bookmarks yet')}
|
||||||
|
>
|
||||||
|
<Trans i18nKey="bookmarks-page.empty.tip">
|
||||||
|
Hover over any item in the nav menu and click on the bookmark icon to add it here.
|
||||||
|
</Trans>
|
||||||
|
</EmptyState>
|
||||||
|
) : (
|
||||||
<section className={styles.grid}>
|
<section className={styles.grid}>
|
||||||
{pinnedItems.map((url) => {
|
{validItems.map((item) => {
|
||||||
const item = findByUrl(navTree, url);
|
|
||||||
if (!item) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<NavLandingPageCard
|
<NavLandingPageCard
|
||||||
key={item.id || item.url}
|
key={item.id || item.url}
|
||||||
@ -33,6 +48,7 @@ export function BookmarksPage() {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</section>
|
</section>
|
||||||
|
)}
|
||||||
</Page.Contents>
|
</Page.Contents>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
@ -233,6 +233,12 @@
|
|||||||
"message": "No API keys found"
|
"message": "No API keys found"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"bookmarks-page": {
|
||||||
|
"empty": {
|
||||||
|
"message": "It looks like you haven’t created any bookmarks yet",
|
||||||
|
"tip": "Hover over any item in the nav menu and click on the bookmark icon to add it here."
|
||||||
|
}
|
||||||
|
},
|
||||||
"bouncing-loader": {
|
"bouncing-loader": {
|
||||||
"label": "Loading"
|
"label": "Loading"
|
||||||
},
|
},
|
||||||
|
@ -233,6 +233,12 @@
|
|||||||
"message": "Ńő ÅPĨ ĸęyş ƒőūʼnđ"
|
"message": "Ńő ÅPĨ ĸęyş ƒőūʼnđ"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"bookmarks-page": {
|
||||||
|
"empty": {
|
||||||
|
"message": "Ĩŧ ľőőĸş ľįĸę yőū ĥävęʼn’ŧ čřęäŧęđ äʼny þőőĸmäřĸş yęŧ",
|
||||||
|
"tip": "Ħővęř ővęř äʼny įŧęm įʼn ŧĥę ʼnäv męʼnū äʼnđ čľįčĸ őʼn ŧĥę þőőĸmäřĸ įčőʼn ŧő äđđ įŧ ĥęřę."
|
||||||
|
}
|
||||||
|
},
|
||||||
"bouncing-loader": {
|
"bouncing-loader": {
|
||||||
"label": "Ŀőäđįʼnģ"
|
"label": "Ŀőäđįʼnģ"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user