mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
Fix for tests
This commit is contained in:
parent
6b6095b57f
commit
0d984835a1
@ -12,9 +12,9 @@ import '!file?name=[name].[ext]!./manifest.json';
|
|||||||
import 'file?name=[name].[ext]!./.htaccess';
|
import 'file?name=[name].[ext]!./.htaccess';
|
||||||
/* eslint-enable import/no-unresolved */
|
/* eslint-enable import/no-unresolved */
|
||||||
// Import all the third party stuff
|
// Import all the third party stuff
|
||||||
import React from 'react';
|
// import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
// import ReactDOM from 'react-dom';
|
||||||
import { Provider } from 'react-redux';
|
// import { Provider } from 'react-redux';
|
||||||
import { browserHistory } from 'react-router';
|
import { browserHistory } from 'react-router';
|
||||||
// import { syncHistoryWithStore } from 'react-router-redux';
|
// import { syncHistoryWithStore } from 'react-router-redux';
|
||||||
// import useScroll from 'react-router-scroll';
|
// import useScroll from 'react-router-scroll';
|
||||||
@ -52,7 +52,7 @@ const rootRoute = {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
store,
|
store,
|
||||||
}
|
};
|
||||||
|
|
||||||
// import SettingsManagerApp from 'containers/App/index';
|
// import SettingsManagerApp from 'containers/App/index';
|
||||||
|
|
||||||
@ -74,7 +74,6 @@ export {
|
|||||||
// console.log('this', this);
|
// console.log('this', this);
|
||||||
// ReactDOM.render(
|
// ReactDOM.render(
|
||||||
// return (
|
// return (
|
||||||
//
|
|
||||||
// );
|
// );
|
||||||
// </Provider>
|
// </Provider>
|
||||||
// );
|
// );
|
||||||
@ -106,13 +105,15 @@ export {
|
|||||||
// install();
|
// install();
|
||||||
|
|
||||||
// Register the plugin
|
// Register the plugin
|
||||||
window.Strapi.registerPlugin({
|
if (window.Strapi) {
|
||||||
name: 'Settings Manager',
|
window.Strapi.registerPlugin({
|
||||||
id: 'settings-manager',
|
name: 'Settings Manager',
|
||||||
leftMenuLink: {
|
id: 'settings-manager',
|
||||||
label: 'Settings Manager',
|
leftMenuLink: {
|
||||||
to: '/settings-manager',
|
label: 'Settings Manager',
|
||||||
},
|
to: '/settings-manager',
|
||||||
routes: rootRoute,
|
},
|
||||||
mainComponent: App,
|
routes: rootRoute,
|
||||||
});
|
mainComponent: App,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* PluginHeaderActions
|
* PluginHeaderActions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
@ -12,16 +12,18 @@ class PluginHeaderActions extends React.Component { // eslint-disable-line react
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className={`${styles.pluginHeaderActions} pull-lg-right`}>
|
<div className={`${styles.pluginHeaderActions} pull-lg-right`}>
|
||||||
<button type="button"
|
<button
|
||||||
className={`${styles.pluginHeaderActionsButton} btn btn-secondary`}
|
type="button"
|
||||||
onClick={this.props.onCancel}
|
className={`${styles.pluginHeaderActionsButton} btn btn-secondary`}
|
||||||
|
onClick={this.props.onCancel}
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button type="submit"
|
<button
|
||||||
className={`${styles.pluginHeaderActionsButton} btn btn-primary`}
|
type="submit"
|
||||||
disabled={this.props.loading}
|
className={`${styles.pluginHeaderActionsButton} btn btn-primary`}
|
||||||
onClick={this.props.onFormSubmit}
|
disabled={this.props.loading}
|
||||||
|
onClick={this.props.onFormSubmit}
|
||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</button>
|
</button>
|
||||||
|
@ -71,47 +71,47 @@ export function generalSettingsLoadingError(error) {
|
|||||||
export function changeName(name) {
|
export function changeName(name) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_NAME,
|
type: CHANGE_NAME,
|
||||||
name: name
|
name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changeDescription(description) {
|
export function changeDescription(description) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_DESCRIPTION,
|
type: CHANGE_DESCRIPTION,
|
||||||
description: description
|
description,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function changeVersion(version) {
|
export function changeVersion(version) {
|
||||||
return {
|
return {
|
||||||
type: CHANGE_VERSION,
|
type: CHANGE_VERSION,
|
||||||
version: version
|
version,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateGeneralSettings(data) {
|
export function updateGeneralSettings(data) {
|
||||||
return {
|
return {
|
||||||
type: UPDATE_GENERAL_SETTINGS,
|
type: UPDATE_GENERAL_SETTINGS,
|
||||||
data: data
|
data,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generalSettingsUpdated(data) {
|
export function generalSettingsUpdated(data) {
|
||||||
return {
|
return {
|
||||||
type: UPDATE_GENERAL_SETTINGS_SUCCESS,
|
type: UPDATE_GENERAL_SETTINGS_SUCCESS,
|
||||||
data: data
|
data,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generalSettingsUpdatedError(error) {
|
export function generalSettingsUpdatedError(error) {
|
||||||
return {
|
return {
|
||||||
type: UPDATE_GENERAL_SETTINGS_ERROR,
|
type: UPDATE_GENERAL_SETTINGS_ERROR,
|
||||||
error: error
|
error,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cancelGeneralSettings() {
|
export function cancelGeneralSettings() {
|
||||||
return {
|
return {
|
||||||
type: CANCEL_GENERAL_SETTINGS,
|
type: CANCEL_GENERAL_SETTINGS,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {connect} from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {createStructuredSelector} from 'reselect';
|
import { createStructuredSelector } from 'reselect';
|
||||||
|
|
||||||
import PluginHeader from 'components/PluginHeader';
|
import PluginHeader from 'components/PluginHeader';
|
||||||
import RightContentSectionTitle from 'components/RightContentSectionTitle';
|
import RightContentSectionTitle from 'components/RightContentSectionTitle';
|
||||||
@ -50,8 +50,7 @@ export class HomePage extends React.Component {
|
|||||||
<PluginHeader {...this.props}></PluginHeader>
|
<PluginHeader {...this.props}></PluginHeader>
|
||||||
<Container>
|
<Container>
|
||||||
<RightContentTitle title="General" description="Configure your general settings."></RightContentTitle>
|
<RightContentTitle title="General" description="Configure your general settings."></RightContentTitle>
|
||||||
<RightContentSectionTitle title="Application"
|
<RightContentSectionTitle title="Application" description="The general settings of your Strapi application."></RightContentSectionTitle>
|
||||||
description="The general settings of your Strapi application."></RightContentSectionTitle>
|
|
||||||
<form onSubmit={this.props.onFormSubmit}>
|
<form onSubmit={this.props.onFormSubmit}>
|
||||||
<div className={`form-group row ${styles.homePageRightContentFormGroup}`}>
|
<div className={`form-group row ${styles.homePageRightContentFormGroup}`}>
|
||||||
<label htmlFor="applicationName" className="col-xs-7 col-form-label">Name</label>
|
<label htmlFor="applicationName" className="col-xs-7 col-form-label">Name</label>
|
||||||
@ -63,7 +62,7 @@ export class HomePage extends React.Component {
|
|||||||
id="applicationName"
|
id="applicationName"
|
||||||
value={this.props.name || ''}
|
value={this.props.name || ''}
|
||||||
onChange={this.props.onChangeName}
|
onChange={this.props.onChangeName}
|
||||||
autoFocus={true}
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -104,34 +103,35 @@ export class HomePage extends React.Component {
|
|||||||
|
|
||||||
HomePage.propTypes = {
|
HomePage.propTypes = {
|
||||||
changeRoute: React.PropTypes.func,
|
changeRoute: React.PropTypes.func,
|
||||||
loading: React.PropTypes.bool,
|
|
||||||
error: React.PropTypes.oneOfType([
|
|
||||||
React.PropTypes.object,
|
|
||||||
React.PropTypes.bool,
|
|
||||||
]),
|
|
||||||
name: React.PropTypes.oneOfType([
|
|
||||||
React.PropTypes.string,
|
|
||||||
React.PropTypes.bool,
|
|
||||||
]),
|
|
||||||
description: React.PropTypes.oneOfType([
|
description: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.string,
|
React.PropTypes.string,
|
||||||
React.PropTypes.bool,
|
React.PropTypes.bool,
|
||||||
]),
|
]),
|
||||||
|
error: React.PropTypes.oneOfType([
|
||||||
|
React.PropTypes.object,
|
||||||
|
React.PropTypes.bool,
|
||||||
|
]),
|
||||||
|
loading: React.PropTypes.bool,
|
||||||
|
name: React.PropTypes.oneOfType([
|
||||||
|
React.PropTypes.string,
|
||||||
|
React.PropTypes.bool,
|
||||||
|
]),
|
||||||
|
onCancel: React.PropTypes.func,
|
||||||
|
onChangeName: React.PropTypes.func,
|
||||||
|
onChangeDescription: React.PropTypes.func,
|
||||||
|
onChangeVersion: React.PropTypes.func,
|
||||||
|
onFormSubmit: React.PropTypes.func,
|
||||||
|
onPageLoad: React.PropTypes.func,
|
||||||
version: React.PropTypes.oneOfType([
|
version: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.string,
|
React.PropTypes.string,
|
||||||
React.PropTypes.bool,
|
React.PropTypes.bool,
|
||||||
]),
|
]),
|
||||||
onPageLoad: React.PropTypes.func,
|
|
||||||
onCancel: React.PropTypes.func,
|
|
||||||
onFormSubmit: React.PropTypes.func,
|
|
||||||
onChangeName: React.PropTypes.func,
|
|
||||||
onChangeDescription: React.PropTypes.func,
|
|
||||||
onChangeVersion: React.PropTypes.func,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function mapDispatchToProps(dispatch) {
|
export function mapDispatchToProps(dispatch) {
|
||||||
return {
|
return {
|
||||||
onCancel: (evt) => dispatch(cancelGeneralSettings()),
|
onCancel: () => dispatch(cancelGeneralSettings()),
|
||||||
onChangeName: (evt) => dispatch(changeName(evt.target.value)),
|
onChangeName: (evt) => dispatch(changeName(evt.target.value)),
|
||||||
onChangeDescription: (evt) => dispatch(changeDescription(evt.target.value)),
|
onChangeDescription: (evt) => dispatch(changeDescription(evt.target.value)),
|
||||||
onChangeVersion: (evt) => dispatch(changeVersion(evt.target.value)),
|
onChangeVersion: (evt) => dispatch(changeVersion(evt.target.value)),
|
||||||
@ -139,12 +139,10 @@ export function mapDispatchToProps(dispatch) {
|
|||||||
if (evt !== undefined && evt.preventDefault) evt.preventDefault();
|
if (evt !== undefined && evt.preventDefault) evt.preventDefault();
|
||||||
dispatch(updateGeneralSettings());
|
dispatch(updateGeneralSettings());
|
||||||
},
|
},
|
||||||
changeRoute: (url) => dispatch(push(url)),
|
|
||||||
onPageLoad: (evt) => {
|
onPageLoad: (evt) => {
|
||||||
if (evt !== undefined && evt.preventDefault) evt.preventDefault();
|
if (evt !== undefined && evt.preventDefault) evt.preventDefault();
|
||||||
dispatch(loadGeneralSettings());
|
dispatch(loadGeneralSettings());
|
||||||
},
|
},
|
||||||
|
|
||||||
dispatch,
|
dispatch,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -152,9 +150,9 @@ export function mapDispatchToProps(dispatch) {
|
|||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
name: selectName(),
|
name: selectName(),
|
||||||
description: selectDescription(),
|
description: selectDescription(),
|
||||||
version: selectVersion(),
|
|
||||||
loading: selectLoading(),
|
|
||||||
error: selectError(),
|
error: selectError(),
|
||||||
|
loading: selectLoading(),
|
||||||
|
version: selectVersion(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Wrap the component to inject dispatch and state into it
|
// Wrap the component to inject dispatch and state into it
|
||||||
|
@ -22,7 +22,7 @@ import {
|
|||||||
UPDATE_GENERAL_SETTINGS_ERROR,
|
UPDATE_GENERAL_SETTINGS_ERROR,
|
||||||
CANCEL_GENERAL_SETTINGS,
|
CANCEL_GENERAL_SETTINGS,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
import {fromJS} from 'immutable';
|
import { fromJS } from 'immutable';
|
||||||
|
|
||||||
// The initial state of the App
|
// The initial state of the App
|
||||||
const initialState = fromJS({
|
const initialState = fromJS({
|
||||||
@ -36,7 +36,7 @@ const initialState = fromJS({
|
|||||||
name: false,
|
name: false,
|
||||||
description: false,
|
description: false,
|
||||||
version: false,
|
version: false,
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
function appReducer(state = initialState, action) {
|
function appReducer(state = initialState, action) {
|
||||||
@ -85,11 +85,10 @@ function appReducer(state = initialState, action) {
|
|||||||
.set('error', action.error)
|
.set('error', action.error)
|
||||||
.set('loading', false);
|
.set('loading', false);
|
||||||
case CANCEL_GENERAL_SETTINGS:
|
case CANCEL_GENERAL_SETTINGS:
|
||||||
const backup = state.get('backup');
|
|
||||||
return state
|
return state
|
||||||
.set('name', backup.get('name'))
|
.set('name', state.get('backup').get('name'))
|
||||||
.set('description', backup.get('description'))
|
.set('description', state.get('backup').get('description'))
|
||||||
.set('version', backup.get('version'));
|
.set('version', state.get('backup').get('version'));
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { LOCATION_CHANGE } from 'react-router-redux';
|
|||||||
import {
|
import {
|
||||||
LOAD_GENERAL_SETTINGS,
|
LOAD_GENERAL_SETTINGS,
|
||||||
UPDATE_GENERAL_SETTINGS,
|
UPDATE_GENERAL_SETTINGS,
|
||||||
} from 'containers/HomePage/constants';
|
} from 'containers/HomePage/constants';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
generalSettingsLoaded,
|
generalSettingsLoaded,
|
||||||
@ -28,7 +28,7 @@ import request from 'utils/request';
|
|||||||
* Github generalSettings request/response handler
|
* Github generalSettings request/response handler
|
||||||
*/
|
*/
|
||||||
export function* getGeneralSettings() {
|
export function* getGeneralSettings() {
|
||||||
const requestURL = `http://localhost:1337/settingsmanager/settings/general`;
|
const requestURL = 'http://localhost:1337/settingsmanager/settings/general';
|
||||||
|
|
||||||
// Call our request helper (see 'utils/request')
|
// Call our request helper (see 'utils/request')
|
||||||
const generalSettings = yield call(request, requestURL);
|
const generalSettings = yield call(request, requestURL);
|
||||||
@ -36,7 +36,7 @@ export function* getGeneralSettings() {
|
|||||||
if (!generalSettings.err) {
|
if (!generalSettings.err) {
|
||||||
yield put(generalSettingsLoaded(generalSettings.data));
|
yield put(generalSettingsLoaded(generalSettings.data));
|
||||||
} else {
|
} else {
|
||||||
yield put(repoLoadingError(generalSettings.err));
|
yield put(generalSettingsLoadingError(generalSettings.err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ export function* updateGeneralSettings() {
|
|||||||
type: 'general',
|
type: 'general',
|
||||||
};
|
};
|
||||||
|
|
||||||
const requestURL = `http://localhost:1337/settingsmanager/settings`;
|
const requestURL = 'http://localhost:1337/settingsmanager/settings';
|
||||||
|
|
||||||
// Call our request helper (see 'utils/request')
|
// Call our request helper (see 'utils/request')
|
||||||
const generalSettings = yield call(
|
const generalSettings = yield call(
|
||||||
@ -58,8 +58,8 @@ export function* updateGeneralSettings() {
|
|||||||
requestURL, {
|
requestURL, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
Accept: 'application/json',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ export function* generalSettingsData() {
|
|||||||
// Fork watcher so we can continue execution
|
// Fork watcher so we can continue execution
|
||||||
|
|
||||||
const watcher = yield fork(getGeneralSettingsWatcher);
|
const watcher = yield fork(getGeneralSettingsWatcher);
|
||||||
const updateWatcher = yield fork(updateGeneralSettingsWatcher);
|
yield fork(updateGeneralSettingsWatcher);
|
||||||
|
|
||||||
// Suspend execution until location changes
|
// Suspend execution until location changes
|
||||||
yield take(LOCATION_CHANGE);
|
yield take(LOCATION_CHANGE);
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import messages from './messages';
|
import messages from './messages';
|
||||||
import Container from 'components/Container';
|
|
||||||
|
|
||||||
export default class NotFound extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
export default class NotFound extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import { getAsyncInjectors } from 'utils/asyncInjectors';
|
import { getAsyncInjectors } from 'utils/asyncInjectors';
|
||||||
|
|
||||||
const errorLoading = (err) => {
|
const errorLoading = (err) => {
|
||||||
console.log('errLoading', err)
|
|
||||||
console.error('Dynamic page loading failed', err); // eslint-disable-line no-console
|
console.error('Dynamic page loading failed', err); // eslint-disable-line no-console
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,23 +16,20 @@ function parseJSON(response) {
|
|||||||
*
|
*
|
||||||
* @param {object} response A response from a network request
|
* @param {object} response A response from a network request
|
||||||
*
|
*
|
||||||
* @return {object|undefined} Returns either the response, or throws an error
|
* @return {Promise} Returns either the response, or throws an error
|
||||||
*/
|
*/
|
||||||
function checkStatus(response) {
|
function checkStatus(response) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise(resolve => {
|
||||||
if (response.status >= 200 && response.status < 300) {
|
if (response.status >= 200 && response.status < 300) {
|
||||||
return resolve(response);
|
return resolve(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
parseJSON(response)
|
return parseJSON(response)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const error = new Error(data.message || response.statusText);
|
const error = new Error(data.message || response.statusText);
|
||||||
error.data = data;
|
error.data = data;
|
||||||
error.response = response;
|
error.response = response;
|
||||||
throw error;
|
throw error;
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
reject(err);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -47,13 +44,14 @@ function checkStatus(response) {
|
|||||||
*/
|
*/
|
||||||
export default function request(url, options) {
|
export default function request(url, options) {
|
||||||
// Default headers
|
// Default headers
|
||||||
options = options || {};
|
const params = options || { };
|
||||||
options.headers = options && options.headers || {
|
const defaultHeaders = {
|
||||||
'Accept': 'application/json',
|
Accept: 'application/json',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
};
|
};
|
||||||
|
params.headers = params && params.headers ? params.headers : defaultHeaders;
|
||||||
|
|
||||||
return fetch(url, options)
|
return fetch(url, params)
|
||||||
.then(checkStatus)
|
.then(checkStatus)
|
||||||
.then(parseJSON)
|
.then(parseJSON)
|
||||||
.then((data) => ({ data }))
|
.then((data) => ({ data }))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user