From 2442571e2f0962e8244772396a8a8df2fa3c9a83 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Tue, 12 Sep 2017 00:28:43 +0530 Subject: [PATCH] Fix: Issue #319 Load logo from config Review: catch block --- src/api/web/index.js | 5 ++--- src/webui/src/components/Header/index.js | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/api/web/index.js b/src/api/web/index.js index e849a535b..ec629e58b 100644 --- a/src/api/web/index.js +++ b/src/api/web/index.js @@ -32,9 +32,8 @@ module.exports = function(config, auth, storage) { }); }); - router.get('/-/logo', function(req, res) { - res.sendFile(_.get(config, 'web.logo') || `${env.APP_ROOT}/static/logo-sm.png` - ); + router.get('/-/verdaccio/logo', function(req, res) { + res.send(_.get(config, 'web.logo') || '/-/static/logo.png'); }); router.get('/', function(req, res) { diff --git a/src/webui/src/components/Header/index.js b/src/webui/src/components/Header/index.js index 6e411329a..d1e7b6f0d 100644 --- a/src/webui/src/components/Header/index.js +++ b/src/webui/src/components/Header/index.js @@ -10,13 +10,14 @@ import storage from '../../../utils/storage'; import classes from './header.scss'; -import logo from './logo.png'; +import './logo.png'; export default class Header extends React.Component { state = { showLogin: false, username: '', - password: '' + password: '', + logo: '' } constructor(props) { @@ -37,6 +38,16 @@ export default class Header extends React.Component { }); } + componentWillMount() { + API.get('logo') + .then((response) => { + this.setState({logo: response.data}); + }) + .catch((error) => { + throw new Error(error); + }); + } + async handleSubmit() { if (this.state.username === '' || this.state.password === '') { return MessageBox.alert('Username or password can\'t be empty!', ''); @@ -120,7 +131,7 @@ export default class Header extends React.Component {
- +
npm set registry { location.origin }