Merge branch 'add-translations' into backend-connection

This commit is contained in:
Delucse
2020-12-14 15:23:01 +01:00
45 changed files with 1033 additions and 548 deletions
+17 -18
View File
@@ -6,7 +6,6 @@ import { getProject, resetProject } from '../../actions/projectActions';
import { clearMessages, returnErrors } from '../../actions/messageActions';
import { withRouter } from 'react-router-dom';
import { createNameId } from 'mnemonic-id';
import Home from '../Home';
import Breadcrumbs from '../Breadcrumbs';
@@ -23,16 +22,16 @@ class Project extends Component {
}
componentDidUpdate(props) {
if(props.location.pathname !== this.props.location.pathname ||
props.match.params[`${this.props.type}Id`] !== this.props.match.params[`${this.props.type}Id`]){
if(this.props.message.msg){
if (props.location.pathname !== this.props.location.pathname ||
props.match.params[`${this.props.type}Id`] !== this.props.match.params[`${this.props.type}Id`]) {
if (this.props.message.msg) {
this.props.clearMessages();
}
this.getProject();
}
if(this.props.message !== props.message){
if(this.props.message.id === 'PROJECT_EMPTY' || this.props.message.id === 'GET_PROJECT_FAIL'){
if(this.props.type!=='share'){
if (this.props.message !== props.message) {
if (this.props.message.id === 'PROJECT_EMPTY' || this.props.message.id === 'GET_PROJECT_FAIL') {
if (this.props.type !== 'share') {
this.props.returnErrors('', 404, 'GET_PROJECT_FAIL');
this.props.history.push(`/${this.props.type}`);
} else {
@@ -40,10 +39,10 @@ class Project extends Component {
this.props.returnErrors('', 404, 'GET_SHARE_FAIL');
}
}
else if(this.props.message.id === 'GET_PROJECT_SUCCESS'){
else if (this.props.message.id === 'GET_PROJECT_SUCCESS') {
this.props.workspaceName(this.props.project.title);
}
else if(this.props.message.id === 'PROJECT_DELETE_SUCCESS' || this.props.message.id === 'GALLERY_DELETE_SUCCESS'){
else if (this.props.message.id === 'PROJECT_DELETE_SUCCESS' || this.props.message.id === 'GALLERY_DELETE_SUCCESS') {
this.props.history.push(`/${this.props.type}`);
}
}
@@ -55,8 +54,8 @@ class Project extends Component {
}
getProject = () => {
var id = this.props.location.pathname.replace(/\/[a-z]{1,}\//,'');
var param = this.props.location.pathname.replace(`/${id}`,'').replace('/','');
var id = this.props.location.pathname.replace(/\/[a-z]{1,}\//, '');
var param = this.props.location.pathname.replace(`/${id}`, '').replace('/', '');
console.log('param', param);
console.log(id);
this.props.getProject(param, id);
@@ -69,13 +68,13 @@ class Project extends Component {
<Backdrop open invisible>
<CircularProgress color="primary" />
</Backdrop>
: this.props.project ?
<div>
{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} projectType={this.props.type}/>
</div> : null
: this.props.project ?
<div>
{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} projectType={this.props.type} />
</div> : null
);
};
}
+24 -24
View File
@@ -41,31 +41,31 @@ class ProjectHome extends Component {
}
componentDidMount() {
var type = this.props.location.pathname.replace('/','');
var type = this.props.location.pathname.replace('/', '');
this.props.getProjects(type);
if(this.props.message){
if(this.props.message.id === 'PROJECT_DELETE_SUCCESS'){
if (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'){
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' });
}
else if(this.props.message.id === 'GET_PROJECT_FAIL'){
this.setState({ snackbar: true, key: Date.now(), message: `Dein angefragtes ${type === 'gallery' ? 'Galerie-':''}Projekt konnte nicht gefunden werden.`, type: 'error' });
else if (this.props.message.id === 'GET_PROJECT_FAIL') {
this.setState({ snackbar: true, key: Date.now(), message: `Dein angefragtes ${type === 'gallery' ? 'Galerie-' : ''}Projekt konnte nicht gefunden werden.`, type: 'error' });
}
}
}
componentDidUpdate(props) {
if(props.location.pathname !== this.props.location.pathname){
this.setState({snackbar: false});
this.props.getProjects(this.props.location.pathname.replace('/',''));
if (props.location.pathname !== this.props.location.pathname) {
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'){
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'){
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' });
}
}
@@ -87,7 +87,7 @@ class ProjectHome extends Component {
<Backdrop open invisible>
<CircularProgress color="primary" />
</Backdrop>
:
:
<div>
{this.props.projects.length > 0 ?
<Grid container spacing={2}>
@@ -96,37 +96,37 @@ class ProjectHome extends Component {
<Grid item xs={12} sm={6} md={4} xl={3} key={i}>
<Paper style={{ padding: '1rem', position: 'relative', overflow: 'hidden' }}>
<Link to={`/${data === 'Projekte' ? 'project' : 'gallery'}/${project._id}`} style={{ textDecoration: 'none', color: 'inherit' }}>
<h3 style={{marginTop: 0}}>{project.title}</h3>
<Divider style={{marginTop: '1rem', marginBottom: '10px'}}/>
<h3 style={{ marginTop: 0 }}>{project.title}</h3>
<Divider style={{ marginTop: '1rem', marginBottom: '10px' }} />
<BlocklyWindow
svg
blockDisabled
initialXml={project.xml}
/>
<Typography variant='body2' style={{fontStyle: 'italic', margin: 0, marginTop: '-10px'}}>{project.description}</Typography>
<Typography variant='body2' style={{ fontStyle: 'italic', margin: 0, marginTop: '-10px' }}>{project.description}</Typography>
</Link>
{this.props.user && this.props.user.email === project.creator ?
<div>
<Divider style={{marginTop: '10px', marginBottom: '10px'}}/>
<div style={{float: 'right'}}>
<Divider style={{ marginTop: '10px', marginBottom: '10px' }} />
<div style={{ float: 'right' }}>
<WorkspaceFunc
multiple
project={project}
projectType={this.props.location.pathname.replace('/','')}
projectType={this.props.location.pathname.replace('/', '')}
/>
</div>
</div>
: null}
: null}
</Paper>
</Grid>
)
})}
</Grid>
: <div>
<Typography style={{marginBottom: '10px'}}>Es sind aktuell keine Projekte vorhanden.</Typography>
{this.props.location.pathname.replace('/','') === 'project' ?
: <div>
<Typography style={{ marginBottom: '10px' }}>Es sind aktuell keine Projekte vorhanden.</Typography>
{this.props.location.pathname.replace('/', '') === 'project' ?
<Typography>Erstelle jetzt dein <Link to={'/'} className={this.props.classes.link}>eigenes Projekt</Link> oder lasse dich von Projektbeispielen in der <Link to={'/gallery'} className={this.props.classes.link}>Galerie</Link> inspirieren.</Typography>
: null}
: null}
</div>
}
</div>