EN · DE · RU · FR · ES

#2622: index.jsx

projectforge-webapp/src/components/base/navigation/index.jsx React component, projectforge-webapp/src/components/base/navigation/index.jsx 38 lines · 34 code · 0 comments · 4 blank
Purpose: React webapp: index.jsx. index.jsx is part of the ProjectForge open-source project management application.

Source (first 100 lines)

import PropTypes from 'prop-types';
import React from 'react';
import { menuItemPropType } from '../../../utilities/propTypes';
import { Nav } from '../../design';
import NavigationDropdown from './Dropdown';
import NavigationEntry from './Entry';

function Navigation({ entries, className = 'ml-auto', right = false }) {
    return (
        <Nav className={className}>
            {entries.map((entry) => {
                let Tag;

                if (entry.subMenu) {
                    Tag = NavigationDropdown;
                } else {
                    Tag = NavigationEntry;
                }
                return (
                    <Tag
                        {...entry}
                        key={entry.key || entry.id}
                        entryKey={entry.key}
                        right={right}
                    />
                );
            })}
        </Nav>
    );
}

Navigation.propTypes = {
    entries: PropTypes.arrayOf(menuItemPropType).isRequired,
    className: PropTypes.string,
    right: PropTypes.bool,
};

export default Navigation;

Git History

7c88abd0f wip lift dependencies
3685edd6c lift to react 18 wip
2f659535f right menu (my account etc.) is now tagged as right for proper alignment and spaces.
36bfe1dbe New react version, eslint reviewed by Fin.
c23bfbdf5 es-lint: review with Fin required.

7c88abd0f

wip lift dependencies
7c88abd0faab49ba2656010cb6a687f944b874e1
diff --git a/projectforge-webapp/src/components/base/navigation/index.jsx b/projectforge-webapp/src/components/base/navigation/index.jsx
index 0a502a8bc..2529c75b6 100644
--- a/projectforge-webapp/src/components/base/navigation/index.jsx
+++ b/projectforge-webapp/src/components/base/navigation/index.jsx
@@ -16,8 +16,14 @@ function Navigation({ entries, className = 'ml-auto', right = false }) {
                 } else {
                     Tag = NavigationEntry;
                 }
-                // eslint-disable-next-line max-len
-                return <Tag key={entry.key || entry.id} {...entry} entryKey={entry.key} right={right} />;
+                return (
+                    <Tag
+                        {...entry}
+                        key={entry.key || entry.id}
+                        entryKey={entry.key}
+                        right={right}
+                    />
+                );
             })}
         </Nav>
     );

3685edd6c

lift to react 18 wip
3685edd6c9f0dfd4582dbeb01c05491c254ccb84
diff --git a/projectforge-webapp/src/components/base/navigation/index.jsx b/projectforge-webapp/src/components/base/navigation/index.jsx
index cc9c74a08..0a502a8bc 100644
--- a/projectforge-webapp/src/components/base/navigation/index.jsx
+++ b/projectforge-webapp/src/components/base/navigation/index.jsx
@@ -5,7 +5,7 @@ import { Nav } from '../../design';
 import NavigationDropdown from './Dropdown';
 import NavigationEntry from './Entry';
 
-function Navigation({ entries, className, right }) {
+function Navigation({ entries, className = 'ml-auto', right = false }) {
     return (
         <Nav className={className}>
             {entries.map((entry) => {
@@ -29,9 +29,4 @@ Navigation.propTypes = {
     right: PropTypes.bool,
 };
 
-Navigation.defaultProps = {
-    className: 'ml-auto',
-    right: false,
-};
-
 export default Navigation;

2f659535f

right menu (my account etc.) is now tagged as right for proper alignment and spaces.
2f659535f253a134974f220542362354397d2226
diff --git a/projectforge-webapp/src/components/base/navigation/index.jsx b/projectforge-webapp/src/components/base/navigation/index.jsx
index fd998a485..cc9c74a08 100644
--- a/projectforge-webapp/src/components/base/navigation/index.jsx
+++ b/projectforge-webapp/src/components/base/navigation/index.jsx
@@ -5,7 +5,7 @@ import { Nav } from '../../design';
 import NavigationDropdown from './Dropdown';
 import NavigationEntry from './Entry';
 
-function Navigation({ entries, className }) {
+function Navigation({ entries, className, right }) {
     return (
         <Nav className={className}>
             {entries.map((entry) => {
@@ -16,7 +16,8 @@ function Navigation({ entries, className }) {
                 } else {
                     Tag = NavigationEntry;
                 }
-                return <Tag key={entry.key || entry.id} {...entry} entryKey={entry.key} />;
+                // eslint-disable-next-line max-len
+                return <Tag key={entry.key || entry.id} {...entry} entryKey={entry.key} right={right} />;
             })}
         </Nav>
     );
@@ -25,10 +26,12 @@ function Navigation({ entries, className }) {
 Navigation.propTypes = {
     entries: PropTypes.arrayOf(menuItemPropType).isRequired,
     className: PropTypes.string,
+    right: PropTypes.bool,
 };
 
 Navigation.defaultProps = {
     className: 'ml-auto',
+    right: false,
 };
 
 export default Navigation;

36bfe1dbe

New react version, eslint reviewed by Fin.
36bfe1dbe1091ce01c65ef320ec3610e7d3f3900
diff --git a/projectforge-webapp/src/components/base/navigation/index.jsx b/projectforge-webapp/src/components/base/navigation/index.jsx
index 52a65be9a..fd998a485 100644
--- a/projectforge-webapp/src/components/base/navigation/index.jsx
+++ b/projectforge-webapp/src/components/base/navigation/index.jsx
@@ -16,7 +16,6 @@ function Navigation({ entries, className }) {
                 } else {
                     Tag = NavigationEntry;
                 }
-                // eslint-disable-next-line react/jsx-props-no-spreading
                 return <Tag key={entry.key || entry.id} {...entry} entryKey={entry.key} />;
             })}
         </Nav>

c23bfbdf5

es-lint: review with Fin required.
c23bfbdf5b54c9e3c7c3b2537375d9fb255a2730
diff --git a/projectforge-webapp/src/components/base/navigation/index.jsx b/projectforge-webapp/src/components/base/navigation/index.jsx
index c67ccd602..52a65be9a 100644
--- a/projectforge-webapp/src/components/base/navigation/index.jsx
+++ b/projectforge-webapp/src/components/base/navigation/index.jsx
@@ -16,7 +16,7 @@ function Navigation({ entries, className }) {
                 } else {
                     Tag = NavigationEntry;
                 }
-
+                // eslint-disable-next-line react/jsx-props-no-spreading
                 return <Tag key={entry.key || entry.id} {...entry} entryKey={entry.key} />;
             })}
         </Nav>