File tree Expand file tree Collapse file tree 8 files changed +82
-82
lines changed
overmind/namespaces/editor
pages/Sandbox/Editor/Workspace/Dependencies Expand file tree Collapse file tree 8 files changed +82
-82
lines changed Original file line number Diff line number Diff line change @@ -50,15 +50,15 @@ export const addNpmDependency: AsyncAction<{
5050 }
5151) ;
5252
53- export const npmDependencyRemoved : AsyncAction < {
54- name : string ;
55- } > = withOwnedSandbox ( async ( { effects, actions } , { name } ) => {
56- effects . analytics . track ( 'Remove NPM Dependency' ) ;
53+ export const npmDependencyRemoved : AsyncAction < string > = withOwnedSandbox (
54+ async ( { actions, effects } , name ) => {
55+ effects . analytics . track ( 'Remove NPM Dependency' ) ;
5756
58- await actions . editor . internal . removeNpmDependencyFromPackageJson ( name ) ;
57+ await actions . editor . internal . removeNpmDependencyFromPackageJson ( name ) ;
5958
60- effects . preview . executeCodeImmediately ( ) ;
61- } ) ;
59+ effects . preview . executeCodeImmediately ( ) ;
60+ }
61+ ) ;
6262
6363export const sandboxChanged : AsyncAction < { id : string } > = withLoadApp < {
6464 id : string ;
Original file line number Diff line number Diff line change @@ -3,3 +3,7 @@ import styled from 'styled-components';
33export const ButtonContainer = styled . div `
44 margin: 0.5rem 1rem;
55` ;
6+
7+ export const Container = styled . div `
8+ position: relative;
9+ ` ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { Button } from '@codesandbox/common/lib/components/Button' ;
2+ import { ENTER } from '@codesandbox/common/lib/utils/keycodes' ;
3+ import React , {
4+ ChangeEvent ,
5+ FunctionComponent ,
6+ KeyboardEvent ,
7+ useState ,
8+ } from 'react' ;
9+
10+ import { useOvermind } from 'app/overmind' ;
11+
12+ import { WorkspaceInputContainer } from '../../elements' ;
13+
14+ import { ButtonContainer , Container } from './elements' ;
15+
16+ export const AddResource : FunctionComponent = ( ) => {
17+ const {
18+ actions : {
19+ workspace : { externalResourceAdded } ,
20+ } ,
21+ } = useOvermind ( ) ;
22+ const [ name , setName ] = useState ( '' ) ;
23+
24+ const addResource = async ( ) => {
25+ if ( name ) {
26+ await externalResourceAdded ( name . trim ( ) ) ;
27+
28+ setName ( '' ) ;
29+ }
30+ } ;
31+ const changeName = ( { target : { value } } : ChangeEvent < HTMLInputElement > ) =>
32+ setName ( value ) ;
33+ const handleKeyUp = ( { keyCode } : KeyboardEvent < HTMLInputElement > ) => {
34+ if ( keyCode === ENTER ) {
35+ addResource ( ) ;
36+ }
37+ } ;
38+
39+ return (
40+ < Container >
41+ < WorkspaceInputContainer >
42+ < input
43+ onChange = { changeName }
44+ onKeyUp = { handleKeyUp }
45+ placeholder = "https://cdn.com/bootstrap.css"
46+ value = { name }
47+ />
48+ </ WorkspaceInputContainer >
49+
50+ < ButtonContainer >
51+ < Button block disabled = { name === '' } onClick = { addResource } small >
52+ Add Resource
53+ </ Button >
54+ </ ButtonContainer >
55+ </ Container >
56+ ) ;
57+ } ;
Original file line number Diff line number Diff line change @@ -3,3 +3,7 @@ import styled from 'styled-components';
33export const ButtonContainer = styled . div `
44 margin: 0.5rem 1rem;
55` ;
6+
7+ export const Container = styled . div `
8+ position: relative;
9+ ` ;
Original file line number Diff line number Diff line change @@ -3,15 +3,15 @@ import React, { FunctionComponent } from 'react';
33
44import { useOvermind } from 'app/overmind' ;
55
6- import { ButtonContainer } from './elements' ;
6+ import { ButtonContainer , Container } from './elements' ;
77
88export const AddVersion : FunctionComponent = ( { children } ) => {
99 const {
1010 actions : { modalOpened } ,
1111 } = useOvermind ( ) ;
1212
1313 return (
14- < div style = { { position : 'relative' } } >
14+ < Container >
1515 < ButtonContainer >
1616 < Button
1717 block
@@ -21,6 +21,6 @@ export const AddVersion: FunctionComponent = ({ children }) => {
2121 { children }
2222 </ Button >
2323 </ ButtonContainer >
24- </ div >
24+ </ Container >
2525 ) ;
2626} ;
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ import { VersionEntry } from './VersionEntry';
1515export const Dependencies : FunctionComponent = ( ) => {
1616 const {
1717 actions : {
18- workspace : { externalResourceAdded } ,
1918 editor : { addNpmDependency, npmDependencyRemoved } ,
2019 } ,
2120 state : {
@@ -56,7 +55,7 @@ export const Dependencies: FunctionComponent = () => {
5655 dependency = { dependency }
5756 key = { dependency }
5857 onRefresh = { ( name , version ) => addNpmDependency ( { name, version } ) }
59- onRemove = { name => npmDependencyRemoved ( { name } ) }
58+ onRemove = { name => npmDependencyRemoved ( name ) }
6059 />
6160 ) ) }
6261
@@ -72,7 +71,7 @@ export const Dependencies: FunctionComponent = () => {
7271 dependency={dependency}
7372 key={dependency}
7473 onRefresh={(name, version) => addNpmDependency({ name, version })}
75- onRemove={npmDependencyRemoved}
74+ onRemove={name => npmDependencyRemoved(name) }
7675 />
7776 ))} */ }
7877
@@ -83,9 +82,7 @@ export const Dependencies: FunctionComponent = () => {
8382 < div >
8483 < WorkspaceSubtitle > External Resources</ WorkspaceSubtitle >
8584
86- < AddResource
87- addResource = { resource => externalResourceAdded ( resource ) }
88- />
85+ < AddResource />
8986
9087 { otherResources . map ( resource => (
9188 < ExternalResource key = { resource } resource = { resource } />
Original file line number Diff line number Diff line change @@ -435,18 +435,10 @@ export type PackageJSON = {
435435 keywords ?: string [ ] ;
436436 main ?: string ;
437437 module ?: string ;
438- scripts ?: {
439- [ command : string ] : string ;
440- } ;
441- dependencies ?: {
442- [ dep : string ] : string ;
443- } ;
444- devDependencies ?: {
445- [ dep : string ] : string ;
446- } ;
447- jest ?: {
448- setupFilesAfterEnv ?: string [ ] ;
449- } ;
438+ scripts ?: { [ command : string ] : string ; } ;
439+ dependencies ?: { [ dependency : string ] : string ; } ;
440+ devDependencies ?: { [ dependency : string ] : string ; } ;
441+ jest ?: { setupFilesAfterEnv ?: string [ ] ; } ;
450442 resolutions ?: { [ dependency : string ] : string } ;
451443} ;
452444
You can’t perform that action at this time.
0 commit comments