Skip to content

Commit

Permalink
can bring the UI back up with lots of JS changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Oct 17, 2017
1 parent bec356e commit 7db394e
Show file tree
Hide file tree
Showing 18 changed files with 9,906 additions and 216 deletions.
90 changes: 3 additions & 87 deletions client/client.js
@@ -1,88 +1,4 @@
// Array.prototype.findIndex - MIT License (c) 2013 Paul Miller <http://paulmillr.com>
// For all details and docs: <https://github.com/paulmillr/Array.prototype.findIndex>
(function (globals) {
if (Array.prototype.findIndex) return;
import Routing from './components/routing'
import Screen from './screen';

var findIndex = function(predicate) {
var list = Object(this);
var length = Math.max(0, list.length) >>> 0; // ES.ToUint32;
if (length === 0) return -1;
if (typeof predicate !== 'function' || Object.prototype.toString.call(predicate) !== '[object Function]') {
throw new TypeError('Array#findIndex: predicate must be a function');
}
var thisArg = arguments.length > 1 ? arguments[1] : undefined;
for (var i = 0; i < length; i++) {
if (predicate.call(thisArg, list[i], i, list)) return i;
}
return -1;
};

if (Object.defineProperty) {
try {
Object.defineProperty(Array.prototype, 'findIndex', {
value: findIndex, configurable: true, writable: true
});
} catch(e) {}
}

if (!Array.prototype.findIndex) {
Array.prototype.findIndex = findIndex;
}
}(this));

var Postal = require('postal');
var app = require('./components/app').default;
var disconnect = require('./components/disconnected').default;

// TODO -- HOKEY!!!!!
var theStore = null;
var startRouting = app(Storyteller.initialization, store => {
theStore = store;

Postal.subscribe({
channel: 'engine',
topic: '*',
callback: (data, env) => {
data.type = env.topic;
store.dispatch(data);
}
});


});

var Communicator = require('./communicator');
var wsAddress = Storyteller.wsAddress;

var rebroadcast = m => {
Postal.publish({
channel: 'engine',
topic: m.type,
data: m
});
}

var dispatch = msg => {
theStore.dispatch(msg);



switch (msg.type){
case 'spec-added':
var href = '#/spec/editing/' + msg.data.id;
window.location = href;

case 'spec-saved':
rebroadcast(msg);

case 'runtime-error':
rebroadcast(msg);
}
}

var communicator = new Communicator(dispatch, wsAddress, disconnect);

require('./lib/command-processor')(communicator, theStore);
require('./lib/presentation/spec-editor-presenter')(theStore, communicator);

startRouting();
Screen(Routing);
51 changes: 2 additions & 49 deletions client/components/app.jsx
@@ -1,38 +1,16 @@
import React from 'react';
import ReactDOM from 'react-dom';
import Postal from 'postal';


import {Router, Route, IndexRoute, Link, RouteHandler, browserHistory} from 'react-router';
import { Provider } from 'react-redux'


import SpecExplorer from './explorer/spec-explorer';
import Language from './language/language';
import Documentation from './documentation';
import QueuePage from './queue/queue-page';
import Header from './header/header';
import GrammarErrors from './grammars/grammar-errors';
import SpecEditor from './editing/spec-editor';
import SpecPreview from './editing/spec-preview';
import SpecResults from './editing/spec-results';
import SpecStepthrough from './editing/spec-stepthrough';
import SuiteExplorer from './explorer/suite-explorer';
import ResultsPane from './results/results-pane';


import FixtureTable from './language/fixture-table';
import uuid from 'node-uuid';

import $ from 'jquery';

import Reducer from './../lib/state/reducer';

import { createStore } from 'redux';

import disconnect from './../components/disconnected';

