Преглед изворни кода

[wip] integration of PopupCreateContent

Skylsmoi пре 6 година
родитељ
комит
f84ea3fd2b

+ 0 - 44
src/component/PopupContent/FileContent.jsx Прегледај датотеку

1
-import React, { Component } from 'react'
2
-
3
-class fileContent extends Component {
4
-  render () {
5
-    return (
6
-      <div className='filecontent p-3'>
7
-        <div className='filecontent__close d-flex justify-content-end'>
8
-          <i className='fa fa-times' />
9
-        </div>
10
-        <div className='filecontent__contentname d-flex align-items-center mb-4'>
11
-          <div className='filecontent__contentname__icon mr-3'>
12
-            <i className='fa fa-file-text-o' />
13
-          </div>
14
-          <div className='filecontent__contentname__title'>
15
-            Fichier de prévisualisation
16
-          </div>
17
-        </div>
18
-
19
-        <div className='filecontent__text'>Importer votre fichier :</div>
20
-        <div className='filecontent__form mb-4' drop='true'>
21
-          <div className='filecontent__form__icon d-flex justify-content-center'>
22
-            <label htmlFor='filecontentUpload' type='file'>
23
-              <i className='fa fa-download' />
24
-            </label>
25
-            <input type='file' className='d-none' id='filecontentUpload' />
26
-          </div>
27
-          <div className='filecontent__form__instruction text-center'>
28
-            Glisser votre fichier ici
29
-          </div>
30
-          <div className='filecontent__form__text text-center'>
31
-            Vous pouvez également importer votre fichier en cliquant sur l'icon
32
-          </div>
33
-        </div>
34
-        <div className='filecontent__button d-flex justify-content-end'>
35
-          <button className='filecontent__form__button btn btn-outline-primary'>
36
-            Créer et Valider
37
-          </button>
38
-        </div>
39
-      </div>
40
-    )
41
-  }
42
-}
43
-
44
-export default fileContent

+ 0 - 33
src/component/PopupContent/GenericContent.jsx Прегледај датотеку

1
-import React, { Component } from 'react'
2
-
3
-class GenericContent extends Component {
4
-  render () {
5
-    return (
6
-      <div className='genericcontent p-3'>
7
-        <div className='genericcontent__close d-flex justify-content-end'>
8
-          <i className='fa fa-times' />
9
-        </div>
10
-        <div className='genericcontent__contentname d-flex align-items-center mb-4'>
11
-          <div className='genericcontent__contentname__icon mr-3'>
12
-            <i className='fa fa-file-word-o' />
13
-          </div>
14
-          <div className='genericcontent__contentname__title'>
15
-            Fichier Texte
16
-          </div>
17
-        </div>
18
-        <form className='genericcontent__form'>
19
-          <div className='genericcontent__form__input mb-2'>
20
-            <input type='text' placeholder='Titre du document' />
21
-          </div>
22
-          <div className='genericcontent__form__button d-flex justify-content-end p-3'>
23
-            <button className='genericcontent__form__button btn btn-outline-primary' type='submit'>
24
-              Créer et Valider
25
-            </button>
26
-          </div>
27
-        </form>
28
-      </div>
29
-    )
30
-  }
31
-}
32
-
33
-export default GenericContent

+ 0 - 30
src/component/PopupContent/WksContent.jsx Прегледај датотеку

1
-import React, { Component } from 'react'
2
-
3
-class wksContent extends Component {
4
-  render () {
5
-    return (
6
-      <div className='wkscontent p-3'>
7
-        <div className='wkscontent__close d-flex justify-content-end'>
8
-          <i className='fa fa-times' />
9
-        </div>
10
-        <div className='wkscontent__contentname d-flex align-items-center mb-4'>
11
-          <div className='wkscontent__contentname__title'>
12
-            Création d'un espace de travail
13
-          </div>
14
-        </div>
15
-        <form className='wkscontent__form'>
16
-          <div className='wkscontent__form__input mb-2'>
17
-            <input type='text' placeholder='Titre du document' />
18
-          </div>
19
-          <div className='wkscontent__form__button d-flex justify-content-end p-3'>
20
-            <button className='wkscontent__form__button btn btn-outline-primary' type='submit'>
21
-              Créer et Valider
22
-            </button>
23
-          </div>
24
-        </form>
25
-      </div>
26
-    )
27
-  }
28
-}
29
-
30
-export default wksContent

