possiblilty to change title of project, get share link, delete project for every project via button

This commit is contained in:
Delucse
2020-12-07 18:18:08 +01:00
parent b2f6b1d012
commit 50e22fdf92
8 changed files with 145 additions and 78 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ class Project extends Component {
{this.props.type !== 'share' ?
<Breadcrumbs content={[{ link: `/${this.props.type}`, title: data },{ link: this.props.location.pathname, title: this.props.project.title }]} />
: null}
<Home project={this.props.project.xml}/>
<Home project={this.props.project} projectType={this.props.type}/>
</div> : null
);
};
+27 -4
View File
@@ -10,6 +10,7 @@ import { Link, withRouter } from 'react-router-dom';
import Breadcrumbs from '../Breadcrumbs';
import BlocklyWindow from '../Blockly/BlocklyWindow';
import Snackbar from '../Snackbar';
import WorkspaceFunc from '../WorkspaceFunc';
import { withStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid';
@@ -61,6 +62,14 @@ class ProjectHome extends Component {
this.setState({snackbar: false});
this.props.getProjects(this.props.location.pathname.replace('/',''));
}
if(props.message !== this.props.message){
if(this.props.message.id === 'PROJECT_DELETE_SUCCESS'){
this.setState({ snackbar: true, key: Date.now(), message: `Dein Projekt wurde erfolgreich gelöscht.`, type: 'success' });
}
else if(this.props.message.id === 'GALLERY_DELETE_SUCCESS'){
this.setState({ snackbar: true, key: Date.now(), message: `Dein Galerie-Projekt wurde erfolgreich gelöscht.`, type: 'success' });
}
}
}
componentWillUnmount() {
@@ -86,8 +95,8 @@ class ProjectHome extends Component {
{this.props.projects.map((project, i) => {
return (
<Grid item xs={12} sm={6} md={4} xl={3} key={i}>
<Link to={`/${data === 'Projekte' ? 'project' : 'gallery'}/${project._id._id ? project._id._id : project._id}`} style={{ textDecoration: 'none', color: 'inherit' }}>
<Paper style={{ padding: '1rem', position: 'relative', overflow: 'hidden' }}>
<Paper style={{ padding: '1rem', position: 'relative', overflow: 'hidden' }}>
<Link to={`/${data === 'Projekte' ? 'project' : 'gallery'}/${project._id._id ? project._id._id : project._id}`} style={{ textDecoration: 'none', color: 'inherit' }}>
<h3 style={{marginTop: 0}}>{project.title}</h3>
<Divider style={{marginTop: '1rem', marginBottom: '10px'}}/>
<BlocklyWindow
@@ -96,8 +105,20 @@ class ProjectHome extends Component {
initialXml={project.xml}
/>
<Typography variant='body2' style={{fontStyle: 'italic', margin: 0, marginTop: '-30px'}}>{project.description}</Typography>
</Paper>
</Link>
</Link>
{this.props.user && this.props.user.email === project.creator ?
<div>
<Divider style={{marginTop: '10px', marginBottom: '10px'}}/>
<div style={{float: 'right'}}>
<WorkspaceFunc
multiple
project={project}
projectType={this.props.location.pathname.replace('/','')}
/>
</div>
</div>
: null}
</Paper>
</Grid>
)
})}
@@ -128,12 +149,14 @@ ProjectHome.propTypes = {
clearMessages: PropTypes.func.isRequired,
projects: PropTypes.array.isRequired,
progress: PropTypes.bool.isRequired,
user: PropTypes.object,
message: PropTypes.object.isRequired
};
const mapStateToProps = state => ({
projects: state.project.projects,
progress: state.project.progress,
user: state.auth.user,
message: state.message
});