Browse Source

[https://github.com/tracim/tracim/issues/787] moved admin link into specific dropdown

Skylsmoi 6 years ago
parent
commit
2f8f2837fa

+ 29 - 0
frontend/src/component/Header/MenuActionListItem/AdminLink.jsx View File

1
+import React from 'react'
2
+import { Link } from 'react-router-dom'
3
+import { PAGE } from '../../../helper.js'
4
+
5
+const AdminLink = props => {
6
+  return (
7
+    <li className='header__menu__rightside__adminlink'>
8
+      <div className='adminlink dropdown'>
9
+        <button className='adminlink__btn btn dropdown-toggle' type='button' data-toggle='dropdown'>
10
+          Administration
11
+        </button>
12
+
13
+        <div className='adminlink__setting dropdown-menu' aria-labelledby='dropdownMenuButton'>
14
+          <Link className='setting__link dropdown-item' to={PAGE.ADMIN.WORKSPACE}>
15
+            <i className='fa fa-fw fa-space-shuttle mr-2' />
16
+            {props.t('Admin workspace')}
17
+          </Link>
18
+
19
+          <Link className='setting__link dropdown-item' to={PAGE.ADMIN.USER}>
20
+            <i className='fa fa-fw fa-users mr-2' />
21
+            {props.t('Admin user')}
22
+          </Link>
23
+        </div>
24
+      </div>
25
+    </li>
26
+  )
27
+}
28
+
29
+export default AdminLink

+ 4 - 18
frontend/src/component/Header/MenuActionListItem/MenuProfil.jsx View File

1
 import React from 'react'
1
 import React from 'react'
2
 import { Link } from 'react-router-dom'
2
 import { Link } from 'react-router-dom'
3
 import PropTypes from 'prop-types'
3
 import PropTypes from 'prop-types'
4
-import { PAGE, PROFILE } from '../../../helper.js'
4
+import { PAGE } from '../../../helper.js'
5
 import { translate } from 'react-i18next'
5
 import { translate } from 'react-i18next'
6
 
6
 
7
 const MenuProfil = props => {
7
 const MenuProfil = props => {
8
-  return props.user.logged
9
-    ? (
8
+  if (!props.user.logged) return null
9
+
10
+  return (
10
       <li className='header__menu__rightside__itemprofil'>
11
       <li className='header__menu__rightside__itemprofil'>
11
         <div className='profilgroup dropdown'>
12
         <div className='profilgroup dropdown'>
12
           <button className='profilgroup__name btn btn-outline-primary dropdown-toggle' type='button' id='dropdownMenuButton' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
13
           <button className='profilgroup__name btn btn-outline-primary dropdown-toggle' type='button' id='dropdownMenuButton' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
18
           </button>
19
           </button>
19
 
20
 
20
           <div className='profilgroup__setting dropdown-menu' aria-labelledby='dropdownMenuButton'>
21
           <div className='profilgroup__setting dropdown-menu' aria-labelledby='dropdownMenuButton'>
21
-            {props.user.profile === PROFILE.ADMINISTRATOR &&
22
-              <Link className='setting__link dropdown-item' to={PAGE.ADMIN.WORKSPACE}>
23
-                <i className='fa fa-fw fa-space-shuttle mr-2' />
24
-                {props.t('Admin workspace')}
25
-              </Link>
26
-            }
27
-
28
-            {props.user.profile === PROFILE.ADMINISTRATOR &&
29
-              <Link className='setting__link dropdown-item' to={PAGE.ADMIN.USER}>
30
-                <i className='fa fa-fw fa-users mr-2' />
31
-                {props.t('Admin user')}
32
-              </Link>
33
-            }
34
-
35
             <Link className='setting__link dropdown-item' to={PAGE.ACCOUNT}>
22
             <Link className='setting__link dropdown-item' to={PAGE.ACCOUNT}>
36
               <i className='fa fa-fw fa-user-o mr-2' />
23
               <i className='fa fa-fw fa-user-o mr-2' />
37
               {props.t('My Account')}
24
               {props.t('My Account')}
46
         </div>
33
         </div>
47
       </li>
34
       </li>
48
     )
35
     )
49
-    : ''
50
 }
36
 }
51
 export default translate()(MenuProfil)
37
 export default translate()(MenuProfil)
52
 
38
 

+ 6 - 1
frontend/src/container/Header.jsx View File

13
 import MenuActionListItemHelp from '../component/Header/MenuActionListItem/Help.jsx'
13
 import MenuActionListItemHelp from '../component/Header/MenuActionListItem/Help.jsx'
14
 import MenuActionListItemMenuProfil from '../component/Header/MenuActionListItem/MenuProfil.jsx'
14
 import MenuActionListItemMenuProfil from '../component/Header/MenuActionListItem/MenuProfil.jsx'
15
 import MenuActionListItemNotification from '../component/Header/MenuActionListItem/Notification.jsx'
15
 import MenuActionListItemNotification from '../component/Header/MenuActionListItem/Notification.jsx'
16
+import MenuActionListAdminLink from '../component/Header/MenuActionListItem/AdminLink.jsx'
16
 import logoHeader from '../img/logo-tracim.png'
17
 import logoHeader from '../img/logo-tracim.png'
17
 import {
18
 import {
18
   newFlashMessage,
19
   newFlashMessage,
22
 import {
23
 import {
23
   postUserLogout
24
   postUserLogout
24
 } from '../action-creator.async.js'
25
 } from '../action-creator.async.js'
25
-import { COOKIE, PAGE } from '../helper.js'
26
+import { COOKIE, PAGE, PROFILE } from '../helper.js'
26
 
27
 
27
 class Header extends React.Component {
28
 class Header extends React.Component {
28
   handleClickLogo = () => {}
29
   handleClickLogo = () => {}
86
                 onClickSubmit={this.handleClickSubmit}
87
                 onClickSubmit={this.handleClickSubmit}
87
               />
88
               />
88
 
89
 
90
+              {user.profile === PROFILE.ADMINISTRATOR &&
91
+                <MenuActionListAdminLink t={this.props.t} />
92
+              }
93
+
89
               <MenuActionListItemDropdownLang
94
               <MenuActionListItemDropdownLang
90
                 langList={lang}
95
                 langList={lang}
91
                 idLangActive={user.lang}
96
                 idLangActive={user.lang}

+ 6 - 0
frontend/src/css/Header.styl View File

69
           margin-right 30px
69
           margin-right 30px
70
           .btnquestion__icon
70
           .btnquestion__icon
71
             color darkGrey
71
             color darkGrey
72
+      &__adminlink
73
+        margin-right 15px
74
+        .adminlink__btn
75
+          border none
76
+          cursor pointer
77
+          background-color transparent
72
       &__itemprofil
78
       &__itemprofil
73
         .profilgroup
79
         .profilgroup
74
           margin-right 30px
80
           margin-right 30px