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