11import './styles.css' ;
22
3- import { listen } from 'codesandbox-api' ;
3+ import { listen , dispatch } from 'codesandbox-api' ;
44import React from 'react' ;
55import PlusIcon from 'react-icons/lib/md/add' ;
66import { withTheme } from 'styled-components' ;
77import uuid from 'uuid' ;
88
9+ import { notificationState } from '@codesandbox/common/lib/utils/notifications' ;
10+ import { NotificationStatus } from '@codesandbox/notifications' ;
911import { Shell } from './Shell' ;
1012import { TerminalComponent } from './Shell/Term' ;
1113import { ShellTabs } from './ShellTabs' ;
@@ -36,6 +38,7 @@ class DevToolTerminal extends React.Component<
3638 listener : ( ) => void ;
3739 node ?: HTMLElement ;
3840 timeout ?: number ;
41+ shownReadonlyNotification : boolean = false ;
3942
4043 componentDidMount ( ) {
4144 createShell = this . createShell ;
@@ -48,6 +51,32 @@ class DevToolTerminal extends React.Component<
4851
4952 this . messageQueue . forEach ( this . handleMessage ) ;
5053 this . messageQueue . length = 0 ;
54+
55+ terminal . on ( 'data' , ( ) => {
56+ if ( this . props . owned ) {
57+ if ( ! this . shownReadonlyNotification ) {
58+ notificationState . addNotification ( {
59+ title : 'Terminal Read-Only' ,
60+ message :
61+ "The main terminal is read-only and runs what's defined in package.json#start, you can create a new terminal to input commands" ,
62+ status : NotificationStatus . NOTICE ,
63+ actions : {
64+ primary : [
65+ {
66+ label : 'Create Terminal' ,
67+ run : ( ) => {
68+ dispatch ( {
69+ type : 'codesandbox:create-shell' ,
70+ } ) ;
71+ } ,
72+ } ,
73+ ] ,
74+ } ,
75+ } ) ;
76+ }
77+ this . shownReadonlyNotification = true ;
78+ }
79+ } ) ;
5180 } ;
5281
5382 handleMessage = ( data : any ) => {
0 commit comments