Skip to content

Commit c29d615

Browse files
committed
Refactored editor workspace files
1 parent 729d375 commit c29d615

File tree

4 files changed

+67
-86
lines changed

4 files changed

+67
-86
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/index.js

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { getModulePath } from '@codesandbox/common/lib/sandbox/modules';
2+
import { useOvermind } from 'app/overmind';
3+
import React from 'react';
4+
5+
import EditIcons from './DirectoryEntry/Entry/EditIcons';
6+
import DirectoryEntry from './DirectoryEntry/index';
7+
8+
interface IFilesProps {
9+
setEditActions: React.Dispatch<any>;
10+
}
11+
12+
export const Files: React.FC<IFilesProps> = ({ setEditActions }) => {
13+
const {
14+
state: {
15+
editor: { currentSandbox: sandbox },
16+
isLoggedIn,
17+
},
18+
actions: {
19+
editor: {
20+
createZipClicked,
21+
}
22+
},
23+
} = useOvermind();
24+
25+
const _getModulePath = moduleId => {
26+
try {
27+
return getModulePath(sandbox.modules, sandbox.directories, moduleId);
28+
} catch (e) {
29+
return '';
30+
}
31+
};
32+
33+
return (
34+
<DirectoryEntry
35+
root
36+
getModulePath={_getModulePath}
37+
title={sandbox.title || 'Project'}
38+
initializeProperties={({
39+
onCreateModuleClick,
40+
onCreateDirectoryClick,
41+
onUploadFileClick,
42+
}) => {
43+
if (setEditActions) {
44+
setEditActions(
45+
<EditIcons
46+
hovering
47+
forceShow={window.__isTouch}
48+
onCreateFile={onCreateModuleClick}
49+
onCreateDirectory={onCreateDirectoryClick}
50+
onDownload={createZipClicked}
51+
onUploadFile={
52+
isLoggedIn && sandbox.privacy === 0
53+
? onUploadFileClick
54+
: undefined
55+
}
56+
/>
57+
);
58+
}
59+
}}
60+
depth={-1}
61+
id={null}
62+
shortid={null}
63+
/>
64+
);
65+
};

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Files/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react';
22

33
import { useOvermind } from 'app/overmind';
4-
import Files from '../../Files';
4+
import { Files } from '../../Files';
55
import { Dependencies } from '../../Dependencies';
66
import { WorkspaceItem } from '../../WorkspaceItem';
77
import { ItemTitle } from '../../elements';

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/NotOwnedSandboxInfo/NotOwnedSandboxInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react';
22
import { useOvermind } from 'app/overmind';
33
import { Dependencies } from '../../Dependencies';
4-
import Files from '../../Files';
4+
import { Files } from '../../Files';
55
import { Project } from '../../Project';
66
import { WorkspaceItem } from '../../WorkspaceItem';
77

0 commit comments

Comments
 (0)