浏览代码

moved pagehtml and thread into a specific folder + removed linting warning

Skylsmoi 6 年前
父节点
当前提交
41f3a39925

src/container/PageText.jsx → src/container/FileType/PageHtml.jsx 查看文件

@@ -1,11 +1,11 @@
1 1
 import React, { Component } from 'react'
2
-import PopinFixed from '../component/common/PopinFixed/PopinFixed'
3
-import PopinFixedHeader from '../component/common/PopinFixed/PopinFixedHeader.jsx'
4
-import PopinFixedOption from '../component/common/PopinFixed/PopinFixedOption.jsx'
5
-import PopinFixedContent from '../component/common/PopinFixed/PopinFixedContent.jsx'
6
-import Timeline from '../component/Timeline.jsx'
2
+import PopinFixed from '../../component/common/PopinFixed/PopinFixed'
3
+import PopinFixedHeader from '../../component/common/PopinFixed/PopinFixedHeader.jsx'
4
+import PopinFixedOption from '../../component/common/PopinFixed/PopinFixedOption.jsx'
5
+import PopinFixedContent from '../../component/common/PopinFixed/PopinFixedContent.jsx'
6
+import Timeline from '../../component/Timeline.jsx'
7 7
 
8
-class PageText extends Component {
8
+class PageHtml extends Component {
9 9
   render () {
10 10
     return (
11 11
       <PopinFixed customClass={'wsFileText'}>
@@ -25,7 +25,7 @@ class PageText extends Component {
25 25
   }
26 26
 }
27 27
 
28
-export default PageText
28
+export default PageHtml
29 29
 
30 30
 /*
31 31
       <div className={classnames('wsFileText wsFileGeneric', {'visible': this.props.visible})}>

src/container/Thread.jsx → src/container/FileType/Thread.jsx 查看文件

@@ -1,6 +1,6 @@
1 1
 import React, { Component } from 'react'
2 2
 import classnames from 'classnames'
3
-import imgProfil from '../img/imgProfil.png'
3
+import imgProfil from '../../img/imgProfil.png'
4 4
 
5 5
 class Thread extends Component {
6 6
   render () {

+ 71 - 69
src/container/Login.jsx 查看文件

@@ -26,86 +26,88 @@ class Login extends React.Component {
26 26
   handleChangePassword = e => this.setState({inputPassword: e.target.value})
27 27
   handleChangeRememberMe = () => this.setState(prev => ({inputRememberMe: !prev.inputRememberMe}))
28 28
 
29
-  handleClickSubmit = () => {
29
+  handleClickSubmit = async () => {
30 30
     const { history, dispatch } = this.props
31 31
     const { inputLogin, inputPassword, inputRememberMe } = this.state
32 32
 
33
-    dispatch(userLogin(inputLogin, inputPassword, inputRememberMe))
34
-    .then(() => history.push('/'))
33
+    await dispatch(userLogin(inputLogin, inputPassword, inputRememberMe))
34
+    history.push('/')
35 35
   }
36 36
 
37 37
   render () {
38 38
     if (this.props.user.isLoggedIn) return <Redirect to={{pathname: '/'}} />
39
-    else return (
40
-      <section className='loginpage'>
41
-        <div className='container-fluid'>
42
-
43
-          <LoginLogo customClass='loginpage__logo' logoSrc={LoginLogoImg} />
44
-
45
-          <div className='row justify-content-center'>
46
-            <div className='col-12 col-sm-11 col-md-8 col-lg-6 col-xl-5'>
47
-
48
-              <Card customClass='loginpage__connection'>
49
-                <CardHeader customClass='connection__header text-center'>{'Connexion'}</CardHeader>
50
-
51
-                <CardBody formClass='connection__form'>
52
-                  <InputGroupText
53
-                    parentClassName='connection__form__groupemail'
54
-                    customClass='mb-3 mt-4'
55
-                    icon='fa-envelope-open-o'
56
-                    type='email'
57
-                    placeHolder='Adresse Email'
58
-                    invalidMsg='Email invalide.'
59
-                    value={this.state.inputLogin}
60
-                    onChange={this.handleChangeLogin}
61
-                  />
62
-
63
-                  <InputGroupText
64
-                    parentClassName='connection__form__groupepw'
65
-                    customClass=''
66
-                    icon='fa-lock'
67
-                    type='password'
68
-                    placeHolder='Mot de passe'
69
-                    invalidMsg='Mot de passe invalide.'
70
-                    value={this.state.inputPassword}
71
-                    onChange={this.handleChangePassword}
72
-                  />
73
-
74
-                  <div className='row mt-4 mb-4'>
75
-                    <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
76
-                      <InputCheckbox
77
-                        parentClassName='connection__form__rememberme'
78
-                        customClass=''
79
-                        label='Se souvenir de moi'
80
-                        checked={this.state.inputRememberMe}
81
-                        onChange={this.handleChangeRememberMe}
82
-                      />
39
+    else {
40
+      return (
41
+        <section className='loginpage'>
42
+          <div className='container-fluid'>
43
+
44
+            <LoginLogo customClass='loginpage__logo' logoSrc={LoginLogoImg} />
45
+
46
+            <div className='row justify-content-center'>
47
+              <div className='col-12 col-sm-11 col-md-8 col-lg-6 col-xl-5'>
48
+
49
+                <Card customClass='loginpage__connection'>
50
+                  <CardHeader customClass='connection__header text-center'>{'Connexion'}</CardHeader>
51
+
52
+                  <CardBody formClass='connection__form'>
53
+                    <InputGroupText
54
+                      parentClassName='connection__form__groupemail'
55
+                      customClass='mb-3 mt-4'
56
+                      icon='fa-envelope-open-o'
57
+                      type='email'
58
+                      placeHolder='Adresse Email'
59
+                      invalidMsg='Email invalide.'
60
+                      value={this.state.inputLogin}
61
+                      onChange={this.handleChangeLogin}
62
+                    />
63
+
64
+                    <InputGroupText
65
+                      parentClassName='connection__form__groupepw'
66
+                      customClass=''
67
+                      icon='fa-lock'
68
+                      type='password'
69
+                      placeHolder='Mot de passe'
70
+                      invalidMsg='Mot de passe invalide.'
71
+                      value={this.state.inputPassword}
72
+                      onChange={this.handleChangePassword}
73
+                    />
74
+
75
+                    <div className='row mt-4 mb-4'>
76
+                      <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
77
+                        <InputCheckbox
78
+                          parentClassName='connection__form__rememberme'
79
+                          customClass=''
80
+                          label='Se souvenir de moi'
81
+                          checked={this.state.inputRememberMe}
82
+                          onChange={this.handleChangeRememberMe}
83
+                        />
84
+                      </div>
85
+
86
+                      <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6 text-sm-right'>
87
+                        <LoginBtnForgotPw
88
+                          customClass='connection__form__pwforgot'
89
+                          label='Mot de passe oublié ?'
90
+                        />
91
+                      </div>
83 92
                     </div>
84 93
 
85
-                    <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6 text-sm-right'>
86
-                      <LoginBtnForgotPw
87
-                        customClass='connection__form__pwforgot'
88
-                        label='Mot de passe oublié ?'
89
-                      />
90
-                    </div>
91
-                  </div>
92
-
93
-                  <Button
94
-                    htmlType='button'
95
-                    bootstrapType='primary'
96
-                    customClass='connection__form__btnsubmit'
97
-                    label='Connexion'
98
-                    onClick={this.handleClickSubmit}
99
-                  />
100
-                </CardBody>
101
-              </Card>
102
-
94
+                    <Button
95
+                      htmlType='button'
96
+                      bootstrapType='primary'
97
+                      customClass='connection__form__btnsubmit'
98
+                      label='Connexion'
99
+                      onClick={this.handleClickSubmit}
100
+                    />
101
+                  </CardBody>
102
+                </Card>
103
+
104
+              </div>
103 105
             </div>
104
-          </div>
105 106
 
106
-        </div>
107
-      </section>
108
-    )
107
+          </div>
108
+        </section>
109
+      )
110
+    }
109 111
   }
110 112
 }
111 113
 

+ 0 - 16
src/container/Page.jsx 查看文件

@@ -1,16 +0,0 @@
1
-import React from 'react'
2
-import { connect } from 'react-redux'
3
-
4
-class Page extends React.Component {
5
-  render () {
6
-    const { user } = this.props
7
-    return (
8
-      <div>
9
-        Page ! user Logged in : {user.isLoggedIn.toString()}
10
-      </div>
11
-    )
12
-  }
13
-}
14
-
15
-const mapStateToProps = ({ user }) => ({ user })
16
-export default connect(mapStateToProps)(Page)

+ 6 - 9
src/container/PrivateRoute.jsx 查看文件

@@ -7,15 +7,12 @@ import { Route, Redirect, withRouter } from 'react-router-dom'
7 7
 
8 8
 // /!\ you shall destruct props.component otherwise you get a warning:
9 9
 // "You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored
10
-const PrivateRoute = ({ component: Component, ...rest }) => {
11
-  if (rest.user.isLoggedIn === undefined) return <div />
12
-  else return (
13
-    <Route {...rest} render={props => rest.user.isLoggedIn
14
-      ? <Component {...props} />
15
-      : <Redirect to={{pathname: '/login', state: {from: props.location}}} />
16
-    } />
17
-  )
18
-}
10
+const PrivateRoute = ({ component: Component, ...rest }) => (
11
+  <Route {...rest} render={props => rest.user.isLoggedIn
12
+    ? <Component {...props} />
13
+    : <Redirect to={{pathname: '/login', state: {from: props.location}}} />
14
+  } />
15
+)
19 16
 
20 17
 const mapStateToProps = ({ user }) => ({ user })
21 18
 export default withRouter(connect(mapStateToProps)(PrivateRoute))

+ 11 - 12
src/container/Tracim.jsx 查看文件

@@ -4,7 +4,6 @@ import Footer from '../component/Footer.jsx'
4 4
 import Header from './Header.jsx'
5 5
 import Sidebar from './Sidebar.jsx'
6 6
 import Login from './Login.jsx'
7
-import Page from './Page.jsx'
8 7
 import WorkspaceContent from './WorkspaceContent.jsx'
9 8
 import {
10 9
   Route,
@@ -13,16 +12,6 @@ import {
13 12
 import PrivateRoute from './PrivateRoute.jsx'
14 13
 import { getIsUserConnected } from '../action-creator.async.js'
15 14
 
16
-const SidebarWrapper = props => {
17
-  if (props.locationPath !== '/login') return (
18
-    <div className='sidebarpagecontainer'>
19
-      <Sidebar />
20
-      {props.children}
21
-    </div>
22
-  )
23
-  else return props.children
24
-}
25
-
26 15
 class Tracim extends React.Component {
27 16
   componentDidMount = () => {
28 17
     this.props.dispatch(getIsUserConnected())
@@ -31,6 +20,17 @@ class Tracim extends React.Component {
31 20
   render () {
32 21
     const { user, location } = this.props
33 22
 
23
+    const SidebarWrapper = props => {
24
+      if (props.locationPath !== '/login') {
25
+        return (
26
+          <div className='sidebarpagecontainer'>
27
+            <Sidebar />
28
+            {props.children}
29
+          </div>
30
+        )
31
+      } else return props.children
32
+    }
33
+
34 34
     return (
35 35
       <div>
36 36
         <Header />
@@ -44,7 +44,6 @@ class Tracim extends React.Component {
44 44
               <SidebarWrapper locationPath={location.pathname}>
45 45
 
46 46
                 <PrivateRoute exact path='/' component={WorkspaceContent} />
47
-                <PrivateRoute path='/page' component={Page} />
48 47
 
49 48
               </SidebarWrapper>
50 49
 

+ 3 - 3
src/container/WorkspaceContent.jsx 查看文件

@@ -3,8 +3,8 @@ import { connect } from 'react-redux'
3 3
 import Folder from '../component/Workspace/Folder.jsx'
4 4
 import FileItem from '../component/Workspace/FileItem.jsx'
5 5
 import FileItemHeader from '../component/Workspace/FileItemHeader.jsx'
6
-// import Thread from './Thread.jsx'
7
-import PageText from './PageText.jsx'
6
+// import Thread from './FileType/Thread.jsx'
7
+import PageHtml from './FileType/PageHtml.jsx'
8 8
 import PageWrapper from '../component/common/layout/PageWrapper.jsx'
9 9
 import PageTitle from '../component/common/layout/PageTitle.jsx'
10 10
 import PageContent from '../component/common/layout/PageContent.jsx'
@@ -57,7 +57,7 @@ class WorkspaceContent extends React.Component {
57 57
 
58 58
           <DropdownCreateButton customClass='workspace__content__button mb-5' />
59 59
 
60
-          <PageText visible={this.state.activeFileType === 'file'} />
60
+          <PageHtml visible={this.state.activeFileType === 'file'} />
61 61
           {/*
62 62
           <Thread visible={this.state.activeFileType === 'chat'} />
63 63
           */}

src/css/PageText.styl → src/css/PageHtml.styl 查看文件


+ 1 - 1
src/css/index.styl 查看文件

@@ -18,5 +18,5 @@ html, body, #content, #content > div
18 18
 @import 'Folder'
19 19
 
20 20
 @import 'Thread'
21
-@import 'PageText'
21
+@import 'PageHtml'
22 22
 @import 'Timeline'