Skip to content

Commit

Permalink
fix(@embark/cockpit): fix console not rendering with ganache and not …
Browse files Browse the repository at this point in the history
…showing blockchain when removing the data-wrapper
  • Loading branch information
jrainville committed Apr 2, 2020
1 parent 1a61bc6 commit aef50ab
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
28 changes: 23 additions & 5 deletions packages/cockpit/ui/src/components/Console.js
Expand Up @@ -16,11 +16,29 @@ const convert = new Convert({newline: true, escapeXML: true});
class Console extends Component {
constructor(props) {
super(props);

this.state = {
value: '',
isLoading: true,
options: [],
activeTab: EMBARK_PROCESS_NAME,
processes: this.getProcesses()
};
}

getProcesses() {
// Add embark to the start of the list
this.processes = [...props.processes];
this.processes.unshift({name: 'embark', state: 'running'});
const processes = [...this.props.processes];
processes.unshift({name: 'embark', state: 'running'});
return processes;
}

this.state = {value: '', isLoading: true, options: [], activeTab: EMBARK_PROCESS_NAME};
componentDidUpdate(prevProps) {
if (prevProps.processes.length !== this.props.processes.length) {
this.setState({
processes: this.getProcesses()
});
}
}

handleSubmit(event) {
Expand Down Expand Up @@ -52,7 +70,7 @@ class Console extends Component {
renderNav() {
return (
<Nav tabs>
{this.processes.map((process) => (
{this.state.processes.map((process) => (
<NavItem key={process.name}>
<NavLink
className={classnames({ active: this.state.activeTab === process.name })}
Expand Down Expand Up @@ -90,7 +108,7 @@ class Console extends Component {

return (
<TabContent activeTab={this.state.activeTab}>
{this.processes.map(process => (
{this.state.processes.map(process => (
<TabPane key={process.name} tabId={process.name}>
<Logs>
{processLogs
Expand Down
29 changes: 14 additions & 15 deletions packages/cockpit/ui/src/containers/HomeContainer.js
Expand Up @@ -48,26 +48,25 @@ class HomeContainer extends Component {
}

render() {
const {processes, postCommand, postCommandSuggestions, processLogs, commandSuggestions} = this.props;
return (
<React.Fragment>
<PageHead title="Dashboard" description="Overview of available services and logs. Interact with Embark using the console. Summary of deployed contracts." />
<ServicesContainer />

<DataWrapper shouldRender={this.props.processes.length > 0 } {...this.props} render={({processes, postCommand, postCommandSuggestions, processLogs, commandSuggestions}) => (
<Card>
<CardBody>
<CardTitle>Console</CardTitle>
<Console activeProcess={this.state.activeProcess}
postCommand={postCommand}
postCommandSuggestions={postCommandSuggestions}
processes={processes}
processLogs={processLogs}
commandSuggestions={commandSuggestions}
isEmbark={() => this.isEmbark}
updateTab={processName => this.updateTab(processName)} />
</CardBody>
</Card>
)} />
<Card>
<CardBody>
<CardTitle>Console</CardTitle>
<Console activeProcess={this.state.activeProcess}
postCommand={postCommand}
postCommandSuggestions={postCommandSuggestions}
processes={processes}
processLogs={processLogs}
commandSuggestions={commandSuggestions}
isEmbark={() => this.isEmbark}
updateTab={processName => this.updateTab(processName)} />
</CardBody>
</Card>

<Card>
<CardBody>
Expand Down
2 changes: 1 addition & 1 deletion packages/cockpit/ui/src/sagas/index.js
Expand Up @@ -150,7 +150,7 @@ export function *watchFetchProcesses() {
}

export function *watchFetchServices() {
yield takeLatest(actions.PROCESSES[actions.REQUEST], fetchServices);
yield takeLatest(actions.SERVICES[actions.REQUEST], fetchServices);
}

export function *watchPostCommand() {
Expand Down

0 comments on commit aef50ab

Please sign in to comment.