Skip to content

Commit 94c859f

Browse files
merge
2 parents 1044e8d + ae15fee commit 94c859f

File tree

17 files changed

+120
-50
lines changed

17 files changed

+120
-50
lines changed

packages/app/config/build.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ const staticAssets = [
2929
from: 'packages/app/static',
3030
to: 'static',
3131
},
32+
{
33+
from: isDev
34+
? 'standalone-packages/codesandbox-browserfs/build'
35+
: 'standalone-packages/codesandbox-browserfs/dist',
36+
to: 'static/browserfs6',
37+
},
38+
// For caching purposes
3239
{
3340
from: isDev
3441
? 'standalone-packages/codesandbox-browserfs/build'

packages/app/src/app/components/CodeEditor/Monaco/workers/linter/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Linter from 'eslint/lib/linter';
33
import monkeypatch from './monkeypatch-babel-eslint';
44

55
self.importScripts(
6-
`${process.env.CODESANDBOX_HOST}/static/browserfs5/browserfs.min.js`
6+
`${process.env.CODESANDBOX_HOST}/static/browserfs6/browserfs.min.js`
77
);
88

99
/* eslint-disable global-require */

packages/app/src/app/components/Preview/DevTools/Terminal/Shell/Term.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ import * as fit from 'xterm/lib/addons/fit/fit';
55

66
import ResizeObserver from 'resize-observer-polyfill';
77

8+
import { notificationState } from '@codesandbox/common/lib/utils/notifications';
9+
import { dispatch } from 'codesandbox-api';
10+
import { NotificationStatus } from '@codesandbox/notifications';
811
import getTerminalTheme, { VSTheme } from '../terminal-theme';
912
import { TerminalWithFit } from '../types';
1013

1114
type Props = {
1215
theme: VSTheme;
16+
owned: boolean;
1317
hidden: boolean;
1418
onTerminalInitialized: (term: TerminalWithFit) => void;
1519
};
@@ -35,6 +39,37 @@ export class TerminalComponentNoTheme extends React.PureComponent<Props> {
3539
this.resizeTerminal();
3640
window.addEventListener('resize', this.listenForResize);
3741

42+
let shownNotification = false;
43+
44+
this.term.on('data', () => {
45+
// This is readonly, so let the user know they need to open a new
46+
// terminal
47+
48+
if (!shownNotification) {
49+
if (this.props.owned) {
50+
notificationState.addNotification({
51+
title: 'Terminal Read-Only',
52+
message:
53+
"The main terminal is read-only and runs what's defined in package.json#start, you can create a new terminal to input commands",
54+
status: NotificationStatus.NOTICE,
55+
actions: {
56+
primary: [
57+
{
58+
label: 'Create Terminal',
59+
run: () => {
60+
dispatch({
61+
type: 'codesandbox:create-shell',
62+
});
63+
},
64+
},
65+
],
66+
},
67+
});
68+
}
69+
shownNotification = true;
70+
}
71+
});
72+
3873
this.props.onTerminalInitialized(this.term);
3974
};
4075

packages/app/src/app/components/Preview/DevTools/Terminal/Shell/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TerminalComponent } from './Term';
1010
type Props = {
1111
id: string;
1212
theme: VSTheme;
13+
owned: boolean;
1314
script?: string;
1415
closeShell: () => void;
1516
endShell: () => void;
@@ -107,9 +108,10 @@ class ShellComponent extends React.PureComponent<Props> {
107108
}
108109

109110
render() {
110-
const { hidden, theme } = this.props;
111+
const { hidden, theme, owned } = this.props;
111112
return (
112113
<TerminalComponent
114+
owned={owned}
113115
hidden={hidden}
114116
theme={theme}
115117
onTerminalInitialized={this.initializeTerminal}

packages/app/src/app/components/Preview/DevTools/Terminal/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class DevToolTerminal extends React.Component<
152152
<div style={{ position: 'relative', flex: 'auto' }}>
153153
<TerminalComponent
154154
hidden={hidden || selectedShell !== undefined}
155+
owned={this.props.owned}
155156
theme={theme}
156157
onTerminalInitialized={this.setTerminal}
157158
/>
@@ -161,6 +162,7 @@ class DevToolTerminal extends React.Component<
161162
id={shell.id}
162163
script={shell.script}
163164
ended={shell.ended}
165+
owned={this.props.owned}
164166
hidden={hidden || shell.id !== this.state.selectedShell}
165167
closeShell={() => this.closeShell(shell.id)}
166168
endShell={() => this.endShell(shell.id)}

packages/app/src/app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</script>
4949
<!-- End Google Tag Manager -->
5050
<!-- <script async src="//cdn.headwayapp.co/widget.js"></script> -->
51-
<script src="<%= webpackConfig.output.publicPath %>static/browserfs5/browserfs<%=process.env.NODE_ENV
51+
<script src="<%= webpackConfig.output.publicPath %>static/browserfs6/browserfs<%=process.env.NODE_ENV
5252
=== 'development' ? '' : '.min'%>.js"
5353
type="text/javascript"></script>
5454

packages/app/src/app/overmind/effects/vscode/extensionHostWorker/common/global.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const initializePolyfills = () => {
2020

2121
export const loadBrowserFS = () => {
2222
ctx.importScripts(
23-
`${process.env.CODESANDBOX_HOST}/static/browserfs5/browserfs.js`
23+
`${process.env.CODESANDBOX_HOST}/static/browserfs6/browserfs.min.js`
2424
);
2525
};
2626

packages/app/src/app/pages/Dashboard/Content/SandboxCard/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,15 @@ class SandboxItemComponent extends React.PureComponent<Props, State> {
121121
};
122122

123123
checkScreenshot() {
124-
if (this.props.screenshotOutdated && this.hasScreenshot()) {
125-
// We only request the screenshot if the sandbox card is in view for > 1 second
126-
this.screenshotTimeout = window.setTimeout(() => {
127-
this.requestScreenshot();
128-
}, 1000);
124+
if (this.props.screenshotOutdated) {
125+
if (this.hasScreenshot()) {
126+
// We only request the screenshot if the sandbox card is in view for > 1 second
127+
this.screenshotTimeout = window.setTimeout(() => {
128+
this.requestScreenshot();
129+
}, 1000);
130+
}
131+
} else {
132+
this.setState({ screenshotUrl: this.props.screenshotUrl });
129133
}
130134
}
131135

@@ -266,9 +270,7 @@ class SandboxItemComponent extends React.PureComponent<Props, State> {
266270
action: () => {
267271
if (this.props.collectionTeamId) {
268272
history.push(
269-
`/dashboard/teams/${this.props.collectionTeamId}/sandboxes${
270-
this.props.collectionPath
271-
}`
273+
`/dashboard/teams/${this.props.collectionTeamId}/sandboxes${this.props.collectionPath}`
272274
);
273275
} else {
274276
history.push(`/dashboard/sandboxes${this.props.collectionPath}`);

packages/app/src/embed/components/Content/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ export default class Content extends React.PureComponent<Props, State> {
454454
onToggleProjectView={this.onToggleProjectView}
455455
onResize={this.handleResize}
456456
dragging={this.state.dragging}
457+
showScreenshotOverlay
457458
/>
458459
),
459460
actions: [],

packages/app/src/embed/components/Sidebar/ExternalResources/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
import React from 'react';
22
import { Container, Row } from './elements';
33

4+
function getFontFamily(search) {
5+
const hashes = search.slice(search.indexOf('?') + 1).split('&');
6+
const family = hashes
7+
.find(hash => hash.split('=')[0] === 'family')
8+
.split('=')[1];
9+
10+
return family.split('+').join(' ');
11+
}
12+
413
function getName(resource) {
14+
if (resource.includes('https://fonts.googleapis.com/css')) {
15+
return `${getFontFamily(resource)} (Google Fonts)`;
16+
}
17+
518
if (resource.endsWith('.css') || resource.endsWith('.js')) {
619
const match = resource.match(/.*\/(.*)/);
720
if (match && match[1]) {

0 commit comments

Comments
 (0)