diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index 4896a2ec14..87722d41a7 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -18,7 +18,7 @@ class AppsController < ApplicationController def update @app = App.find params[:id] - @app.update(definition: params[:definition], name: params[:name], current_version_id: params['currentVersion']) + @app.update(params["app"].permit("name", "current_version_id")) end def users diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index b3fce41313..546e0ea8dc 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -145,10 +145,11 @@ class Editor extends React.Component { }) } - saveApp = () => { - const { app, appDefinition } = this.state; - appService.saveApp(app.id, app.name, appDefinition).then((data) => { - toast.success('App saved & deployed sucessfully', { hideProgressBar: true, position: "top-center" }) + saveApp = (id, attributes, notify = false) => { + appService.saveApp(id, attributes).then((data) => { + if(notify){ + toast.success('App saved sucessfully', { hideProgressBar: true, position: "top-center" }) + } }); } @@ -282,6 +283,7 @@ class Editor extends React.Component { type="text" style={{width: '200px', left: '80px', position: 'absolute'}} onChange={(e) => this.onNameChanged(e.target.value)} + onBlur={(e) => this.saveApp(this.state.app.id, { name: e.target.value })} className="form-control-plaintext form-control-plaintext-sm" value={this.state.app.name} /> diff --git a/frontend/src/Editor/SaveAndPreview.jsx b/frontend/src/Editor/SaveAndPreview.jsx index c23191d9be..ce64a57cb0 100644 --- a/frontend/src/Editor/SaveAndPreview.jsx +++ b/frontend/src/Editor/SaveAndPreview.jsx @@ -63,7 +63,7 @@ class SaveAndPreview extends React.Component { deployVersion = (versionId) => { this.setState({ isDeploying: true }); - appService.saveApp(this.props.appId, this.props.appName ,undefined, versionId).then(data => { + appService.saveApp(this.props.appId, { name: this.props.appName, current_version_id: versionId }).then(data => { this.setState({ isDeploying: false }); toast.success('Version Deployed', { hideProgressBar: true, position: "top-center", }); }); diff --git a/frontend/src/_services/app.service.js b/frontend/src/_services/app.service.js index c90c6d6759..3d0d8a2bc1 100644 --- a/frontend/src/_services/app.service.js +++ b/frontend/src/_services/app.service.js @@ -31,19 +31,13 @@ function getApp(id) { } -function saveApp(id, name, definition, currentVersion) { +function saveApp(id, attributes) { const headers = { ...authHeader(), 'Content-Type': 'application/json' } - const body = { - definition, - name, - currentVersion - }; - - const requestOptions = { method: 'PUT', headers: headers, body: JSON.stringify(body) }; + const requestOptions = { method: 'PUT', headers: headers, body: JSON.stringify({app: attributes}) }; return fetch(`${config.apiUrl}/apps/${id}`, requestOptions).then(handleResponse); }