mirror of https://github.com/embarklabs/embark.git
only show footer when embark tab
This commit is contained in:
parent
b34a9e5e63
commit
af21dcc910
|
@ -1,6 +1,6 @@
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {Grid, Card, Form, Tabs, Tab} from 'tabler-react';
|
import {Grid, Card, Form, Tabs, Tab, TabbedHeader, TabbedContainer} from 'tabler-react';
|
||||||
import Logs from "./Logs";
|
import Logs from "./Logs";
|
||||||
import Convert from 'ansi-to-html';
|
import Convert from 'ansi-to-html';
|
||||||
|
|
||||||
|
@ -17,7 +17,10 @@ CommandResult.propTypes = {
|
||||||
class Console extends Component {
|
class Console extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {value: ''};
|
this.state = {
|
||||||
|
value: '',
|
||||||
|
selectedProcess: 'Embark'
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit(event) {
|
handleSubmit(event) {
|
||||||
|
@ -31,25 +34,16 @@ class Console extends Component {
|
||||||
this.setState({value: event.target.value});
|
this.setState({value: event.target.value});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
renderTabs() {
|
||||||
const {processLogs, processes, commands}= this.props;
|
const {processLogs, processes, commands} = this.props;
|
||||||
return (
|
return [
|
||||||
<Grid.Row cards className="console">
|
(<Tab title="Embark" key="Embark">
|
||||||
<Grid.Col>
|
|
||||||
<Card>
|
|
||||||
<Card.Header>
|
|
||||||
<Card.Title>Embark console</Card.Title>
|
|
||||||
</Card.Header>
|
|
||||||
<Card.Body >
|
|
||||||
<Tabs initialTab="Embark">
|
|
||||||
<Tab title="Embark">
|
|
||||||
<Logs>
|
<Logs>
|
||||||
{commands.map((command, index) => <CommandResult key={index} result={command.result}/>)}
|
{commands.map((command, index) => <CommandResult key={index} result={command.result}/>)}
|
||||||
</Logs>
|
</Logs>
|
||||||
</Tab>
|
</Tab>)
|
||||||
{processes.map(process => {
|
].concat(processes.map(process => (
|
||||||
return (
|
<Tab title={process.name} key={process.name} onClick={(e, x) => this.clickTab(e, x)}>
|
||||||
<Tab title={process.name} key={process.name}>
|
|
||||||
<Logs>
|
<Logs>
|
||||||
{
|
{
|
||||||
processLogs.filter((item) => item.name === process.name)
|
processLogs.filter((item) => item.name === process.name)
|
||||||
|
@ -58,19 +52,38 @@ class Console extends Component {
|
||||||
}
|
}
|
||||||
</Logs>
|
</Logs>
|
||||||
</Tab>
|
</Tab>
|
||||||
);
|
)));
|
||||||
})}
|
}
|
||||||
</Tabs>
|
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const tabs = this.renderTabs();
|
||||||
|
const {selectedProcess, value} = this.state;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Grid.Row cards className="console">
|
||||||
|
<Grid.Col>
|
||||||
|
<Card>
|
||||||
|
<Card.Body className="console-container">
|
||||||
|
<React.Fragment>
|
||||||
|
<TabbedHeader
|
||||||
|
selectedTitle={selectedProcess}
|
||||||
|
stateCallback={newProcess => this.setState({selectedProcess: newProcess})}
|
||||||
|
>
|
||||||
|
{tabs}
|
||||||
|
</TabbedHeader>
|
||||||
|
<TabbedContainer selectedTitle={selectedProcess}>
|
||||||
|
{tabs}
|
||||||
|
</TabbedContainer>
|
||||||
|
</React.Fragment>
|
||||||
</Card.Body>
|
</Card.Body>
|
||||||
<Card.Footer>
|
{selectedProcess === 'Embark' && <Card.Footer>
|
||||||
<form onSubmit={(event) => this.handleSubmit(event)} autoComplete="off">
|
<form onSubmit={(event) => this.handleSubmit(event)} autoComplete="off">
|
||||||
<Form.Input value={this.state.value}
|
<Form.Input value={value}
|
||||||
onChange={(event) => this.handleChange(event)}
|
onChange={(event) => this.handleChange(event)}
|
||||||
name="command"
|
name="command"
|
||||||
placeholder="Type a command (e.g help)" />
|
placeholder="Type a command (e.g help)"/>
|
||||||
</form>
|
</form>
|
||||||
</Card.Footer>
|
</Card.Footer>}
|
||||||
</Card>
|
</Card>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
color: white;
|
color: white;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
max-height: 400px;
|
max-height: 350px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,15 @@
|
||||||
color: #8f98a2;
|
color: #8f98a2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.console-container {
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.console-container .nav-link {
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
.text__new-line, .card.warnings-card .list-group-item, .card.errors-card .list-group-item {
|
.text__new-line, .card.warnings-card .list-group-item, .card.errors-card .list-group-item {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
|
Loading…
Reference in New Issue