File tree Expand file tree Collapse file tree 10 files changed +85
-85
lines changed
overmind/namespaces/editor
pages/Sandbox/Editor/Workspace
screens/Explorer/Dependencies Expand file tree Collapse file tree 10 files changed +85
-85
lines changed Original file line number Diff line number Diff line change @@ -51,15 +51,15 @@ export const addNpmDependency: AsyncAction<{
51
51
}
52
52
) ;
53
53
54
- export const npmDependencyRemoved : AsyncAction < {
55
- name : string ;
56
- } > = withOwnedSandbox ( async ( { effects, actions } , { name } ) => {
57
- effects . analytics . track ( 'Remove NPM Dependency' ) ;
54
+ export const npmDependencyRemoved : AsyncAction < string > = withOwnedSandbox (
55
+ async ( { actions, effects } , name ) => {
56
+ effects . analytics . track ( 'Remove NPM Dependency' ) ;
58
57
59
- await actions . editor . internal . removeNpmDependencyFromPackageJson ( name ) ;
58
+ await actions . editor . internal . removeNpmDependencyFromPackageJson ( name ) ;
60
59
61
- effects . preview . executeCodeImmediately ( ) ;
62
- } ) ;
60
+ effects . preview . executeCodeImmediately ( ) ;
61
+ }
62
+ ) ;
63
63
64
64
export const sandboxChanged : AsyncAction < { id : string } > = withLoadApp < {
65
65
id : string ;
Original file line number Diff line number Diff line change @@ -3,3 +3,7 @@ import styled from 'styled-components';
3
3
export const ButtonContainer = styled . div `
4
4
margin: 0.5rem 1rem;
5
5
` ;
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';
3
3
export const ButtonContainer = styled . div `
4
4
margin: 0.5rem 1rem;
5
5
` ;
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';
3
3
4
4
import { useOvermind } from 'app/overmind' ;
5
5
6
- import { ButtonContainer } from './elements' ;
6
+ import { ButtonContainer , Container } from './elements' ;
7
7
8
8
export const AddVersion : FunctionComponent = ( { children } ) => {
9
9
const {
10
10
actions : { modalOpened } ,
11
11
} = useOvermind ( ) ;
12
12
13
13
return (
14
- < div style = { { position : 'relative' } } >
14
+ < Container >
15
15
< ButtonContainer >
16
16
< Button
17
17
block
@@ -21,6 +21,6 @@ export const AddVersion: FunctionComponent = ({ children }) => {
21
21
{ children }
22
22
</ Button >
23
23
</ ButtonContainer >
24
- </ div >
24
+ </ Container >
25
25
) ;
26
26
} ;
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ import CrossIcon from 'react-icons/lib/md/clear';
3
3
4
4
import { useOvermind } from 'app/overmind' ;
5
5
6
- import { EntryContainer , IconArea , Icon } from '../../ elements' ;
6
+ import { EntryContainer , IconArea , Icon } from '../elements' ;
7
7
8
- import { Link } from '.. /elements' ;
8
+ import { Link } from './elements' ;
9
9
10
10
const getNormalizedUrl = ( url : string ) => `${ url . replace ( / \/ $ / g, '' ) } /` ;
11
11
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ import { VersionEntry } from './VersionEntry';
15
15
export const Dependencies : FunctionComponent = ( ) => {
16
16
const {
17
17
actions : {
18
- workspace : { externalResourceAdded } ,
19
18
editor : { addNpmDependency, npmDependencyRemoved } ,
20
19
} ,
21
20
state : {
@@ -56,7 +55,7 @@ export const Dependencies: FunctionComponent = () => {
56
55
dependency = { dependency }
57
56
key = { dependency }
58
57
onRefresh = { ( name , version ) => addNpmDependency ( { name, version } ) }
59
- onRemove = { name => npmDependencyRemoved ( { name } ) }
58
+ onRemove = { name => npmDependencyRemoved ( name ) }
60
59
/>
61
60
) ) }
62
61
@@ -72,7 +71,7 @@ export const Dependencies: FunctionComponent = () => {
72
71
dependency={dependency}
73
72
key={dependency}
74
73
onRefresh={(name, version) => addNpmDependency({ name, version })}
75
- onRemove={npmDependencyRemoved}
74
+ onRemove={name => npmDependencyRemoved(name) }
76
75
/>
77
76
))} */ }
78
77
@@ -83,9 +82,7 @@ export const Dependencies: FunctionComponent = () => {
83
82
< div >
84
83
< WorkspaceSubtitle > External Resources</ WorkspaceSubtitle >
85
84
86
- < AddResource
87
- addResource = { resource => externalResourceAdded ( resource ) }
88
- />
85
+ < AddResource />
89
86
90
87
{ otherResources . map ( resource => (
91
88
< ExternalResource key = { resource } resource = { resource } />
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export const Dependencies: FunctionComponent = () => {
52
52
dependency = { dependency }
53
53
key = { dependency }
54
54
onRefresh = { ( name , version ) => addNpmDependency ( { name, version } ) }
55
- onRemove = { name => npmDependencyRemoved ( { name } ) }
55
+ onRemove = { npmDependencyRemoved }
56
56
/>
57
57
) ) }
58
58
</ List >
Original file line number Diff line number Diff line change @@ -443,18 +443,10 @@ export type PackageJSON = {
443
443
keywords ?: string [ ] ;
444
444
main ?: string ;
445
445
module ?: string ;
446
- scripts ?: {
447
- [ command : string ] : string ;
448
- } ;
449
- dependencies ?: {
450
- [ dep : string ] : string ;
451
- } ;
452
- devDependencies ?: {
453
- [ dep : string ] : string ;
454
- } ;
455
- jest ?: {
456
- setupFilesAfterEnv ?: string [ ] ;
457
- } ;
446
+ scripts ?: { [ command : string ] : string ; } ;
447
+ dependencies ?: { [ dependency : string ] : string ; } ;
448
+ devDependencies ?: { [ dependency : string ] : string ; } ;
449
+ jest ?: { setupFilesAfterEnv ?: string [ ] ; } ;
458
450
resolutions ?: { [ dependency : string ] : string } ;
459
451
} ;
460
452
You can’t perform that action at this time.
0 commit comments