+ 51 - 0
src/component/PopupCreateContent/ContentType/FileContent.jsx Прегледај датотеку

1
+import React from 'react'
2
+
3
+require('./FileContent.styl')
4
+
5
+const FileContent = props => {
6
+  return (
7
+    <div className='filecontent p-3'>
8
+      <div className='filecontent__close d-flex justify-content-end'>
9
+        <i className='fa fa-times' />
10
+      </div>
11
+
12
+      <div className='filecontent__contentname d-flex align-items-center mb-4'>
13
+        <div className='filecontent__contentname__icon mr-3'>
14
+          <i className='fa fa-file-text-o' />
15
+        </div>
16
+
17
+        <div className='filecontent__contentname__title'>
18
+          Fichier de prévisualisation
19
+        </div>
20
+      </div>
21
+
22
+      <div className='filecontent__text'>Importer votre fichier :</div>
23
+
24
+      <div className='filecontent__form mb-4' drop='true'>
25
+        <div className='filecontent__form__icon d-flex justify-content-center'>
26
+          <label htmlFor='filecontentUpload' type='file'>
27
+            <i className='fa fa-download' />
28
+          </label>
29
+
30
+          <input type='file' className='d-none' id='filecontentUpload' />
31
+        </div>
32
+
33
+        <div className='filecontent__form__instruction text-center'>
34
+          Glisser votre fichier ici
35
+        </div>
36
+
37
+        <div className='filecontent__form__text text-center'>
38
+          Vous pouvez également importer votre fichier en cliquant sur l'icon
39
+        </div>
40
+      </div>
41
+
42
+      <div className='filecontent__button d-flex justify-content-end'>
43
+        <button className='filecontent__form__button btn btn-outline-primary'>
44
+          Créer et Valider
45
+        </button>
46
+      </div>
47
+    </div>
48
+  )
49
+}
50
+
51
+export default FileContent

src/css/FileContent.styl → src/component/PopupCreateContent/ContentType/FileContent.styl Прегледај датотеку


+ 37 - 0
src/component/PopupCreateContent/ContentType/GenericContent.jsx Прегледај датотеку

1
+import React from 'react'
2
+
3
+require('./GenericContent.styl')
4
+
5
+const GenericContent = props => {
6
+  return (
7
+    <div className='genericcontent p-3'>
8
+      <div className='genericcontent__close d-flex justify-content-end'>
9
+        <i className='fa fa-times' />
10
+      </div>
11
+
12
+      <div className='genericcontent__contentname d-flex align-items-center mb-4'>
13
+        <div className='genericcontent__contentname__icon mr-3'>
14
+          <i className='fa fa-file-word-o' />
15
+        </div>
16
+
17
+        <div className='genericcontent__contentname__title'>
18
+          Fichier Texte
19
+        </div>
20
+      </div>
21
+
22
+      <form className='genericcontent__form'>
23
+        <div className='genericcontent__form__input mb-2'>
24
+          <input type='text' placeholder='Titre du document' />
25
+        </div>
26
+
27
+        <div className='genericcontent__form__button d-flex justify-content-end p-3'>
28
+          <button className='genericcontent__form__button btn btn-outline-primary' type='submit'>
29
+            Créer et Valider
30
+          </button>
31
+        </div>
32
+      </form>
33
+    </div>
34
+  )
35
+}
36
+
37
+export default GenericContent

+ 16 - 0
src/component/PopupCreateContent/ContentType/GenericContent.styl Прегледај датотеку

1
+.genericcontent
2
+  &__close
3
+    cursor pointer
4
+  &__contentname
5
+    &__icon
6
+      font-size 30px
7
+    &__title
8
+      font-size 20px
9
+      color htmlColor
10
+  &__form
11
+    &__input
12
+      & > input
13
+        border: 1px solid grey;
14
+        border-radius: 5px;
15
+        padding: 5px;
16
+        width: 353PX;

