Fix new plugin/instance/client pages

This commit is contained in:
Tulir Asokan 2018-11-14 00:06:03 +02:00
parent a3dea42b1a
commit 52811681f4
4 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,6 @@
import React, { Component } from "react" import React, { Component } from "react"
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
import Log from "./Log"
class BaseMainView extends Component { class BaseMainView extends Component {
constructor(props) { constructor(props) {
@ -63,6 +64,8 @@ class BaseMainView extends Component {
))} ))}
</div> </div>
) )
renderLog = () => !this.isNew && <Log showName={false} lines={this.props.log}/>
} }
export default BaseMainView export default BaseMainView

View File

@ -21,7 +21,6 @@ import { PrefTable, PrefSwitch, PrefInput } from "../../components/PreferenceTab
import Spinner from "../../components/Spinner" import Spinner from "../../components/Spinner"
import api from "../../api" import api from "../../api"
import BaseMainView from "./BaseMainView" import BaseMainView from "./BaseMainView"
import Log from "./Log"
const ClientListEntry = ({ entry }) => { const ClientListEntry = ({ entry }) => {
const classes = ["client", "entry"] const classes = ["client", "entry"]
@ -158,7 +157,7 @@ class Client extends BaseMainView {
renderPreferences = () => ( renderPreferences = () => (
<PrefTable> <PrefTable>
<PrefInput rowName="User ID" type="text" disabled={!this.isNew} fullWidth={true} <PrefInput rowName="User ID" type="text" disabled={!this.isNew} fullWidth={true}
name={!this.isNew ? "id" : ""} value={this.state.id} className="id" name={this.isNew ? "id" : ""} value={this.state.id} className="id"
placeholder="@fancybot:example.com" onChange={this.inputChange}/> placeholder="@fancybot:example.com" onChange={this.inputChange}/>
<PrefInput rowName="Homeserver" type="text" name="homeserver" <PrefInput rowName="Homeserver" type="text" name="homeserver"
value={this.state.homeserver} placeholder="https://example.com" value={this.state.homeserver} placeholder="https://example.com"
@ -210,7 +209,7 @@ class Client extends BaseMainView {
{this.renderInstances()} {this.renderInstances()}
</div> </div>
</div> </div>
<Log showName={false} lines={this.props.log}/> {this.renderLog()}
</> </>
} }
} }

View File

@ -23,7 +23,6 @@ import PrefTable, { PrefInput, PrefSelect, PrefSwitch } from "../../components/P
import api from "../../api" import api from "../../api"
import Spinner from "../../components/Spinner" import Spinner from "../../components/Spinner"
import BaseMainView from "./BaseMainView" import BaseMainView from "./BaseMainView"
import Log from "./Log"
const InstanceListEntry = ({ entry }) => ( const InstanceListEntry = ({ entry }) => (
<NavLink className="instance entry" to={`/instance/${entry.id}`}> <NavLink className="instance entry" to={`/instance/${entry.id}`}>
@ -168,7 +167,7 @@ class Instance extends BaseMainView {
</button> </button>
</div> </div>
<div className="error">{this.state.error}</div> <div className="error">{this.state.error}</div>
<Log showName={false} lines={this.props.log}/> {this.renderLog()}
</div> </div>
} }
} }

View File

@ -14,14 +14,13 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import React from "react" import React from "react"
import { NavLink } from "react-router-dom" import { NavLink, withRouter } from "react-router-dom"
import { ReactComponent as ChevronRight } from "../../res/chevron-right.svg" import { ReactComponent as ChevronRight } from "../../res/chevron-right.svg"
import { ReactComponent as UploadButton } from "../../res/upload.svg" import { ReactComponent as UploadButton } from "../../res/upload.svg"
import PrefTable, { PrefInput } from "../../components/PreferenceTable" import PrefTable, { PrefInput } from "../../components/PreferenceTable"
import Spinner from "../../components/Spinner" import Spinner from "../../components/Spinner"
import api from "../../api" import api from "../../api"
import BaseMainView from "./BaseMainView" import BaseMainView from "./BaseMainView"
import Log from "./Log"
const PluginListEntry = ({ entry }) => ( const PluginListEntry = ({ entry }) => (
<NavLink className="plugin entry" to={`/plugin/${entry.id}`}> <NavLink className="plugin entry" to={`/plugin/${entry.id}`}>
@ -34,6 +33,11 @@ const PluginListEntry = ({ entry }) => (
class Plugin extends BaseMainView { class Plugin extends BaseMainView {
static ListEntry = PluginListEntry static ListEntry = PluginListEntry
constructor(props) {
super(props)
this.deleteFunc = api.deletePlugin
}
get initialState() { get initialState() {
return { return {
id: "", id: "",
@ -90,10 +94,10 @@ class Plugin extends BaseMainView {
</button> </button>
</div>} </div>}
<div className="error">{this.state.error}</div> <div className="error">{this.state.error}</div>
{!this.isNew && this.renderInstances()} {this.renderInstances()}
<Log showName={false} lines={this.props.log}/> {this.renderLog()}
</div> </div>
} }
} }
export default Plugin export default withRouter(Plugin)