feat: Resource
This commit is contained in:
parent
ad771329d2
commit
b7e50bc6f3
|
@ -14,6 +14,7 @@ import {
|
||||||
|
|
||||||
import Dashboard from 'components/dashboard';
|
import Dashboard from 'components/dashboard';
|
||||||
import ProjectRoute from 'components/project/route';
|
import ProjectRoute from 'components/project/route';
|
||||||
|
import ResourceRoute from 'components/resource/route';
|
||||||
|
|
||||||
const Persea = React.memo(({history}) => {
|
const Persea = React.memo(({history}) => {
|
||||||
const isLoggedIn = useSelector(userIdSelector);
|
const isLoggedIn = useSelector(userIdSelector);
|
||||||
|
@ -24,6 +25,7 @@ const Persea = React.memo(({history}) => {
|
||||||
{isLoggedIn ? <Redirect to="/" /> : Login}
|
{isLoggedIn ? <Redirect to="/" /> : Login}
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/dashboard" component={Dashboard} />
|
<Route path="/dashboard" component={Dashboard} />
|
||||||
|
<Route path="/project/:uuid:uri(/.*)" component={ResourceRoute} />
|
||||||
<Route path="/project/:uuid" component={ProjectRoute} />
|
<Route path="/project/:uuid" component={ProjectRoute} />
|
||||||
</Switch>
|
</Switch>
|
||||||
<Route exact path="/">
|
<Route exact path="/">
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
|
|
||||||
import {PropTypes, React} from '@latus/react';
|
import {join} from 'path';
|
||||||
|
|
||||||
const Project = ({project: {label, resourcePaths}}) => (
|
import {PropTypes, React} from '@latus/react';
|
||||||
|
import {Link} from 'react-router-dom';
|
||||||
|
|
||||||
|
const Project = ({project: {label, resourcePaths}, uuid}) => (
|
||||||
<div className="project">
|
<div className="project">
|
||||||
<h2 className="project__title">{label}</h2>
|
<h2 className="project__title">{label}</h2>
|
||||||
<ul>
|
<ul>
|
||||||
{resourcePaths.map(([isFile, resourcePath]) => (
|
{resourcePaths.map(([isFile, resourcePath]) => (
|
||||||
<li key={resourcePath}>
|
<li key={resourcePath}>
|
||||||
{isFile ? 'File: ' : 'Directory: '}
|
{isFile ? 'File: ' : 'Directory: '}
|
||||||
{resourcePath}
|
<Link to={join('/project', uuid, resourcePath)}>{resourcePath}</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
22
app/src/react/components/resource/index.jsx
Normal file
22
app/src/react/components/resource/index.jsx
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import './index.scss';
|
||||||
|
|
||||||
|
import {PropTypes, React} from '@latus/react';
|
||||||
|
import {useSelector} from '@latus/redux';
|
||||||
|
import {projectsSelector} from '@persea/core';
|
||||||
|
|
||||||
|
const Resource = ({uri, uuid}) => {
|
||||||
|
const {resources} = useSelector(projectsSelector);
|
||||||
|
const buffer = Buffer.from(resources[`${uuid}${uri}`], 'base64');
|
||||||
|
return (
|
||||||
|
<div className="resource">
|
||||||
|
<h2 className="resource__title">{buffer.toString()}</h2>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Resource.propTypes = {
|
||||||
|
uri: PropTypes.string.isRequired,
|
||||||
|
uuid: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Resource;
|
0
app/src/react/components/resource/index.scss
Normal file
0
app/src/react/components/resource/index.scss
Normal file
20
app/src/react/components/resource/route/index.jsx
Normal file
20
app/src/react/components/resource/route/index.jsx
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import './index.scss';
|
||||||
|
|
||||||
|
import {PropTypes, React} from '@latus/react';
|
||||||
|
|
||||||
|
import Resource from '../index';
|
||||||
|
|
||||||
|
const ResourceRoute = ({match: {params: {uri, uuid}}}) => (
|
||||||
|
<Resource uri={uri} uuid={uuid} />
|
||||||
|
);
|
||||||
|
|
||||||
|
ResourceRoute.propTypes = {
|
||||||
|
match: PropTypes.shape({
|
||||||
|
params: PropTypes.shape({
|
||||||
|
uri: PropTypes.string,
|
||||||
|
uuid: PropTypes.string,
|
||||||
|
}),
|
||||||
|
}).isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ResourceRoute;
|
0
app/src/react/components/resource/route/index.scss
Normal file
0
app/src/react/components/resource/route/index.scss
Normal file
Loading…
Reference in New Issue
Block a user