+ 33 - 0
src/component/PopupCreateContent/ContentType/WsContent.jsx Прегледај датотеку

1
+import React from 'react'
2
+
3
+require('./WsContent.styl')
4
+
5
+const WsContent = props => {
6
+  return (
7
+    <div className='wscontent p-3'>
8
+      <div className='wscontent__close d-flex justify-content-end'>
9
+        <i className='fa fa-times' />
10
+      </div>
11
+
12
+      <div className='wscontent__contentname d-flex align-items-center mb-4'>
13
+        <div className='wscontent__contentname__title'>
14
+          Création d'un espace de travail
15
+        </div>
16
+      </div>
17
+
18
+      <form className='wscontent__form'>
19
+        <div className='wscontent__form__input mb-2'>
20
+          <input type='text' placeholder='Titre du document' />
21
+        </div>
22
+
23
+        <div className='wscontent__form__button d-flex justify-content-end p-3'>
24
+          <button className='wscontent__form__button btn btn-outline-primary' type='submit'>
25
+            Créer et Valider
26
+          </button>
27
+        </div>
28
+      </form>
29
+    </div>
30
+  )
31
+}
32
+
33
+export default WsContent

src/css/WksContent.styl → src/component/PopupCreateContent/ContentType/WsContent.styl Прегледај датотеку

1
-.wkscontent
1
+.wscontent
2
   &__close
2
   &__close
3
     cursor pointer
3
     cursor pointer
4
   &__contentname
4
   &__contentname

+ 47 - 0
src/component/PopupCreateContent/PopupCreateContainer.jsx Прегледај датотеку

1
+import React from 'react'
2
+import PropTypes from 'prop-types'
3
+import CardPopup from '../common/CardPopup/CardPopup.jsx'
4
+import GenericContent from './ContentType/GenericContent.jsx'
5
+import FileContent from './ContentType/FileContent.jsx'
6
+import WsContent from './ContentType/WsContent.jsx'
7
+
8
+require('./PopupCreateContainer.styl')
9
+
10
+const PopupCreateContainer = props => {
11
+  const FormCreateContent = (() => {
12
+    switch (props.type) {
13
+      case 'Workspace':
14
+        return <WsContent />
15
+      case 'File':
16
+        return <FileContent />
17
+      case 'folder':
18
+        return <GenericContent />
19
+      default:
20
+        return <GenericContent />
21
+    }
22
+  })()
23
+
24
+  // return (
25
+  //   <div className='popupcontent'>
26
+  //     <div className='popupcontent__container card'>
27
+  //       <div className='popupcontent__container__header' />
28
+  //       <div className='card-body nopadding'>
29
+  //         { FormCreateContent }
30
+  //       </div>
31
+  //     </div>
32
+  //   </div>
33
+  // )
34
+  return (
35
+    <CardPopup customClass='popupCreateContent' onClose={props.onClose}>
36
+      { FormCreateContent }
37
+    </CardPopup>
38
+  )
39
+}
40
+
41
+export default PopupCreateContainer
42
+
43
+PopupCreateContainer.propTypes = {
44
+  type: PropTypes.string.isRequired,
45
+  folder: PropTypes.object,
46
+  onClose: PropTypes.func.isRequired
47
+}

+ 23 - 0
src/component/PopupCreateContent/PopupCreateContainer.styl Прегледај датотеку

1
+@import '../../css/Variable.styl'
2
+
3
+.popupCreateContent
4
+  position fixed
5
+  top 0
6
+  left 0
7
+  display flex
8
+  justify-content center
9
+  width 100%
10
+  z-index 5
11
+  .cardPopup__container
12
+    margin-top 120px
13
+    border 0
14
+    border-radius 10px
15
+    width 400px
16
+    background lightGrey
17
+    box-shadow shadow-all
18
+  &__header
19
+    border-top-right-radius 10px
20
+    border-top-left-radius 10px
21
+    width 100%
22
+    height 8px
23
+    background-color fileColor

