-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(explorer): .wapp files are now folders
- Loading branch information
1 parent
30dbd4a
commit 9a58b5c
Showing
8 changed files
with
131 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,58 @@ | ||
import * as React from 'react'; | ||
import Dirent from 'memfs/lib/Dirent'; | ||
import FolderIcon from '@material-ui/icons/Folder'; | ||
import { getFileExtension, readFileAsync } from '../../../../services/FileSystemService'; | ||
import InstanceBag from '../../../../InstanceBag'; | ||
import { WasmFs } from '@wasmer/wasmfs'; | ||
import { getWappInformation } from '../../../../services/WappService'; | ||
const styles = require('./Folder.scss'); | ||
|
||
const WAPP_EXTENSION = 'wapp'; | ||
|
||
interface Props { | ||
folder: Dirent | ||
path: string; | ||
onClick?: (folder: Dirent) => void; | ||
} | ||
|
||
export default function Folder(props: Props) { | ||
const [icon, setIcon] = React.useState(''); | ||
const [name, setName] = React.useState(props.folder.name); | ||
|
||
React.useEffect(() => { | ||
async function processFile() { | ||
// This is a special folder with an "extension" | ||
const folderName: any = props.folder.name; | ||
const folderExtension = getFileExtension(folderName); | ||
|
||
if (folderExtension === WAPP_EXTENSION) { | ||
const wappInfo = await getWappInformation(`${props.path}/${folderName}`); | ||
|
||
|
||
// We should read the wapp for an icon | ||
// const wasmFs = InstanceBag.get<WasmFs>('fs'); | ||
// const file: any = await readFileAsync(wasmFs.fs, `${props.path}/${props.file.name}`); | ||
// const info = await getWappInformation(file); | ||
|
||
if (wappInfo !== null) { | ||
const newFolderName = folderName.replace('.' + WAPP_EXTENSION, ''); | ||
|
||
setIcon(wappInfo.icon); | ||
setName(newFolderName); | ||
} | ||
} | ||
} | ||
|
||
processFile(); | ||
}, []); | ||
|
||
return ( | ||
<div className={styles.folder}> | ||
<FolderIcon className={styles.icon} onClick={() => props.onClick(props.folder)} /> | ||
<span>{props.folder.name}</span> | ||
<div className={styles.iconWrapper} onClick={() => props.onClick(props.folder)}> | ||
{icon === '' && <FolderIcon className={styles.icon} />} | ||
{icon !== '' && <img className={styles.appIcon} src={icon} />} | ||
</div> | ||
<span>{name}</span> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters