Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/app/src/app/overmind/namespaces/editor/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export const addNpmDependency: AsyncAction<{
}
);

export const npmDependencyRemoved: AsyncAction<{
name: string;
}> = withOwnedSandbox(async ({ effects, actions }, { name }) => {
effects.analytics.track('Remove NPM Dependency');
export const npmDependencyRemoved: AsyncAction<string> = withOwnedSandbox(
async ({ actions, effects }, name) => {
effects.analytics.track('Remove NPM Dependency');

await actions.editor.internal.removeNpmDependencyFromPackageJson(name);
await actions.editor.internal.removeNpmDependencyFromPackageJson(name);

effects.preview.executeCodeImmediately();
});
effects.preview.executeCodeImmediately();
}
);

export const sandboxChanged: AsyncAction<{ id: string }> = withLoadApp<{
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import styled from 'styled-components';
export const ButtonContainer = styled.div`
margin: 0.5rem 1rem;
`;

export const Container = styled.div`
position: relative;
`;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Button } from '@codesandbox/common/lib/components/Button';
import { ENTER } from '@codesandbox/common/lib/utils/keycodes';
import React, {
ChangeEvent,
FunctionComponent,
KeyboardEvent,
useState,
} from 'react';

import { useOvermind } from 'app/overmind';

import { WorkspaceInputContainer } from '../../elements';

import { ButtonContainer, Container } from './elements';

export const AddResource: FunctionComponent = () => {
const {
actions: {
workspace: { externalResourceAdded },
},
} = useOvermind();
const [name, setName] = useState('');

const addResource = async () => {
if (name) {
await externalResourceAdded(name.trim());

setName('');
}
};
const changeName = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
setName(value);
const handleKeyUp = ({ keyCode }: KeyboardEvent<HTMLInputElement>) => {
if (keyCode === ENTER) {
addResource();
}
};

return (
<Container>
<WorkspaceInputContainer>
<input
onChange={changeName}
onKeyUp={handleKeyUp}
placeholder="https://cdn.com/bootstrap.css"
value={name}
/>
</WorkspaceInputContainer>

<ButtonContainer>
<Button block disabled={name === ''} onClick={addResource} small>
Add Resource
</Button>
</ButtonContainer>
</Container>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import styled from 'styled-components';
export const ButtonContainer = styled.div`
margin: 0.5rem 1rem;
`;

export const Container = styled.div`
position: relative;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import React, { FunctionComponent } from 'react';

import { useOvermind } from 'app/overmind';

import { ButtonContainer } from './elements';
import { ButtonContainer, Container } from './elements';

export const AddVersion: FunctionComponent = ({ children }) => {
const {
actions: { modalOpened },
} = useOvermind();

return (
<div style={{ position: 'relative' }}>
<Container>
<ButtonContainer>
<Button
block
Expand All @@ -21,6 +21,6 @@ export const AddVersion: FunctionComponent = ({ children }) => {
{children}
</Button>
</ButtonContainer>
</div>
</Container>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import CrossIcon from 'react-icons/lib/md/clear';

import { useOvermind } from 'app/overmind';

import { EntryContainer, IconArea, Icon } from '../../elements';
import { EntryContainer, IconArea, Icon } from '../elements';

import { Link } from '../elements';
import { Link } from './elements';

const getNormalizedUrl = (url: string) => `${url.replace(/\/$/g, '')}/`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { VersionEntry } from './VersionEntry';
export const Dependencies: FunctionComponent = () => {
const {
actions: {
workspace: { externalResourceAdded },
editor: { addNpmDependency, npmDependencyRemoved },
},
state: {
Expand Down Expand Up @@ -56,7 +55,7 @@ export const Dependencies: FunctionComponent = () => {
dependency={dependency}
key={dependency}
onRefresh={(name, version) => addNpmDependency({ name, version })}
onRemove={name => npmDependencyRemoved({ name })}
onRemove={name => npmDependencyRemoved(name)}
/>
))}

Expand All @@ -72,7 +71,7 @@ export const Dependencies: FunctionComponent = () => {
dependency={dependency}
key={dependency}
onRefresh={(name, version) => addNpmDependency({ name, version })}
onRemove={npmDependencyRemoved}
onRemove={name => npmDependencyRemoved(name)}
/>
))} */}

Expand All @@ -83,9 +82,7 @@ export const Dependencies: FunctionComponent = () => {
<div>
<WorkspaceSubtitle>External Resources</WorkspaceSubtitle>

<AddResource
addResource={resource => externalResourceAdded(resource)}
/>
<AddResource />

{otherResources.map(resource => (
<ExternalResource key={resource} resource={resource} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Dependencies: FunctionComponent = () => {
dependency={dependency}
key={dependency}
onRefresh={(name, version) => addNpmDependency({ name, version })}
onRemove={name => npmDependencyRemoved({ name })}
onRemove={npmDependencyRemoved}
/>
))}
</List>
Expand Down
16 changes: 4 additions & 12 deletions packages/common/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,10 @@ export type PackageJSON = {
keywords?: string[];
main?: string;
module?: string;
scripts?: {
[command: string]: string;
};
dependencies?: {
[dep: string]: string;
};
devDependencies?: {
[dep: string]: string;
};
jest?: {
setupFilesAfterEnv?: string[];
};
scripts?: { [command: string]: string; };
dependencies?: { [dependency: string]: string; };
devDependencies?: { [dependency: string]: string; };
jest?: { setupFilesAfterEnv?: string[]; };
resolutions?: { [dependency: string]: string };
};

Expand Down