export default function(initialization, register) {
export default function(initialization, Component, register) {
// activate keyboard shortcuts
require('./../lib/presentation/keyboard-shortcuts').register();

Expand All @@ -53,37 +31,12 @@ export default function(initialization, register) {
return () => {
ReactDOM.render(
<Provider store={store}>
<div>

<Header />
<div className="container-fluid">

<Router>
<Route name="app" path="/" >
<Route name="language" path="/language" component={Language}/>
<Route name="documentation" path="/docs" component={Documentation}/>
<Route name="queue" path="/queue" component={QueuePage} />
<Route name="grammar-errors" path="/grammar-errors" component={GrammarErrors} />
<Route name="spec-preview" path="/spec/preview/:id" component={SpecPreview} />
<Route name="spec-editor" path="/spec/editing/:id" component={SpecEditor} />
<Route name="spec-results" path="/spec/results/:id" component={SpecResults} />
<Route name="spec-stepthrough" path="/spec/stepthrough/:id" component={SpecStepthrough} />
<Route name="fixture" path="/fixture/:key" component={FixtureTable} />
<Route name="suite-explorer" path="/suite/*" component={SuiteExplorer} />
<Route name="results" path="/results" component={ResultsPane} />
<IndexRoute component={SpecExplorer}/>
</Route>
</Router>

</div>

</div>
<Component />
</Provider>


, document.getElementById('main'));

register(store);
};

}
2 changes: 1 addition & 1 deletion client/components/editing/adders/step-adder-lookup.jsx
Expand Up @@ -5,7 +5,7 @@ import GrammarLookup from './../../../lib/presentation/grammar-adder-lookup';
import $ from 'jquery';
import scrollIntoView from 'scroll-into-view';

class StepAdderLookup extends Range.Component {
class StepAdderLookup extends React.Component {
componentDidMount(){
const element = ReactDOM.findDOMNode(this);
scrollIntoView(element);
Expand Down
21 changes: 12 additions & 9 deletions client/components/explorer/command-with-name-entry-link.jsx
Expand Up @@ -6,22 +6,25 @@ import { Modal, ModalTrigger, Button } from 'react-bootstrap';
import $ from 'jquery';

class CommandWithNameEntryLink extends React.Component {
constructor(props){
super(props);

const value = this.props.value;

this.state = {
showModal: false,
buttonDisabled: !(value && value.length > 0),
name: value
};
}

componentDidUpdate(){
if (this.state.showModal){
const element = ReactDOM.findDOMNode(this);
$('#modal-name').focus();
}
}

getInitialState() {
const value = this.props.value;
return {
showModal: false,
buttonDisabled: !(value && value.length > 0),
name: value
};
}

close() {
this.setState({ showModal: false });
}
Expand Down
6 changes: 4 additions & 2 deletions client/components/explorer/delete-link.jsx
Expand Up @@ -4,8 +4,10 @@ import Postal from 'postal';
import { Button, Modal } from 'react-bootstrap';

class DeleteLink extends React.Component {
getInitialState() {
return { showModal: false };
constructor(){
super();

this.state = { showModal: false };
}

close() {
Expand Down
2 changes: 1 addition & 1 deletion client/components/header/header.jsx
Expand Up @@ -42,7 +42,7 @@ const Header = (props) => {
<div>
<Navbar inverse={true} id="top-nav">
<Nav>
<a className="navbar-brand" href="#/">Storyteller 4</a>
<NavItem href="#/">Storyteller 5</NavItem>

<NavItem id="project-title" eventKey="4" href="#/">{name}</NavItem>
</Nav>
Expand Down
10 changes: 6 additions & 4 deletions client/components/header/help.jsx
Expand Up @@ -43,6 +43,12 @@ function Help(props){


class HelpButton extends React.Component {
constructor(){
super();

this.state = { showModal: false };
}

componentDidMount(){
Postal.subscribe({
channel: 'explorer',
Expand All @@ -55,10 +61,6 @@ class HelpButton extends React.Component {
})
}

getInitialState() {
return { showModal: false };
}

close() {
this.setState({ showModal: false });
}
Expand Down
11 changes: 7 additions & 4 deletions client/components/header/runtime-error.jsx
Expand Up @@ -3,6 +3,13 @@ import { Button, Modal } from 'react-bootstrap';
import Postal from 'postal';

class RuntimeError extends React.Component{
constructor(){
super();

this.state = { showModal: false, error: null };
}


componentDidMount(){
Postal.subscribe({
channel: 'engine',
Expand All @@ -27,10 +34,6 @@ class RuntimeError extends React.Component{
})
}

getInitialState() {
return { showModal: false, error: null };
}

close() {
this.setState({ showModal: false });
}
Expand Down
13 changes: 13 additions & 0 deletions client/components/hotreloading.jsx
@@ -0,0 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
var Routing = require('./routing');
import { AppContainer } from 'react-hot-loader'

export default function HotReloaded(){
return (
<AppContainer>
<Routing />
</AppContainer>
);
}

52 changes: 52 additions & 0 deletions client/components/routing.jsx
@@ -0,0 +1,52 @@
import React from 'react';
import ReactDOM from 'react-dom';

import {BrowserRouter as Router, Route, Link, RouteHandler} from 'react-router-dom';
import createHistory from 'history/createBrowserHistory';

import SpecExplorer from './explorer/spec-explorer';
import Language from './language/language';
import Documentation from './documentation';
import QueuePage from './queue/queue-page';
import Header from './header/header';
import GrammarErrors from './grammars/grammar-errors';
import SpecEditor from './editing/spec-editor';
import SpecPreview from './editing/spec-preview';
import SpecResults from './editing/spec-results';
import SpecStepthrough from './editing/spec-stepthrough';
import SuiteExplorer from './explorer/suite-explorer';
import ResultsPane from './results/results-pane';
import FixtureTable from './language/fixture-table';

var history = createHistory();
history.listen(location => {
setLocation(location);
});

function Routing(){
return (
<div>
<Header />

<Router>
<div className="container-fluid">
<Route name="language" path="/language" component={Language}/>
<Route name="documentation" path="/docs" component={Documentation}/>
<Route name="queue" path="/queue" component={QueuePage} />
<Route name="grammar-errors" path="/grammar-errors" component={GrammarErrors} />
<Route name="spec-preview" path="/spec/preview/:id" component={SpecPreview} />
<Route name="spec-editor" path="/spec/editing/:id" component={SpecEditor} />
<Route name="spec-results" path="/spec/results/:id" component={SpecResults} />
<Route name="spec-stepthrough" path="/spec/stepthrough/:id" component={SpecStepthrough} />
<Route name="fixture" path="/fixture/:key" component={FixtureTable} />
<Route name="suite-explorer" path="/suite/*" component={SuiteExplorer} />
<Route name="results" path="/results" component={ResultsPane} />
<Route name="home" exact path="/" component={SpecExplorer}/>
</div>
</Router>

</div>
);
}

module.exports = Routing;
4 changes: 4 additions & 0 deletions client/hotreload.js
@@ -0,0 +1,4 @@
import Screen from './screen'
import HotReloading from './components/hotreloading'

Screen(HotReloading);
7 changes: 2 additions & 5 deletions client/lib/presentation/spec-editor-presenter.js
@@ -1,4 +1,4 @@
var { createHistory } = require('history');
import createHistory from 'history/createBrowserHistory';
var Broadcaster = require('./../broadcaster');
var Postal = require('postal');
var changes = require('./../model/change-commands');
Expand Down Expand Up @@ -49,10 +49,7 @@ function setLocation(location){
}
}

var history = createHistory();
history.listen(location => {
setLocation(location);
});


function subscribe(topic, callback, channel = 'editor'){
Postal.subscribe({
Expand Down

0 comments on commit 7db394e

Please sign in to comment.