mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 06:04:29 +00:00
Enable description and version updates
This commit is contained in:
parent
a4d6a10228
commit
82a96a0f20
@ -31,9 +31,19 @@ module.exports = {
|
||||
// Update application name
|
||||
if (this.request.body.name) {
|
||||
packageJSONContent.name = this.request.body.name;
|
||||
fs.writeFileSync('package.json', JSON.stringify(packageJSONContent, null, 4), 'utf8');
|
||||
}
|
||||
|
||||
if (this.request.body.description) {
|
||||
packageJSONContent.description = this.request.body.description;
|
||||
}
|
||||
|
||||
if (this.request.body.version) {
|
||||
packageJSONContent.version = this.request.body.version;
|
||||
}
|
||||
|
||||
|
||||
fs.writeFileSync('package.json', JSON.stringify(packageJSONContent, null, 4), 'utf8');
|
||||
|
||||
return this.body = {
|
||||
name: packageJSONContent.name
|
||||
};
|
||||
|
||||
@ -19,7 +19,9 @@ import {
|
||||
LOAD_GENERAL_SETTINGS,
|
||||
LOAD_GENERAL_SETTINGS_SUCCESS,
|
||||
LOAD_GENERAL_SETTINGS_ERROR,
|
||||
CHANGE_APP_NAME,
|
||||
CHANGE_NAME,
|
||||
CHANGE_DESCRIPTION,
|
||||
CHANGE_VERSION,
|
||||
UPDATE_GENERAL_SETTINGS,
|
||||
} from './constants';
|
||||
|
||||
@ -65,11 +67,25 @@ export function generalSettingsLoadingError(error) {
|
||||
|
||||
export function changeName(name) {
|
||||
return {
|
||||
type: CHANGE_APP_NAME,
|
||||
type: CHANGE_NAME,
|
||||
name: name
|
||||
};
|
||||
}
|
||||
|
||||
export function changeDescription(description) {
|
||||
return {
|
||||
type: CHANGE_DESCRIPTION,
|
||||
description: description
|
||||
};
|
||||
}
|
||||
|
||||
export function changeVersion(version) {
|
||||
return {
|
||||
type: CHANGE_VERSION,
|
||||
version: version
|
||||
};
|
||||
}
|
||||
|
||||
export function updateGeneralSettings(data) {
|
||||
return {
|
||||
type: UPDATE_GENERAL_SETTINGS,
|
||||
|
||||
@ -12,5 +12,7 @@
|
||||
export const LOAD_GENERAL_SETTINGS = 'settingsmanager/HomePage/LOAD_GENERAL_SETTINGS';
|
||||
export const LOAD_GENERAL_SETTINGS_SUCCESS = 'settingsmanager/HomePage/LOAD_GENERAL_SETTINGS_SUCCESS';
|
||||
export const LOAD_GENERAL_SETTINGS_ERROR = 'settingsmanager/HomePage/LOAD_GENERAL_SETTINGS_ERROR';
|
||||
export const CHANGE_APP_NAME = 'settingsmanager/HomePage/CHANGE_APP_NAME';
|
||||
export const CHANGE_NAME = 'settingsmanager/HomePage/CHANGE_NAME';
|
||||
export const CHANGE_DESCRIPTION = 'settingsmanager/HomePage/CHANGE_DESCRIPTION';
|
||||
export const CHANGE_VERSION = 'settingsmanager/HomePage/CHANGE_VERSION';
|
||||
export const UPDATE_GENERAL_SETTINGS = 'settingsmanager/HomePage/UPDATE_GENERAL_SETTINGS';
|
||||
|
||||
@ -20,6 +20,8 @@ import RightContentTitle from 'components/RightContentTitle';
|
||||
|
||||
import {
|
||||
selectName,
|
||||
selectDescription,
|
||||
selectVersion,
|
||||
selectLoading,
|
||||
selectError,
|
||||
} from 'containers/HomePage/selectors';
|
||||
@ -27,6 +29,8 @@ import {
|
||||
import {
|
||||
loadGeneralSettings,
|
||||
changeName,
|
||||
changeDescription,
|
||||
changeVersion,
|
||||
updateGeneralSettings,
|
||||
} from 'containers/HomePage/actions';
|
||||
|
||||
@ -36,10 +40,6 @@ export class HomePage extends React.Component {
|
||||
|
||||
componentDidMount() {
|
||||
this.props.onPageLoad();
|
||||
|
||||
setTimeout(() => {
|
||||
this.props.onFormSubmit();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -60,20 +60,34 @@ export class HomePage extends React.Component {
|
||||
placeholder="My Application"
|
||||
id="applicationName"
|
||||
value={this.props.name}
|
||||
onChange={this.props.onChangeAppName}
|
||||
onChange={this.props.onChangeName}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`form-group row ${styles.homePageRightContentFormGroup}`}>
|
||||
<label htmlFor="applicationDescription" className="col-xs-7 col-form-label">Description</label>
|
||||
<div className="col-xs-5">
|
||||
<input className="form-control" type="text" placeholder="A Strapi application" id="applicationDescription"></input>
|
||||
<input
|
||||
className="form-control"
|
||||
type="text"
|
||||
placeholder="A Strapi application"
|
||||
id="applicationDescription"
|
||||
value={this.props.description}
|
||||
onChange={this.props.onChangeDescription}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`form-group row ${styles.homePageRightContentFormGroup}`}>
|
||||
<label htmlFor="applicationVersion" className="col-xs-7 col-form-label">Version</label>
|
||||
<div className="col-xs-5">
|
||||
<input className="form-control" type="text" placeholder="0.0.1" id="applicationVersion"></input>
|
||||
<input
|
||||
className="form-control"
|
||||
type="text"
|
||||
placeholder="0.0.1"
|
||||
id="applicationVersion"
|
||||
value={this.props.version}
|
||||
onChange={this.props.onChangeVersion}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<button className="btn btn-primary" type="submit">
|
||||
@ -98,15 +112,27 @@ HomePage.propTypes = {
|
||||
React.PropTypes.string,
|
||||
React.PropTypes.bool,
|
||||
]),
|
||||
description: React.PropTypes.oneOfType([
|
||||
React.PropTypes.string,
|
||||
React.PropTypes.bool,
|
||||
]),
|
||||
version: React.PropTypes.oneOfType([
|
||||
React.PropTypes.string,
|
||||
React.PropTypes.bool,
|
||||
]),
|
||||
onPageLoad: React.PropTypes.func,
|
||||
onFormSubmit: React.PropTypes.func,
|
||||
// username: React.PropTypes.string,
|
||||
onChangeAppName: React.PropTypes.func,
|
||||
onChangeName: React.PropTypes.func,
|
||||
onChangeDescription: React.PropTypes.func,
|
||||
onChangeVersion: React.PropTypes.func,
|
||||
};
|
||||
|
||||
export function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
onChangeAppName: (evt) => dispatch(changeName(evt.target.value)),
|
||||
onChangeName: (evt) => dispatch(changeName(evt.target.value)),
|
||||
onChangeDescription: (evt) => dispatch(changeDescription(evt.target.value)),
|
||||
onChangeVersion: (evt) => dispatch(changeVersion(evt.target.value)),
|
||||
onFormSubmit: (e) => {
|
||||
e.preventDefault();
|
||||
dispatch(updateGeneralSettings());
|
||||
@ -124,6 +150,8 @@ HomePage.propTypes = {
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
// generalSettings: selectGeneralSettings(),
|
||||
name: selectName(),
|
||||
description: selectDescription(),
|
||||
version: selectVersion(),
|
||||
// username: selectUsername(),
|
||||
// loading: selectLoading(),
|
||||
// error: selectError(),
|
||||
|
||||
@ -14,7 +14,9 @@ import {
|
||||
LOAD_GENERAL_SETTINGS_SUCCESS,
|
||||
LOAD_GENERAL_SETTINGS,
|
||||
LOAD_GENERAL_SETTINGS_ERROR,
|
||||
CHANGE_APP_NAME,
|
||||
CHANGE_NAME,
|
||||
CHANGE_DESCRIPTION,
|
||||
CHANGE_VERSION,
|
||||
} from './constants';
|
||||
import { fromJS } from 'immutable';
|
||||
|
||||
@ -23,7 +25,7 @@ const initialState = fromJS({
|
||||
loading: false,
|
||||
error: false,
|
||||
|
||||
name: false ,
|
||||
name: false,
|
||||
description: false,
|
||||
version: false,
|
||||
});
|
||||
@ -48,9 +50,15 @@ function appReducer(state = initialState, action) {
|
||||
return state
|
||||
.set('error', action.error)
|
||||
.set('loading', false);
|
||||
case CHANGE_APP_NAME:
|
||||
case CHANGE_NAME:
|
||||
return state
|
||||
.set('name', action.name);
|
||||
case CHANGE_DESCRIPTION:
|
||||
return state
|
||||
.set('description', action.description);
|
||||
case CHANGE_VERSION:
|
||||
return state
|
||||
.set('version', action.version);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -9,7 +9,11 @@ import {
|
||||
UPDATE_GENERAL_SETTINGS,
|
||||
} from 'containers/HomePage/constants';
|
||||
import { generalSettingsLoaded, generalSettingsLoadingError } from 'containers/HomePage/actions';
|
||||
import { selectName } from 'containers/HomePage/selectors';
|
||||
import {
|
||||
selectName,
|
||||
selectDescription,
|
||||
selectVersion,
|
||||
} from 'containers/HomePage/selectors';
|
||||
|
||||
import request from 'utils/request';
|
||||
|
||||
@ -32,10 +36,10 @@ export function* getGeneralSettings() {
|
||||
export function* updateGeneralSettings() {
|
||||
const data = {
|
||||
name: yield select(selectName()),
|
||||
description: yield select(selectDescription()),
|
||||
version: yield select(selectVersion()),
|
||||
};
|
||||
|
||||
console.log('data', data);
|
||||
|
||||
const requestURL = `http://localhost:1337/settingsmanager/settings`;
|
||||
|
||||
// Call our request helper (see 'utils/request')
|
||||
|
||||
@ -26,6 +26,16 @@ const selectName = () => createSelector(
|
||||
(homeState) => homeState.get('name')
|
||||
);
|
||||
|
||||
const selectDescription = () => createSelector(
|
||||
selectHome(),
|
||||
(homeState) => homeState.get('description')
|
||||
);
|
||||
|
||||
const selectVersion = () => createSelector(
|
||||
selectHome(),
|
||||
(homeState) => homeState.get('version')
|
||||
);
|
||||
|
||||
const selectLocationState = () => {
|
||||
let prevRoutingState;
|
||||
let prevRoutingStateJS;
|
||||
@ -48,5 +58,7 @@ export {
|
||||
selectError,
|
||||
selectGeneralSettings,
|
||||
selectName,
|
||||
selectDescription,
|
||||
selectVersion,
|
||||
selectLocationState,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user