Skip to content

Commit

Permalink
Move Tabbar, Closes #246
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Nov 23, 2017
1 parent befeea6 commit f3c2915
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions packages/graphql-playground-electron/src/ElectronApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,12 @@ export default class ElectronApp extends React.Component<{}, State> {
// Select first enpoind found
const activeEndpoint = projectsState[0].endpoints[0]

this.setState(
{
openInitialView: false,
activeEndpoint,
endpoint: activeEndpoint.url,
projects: projectsState,
} as State,
)
this.setState({
openInitialView: false,
activeEndpoint,
endpoint: activeEndpoint.url,
projects: projectsState,
} as State)
} catch (error) {
alert(error)
}
Expand All @@ -132,9 +130,9 @@ export default class ElectronApp extends React.Component<{}, State> {
}

handleChangeTheme = () => {
this.setState(
{ theme: this.state.theme === 'dark' ? 'light' : 'dark' } as State,
)
this.setState({
theme: this.state.theme === 'dark' ? 'light' : 'dark',
} as State)
}

handleOpenNewWindow = () => {
Expand Down Expand Up @@ -176,7 +174,10 @@ export default class ElectronApp extends React.Component<{}, State> {
componentWillUnmount() {
ipcRenderer.removeListener('Tab', this.readTabMessage)
ipcRenderer.removeListener('File', this.readFileMessage)
ipcRenderer.removeListener('OpenSelectedFile', this.readOpenSelectedFileMessage)
ipcRenderer.removeListener(
'OpenSelectedFile',
this.readOpenSelectedFileMessage,
)
}

readFileMessage = (error, message) => {
Expand Down Expand Up @@ -208,9 +209,7 @@ export default class ElectronApp extends React.Component<{}, State> {
localStorage.setItem('platformToken', rc.platformToken)
}

const permissionSession = this.getPermissionSessionForPath(
fileToOpen,
)
const permissionSession = this.getPermissionSessionForPath(fileToOpen)

this.playground.newPermissionTab(
permissionSession,
Expand All @@ -221,19 +220,22 @@ export default class ElectronApp extends React.Component<{}, State> {
}

showOpenDialog() {
dialog.showOpenDialog({
title: 'Choose a .graphql file to edit',
properties: ['openFile'],
// filters: [{
// name: '*',
// extensions: ['graphql']
// }]
}, fileNames => {
if (fileNames && fileNames.length > 0) {
const file = fileNames[0]
this.openFile(file)
}
})
dialog.showOpenDialog(
{
title: 'Choose a .graphql file to edit',
properties: ['openFile'],
// filters: [{
// name: '*',
// extensions: ['graphql']
// }]
},
fileNames => {
if (fileNames && fileNames.length > 0) {
const file = fileNames[0]
this.openFile(file)
}
},
)
}

getSaveFileName(): Promise<string> {
Expand Down Expand Up @@ -378,7 +380,7 @@ export default class ElectronApp extends React.Component<{}, State> {
letter-spacing: 0.5px;
}
body .root .tabs.isApp {
padding-left: 58px;
padding-left: 74px;
}
`}</style>
<style jsx={true}>{`
Expand Down Expand Up @@ -439,17 +441,15 @@ export default class ElectronApp extends React.Component<{}, State> {
onSelectFolder={this.handleSelectFolder}
onSelectEndpoint={this.handleSelectEndpoint}
/>
{endpoint &&
{endpoint && (
<div className={cx('app-content', { 'app-endpoint': !projects })}>
{projects &&
{projects && (
<div className={cx('left-content', theme)}>
<div className="list">
{projects.map(project =>
{projects.map(project => (
<div key={project.name}>
<div className={cx('list-item')}>
{project.name}
</div>
{project.endpoints.map(ept =>
<div className={cx('list-item')}>{project.name}</div>
{project.endpoints.map(ept => (
<div
key={ept.name}
className={cx('list-item list-item-project', {
Expand All @@ -459,10 +459,10 @@ export default class ElectronApp extends React.Component<{}, State> {
onClick={() => this.handleChangeItem(ept)}
>
{ept.name}
</div>,
)}
</div>,
)}
</div>
))}
</div>
))}
</div>
<div className="sidenav-footer">
<button
Expand All @@ -480,7 +480,8 @@ export default class ElectronApp extends React.Component<{}, State> {
NEW WINDOW
</button>
</div>
</div>}
</div>
)}
<div className="playground">
<Playground
getRef={this.setRef}
Expand All @@ -492,7 +493,8 @@ export default class ElectronApp extends React.Component<{}, State> {
adminAuthToken={platformToken}
/>
</div>
</div>}
</div>
)}
</div>
</Provider>
)
Expand Down

0 comments on commit f3c2915

Please sign in to comment.