1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-24 01:18:01 +02:00

feat: Add option for custom ui links (#195)

This commit is contained in:
Ivar Conradi Østhus 2019-10-26 22:05:38 +02:00 committed by GitHub
parent 8b36bc1c0e
commit d837f525bd
6 changed files with 91 additions and 70 deletions

View File

@ -105,29 +105,7 @@ exports[`should render DrawerMenu 1`] = `
<hr /> <hr />
<react-mdl-Navigation <react-mdl-Navigation
className="navigation" className="navigation"
> />
<a
className="navigationLink mdl-color-text--grey-900"
href="https://unleash.github.io"
target="_blank"
>
<react-mdl-Icon
className="navigationIcon"
name="library_books"
/>
User documentation
</a>
<a
className="navigationLink mdl-color-text--grey-900"
href="https://github.com/Unleash"
target="_blank"
>
<i
className="material-icons navigationIcon iconGitHub"
/>
GitHub
</a>
</react-mdl-Navigation>
</react-mdl-Drawer> </react-mdl-Drawer>
`; `;
@ -237,28 +215,6 @@ exports[`should render DrawerMenu with "features" selected 1`] = `
<hr /> <hr />
<react-mdl-Navigation <react-mdl-Navigation
className="navigation" className="navigation"
> />
<a
className="navigationLink mdl-color-text--grey-900"
href="https://unleash.github.io"
target="_blank"
>
<react-mdl-Icon
className="navigationIcon"
name="library_books"
/>
User documentation
</a>
<a
className="navigationLink mdl-color-text--grey-900"
href="https://github.com/Unleash"
target="_blank"
>
<i
className="material-icons navigationIcon iconGitHub"
/>
GitHub
</a>
</react-mdl-Navigation>
</react-mdl-Drawer> </react-mdl-Drawer>
`; `;

View File

@ -1,11 +1,20 @@
import React from 'react'; import React from 'react';
import { Drawer, Icon, Navigation } from 'react-mdl'; import { Drawer, Icon, Navigation } from 'react-mdl';
import { NavLink } from 'react-router-dom'; import { NavLink } from 'react-router-dom';
import PropTypes from 'prop-types';
import styles from '../styles.scss'; import styles from '../styles.scss';
import { baseRoutes as routes } from './routes'; import { baseRoutes as routes } from './routes';
export const DrawerMenu = () => ( function getIcon(name) {
if (name === 'c_github') {
return <i className={['material-icons', styles.navigationIcon, styles.iconGitHub].join(' ')} />;
} else {
return <Icon name={name} className={styles.navigationIcon} />;
}
}
export const DrawerMenu = ({ links = [] }) => (
<Drawer className="mdl-color--white"> <Drawer className="mdl-color--white">
<span className={[styles.drawerTitle, 'mdl-layout-title'].join(' ')}> <span className={[styles.drawerTitle, 'mdl-layout-title'].join(' ')}>
<img src="public/logo.png" width="32" height="32" className={styles.drawerTitleLogo} /> <img src="public/logo.png" width="32" height="32" className={styles.drawerTitleLogo} />
@ -28,20 +37,20 @@ export const DrawerMenu = () => (
</Navigation> </Navigation>
<hr /> <hr />
<Navigation className={styles.navigation}> <Navigation className={styles.navigation}>
<a {links.map(link => (
href="https://unleash.github.io" <a
target="_blank" href={link.href}
className={[styles.navigationLink, 'mdl-color-text--grey-900'].join(' ')} target="_blank"
> className={[styles.navigationLink, 'mdl-color-text--grey-900'].join(' ')}
<Icon name="library_books" className={styles.navigationIcon} /> User documentation title={link.title}
</a> >
<a {getIcon(link.icon)} {link.value}
href="https://github.com/Unleash" </a>
target="_blank" ))}
className={[styles.navigationLink, 'mdl-color-text--grey-900'].join(' ')}
>
<i className={['material-icons', styles.navigationIcon, styles.iconGitHub].join(' ')} /> GitHub
</a>
</Navigation> </Navigation>
</Drawer> </Drawer>
); );
DrawerMenu.propTypes = {
links: PropTypes.array,
};

View File

@ -37,7 +37,7 @@ class HeaderComponent extends PureComponent {
} }
render() { render() {
const { headerBackground } = this.props.uiConfig; const { headerBackground, links } = this.props.uiConfig;
const style = headerBackground ? { background: headerBackground } : {}; const style = headerBackground ? { background: headerBackground } : {};
return ( return (
<React.Fragment> <React.Fragment>
@ -46,7 +46,7 @@ class HeaderComponent extends PureComponent {
<ShowUserContainer /> <ShowUserContainer />
</Navigation> </Navigation>
</Header> </Header>
<DrawerMenu /> <DrawerMenu links={links} />
</React.Fragment> </React.Fragment>
); );
} }

View File

@ -79,7 +79,7 @@
} }
.navigationIcon { .navigationIcon {
margin-right: 32px; margin-right: 24px;
} }
.iconGitHub { .iconGitHub {

View File

@ -2,9 +2,23 @@
exports[`should be default state 1`] = ` exports[`should be default state 1`] = `
Object { Object {
"environment": undefined, "environment": "Open-Soruce",
"headerBackground": undefined, "headerBackground": undefined,
"slogan": "A product originally created by FINN.no.", "links": Array [
Object {
"href": "https://unleash.github.io",
"icon": "library_books",
"title": "User documentation",
"value": "User documentation",
},
Object {
"href": "https://github.com/Unleash",
"icon": "c_github",
"title": "Source code on GitHub",
"value": "GitHub",
},
],
"slogan": "The enterprise ready feature toggle service.",
} }
`; `;
@ -12,14 +26,42 @@ exports[`should be merged state all 1`] = `
Object { Object {
"environment": "dev", "environment": "dev",
"headerBackground": "red", "headerBackground": "red",
"links": Array [
Object {
"href": "https://unleash.github.io",
"icon": "library_books",
"title": "User documentation",
"value": "User documentation",
},
Object {
"href": "https://github.com/Unleash",
"icon": "c_github",
"title": "Source code on GitHub",
"value": "GitHub",
},
],
"slogan": "hello", "slogan": "hello",
} }
`; `;
exports[`should only update headerBackground 1`] = ` exports[`should only update headerBackground 1`] = `
Object { Object {
"environment": undefined, "environment": "Open-Soruce",
"headerBackground": "black", "headerBackground": "black",
"slogan": "A product originally created by FINN.no.", "links": Array [
Object {
"href": "https://unleash.github.io",
"icon": "library_books",
"title": "User documentation",
"value": "User documentation",
},
Object {
"href": "https://github.com/Unleash",
"icon": "c_github",
"title": "Source code on GitHub",
"value": "GitHub",
},
],
"slogan": "The enterprise ready feature toggle service.",
} }
`; `;

View File

@ -11,8 +11,22 @@ const UI_CONFIG = `${basePath}:ui_config`;
const DEFAULT = new $Map({ const DEFAULT = new $Map({
headerBackground: undefined, headerBackground: undefined,
environment: undefined, environment: 'Open-Soruce',
slogan: 'A product originally created by FINN.no.', slogan: 'The enterprise ready feature toggle service.',
links: [
{
value: 'User documentation',
icon: 'library_books',
href: 'https://unleash.github.io',
title: 'User documentation',
},
{
value: 'GitHub',
icon: 'c_github',
href: 'https://github.com/Unleash',
title: 'Source code on GitHub',
},
],
}); });
function getInitState() { function getInitState() {