+ 12 - 13
src/component/Workspace/Folder.jsx Прегледај датотеку

19
     this.setState({open: !this.state.open})
19
     this.setState({open: !this.state.open})
20
   }
20
   }
21
 
21
 
22
-  handleClickNewFile = e => {
22
+  handleClickCreateContent = (e, folder, type) => {
23
     e.stopPropagation() // because we have a link inside a link (togler and newFile)
23
     e.stopPropagation() // because we have a link inside a link (togler and newFile)
24
-    console.log('new file') // @TODO
24
+    this.props.onClickCreateContent(folder, type)
25
   }
25
   }
26
 
26
 
27
   render () {
27
   render () {
53
 
53
 
54
           <div className='folder__header__button'>
54
           <div className='folder__header__button'>
55
 
55
 
56
-            <div
57
-              className='folder__header__button__addbtn'
58
-              onClick={this.handleClickNewFile}
59
-            >
56
+            <div className='folder__header__button__addbtn'>
60
               <button className='addbtn__text btn btn-outline-primary dropdown-toggle' type='button' id='dropdownMenuButton' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
57
               <button className='addbtn__text btn btn-outline-primary dropdown-toggle' type='button' id='dropdownMenuButton' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
61
                 {t('Folder.create')} ...
58
                 {t('Folder.create')} ...
62
               </button>
59
               </button>
63
 
60
 
61
+              {/* @TODO generate the subdropdown with available app from redux */}
62
+
64
               <div className='addbtn__subdropdown dropdown-menu' aria-labelledby='dropdownMenuButton'>
63
               <div className='addbtn__subdropdown dropdown-menu' aria-labelledby='dropdownMenuButton'>
65
-                <div className='subdropdown__link dropdown-item'>
64
+                <div className='subdropdown__link dropdown-item' onClick={e => this.handleClickCreateContent(e, folderData, 'folder')}>
66
                   <div className='subdropdown__link__folder d-flex align-items-center'>
65
                   <div className='subdropdown__link__folder d-flex align-items-center'>
67
                     <div className='subdropdown__link__folder__icon mr-3'>
66
                     <div className='subdropdown__link__folder__icon mr-3'>
68
                       <i className='fa fa-fw fa-folder-o' />
67
                       <i className='fa fa-fw fa-folder-o' />
72
                     </div>
71
                     </div>
73
                   </div>
72
                   </div>
74
                 </div>
73
                 </div>
75
-                <div className='subdropdown__link dropdown-item'>
74
+                <div className='subdropdown__link dropdown-item' onClick={e => this.handleClickCreateContent(e, folderData, 'PageHtml')}>
76
                   <div className='subdropdown__link__apphtml d-flex align-items-center'>
75
                   <div className='subdropdown__link__apphtml d-flex align-items-center'>
77
                     <div className='subdropdown__link__apphtml__icon mr-3'>
76
                     <div className='subdropdown__link__apphtml__icon mr-3'>
78
                       <i className='fa fa-fw fa-file-text-o' />
77
                       <i className='fa fa-fw fa-file-text-o' />
82
                     </div>
81
                     </div>
83
                   </div>
82
                   </div>
84
                 </div>
83
                 </div>
85
-                <div className='subdropdown__link dropdown-item'>
84
+                <div className='subdropdown__link dropdown-item' onClick={e => this.handleClickCreateContent(e, folderData, 'File')}>
86
                   <div className='subdropdown__link__appfile d-flex align-items-center'>
85
                   <div className='subdropdown__link__appfile d-flex align-items-center'>
87
                     <div className='subdropdown__link__appfile__icon mr-3'>
86
                     <div className='subdropdown__link__appfile__icon mr-3'>
88
                       <i className='fa fa-fw fa-file-image-o' />
87
                       <i className='fa fa-fw fa-file-image-o' />
92
                     </div>
91
                     </div>
93
                   </div>
92
                   </div>
94
                 </div>
93
                 </div>
95
-                <div className='subdropdown__link dropdown-item'>
94
+                <div className='subdropdown__link dropdown-item' onClick={e => this.handleClickCreateContent(e, folderData, 'PageMarkdown')}>
96
                   <div className='subdropdown__link__appmarkdown d-flex align-items-center'>
95
                   <div className='subdropdown__link__appmarkdown d-flex align-items-center'>
97
                     <div className='subdropdown__link__appmarkdown__icon mr-3'>
96
                     <div className='subdropdown__link__appmarkdown__icon mr-3'>
98
                       <i className='fa fa-fw fa-file-code-o' />
97
                       <i className='fa fa-fw fa-file-code-o' />
102
                     </div>
101
                     </div>
103
                   </div>
102
                   </div>
104
                 </div>
103
                 </div>
105
-                <div className='subdropdown__link dropdown-item'>
104
+                <div className='subdropdown__link dropdown-item' onClick={e => this.handleClickCreateContent(e, folderData, 'Thread')}>
106
                   <div className='subdropdown__link__appthread d-flex align-items-center'>
105
                   <div className='subdropdown__link__appthread d-flex align-items-center'>
107
                     <div className='subdropdown__link__appthread__icon mr-3'>
106
                     <div className='subdropdown__link__appthread__icon mr-3'>
108
                       <i className='fa fa-fw fa-comments-o' />
107
                       <i className='fa fa-fw fa-comments-o' />
112
                     </div>
111
                     </div>
113
                   </div>
112
                   </div>
114
                 </div>
113
                 </div>
115
-                <div className='subdropdown__link dropdown-item'>
114
+                <div className='subdropdown__link dropdown-item' onClick={e => this.handleClickCreateContent(e, folderData, 'Task')}>
116
                   <div className='subdropdown__link__apptask d-flex align-items-center'>
115
                   <div className='subdropdown__link__apptask d-flex align-items-center'>
117
                     <div className='subdropdown__link__apptask__icon mr-3'>
116
                     <div className='subdropdown__link__apptask__icon mr-3'>
118
                       <i className='fa fa-fw fa-list-ul' />
117
                       <i className='fa fa-fw fa-list-ul' />
122
                     </div>
121
                     </div>
123
                   </div>
122
                   </div>
124
                 </div>
123
                 </div>
125
-                <div className='subdropdown__link dropdown-item'>
124
+                <div className='subdropdown__link dropdown-item' onClick={e => this.handleClickCreateContent(e, folderData, 'Issue')}>
126
                   <div className='subdropdown__link__appissue d-flex align-items-center'>
125
                   <div className='subdropdown__link__appissue d-flex align-items-center'>
127
                     <div className='subdropdown__link__appissue__icon mr-3'>
126
                     <div className='subdropdown__link__appissue__icon mr-3'>
128
                       <i className='fa fa-fw fa-ticket' />
127
                       <i className='fa fa-fw fa-ticket' />

+ 1 - 18
src/component/common/CardPopup/CardPopup.jsx Прегледај датотеку

16
           </div>
16
           </div>
17
 
17
 
18
           <div className='cardPopup__body'>
18
           <div className='cardPopup__body'>
19
-            <div className='cardPopup__body__icon'>
20
-              <i className={props.icon} />
21
-            </div>
22
-
23
-            <div className='cardPopup__body__text'>
24
-              <div className='cardPopup__body__text__title'>
25
-                {props.title}
26
-              </div>
27
-              <div className='cardPopup__body__text__message'>
28
-                {props.message}
29
-              </div>
30
-            </div>
19
+            { props.children }
31
           </div>
20
           </div>
32
         </div>
21
         </div>
33
       </div>
22
       </div>
39
 
28
 
40
 CardPopup.propTypes = {
29
 CardPopup.propTypes = {
41
   customClass: PropTypes.string,
30
   customClass: PropTypes.string,
42
-  title: PropTypes.string,
43
-  message: PropTypes.string,
44
-  icon: PropTypes.string,
45
   onClose: PropTypes.func
31
   onClose: PropTypes.func
46
 }
32
 }
47
 
33
 
48
 CardPopup.defaultProps = {
34
 CardPopup.defaultProps = {
49
   customClass: 'defaultCustomClass',
35
   customClass: 'defaultCustomClass',
50
-  title: 'Default title',
51
-  message: 'Default message',
52
-  icon: 'fa fa-times-circle',
53
   onClose: () => {}
36
   onClose: () => {}
54
 }
37
 }

+ 0 - 54
src/container/PopupCreateContainer.jsx Прегледај датотеку

1
-import React, { Component } from 'react'
2
-// import GenericContent from '../component/PopupContent/GenericContent.jsx'
3
-// import FileContent from '../component/PopupContent/FileContent.jsx'
4
-// import WksContent from '../component/PopupContent/WksContent.jsx'
5
-
6
-class PopupCreateContainer extends Component {
7
-  render () {
8
-    return (
9
-      <div className='popupcontent'>
10
-        <div className='popupcontent__container card'>
11
-          <div className='popupcontent__container__header' />
12
-          <div className='card-body nopadding'>
13
-            <div className='filecontent p-3'>
14
-              <div className='filecontent__close d-flex justify-content-end'>
15
-                <i className='fa fa-times' />
16
-              </div>
17
-              <div className='filecontent__contentname d-flex align-items-center mb-4'>
18
-                <div className='filecontent__contentname__icon mr-3'>
19
-                  <i className='fa fa-file-text-o' />
20
-                </div>
21
-                <div className='filecontent__contentname__title'>
22
-                  Fichier de prévisualisation
23
-                </div>
24
-              </div>
25
-
26
-              <div className='filecontent__text'>Importer votre fichier :</div>
27
-              <div className='filecontent__form mb-4' drop='true'>
28
-                <div className='filecontent__form__icon d-flex justify-content-center'>
29
-                  <label htmlFor='filecontentUpload' type='file'>
30
-                    <i className='fa fa-download' />
31
-                  </label>
32
-                  <input type='file' className='d-none' id='filecontentUpload' />
33
-                </div>
34
-                <div className='filecontent__form__instruction text-center'>
35
-                  Glisser votre fichier ici
36
-                </div>
37
-                <div className='filecontent__form__text text-center'>
38
-                  Vous pouvez également importer votre fichier en cliquant sur l'icon
39
-                </div>
40
-              </div>
41
-              <div className='filecontent__button d-flex justify-content-end'>
42
-                <button className='filecontent__form__button btn btn-outline-primary'>
43
-                  Créer et Valider
44
-                </button>
45
-              </div>
46
-            </div>
47
-          </div>
48
-        </div>
49
-      </div>
50
-    )
51
-  }
52
-}
53
-
54
-export default PopupCreateContainer

+ 1 - 1
src/container/WIPcomponent.jsx Прегледај датотеку

1
 import React from 'react'
1
 import React from 'react'
2
 import { connect } from 'react-redux'
2
 import { connect } from 'react-redux'
3
-import PopupCreateContainer from './PopupCreateContainer.jsx'
3
+import PopupCreateContainer from '../component/PopupCreateContent/PopupCreateContainer.jsx'
4
 import ProgressBar from './ProgressBar.jsx'
4
 import ProgressBar from './ProgressBar.jsx'
5
 import Home from './Home.jsx'
5
 import Home from './Home.jsx'
6
 import CardPopup from '../component/common/CardPopup/CardPopup.jsx'
6
 import CardPopup from '../component/common/CardPopup/CardPopup.jsx'

+ 52 - 14
src/container/WorkspaceContent.jsx Прегледај датотеку

1
 import React from 'react'
1
 import React from 'react'
2
 import { connect } from 'react-redux'
2
 import { connect } from 'react-redux'
3
 import appFactory from '../appFactory.js'
3
 import appFactory from '../appFactory.js'
4
+import { PAGE } from '../helper.js'
4
 import Sidebar from './Sidebar.jsx'
5
 import Sidebar from './Sidebar.jsx'
5
 import Folder from '../component/Workspace/Folder.jsx'
6
 import Folder from '../component/Workspace/Folder.jsx'
6
 import ContentItem from '../component/Workspace/ContentItem.jsx'
7
 import ContentItem from '../component/Workspace/ContentItem.jsx'
9
 import PageTitle from '../component/common/layout/PageTitle.jsx'
10
 import PageTitle from '../component/common/layout/PageTitle.jsx'
10
 import PageContent from '../component/common/layout/PageContent.jsx'
11
 import PageContent from '../component/common/layout/PageContent.jsx'
11
 import DropdownCreateButton from '../component/common/Input/DropdownCreateButton.jsx'
12
 import DropdownCreateButton from '../component/common/Input/DropdownCreateButton.jsx'
13
+import PopupCreateContent from '../component/PopupCreateContent/PopupCreateContainer.jsx'
12
 import {
14
 import {
13
   getAppList,
15
   getAppList,
14
   getWorkspaceContent,
16
   getWorkspaceContent,
15
   getFolderContent
17
   getFolderContent
16
 } from '../action-creator.async.js'
18
 } from '../action-creator.async.js'
17
-import {newFlashMessage, setWorkspaceData} from '../action-creator.sync.js'
18
-import { PAGE } from '../helper.js'
19
+import {
20
+  newFlashMessage,
21
+  setWorkspaceData
22
+} from '../action-creator.sync.js'
19
 
23
 
20
 const qs = require('query-string')
24
 const qs = require('query-string')
21
 
25
 
22
 class WorkspaceContent extends React.Component {
26
 class WorkspaceContent extends React.Component {
27
+  constructor (props) {
28
+    super(props)
29
+    this.state = {
30
+      popupCreateContent: {
31
+        display: false,
32
+        type: undefined,
33
+        folder: undefined
34
+      }
35
+    }
36
+  }
37
+
23
   async componentDidMount () {
38
   async componentDidMount () {
24
     const { workspaceList, app, match, location, dispatch } = this.props
39
     const { workspaceList, app, match, location, dispatch } = this.props
25
 
40
 
26
     if (Object.keys(app).length === 0) dispatch(getAppList()) // async but no need await
41
     if (Object.keys(app).length === 0) dispatch(getAppList()) // async but no need await
27
 
42
 
28
-    const wsToLoad = (() => {
29
-      if (match.params.idws !== undefined) return match.params.idws
30
-      if (workspaceList.length > 0) return workspaceList[0].id // load first ws if none specified
31
-      return null
32
-    })()
43
+    let wsToLoad = null
44
+    if (match.params.idws !== undefined) wsToLoad = match.params.idws
45
+    else if (workspaceList.length > 0) wsToLoad = workspaceList[0].id // load first ws if none specified
33
 
46
 
34
-    if (wsToLoad === null) return
47
+    if (wsToLoad === null) return // ws already loaded
35
 
48
 
36
     const wsContent = await dispatch(getWorkspaceContent(wsToLoad))
49
     const wsContent = await dispatch(getWorkspaceContent(wsToLoad))
37
     if (wsContent.status === 200) {
50
     if (wsContent.status === 200) {
80
     this.props.dispatch(getFolderContent(this.props.workspace.id, folderId))
93
     this.props.dispatch(getFolderContent(this.props.workspace.id, folderId))
81
   }
94
   }
82
 
95
 
83
-  filterWorkspaceContent = (contentList, filter) => filter.length === 0
84
-    ? contentList
85
-    : contentList.filter(c => c.type === 'folder' || filter.includes(c.type)) // keep unfiltered files and folders
86
-      .map(c => c.type !== 'folder' ? c : {...c, content: this.filterWorkspaceContent(c.content, filter)}) // recursively filter folder content
87
-      // .filter(c => c.type !== 'folder' || c.content.length > 0) // remove empty folder => 2018/05/21 - since we load only one lvl of content, don't remove empty folders
96
+  handleClickCreateContent = (folder, contentType) => this.setState({
97
+    popupCreateContent: {
98
+      display: true,
99
+      type: contentType,
100
+      folder: folder
101
+    }
102
+  })
103
+
104
+  handleClosePopupCreateContent = () => this.setState({
105
+    popupCreateContent: {
106
+      display: false,
107
+      type: undefined,
108
+      folder: undefined
109
+    }
110
+  })
88
 
111
 
89
   render () {
112
   render () {
90
     const { workspace, app } = this.props
113
     const { workspace, app } = this.props
91
 
114
 
92
-    const filteredWorkspaceContent = this.filterWorkspaceContent(workspace.content, workspace.filter)
115
+    const filterWorkspaceContent = (contentList, filter) => filter.length === 0
116
+      ? contentList
117
+      : contentList.filter(c => c.type === 'folder' || filter.includes(c.type)) // keep unfiltered files and folders
118
+        .map(c => c.type !== 'folder' ? c : {...c, content: this.filterWorkspaceContent(c.content, filter)}) // recursively filter folder content
119
+    // .filter(c => c.type !== 'folder' || c.content.length > 0) // remove empty folder => 2018/05/21 - since we load only one lvl of content, don't remove empty folders
120
+
121
+    const filteredWorkspaceContent = filterWorkspaceContent(workspace.content, workspace.filter)
93
 
122
 
94
     return (
123
     return (
95
       <div className='sidebarpagecontainer'>
124
       <div className='sidebarpagecontainer'>
105
           </PageTitle>
134
           </PageTitle>
106
 
135
 
107
           <PageContent parentClass='workspace__content'>
136
           <PageContent parentClass='workspace__content'>
137
+            { this.state.popupCreateContent.display &&
138
+              <PopupCreateContent
139
+                type={this.state.popupCreateContent.type}
140
+                folder={this.state.popupCreateContent.folder}
141
+                onClose={this.handleClosePopupCreateContent}
142
+              />
143
+            }
144
+
108
             <div className='workspace__content__fileandfolder folder__content active'>
145
             <div className='workspace__content__fileandfolder folder__content active'>
109
               <ContentItemHeader />
146
               <ContentItemHeader />
110
 
147
 
122
                       delete: this.handleClickDeleteContentItem
159
                       delete: this.handleClickDeleteContentItem
123
                     }}
160
                     }}
124
                     onClickFolder={this.handleClickFolder}
161
                     onClickFolder={this.handleClickFolder}
162
+                    onClickCreateContent={this.handleClickCreateContent}
125
                     isLast={i === filteredWorkspaceContent.length - 1}
163
                     isLast={i === filteredWorkspaceContent.length - 1}
126
                     key={c.id}
164
                     key={c.id}
127
                   />
165
                   />

+ 0 - 18
src/css/Generic.styl Прегледај датотеку

184
       border 1px solid grey
184
       border 1px solid grey
185
       border-radius 10px
185
       border-radius 10px
186
       padding 15px 25px
186
       padding 15px 25px
187
-
188
-.genericcontent
189
-  &__close
190
-    cursor pointer
191
-  &__contentname
192
-    &__icon
193
-      font-size 30px
194
-    &__title
195
-      font-size 20px
196
-      color htmlColor
197
-  &__form
198
-    &__input
199
-      & > input
200
-        border: 1px solid grey;
201
-        border-radius: 5px;
202
-        padding: 5px;
203
-        width: 353PX;
204
-

+ 0 - 19
src/css/PopupCreateContainer.styl Прегледај датотеку

1
-.popupcontent
2
-  position fixed
3
-  display flex
4
-  justify-content center
5
-  width 100%
6
-  z-index 3
7
-  &__container
8
-    margin-top 120px
9
-    border 0
10
-    border-radius 10px
11
-    width 400px
12
-    background lightGrey
13
-    box-shadow shadow-all
14
-    &__header
15
-      border-top-right-radius 10px
16
-      border-top-left-radius 10px
17
-      width 100%
18
-      height 8px
19
-      background-color fileColor

+ 0 - 4
src/css/index.styl Прегледај датотеку

28
 
28
 
29
 @import 'FlashMessage'
29
 @import 'FlashMessage'
30
 
30
 
31
-@import 'PopupCreateContainer'
32
-@import 'FileContent'
33
-@import 'WksContent'
34
-
35
 @import 'Homepage'
31
 @import 'Homepage'
36
 @import 'HomepageCard'
32
 @import 'HomepageCard'
37
 
33