Skip to content

Commit

Permalink
Images for popup
Browse files Browse the repository at this point in the history
  • Loading branch information
flops committed Apr 25, 2019
1 parent e65a0dd commit 6172d38
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 12 deletions.
5 changes: 5 additions & 0 deletions packages/devtool-frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
####Copyrights

#####Icons

https://thenounproject.com/coquet_adrien/collection/music-media-player-control-play-multimedia-record/
1 change: 1 addition & 0 deletions packages/devtool-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"react-monaco-editor": "0.22.0",
"style-loader": "0.23.1",
"ts-loader": "5.3.3",
"url-loader": "1.1.2",
"webpack": "4.28.4",
"webpack-cli": "3.2.1"
}
Expand Down
Binary file added packages/devtool-frontend/src/imgs/next.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/devtool-frontend/src/imgs/pause.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/devtool-frontend/src/imgs/play.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/devtool-frontend/src/imgs/record.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/devtool-frontend/src/imgs/settings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/devtool-frontend/src/imgs/stop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 71 additions & 12 deletions packages/devtool-frontend/src/popup.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import {
ClientWsTransportEvents,
DevtoolEvents,
ITestControllerExecutionState,
TestWorkerAction,
} from '@testring/types';
import * as React from 'react';
import { render } from 'react-dom';

import { ClientWsTransport } from '@testring/client-ws-transport';
import { DevtoolEvents, TestWorkerAction } from '@testring/types';


async function init() {
Expand All @@ -15,38 +20,92 @@ async function init() {
const runAction = (actionType) => wsClient.send(DevtoolEvents.WORKER_ACTION, { actionType });

const btnStyle = {
'height': '40px',
'margin': '30px 10px',
'display': 'inline-block',
width: '50px',
height: '50px',
border: '0px',
'textIndent': '200%',
'whitSpace': 'no-wrap',
backgroundColor: 'transparent',
backgroundPosition: 'center',
overflow: 'hidden',
margin: '25px 10px',
display: 'inline-block',
padding: 0,
};

class ButtonsLayout extends React.Component {
render() {
const getButtonStyle = (base64: string, active: boolean = true) => {
return {
...btnStyle,
backgroundImage: `url(${base64})`,
cursor: active ? 'pointer' : 'default',
opacity: active ? 1 : 0.6,
};
};

class ButtonsLayout extends React.Component <{workerState?: any}> {
componentDidMount(): void {
wsClient.on(ClientWsTransportEvents.MESSAGE, (data) => {
if (data.type === DevtoolEvents.STORE_STATE) {
this.handleStoreUpdate(data.payload);
}
});
wsClient.send(DevtoolEvents.GET_STORE, {});
}

handleStoreUpdate(storeData: any = {}) {
const workerState = (storeData.workerState || {}) as any;

this.setState( {
...this.state,
workerState,
});
}

renderButtons(workerState: ITestControllerExecutionState) {
return (
<div style={{ 'textAlign': 'center' }}>
<div style={{ 'textAlign': 'center', 'verticalAlign': 'top' }}>
<button
style={btnStyle}
disabled={workerState.paused}
style={getButtonStyle(require('./imgs/pause.png'), !workerState.paused)}
onClick={() => runAction(TestWorkerAction.pauseTestExecution)}>
Pause
</button>
<button
style={btnStyle}
style={getButtonStyle(require('./imgs/next.png'))}
onClick={() => runAction(TestWorkerAction.runTillNextExecution)}>
Pause on Next
Next
</button>
<button
style={btnStyle}
disabled={!(workerState.paused || workerState.pausedTilNext)}
style={getButtonStyle(
require('./imgs/play.png'),
workerState.paused || workerState.pausedTilNext
)}
onClick={() => runAction(TestWorkerAction.resumeTestExecution)}>
Resume
</button>
<button
style={btnStyle}
style={getButtonStyle(require('./imgs/stop.png'))}
onClick={() => runAction(TestWorkerAction.releaseTest)}>
Release
</button>
</div>
);
}

render() {
const workerState = (this.state as any || {}).workerState;

if (workerState) {
return this.renderButtons(workerState);
} else {
return (
<div style={{ 'textAlign': 'center' }}>
Waiting for store initialization...
</div>
);
}
}
}

render(
Expand Down
8 changes: 8 additions & 0 deletions packages/devtool-frontend/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ const config: webpack.Configuration = {
},
],
},
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
},
],
},
],
},

Expand Down

0 comments on commit 6172d38

Please sign in to comment.