mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 16:22:10 +00:00
Fixes #810
This commit is contained in:
parent
d3a82618b3
commit
87b5832a51
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { defineMessages, FormattedMessage } from 'react-intl';
|
import { defineMessages, FormattedMessage } from 'react-intl';
|
||||||
|
import { PropTypes } from 'prop-types';
|
||||||
|
import { take } from 'lodash';
|
||||||
|
|
||||||
import LocaleToggle from 'containers/LocaleToggle';
|
import LocaleToggle from 'containers/LocaleToggle';
|
||||||
|
|
||||||
@ -13,15 +15,21 @@ import styles from './styles.scss';
|
|||||||
import messages from './messages.json';
|
import messages from './messages.json';
|
||||||
defineMessages(messages);
|
defineMessages(messages);
|
||||||
|
|
||||||
class LeftMenuFooter extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
function LeftMenuFooter({ version }) { // eslint-disable-line react/prefer-stateless-function
|
||||||
render() {
|
const strapiV = take(`${version.split('.')[0]}${version.split('alpha')[1]}`, 4).join('');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.leftMenuFooter}>
|
<div className={styles.leftMenuFooter}>
|
||||||
<FormattedMessage {...messages.poweredBy} /> <a href="http://strapi.io" target="_blank">Strapi</a>
|
<FormattedMessage {...messages.poweredBy} />
|
||||||
|
<a href="http://strapi.io" target="_blank"> Strapi</a>
|
||||||
|
<span> (v{strapiV})</span>
|
||||||
<LocaleToggle />
|
<LocaleToggle />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LeftMenuFooter.propTypes = {
|
||||||
|
version: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
export default LeftMenuFooter;
|
export default LeftMenuFooter;
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import {
|
|||||||
GET_GA_STATUS_SUCCEEDED,
|
GET_GA_STATUS_SUCCEEDED,
|
||||||
GET_LAYOUT,
|
GET_LAYOUT,
|
||||||
GET_LAYOUT_SUCCEEDED,
|
GET_LAYOUT_SUCCEEDED,
|
||||||
|
GET_STRAPI_VERSION_SUCCEEDED,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
export function getGaStatus() {
|
export function getGaStatus() {
|
||||||
@ -35,3 +36,10 @@ export function getLayoutSucceeded(layout) {
|
|||||||
layout,
|
layout,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getStrapiVersionSucceeded(strapiVersion) {
|
||||||
|
return {
|
||||||
|
type: GET_STRAPI_VERSION_SUCCEEDED,
|
||||||
|
strapiVersion,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -8,3 +8,4 @@ export const GET_GA_STATUS = 'app/Admin/GET_GA_STATUS';
|
|||||||
export const GET_GA_STATUS_SUCCEEDED = 'app/Admin/GET_GA_STATUS_SUCCEEDED';
|
export const GET_GA_STATUS_SUCCEEDED = 'app/Admin/GET_GA_STATUS_SUCCEEDED';
|
||||||
export const GET_LAYOUT = 'app/Admin/GET_LAYOUT';
|
export const GET_LAYOUT = 'app/Admin/GET_LAYOUT';
|
||||||
export const GET_LAYOUT_SUCCEEDED = 'app/Admin/GET_LAYOUT_SUCCEEDED';
|
export const GET_LAYOUT_SUCCEEDED = 'app/Admin/GET_LAYOUT_SUCCEEDED';
|
||||||
|
export const GET_STRAPI_VERSION_SUCCEEDED = 'app/Admin/GET_STRAPI_VERSION_SUCCEEDED';
|
||||||
|
|||||||
@ -137,13 +137,19 @@ export class AdminPage extends React.Component { // eslint-disable-line react/pr
|
|||||||
showLeftMenu = () => !includes(this.props.location.pathname, 'users-permissions/auth/');
|
showLeftMenu = () => !includes(this.props.location.pathname, 'users-permissions/auth/');
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const leftMenu = this.showLeftMenu() ? <LeftMenu plugins={this.props.plugins} layout={this.props.adminPage.layout} /> : '';
|
const { adminPage } = this.props;
|
||||||
const header = this.showLeftMenu() ? <Header /> : '';
|
const header = this.showLeftMenu() ? <Header /> : '';
|
||||||
const style = this.showLeftMenu() ? {} : { width: '100%' };
|
const style = this.showLeftMenu() ? {} : { width: '100%' };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.adminPage}>
|
<div className={styles.adminPage}>
|
||||||
{leftMenu}
|
{this.showLeftMenu() && (
|
||||||
|
<LeftMenu
|
||||||
|
plugins={this.props.plugins}
|
||||||
|
layout={adminPage.layout}
|
||||||
|
version={adminPage.strapiVersion}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{ auth.getToken() && this.props.hasUserPlugin && this.isUrlProtected(this.props) ? (
|
{ auth.getToken() && this.props.hasUserPlugin && this.isUrlProtected(this.props) ? (
|
||||||
<Logout />
|
<Logout />
|
||||||
) : ''}
|
) : ''}
|
||||||
|
|||||||
@ -6,11 +6,16 @@
|
|||||||
|
|
||||||
import { fromJS, Map } from 'immutable';
|
import { fromJS, Map } from 'immutable';
|
||||||
|
|
||||||
import { GET_GA_STATUS_SUCCEEDED, GET_LAYOUT_SUCCEEDED } from './constants';
|
import {
|
||||||
|
GET_GA_STATUS_SUCCEEDED,
|
||||||
|
GET_LAYOUT_SUCCEEDED,
|
||||||
|
GET_STRAPI_VERSION_SUCCEEDED,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
const initialState = fromJS({
|
const initialState = fromJS({
|
||||||
allowGa: true,
|
allowGa: true,
|
||||||
layout: Map({}),
|
layout: Map({}),
|
||||||
|
strapiVersion: '3.0.0-alpha',
|
||||||
});
|
});
|
||||||
|
|
||||||
function adminPageReducer(state = initialState, action) {
|
function adminPageReducer(state = initialState, action) {
|
||||||
@ -19,6 +24,8 @@ function adminPageReducer(state = initialState, action) {
|
|||||||
return state.update('allowGa', () => action.allowGa);
|
return state.update('allowGa', () => action.allowGa);
|
||||||
case GET_LAYOUT_SUCCEEDED:
|
case GET_LAYOUT_SUCCEEDED:
|
||||||
return state.update('layout', () => Map(action.layout));
|
return state.update('layout', () => Map(action.layout));
|
||||||
|
case GET_STRAPI_VERSION_SUCCEEDED:
|
||||||
|
return state.update('strapiVersion', () => action.strapiVersion);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,21 @@
|
|||||||
import { fork, call, put, takeLatest } from 'redux-saga/effects';
|
import { fork, call, put, takeLatest } from 'redux-saga/effects';
|
||||||
import request from 'utils/request';
|
import request from 'utils/request';
|
||||||
|
|
||||||
import { getGaStatusSucceeded, getLayoutSucceeded } from './actions';
|
import {
|
||||||
|
getGaStatusSucceeded,
|
||||||
|
getLayoutSucceeded,
|
||||||
|
getStrapiVersionSucceeded,
|
||||||
|
} from './actions';
|
||||||
import { GET_GA_STATUS, GET_LAYOUT } from './constants';
|
import { GET_GA_STATUS, GET_LAYOUT } from './constants';
|
||||||
|
|
||||||
function* getGaStatus() {
|
function* getGaStatus() {
|
||||||
try {
|
try {
|
||||||
const response = yield call(request, '/admin/gaConfig', { method: 'GET' });
|
const [allowGa, strapiVersion] = yield [
|
||||||
yield put(getGaStatusSucceeded(response.allowGa));
|
call(request, '/admin/gaConfig', { method: 'GET' }),
|
||||||
|
call(request, '/admin/strapiVersion', { method: 'GET' }),
|
||||||
|
];
|
||||||
|
yield put(getGaStatusSucceeded(allowGa));
|
||||||
|
yield put(getStrapiVersionSucceeded(strapiVersion.strapiVersion));
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
strapi.notification.error('notification.error');
|
strapi.notification.error('notification.error');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,16 +18,21 @@ export class LeftMenu extends React.Component { // eslint-disable-line react/pre
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className={styles.leftMenu}>
|
<div className={styles.leftMenu}>
|
||||||
<LeftMenuHeader></LeftMenuHeader>
|
<LeftMenuHeader />
|
||||||
<LeftMenuLinkContainer {...this.props}></LeftMenuLinkContainer>
|
<LeftMenuLinkContainer {...this.props} />
|
||||||
<LeftMenuFooter plugins={this.props.plugins}></LeftMenuFooter>
|
<LeftMenuFooter plugins={this.props.plugins} version={this.props.version} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LeftMenu.defaultProps = {
|
||||||
|
version: '3.0.0-alpha',
|
||||||
|
};
|
||||||
|
|
||||||
LeftMenu.propTypes = {
|
LeftMenu.propTypes = {
|
||||||
plugins: PropTypes.object.isRequired,
|
plugins: PropTypes.object.isRequired,
|
||||||
|
version: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
function mapDispatchToProps(dispatch) {
|
function mapDispatchToProps(dispatch) {
|
||||||
|
|||||||
@ -20,6 +20,12 @@
|
|||||||
"handler": "Admin.getGaConfig",
|
"handler": "Admin.getGaConfig",
|
||||||
"policies": []
|
"policies": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"method": "GET",
|
||||||
|
"path": "/strapiVersion",
|
||||||
|
"handler": "Admin.getStrapiVersion",
|
||||||
|
"policies": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"path": "/layout",
|
"path": "/layout",
|
||||||
|
|||||||
@ -17,6 +17,15 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getStrapiVersion: async ctx => {
|
||||||
|
try {
|
||||||
|
const strapiVersion = _.get(strapi.config, 'info.strapi', null);
|
||||||
|
return ctx.send({ strapiVersion });
|
||||||
|
} catch(err) {
|
||||||
|
return ctx.badRequest(null, [{ messages: [{ id: 'The version is not available' }] }]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getGaConfig: async ctx => {
|
getGaConfig: async ctx => {
|
||||||
try {
|
try {
|
||||||
const allowGa = _.get(strapi.config, 'info.customs.allowGa', true);
|
const allowGa = _.get(strapi.config, 'info.customs.allowGa', true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user