From fc7d67e569f68af3d221ee8c734ebec979c83527 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Sat, 14 Jul 2018 15:49:23 +0530 Subject: [PATCH 1/5] =?UTF-8?q?Share=20TestsView=20works=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/common/Modals/ShareModal/index.js | 18 +++++++++++++++++- packages/app/src/app/store/actions.js | 3 +++ packages/app/src/app/store/sequences.js | 2 +- packages/common/url.js | 10 ++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/app/src/app/pages/common/Modals/ShareModal/index.js b/packages/app/src/app/pages/common/Modals/ShareModal/index.js index 3ba79cd096d..a91d033c8f2 100644 --- a/packages/app/src/app/pages/common/Modals/ShareModal/index.js +++ b/packages/app/src/app/pages/common/Modals/ShareModal/index.js @@ -34,6 +34,7 @@ class ShareView extends React.Component { state = { showEditor: true, showPreview: true, + testsView: false, defaultModule: null, autoResize: false, hideNavigation: false, @@ -78,6 +79,7 @@ class ShareView extends React.Component { defaultModule, showEditor, showPreview, + testsView, autoResize, hideNavigation, isCurrentModuleView, @@ -107,10 +109,13 @@ class ShareView extends React.Component { options.view = 'preview'; } + if (testsView) { + options.previewwindow = 'tests'; + } + if (autoResize) { options.autoresize = 1; } - if (hideNavigation) { options.hidenavigation = 1; } @@ -208,6 +213,10 @@ class ShareView extends React.Component { setFontSize = (fontSize: number) => [this.setState({ fontSize })]; + setTestsView = (testsView: boolean) => { + this.setState({ testsView }); + }; + render() { const sandbox = this.props.store.editor.currentSandbox; const mainModule = this.props.store.editor.mainModule; @@ -215,6 +224,7 @@ class ShareView extends React.Component { const { showEditor, showPreview, + testsView, autoResize, hideNavigation, isCurrentModuleView, @@ -274,6 +284,12 @@ class ShareView extends React.Component { value={isCurrentModuleView} setValue={this.setIsCurrentModuleView} /> + { diff --git a/packages/app/src/app/store/sequences.js b/packages/app/src/app/store/sequences.js index 0b49ba929c5..1c7922d7193 100644 --- a/packages/app/src/app/store/sequences.js +++ b/packages/app/src/app/store/sequences.js @@ -297,8 +297,8 @@ export const setSandbox = [ actions.setCurrentModuleShortid, actions.setMainModuleShortid, actions.setInitialTab, - actions.setUrlOptions, actions.setSandboxConfigOptions, + actions.setUrlOptions, actions.setWorkspace, ]; diff --git a/packages/common/url.js b/packages/common/url.js index 9b970fc2e02..36b6f67a1bd 100644 --- a/packages/common/url.js +++ b/packages/common/url.js @@ -35,6 +35,16 @@ export const getSandboxOptions = (url: string) => { result.isEditorScreen = url.includes('view=editor'); result.isSplitScreen = url.includes('view=split'); + result.isTestPreviewWindow = url.includes('previewwindow=tests'); + result.isConsolePreviewWindow = url.includes('previewwindow=console'); + + if (result.isTestPreviewWindow && !result.isConsolePreviewWindow) { + result.previewWindow = 'tests'; + } + + if (!result.isTestPreviewWindow && result.isConsolePreviewWindow) { + result.previewWindow = 'console'; + } // If there is no view specified and the width of the window is <800 we want // to default to preview if ( From 8489c53f52b9740e2641d0e9220da50c1fda67bb Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Sun, 15 Jul 2018 19:36:07 +0530 Subject: [PATCH 2/5] Add docs for previewWindow --- packages/homepage/content/docs/2-embedding.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/homepage/content/docs/2-embedding.md b/packages/homepage/content/docs/2-embedding.md index 689f9959d64..92d5bddf05a 100644 --- a/packages/homepage/content/docs/2-embedding.md +++ b/packages/homepage/content/docs/2-embedding.md @@ -42,6 +42,7 @@ find them here. | `expanddevtools` | Start with the devtools (console) open. | `0`/`1` | `0` | | `runonclick` | Only load the preview when the user says so. | `0`/`1` | `0` | | `view` | Which view to open by default | `editor`/`split`/`preview` | `split`, `preview` for small screens | +| `previewwindow` | Which preView window to open by default | `console`/`tests`/`browser` | `browser` | | `module` | Which module to open by default | path to module (starting with `/`) | entry path | | `initialpath` | Which url to initially load in address bar | string | `/` | | `fontsize` | Font size of editor | number (in px) | `14` | From 07035296451694e3a08fb33ef3b919ae79aec536 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Sun, 15 Jul 2018 19:43:07 +0530 Subject: [PATCH 3/5] Add satyarohith to contributors --- .all-contributorsrc | 10 ++++++++++ README.md | 2 ++ 2 files changed, 12 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 38f4d75f975..163af746951 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -582,6 +582,16 @@ "bug", "code" ] + }, + { + "login": "satyarohith", + "name": "Satya Rohith", + "avatar_url": "https://avatars2.githubusercontent.com/u/29819102?v=4", + "profile": "https://satya.tech", + "contributions": [ + "code", + "doc" + ] } ], "repoType": "github" diff --git a/README.md b/README.md index b5b4a9585cb..8f58c0adc5f 100644 --- a/README.md +++ b/README.md @@ -49,4 +49,6 @@ Thanks goes to these wonderful people | [
Michel Weststrate](https://twitter.com/mweststrate)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=mweststrate "Code") | [
Oleg](https://kof.github.io)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=kof "Code") | [
Paul Sherman](https://www.pshrmn.com)
[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Apshrmn "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=pshrmn "Code") | [
Ro Savage](https://github.com/ro-savage)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=ro-savage "Code") | [
Sam Denty](https://samdd.me)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=samdenty99 "Code") | [
Zephraph](https://github.com/zephraph)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=zephraph "Code") | [
Josh Waller](https://www.joshwaller.me)
[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Amdxprograms "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=mdxprograms "Code") [📖](https://github.com/CompuIves/codesandbox-client/commits?author=mdxprograms "Documentation") | | [
Joe Ng'ethe](http://joey.co.ke)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=joeynimu "Code") | [
Carles Codony](https://github.com/bitblitter)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=bitblitter "Code") | [
Vytenis](https://github.com/FDiskas)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=FDiskas "Code") | [
Manuel Dugué](http://manueldugue.de)
[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Amdugue "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=mdugue "Code") | [
Demian Dekoninck](https://dem.be)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=DemianD "Code") | [
Drake Costa](http://www.saeris.io)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=Saeris "Code") | [
Marko Stijak](https://cxjs.io/)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=mstijak "Code") | | [
Ilya](https://twitter.com/ilya_komar0ff)
[💬](#question-Komar0ff "Answering Questions") [🤔](#ideas-Komar0ff "Ideas, Planning, & Feedback") | [
Emerson Laurentino](https://twitter.com/elaurent_)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=emersonlaurentino "Code") [🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Aemersonlaurentino "Bug reports") | [
Colton Colcleasure](https://github.com/colshacol)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=colshacol "Code") [🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Acolshacol "Bug reports") | [
PJ Walker](https://github.com/PJWalker)
[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3APJWalker "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=PJWalker "Code") | +| [
Ilya](https://twitter.com/ilya_komar0ff)
[💬](#question-Komar0ff "Answering Questions") [🤔](#ideas-Komar0ff "Ideas, Planning, & Feedback") | [
Emerson Laurentino](https://twitter.com/elaurent_)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=emersonlaurentino "Code") [🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Aemersonlaurentino "Bug reports") | [
Colton Colcleasure](https://github.com/colshacol)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=colshacol "Code") | +| [
Ilya](https://twitter.com/ilya_komar0ff)
[💬](#question-Komar0ff "Answering Questions") [🤔](#ideas-Komar0ff "Ideas, Planning, & Feedback") | [
Emerson Laurentino](https://twitter.com/elaurent_)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=emersonlaurentino "Code") [🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Aemersonlaurentino "Bug reports") | [
Satya Rohith](https://satya.tech)
[💻](https://github.com/CompuIves/codesandbox-client/commits?author=satyarohith "Code") [📖](https://github.com/CompuIves/codesandbox-client/commits?author=satyarohith "Documentation") | From 3a73b20feacf31c3814520782b2848140a5e7921 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Wed, 18 Jul 2018 13:11:54 +0530 Subject: [PATCH 4/5] Support Embed --- packages/app/src/embed/components/App/index.js | 5 +++++ packages/app/src/embed/components/Content/index.js | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/app/src/embed/components/App/index.js b/packages/app/src/embed/components/App/index.js index 939b7d7b64f..d1d8745eaae 100644 --- a/packages/app/src/embed/components/App/index.js +++ b/packages/app/src/embed/components/App/index.js @@ -30,6 +30,7 @@ type State = { fontSize: number, showEditor: boolean, showPreview: boolean, + previewWindow: string, isInProjectView: boolean, currentModule: string, initialPath: string, @@ -65,6 +66,7 @@ export default class App extends React.PureComponent<{}, State> { isInProjectView, isPreviewScreen, isEditorScreen, + previewWindow, isSplitScreen, autoResize, hideNavigation, @@ -85,6 +87,7 @@ export default class App extends React.PureComponent<{}, State> { fontSize: fontSize || 16, showEditor: isSplitScreen || isEditorScreen, showPreview: isSplitScreen || isPreviewScreen, + previewWindow, isInProjectView, currentModule, initialPath, @@ -216,6 +219,7 @@ export default class App extends React.PureComponent<{}, State> { showEditor, verticalMode, showPreview, + previewWindow, isInProjectView, runOnClick, } = this.state; @@ -239,6 +243,7 @@ export default class App extends React.PureComponent<{}, State> { void, sandbox: Sandbox, @@ -298,6 +299,7 @@ export default class Content extends React.PureComponent { sandbox, showEditor, showPreview, + previewWindow, currentModule, hideNavigation, isInProjectView, @@ -315,8 +317,11 @@ export default class Content extends React.PureComponent { const sandboxConfig = sandbox.modules.find( x => x.directoryShortid == null && x.title === 'sandbox.config.json' ); + let view = 'browser'; - if (sandboxConfig) { + if (previewWindow) { + view = previewWindow; + } else if (sandboxConfig) { try { view = JSON.parse(sandboxConfig.code || '').view || 'browser'; } catch (e) { From 23f7d7d8d5b3e173d4ef898e3c9833d96841bfd7 Mon Sep 17 00:00:00 2001 From: Ives van Hoorne Date: Thu, 19 Jul 2018 21:52:22 +0100 Subject: [PATCH 5/5] Update 2-embedding.md --- packages/homepage/content/docs/2-embedding.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/homepage/content/docs/2-embedding.md b/packages/homepage/content/docs/2-embedding.md index 92d5bddf05a..7c7df9a8df4 100644 --- a/packages/homepage/content/docs/2-embedding.md +++ b/packages/homepage/content/docs/2-embedding.md @@ -42,7 +42,7 @@ find them here. | `expanddevtools` | Start with the devtools (console) open. | `0`/`1` | `0` | | `runonclick` | Only load the preview when the user says so. | `0`/`1` | `0` | | `view` | Which view to open by default | `editor`/`split`/`preview` | `split`, `preview` for small screens | -| `previewwindow` | Which preView window to open by default | `console`/`tests`/`browser` | `browser` | +| `previewwindow` | Which preview window to open by default | `console`/`tests`/`browser` | `browser` | | `module` | Which module to open by default | path to module (starting with `/`) | entry path | | `initialpath` | Which url to initially load in address bar | string | `/` | | `fontsize` | Font size of editor | number (in px) | `14` |