From 41b1f0b06934ac1e2bc9138504e961117961b4d6 Mon Sep 17 00:00:00 2001 From: Johannes Schickling Date: Wed, 27 Dec 2017 11:48:15 +0100 Subject: [PATCH] allow tabbing via numbers --- packages/graphql-playground-electron/package.json | 4 ++-- .../src/renderer/components/App.tsx | 2 ++ packages/graphql-playground-electron/yarn.lock | 6 +++--- packages/graphql-playground/package.json | 2 +- .../src/components/Playground.tsx | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/graphql-playground-electron/package.json b/packages/graphql-playground-electron/package.json index 0b6e708c3..3aaf4a270 100644 --- a/packages/graphql-playground-electron/package.json +++ b/packages/graphql-playground-electron/package.json @@ -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", @@ -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", diff --git a/packages/graphql-playground-electron/src/renderer/components/App.tsx b/packages/graphql-playground-electron/src/renderer/components/App.tsx index 9d7c62f61..49b938e4b 100644 --- a/packages/graphql-playground-electron/src/renderer/components/App.tsx +++ b/packages/graphql-playground-electron/src/renderer/components/App.tsx @@ -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) } } diff --git a/packages/graphql-playground-electron/yarn.lock b/packages/graphql-playground-electron/yarn.lock index 25e6b6473..57029590e 100644 --- a/packages/graphql-playground-electron/yarn.lock +++ b/packages/graphql-playground-electron/yarn.lock @@ -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" diff --git a/packages/graphql-playground/package.json b/packages/graphql-playground/package.json index e4da5ac0c..3b1e09154 100644 --- a/packages/graphql-playground/package.json +++ b/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).", diff --git a/packages/graphql-playground/src/components/Playground.tsx b/packages/graphql-playground/src/components/Playground.tsx index 715f05744..7646d23f3 100644 --- a/packages/graphql-playground/src/components/Playground.tsx +++ b/packages/graphql-playground/src/components/Playground.tsx @@ -612,6 +612,21 @@ export class Playground extends React.PureComponent { } } + 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) {