Skip to content

Commit

Permalink
allow tabbing via numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
schickling committed Dec 27, 2017
1 parent 733109a commit 41b1f0b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/graphql-playground-electron/package.json
Expand Up @@ -4,7 +4,7 @@
"homepage": "https://github.com/graphcool/graphql-playground",
"repository": "graphcool/graphql-playground",
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)",
"version": "v1.3.15",
"version": "v1.3.16",
"author": {
"name": "Graphcool",
"email": "hello@graph.cool",
Expand Down Expand Up @@ -134,7 +134,7 @@
"extract-text-webpack-plugin": "^2.0.0-beta.3",
"file-loader": "^0.11.2",
"fork-ts-checker-webpack-plugin": "^0.1.5",
"graphql-playground": "^1.3.13",
"graphql-playground": "^1.3.14",
"happypack": "^3.1.0",
"html-webpack-plugin": "^2.30.1",
"identity-obj-proxy": "^3.0.0",
Expand Down
Expand Up @@ -219,6 +219,8 @@ cd ${folderPath}; graphql playground`)
this.prevTab()
} else if (e.key === '}' && e.metaKey) {
this.nextTab()
} else if (e.key >= 1 && e.key <= 9 && e.metaKey) {
this.playground.switchTab(e.key)
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/graphql-playground-electron/yarn.lock
Expand Up @@ -3539,9 +3539,9 @@ graphql-language-service-utils@^1.0.16:
graphql-config "1.0.8"
graphql-language-service-types "^0.1.14"

graphql-playground@^1.3.13:
version "1.3.13"
resolved "https://registry.yarnpkg.com/graphql-playground/-/graphql-playground-1.3.13.tgz#61b3949bb36f863035d80419c59b57882db6a30f"
graphql-playground@^1.3.14:
version "1.3.14"
resolved "https://registry.yarnpkg.com/graphql-playground/-/graphql-playground-1.3.14.tgz#14db9eeea46a82d8a0d2d5686f51c3dacc068177"
dependencies:
calculate-size "^1.1.1"
classnames "^2.2.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-playground/package.json
@@ -1,6 +1,6 @@
{
"name": "graphql-playground",
"version": "1.3.13",
"version": "1.3.14",
"main": "./lib/lib.js",
"typings": "./lib/lib.d.ts",
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
Expand Down
15 changes: 15 additions & 0 deletions packages/graphql-playground/src/components/Playground.tsx
Expand Up @@ -612,6 +612,21 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
}
}

public switchTab = (index: number) => {
const arrayIndex = index - 1
const { sessions, selectedSessionIndex } = this.state
const numberOfSessions = sessions.length

if (arrayIndex !== selectedSessionIndex || arrayIndex <= numberOfSessions) {
this.setState(state => {
return {
...state,
selectedSessionIndex: arrayIndex,
}
})
}
}

public handleNewSession = (newIndexZero: boolean = false) => {
const session = this.createSession()
if (session.query === defaultQuery) {
Expand Down

0 comments on commit 41b1f0b

Please sign in to comment.