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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from './elements';

type Props = {
children: React.ReactChildren;
children: React.ReactNode;
title: string;
keepState?: boolean;
disabled?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as React from 'react';
import { inject, observer } from 'mobx-react';

import VERSION from '@codesandbox/common/lib/version';
import { observer } from 'mobx-react-lite';
import * as React from 'react';
// Fix css prop types in styled-components (see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31245#issuecomment-463640878)
import {} from 'styled-components/cssprop'; // eslint-disable-line

import getWorkspaceItems from 'app/store/modules/workspace/items';
import SocialInfo from 'app/components/SocialInfo';
import { useStore } from 'app/store';
import getWorkspaceItems from 'app/store/modules/workspace/items';

import Files from './items/Files';
import ProjectInfo from './items/ProjectInfo';
Expand All @@ -16,11 +18,11 @@ import Deployment from './items/Deployment';
import ConfigurationFiles from './items/ConfigurationFiles';
import NotOwnedSandboxInfo from './items/NotOwnedSandboxInfo';

import { ConnectionNotice } from './ConnectionNotice';
import Advertisement from './Advertisement';
import WorkspaceItem from './WorkspaceItem';
import Chat from './Chat';
import { ConnectionNotice } from './ConnectionNotice';
import { SSEDownNotice } from './SSEDownNotice';
import WorkspaceItem from './WorkspaceItem';

import {
Container,
Expand All @@ -41,45 +43,62 @@ const idToItem = {
more: More,
};

function Workspace({ store }) {
const sandbox = store.editor.currentSandbox;
const preferences = store.preferences;

const currentItem = store.workspace.openedWorkspaceItem;
const Workspace = () => {
const store = useStore();
const {
editor: {
currentSandbox: { owned },
},
isPatron,
live: {
isLive,
roomInfo: { chatEnabled },
},
preferences: {
settings: { zenMode },
},
workspace: { openedWorkspaceItem: currentItem },
} = store;

if (!currentItem) {
return null;
}

const Component = idToItem[currentItem];
const item = getWorkspaceItems(store).find(({ id }) => id === currentItem);

const item = getWorkspaceItems(store).find(i => i.id === currentItem);
return (
<Container>
{item && !item.hasCustomHeader && <ItemTitle>{item.name}</ItemTitle>}
<div style={{ flex: 1, overflowY: 'auto' }}>
<Component />
</div>
{store.live.isLive && store.live.roomInfo.chatEnabled && (

{isLive && chatEnabled && (
<WorkspaceItem defaultOpen title="Chat">
<Chat />
</WorkspaceItem>
)}
{!preferences.settings.zenMode && (

{!zenMode && (
<div>
{!store.isPatron && !sandbox.owned && <Advertisement />}
{!(isPatron || owned) && <Advertisement />}

<ContactContainer>
<SocialInfo style={{ display: 'inline-block' }} />

<VersionContainer className="codesandbox-version">
{VERSION}
</VersionContainer>
</ContactContainer>

<SSEDownNotice />

<ConnectionNotice />
</div>
)}
</Container>
);
}
};

export default inject('signals', 'store')(observer(Workspace));
export default observer(Workspace);
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useSignals, useStore } from 'app/store';
import { Error } from './elements';

type Props = {
style: React.CSSProperties;
style?: React.CSSProperties;
};
export const CreateRepo = observer(({ style }: Props) => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const Git = observer(() => {
}: React.ChangeEvent<HTMLInputElement>) => subjectChanged({ subject: value });
const changeDescription = ({
target: { value },
}: React.ChangeEvent<HTMLInputElement>) =>
}: React.ChangeEvent<HTMLTextAreaElement>) =>
descriptionChanged({ description: value });

const modulesNotSaved = !isAllModulesSynced;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const GitHub = observer(() => {
)
) : (
<>
<Description margin={1} top={0}>
<Description>
You can create commits and open pull requests if you add GitHub to your
integrations.
</Description>
Expand Down
31 changes: 22 additions & 9 deletions packages/app/src/app/pages/common/GithubIntegration/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
import { observer } from 'mobx-react-lite';
import React from 'react';
import { inject, observer } from 'mobx-react';
import GithubLogo from 'react-icons/lib/go/mark-github';

import Integration from 'app/components/Integration';
import { useSignals, useStore } from 'app/store';

type Props = {
small?: boolean,
};
const GithubIntegration = ({ small = false }: Props) => {
const { signInGithubClicked, signOutGithubIntegration } = useSignals();
const {
isLoadingGithub,
signOutGithubIntegration: {
integrations: { github },
},
} = useStore();

function GithubIntegration({ store, signals, small }) {
return (
<Integration
name="GitHub"
color="#4078c0"
description={small ? 'Commits & PRs' : 'Committing & Pull Requests'}
Icon={GithubLogo}
loading={isLoadingGithub}
name="GitHub"
signIn={() => signInGithubClicked({ useExtraScopes: true })}
signOut={signOutGithubIntegration}
small={small}
userInfo={store.user.integrations.github}
signOut={() => signals.signOutGithubIntegration()}
signIn={() => signals.signInGithubClicked({ useExtraScopes: true })}
loading={store.isLoadingGithub}
userInfo={github}
/>
);
}
};

export default inject('store', 'signals')(observer(GithubIntegration));
export default observer(GithubIntegration);