Skip to content

Commit

Permalink
Merge branch 'master' of github.com:CompuIves/codesandbox-client
Browse files Browse the repository at this point in the history
  • Loading branch information
SaraVieira committed Mar 26, 2019
2 parents d07516d + 33a33af commit 35760a3
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Down from 'react-icons/lib/fa/angle-down';
import Up from 'react-icons/lib/fa/angle-up';
import Notice from 'common/lib/components/Notice';
import Notice from '@codesandbox/common/lib/components/Notice';
import DetailInfo from './DetailInfo';
import { Container, IntegrationBlock, Name } from './elements';

Expand Down Expand Up @@ -40,7 +40,6 @@ const Integration = ({
width: 1.5rem;
height: auto;
`}
onClick={toggle}
/>
) : (
<Down
Expand All @@ -50,7 +49,6 @@ const Integration = ({
width: 1.5rem;
height: auto;
`}
onClick={toggle}
/>
)}
</IntegrationBlock>
Expand Down
23 changes: 11 additions & 12 deletions packages/app/src/app/pages/Sandbox/Editor/Header/Action/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import MoreInfoIcon from 'react-icons/lib/md/arrow-drop-down';
import Tooltip from '@codesandbox/common/lib/components/Tooltip';

import {
Title,
Expand Down Expand Up @@ -52,18 +53,16 @@ function ActionComponent({
}: Props) {
if (!href && (placeholder || tooltip)) {
return (
<ActionTooltip
content={placeholder || tooltip}
hideOnClick={false}
{...props}
>
<IconContainer onClick={onClick} {...iconContainerProps}>
<Icon {...iconProps} />
{title !== undefined && <Title>{title}</Title>}
{moreInfo && <MoreInfoIcon style={{ fontSize: '1.1rem' }} />}
</IconContainer>
{children}
</ActionTooltip>
<Action {...props}>
<Tooltip content={placeholder || tooltip} hideOnClick={false}>
<IconContainer onClick={onClick} {...iconContainerProps}>
<Icon {...iconProps} />
{title !== undefined && <Title>{title}</Title>}
{moreInfo && <MoreInfoIcon style={{ fontSize: '1.1rem' }} />}
</IconContainer>
{children}
</Tooltip>
</Action>
);
}
if (onClick) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import LinkIcon from 'react-icons/lib/fa/external-link';
import Cogs from 'react-icons/lib/fa/cogs';
import NetlifyLogo from 'app/components/NetlifyLogo';
import DeploymentIntegration from 'app/components/DeploymentIntegration';
import getTemplate from 'common/lib/templates';
import { Button } from 'common/lib/components/Button';
import getTemplate from '@codesandbox/common/lib/templates';
import { Button } from '@codesandbox/common/lib/components/Button';
import { WorkspaceInputContainer, WorkspaceSubtitle } from '../../elements';
import {
Deploys,
Expand Down Expand Up @@ -86,7 +86,7 @@ class NetlifyDeployment extends Component {
>
{deployment.building ? (
<>
<Cogs /> Building
<Cogs /> Building...
</>
) : (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ export const List = styled.ul`
padding: 1.3em;
list-style: none;
font-family: 'dm';
background: #1b1d1f;
background: ${props => props.theme.background4};
max-height: 400px;
overflow: auto;
margin-bottom: 1.3em;
margin: 1.3em 0;
word-break: break-word;
border-radius: 4px;
`;

export const Item = styled.li`
Expand Down
6 changes: 4 additions & 2 deletions packages/app/src/app/pages/common/Modals/NetlifyLogs/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';

import { Button } from 'common/lib/components/Button';
import { Button } from '@codesandbox/common/lib/components/Button';
import { Container } from '../LiveSessionEnded/elements';
import { Heading, Explanation } from '../elements';

Expand Down Expand Up @@ -35,7 +35,9 @@ class NetlifyLogs extends Component {
Builds typically take a minute or two to complete
</Explanation>
<List>{this.state.logs.map(log => <Item key={log}>{log}</Item>)}</List>
<Button onClick={() => signals.modalClosed()}>Close</Button>
<Button small onClick={() => signals.modalClosed()}>
Close
</Button>
</Container>
);
}
Expand Down
6 changes: 4 additions & 2 deletions packages/app/src/sandbox/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import parseConfigurations from '@codesandbox/common/lib/templates/configuration
import initializeErrorTransformers from 'sandbox-hooks/errors/transformers';
import { inject, unmount } from 'sandbox-hooks/react-error-overlay/overlay';
import { isBabel7 } from '@codesandbox/common/lib/utils/is-babel-7';
import getDefinition, { TemplateType } from '@codesandbox/common/lib/templates/index';
import getDefinition, {
TemplateType,
} from '@codesandbox/common/lib/templates/index';

import getPreset from './eval';
import Manager, { Manifest } from './eval/manager';
Expand Down Expand Up @@ -647,7 +649,7 @@ async function compile({
manager.clearCache();

if (firstLoad && changedModuleCount === 0) {
deleteAPICache(manager.id);
await deleteAPICache(manager.id);
}
}

Expand Down
8 changes: 6 additions & 2 deletions packages/app/src/sandbox/eval/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function shouldSaveOnlineCache(firstRun: boolean, changes: number) {
return false;
}

export function clearIndexedDBCache() {
return localforage.clear();
}

export async function saveCache(
sandboxId: string,
managerModuleToTranspile: any,
Expand All @@ -64,7 +68,7 @@ export async function saveCache(
debug(
'Saving cache of ' +
(JSON.stringify(managerState).length / 1024).toFixed(2) +
'kb to localStorage'
'kb to indexedDB'
);
}
localforage.setItem(manager.id, managerState);
Expand Down Expand Up @@ -111,7 +115,7 @@ export async function saveCache(
return Promise.resolve(false);
}

export function deleteAPICache(sandboxId: string) {
export function deleteAPICache(sandboxId: string): Promise<any> {
if (APICacheUsed) {
debug('Deleting cache of API');
return window
Expand Down
7 changes: 3 additions & 4 deletions packages/app/src/sandbox/eval/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { flattenDeep, uniq, values } from 'lodash-es';
import { Protocol } from 'codesandbox-api';
import resolve from 'browser-resolve';
import localforage from 'localforage';

import * as pathUtils from '@codesandbox/common/lib/utils/path';
import _debug from '@codesandbox/common/lib/utils/debug';
Expand All @@ -24,7 +23,7 @@ import TestRunner from './tests/jest-lite';
import dependenciesToQuery from '../npm/dependencies-to-query';
import { packageFilter } from './utils/resolve-utils';

import { ignoreNextCache, deleteAPICache } from './cache';
import { ignoreNextCache, deleteAPICache, clearIndexedDBCache } from './cache';
import { shouldTranspile } from './transpilers/babel/check';
import { getGlobal } from '@codesandbox/common/lib/utils/global';
import { ParsedConfigurationFiles } from '@codesandbox/common/lib/templates/template';
Expand Down Expand Up @@ -1165,12 +1164,12 @@ export default class Manager {

deleteAPICache() {
ignoreNextCache();
deleteAPICache(this.id);
return deleteAPICache(this.id);
}

clearCache() {
try {
localforage.clear();
clearIndexedDBCache();
} catch (ex) {
if (process.env.NODE_ENV === 'development') {
console.error(ex);
Expand Down
8 changes: 5 additions & 3 deletions packages/app/src/sandbox/eval/transpiled-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,10 +789,12 @@ export default class TranspiledModule {
// We're in a reload loop! Ignore all caches!

manager.clearCache();
manager.deleteAPICache();
manager.deleteAPICache().then(() => {
document.location.reload();
});
} else {
document.location.reload();
}

location.reload();
return {};
}
} else if (
Expand Down
5 changes: 2 additions & 3 deletions packages/common/src/components/Preview/Navigator/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import React from 'react';

import LeftIcon from 'react-icons/lib/fa/angle-left';
Expand Down Expand Up @@ -82,7 +81,7 @@ function Navigator({
<Tooltip
delay={0}
content={isProjectView ? 'Project View' : 'Current Module View'}
position="left"
placement="left"
>
<Switch
offMode
Expand All @@ -98,4 +97,4 @@ function Navigator({
);
}

export default Navigator
export default Navigator;
2 changes: 1 addition & 1 deletion packages/common/src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const GlobalStyle = createGlobalStyle`
const Tooltip = ({ children, style = {}, ...props }) => (
<React.Fragment>
<GlobalStyle />
<Tippy {...props}>
<Tippy delay={[500, 0]} {...props}>
<span
style={{
...style,
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23867,11 +23867,6 @@ typescript@^3.3.1:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.1.tgz#6de14e1db4b8a006ac535e482c8ba018c55f750b"
integrity sha512-cTmIDFW7O0IHbn1DPYjkiebHxwtCMU+eTy30ZtJNBPF9j2O1ITu5XH2YnBeVRKWHqF+3JQwWJv0Q0aUgX8W7IA==

typescript@^3.3.4000:
version "3.3.4000"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.4000.tgz#76b0f89cfdbf97827e1112d64f283f1151d6adf0"
integrity sha512-jjOcCZvpkl2+z7JFn0yBOoLQyLoIkNZAs/fYJkUG6VKy6zLPHJGfQJYFHzibB6GJaF/8QrcECtlQ5cpvRHSMEA==

typography-breakpoint-constants@^0.15.10:
version "0.15.10"
resolved "https://registry.yarnpkg.com/typography-breakpoint-constants/-/typography-breakpoint-constants-0.15.10.tgz#bd5308dd57250e7f28a8c6e1c0e668ddf1178c5c"
Expand Down

0 comments on commit 35760a3

Please sign in to comment.