diff --git a/src/components/BrowseUploadsHeader/BrowseUploadsLink.jsx b/src/components/BrowseUploadsHeader/BrowseUploadsLink.jsx new file mode 100644 index 000000000..9dc3dcfd6 --- /dev/null +++ b/src/components/BrowseUploadsHeader/BrowseUploadsLink.jsx @@ -0,0 +1,49 @@ +/* + Copyright (C) 2021 Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React from "react"; +import { Link, useLocation } from "react-router-dom"; + +import PropTypes from "prop-types"; + +const BrowseUploadsLink = ({ path, name }) => { + const location = useLocation(); + return ( + <> + + {name} + + + ); +}; + +BrowseUploadsLink.propTypes = { + path: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, +}; + +export default BrowseUploadsLink; diff --git a/src/components/BrowseUploadsHeader/index.jsx b/src/components/BrowseUploadsHeader/index.jsx index 64830981c..687cb6ec1 100644 --- a/src/components/BrowseUploadsHeader/index.jsx +++ b/src/components/BrowseUploadsHeader/index.jsx @@ -1,5 +1,6 @@ /* Copyright (C) 2021 Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) SPDX-License-Identifier: GPL-2.0 @@ -18,7 +19,6 @@ // React Imports import React from "react"; -import { Link, useLocation } from "react-router-dom"; // React Bootstrap Imports import { Navbar } from "react-bootstrap"; @@ -29,8 +29,10 @@ import routes from "constants/routes"; // Helper Functions import { isAuth } from "shared/authHelper"; +// Custom Component +import BrowseUploadsLink from "./BrowseUploadsLink"; + const Header = () => { - const location = useLocation(); return ( <> @@ -40,56 +42,23 @@ const Header = () => { {/* Checking whether the user is authenticated */} {isAuth() && ( <> - - Software Heritage - - - License Browser - - - File Browser - - - Copyright Browser - - - ECC - + + + + + )} diff --git a/src/components/Header/Dropdowns/HelpPagesDropdown.jsx b/src/components/Header/Dropdowns/HelpPagesDropdown.jsx new file mode 100644 index 000000000..b6b39fd80 --- /dev/null +++ b/src/components/Header/Dropdowns/HelpPagesDropdown.jsx @@ -0,0 +1,67 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React from "react"; +import { Link } from "react-router-dom"; + +// React Bootstrap Imports +import { Dropdown } from "react-bootstrap"; +import { QuestionCircleFill } from "react-bootstrap-icons"; + +// Routes for all the pages +import routes from "constants/routes"; + +// External Link for documention +import externalLinks from "constants/externalLinks"; + +const HelpPagesDropdown = () => { + return ( + <> + + + + + + + About + + + Getting Started + + + License Browser + + + Documentation + + + Third Party Licenses + + + + + ); +}; + +export default HelpPagesDropdown; diff --git a/src/components/Header/Dropdowns/ThemeToggleDropdown.jsx b/src/components/Header/Dropdowns/ThemeToggleDropdown.jsx new file mode 100644 index 000000000..ec2bb7692 --- /dev/null +++ b/src/components/Header/Dropdowns/ThemeToggleDropdown.jsx @@ -0,0 +1,41 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React from "react"; + +// React Bootstrap Imports +import { Dropdown } from "react-bootstrap"; + +// Dark Theme Toggle Button +import DarkThemeToggle from "../../DarkThemeToggle/DarkThemeToggle"; + +const ThemeToggleDropdown = () => { + return ( + <> + + + + + + + ); +}; + +export default ThemeToggleDropdown; diff --git a/src/components/Header/Dropdowns/UserInfoDropdown.jsx b/src/components/Header/Dropdowns/UserInfoDropdown.jsx new file mode 100644 index 000000000..d227c9edc --- /dev/null +++ b/src/components/Header/Dropdowns/UserInfoDropdown.jsx @@ -0,0 +1,98 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React, { useState } from "react"; +import { useHistory } from "react-router-dom"; + +// React Bootstrap Imports +import { Dropdown } from "react-bootstrap"; +import { PersonCircle } from "react-bootstrap-icons"; + +// Routes for all the pages +import routes from "constants/routes"; + +// List of all accessible groups +import { getAllGroups } from "services/groups"; + +// Widgets +import TextIcon from "components/Widgets/TextIcon"; + +// Helper Functions +import { logout, isAuth, getUserName } from "shared/authHelper"; +import { getLocalStorage, setLocalStorage } from "shared/storageHelper"; +import { getNameInitials } from "shared/helper"; + +const UserInfoDropdown = () => { + const [currentGroup, setCurrentGroup] = useState( + getLocalStorage("currentGroup") || getLocalStorage("user")?.default_group + ); + const history = useHistory(); + const handleLogin = () => { + history.push(routes.home); + }; + const handleGroupChange = (e) => { + setLocalStorage("currentGroup", e.target.innerText); + setCurrentGroup(e.target.innerText); + }; + return ( + <> + {getAllGroups() && ( + + + + + + {getAllGroups().map((group) => ( + + {group.name} + + ))} + + + )} + + + + + {isAuth() ? ( + + + User: {getUserName()} + + + logout(null)}>Log out + + + ) : ( + + Log in + + + )} + + + ); +}; + +export default UserInfoDropdown; diff --git a/src/components/Header/HeaderNavLink.jsx b/src/components/Header/HeaderNavLink.jsx new file mode 100644 index 000000000..5ed63a9a2 --- /dev/null +++ b/src/components/Header/HeaderNavLink.jsx @@ -0,0 +1,49 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React from "react"; +import { Link, useLocation } from "react-router-dom"; + +import PropTypes from "prop-types"; + +// React Bootstrap Imports +import { Nav } from "react-bootstrap"; + +const HeaderNavLink = ({ route, name }) => { + const location = useLocation(); + return ( + <> + + {name} + + + ); +}; + +HeaderNavLink.propTypes = { + route: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, +}; + +export default HeaderNavLink; diff --git a/src/components/Header/NavDropdowns/AdminNavDropdown.jsx b/src/components/Header/NavDropdowns/AdminNavDropdown.jsx new file mode 100644 index 000000000..d42ebf7a2 --- /dev/null +++ b/src/components/Header/NavDropdowns/AdminNavDropdown.jsx @@ -0,0 +1,87 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React from "react"; +import { Link } from "react-router-dom"; + +// React Bootstrap Imports +import { NavDropdown, DropdownButton } from "react-bootstrap"; + +// Routes for all the pages +import routes from "constants/routes"; + +const AdminNavDropdown = () => { + return ( + <> + + +
+ + Add Group + + + Delete Group + +
+
+ +
+ + Delete User + +
+
+ +
+ + Add License + + + CSV Export + + + Select License + +
+
+
+ + ); +}; + +export default AdminNavDropdown; diff --git a/src/components/Header/NavDropdowns/JobsNavDropdown.jsx b/src/components/Header/NavDropdowns/JobsNavDropdown.jsx new file mode 100644 index 000000000..eb8d7444b --- /dev/null +++ b/src/components/Header/NavDropdowns/JobsNavDropdown.jsx @@ -0,0 +1,48 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React from "react"; +import { Link } from "react-router-dom"; + +// React Bootstrap Imports +import { NavDropdown } from "react-bootstrap"; + +// Routes for all the pages +import routes from "constants/routes"; + +const JobsNavDropdown = () => { + return ( + <> + + + My Recent Jobs + + + All Recent Jobs + + + Schedule Agents + + + + ); +}; + +export default JobsNavDropdown; diff --git a/src/components/Header/NavDropdowns/OrganizeNavDropdown.jsx b/src/components/Header/NavDropdowns/OrganizeNavDropdown.jsx new file mode 100644 index 000000000..7f455875c --- /dev/null +++ b/src/components/Header/NavDropdowns/OrganizeNavDropdown.jsx @@ -0,0 +1,87 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React from "react"; +import { Link } from "react-router-dom"; + +// React Bootstrap Imports +import { NavDropdown, DropdownButton } from "react-bootstrap"; + +// Routes for all the pages +import routes from "constants/routes"; + +const OrganizeNavDropdown = () => { + return ( + <> + + +
+ + Create + + + Delete Folder + + + Edit Properties + + + Move or Copy + + + Unlink Content + +
+
+ + Licenses + + +
+ + Delete Uploaded File + + + Edit Properties + + + Move or Copy + +
+
+
+ + ); +}; + +export default OrganizeNavDropdown; diff --git a/src/components/Header/NavDropdowns/UploadNavDropdown.jsx b/src/components/Header/NavDropdowns/UploadNavDropdown.jsx new file mode 100644 index 000000000..10be5fc48 --- /dev/null +++ b/src/components/Header/NavDropdowns/UploadNavDropdown.jsx @@ -0,0 +1,66 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// React Imports +import React from "react"; +import { Link } from "react-router-dom"; + +// React Bootstrap Imports +import { NavDropdown } from "react-bootstrap"; + +// Routes for all the pages +import routes from "constants/routes"; + +const UploadNavDropdown = () => { + return ( + <> + + + From File + + + From Server + + + From URL + + + From VCS + + + Import Report + + + Instructions + + + One-Shot Analysis + + + One-Shot Copyright/Email/URL + + + One-Shot Monk + + + + ); +}; + +export default UploadNavDropdown; diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index b81d89fff..1f0f4b1fe 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -1,5 +1,6 @@ /* Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) SPDX-License-Identifier: GPL-2.0 @@ -17,25 +18,14 @@ */ // React Imports -import React, { useState } from "react"; -import { useHistory, Link, useLocation } from "react-router-dom"; +import React from "react"; +import { Link } from "react-router-dom"; // React Bootstrap Imports -import { - Navbar, - Nav, - NavDropdown, - Dropdown, - DropdownButton, -} from "react-bootstrap"; -import { QuestionCircleFill, PersonCircle } from "react-bootstrap-icons"; - -// List of all accessible groups -import { getAllGroups } from "services/groups"; +import { Navbar, Nav } from "react-bootstrap"; // Widgets import Image from "components/Widgets/Image"; -import TextIcon from "components/Widgets/TextIcon"; // Assets import logo from "assets/images/logo.svg"; @@ -43,30 +33,20 @@ import logo from "assets/images/logo.svg"; // Routes for all the pages import routes from "constants/routes"; -// External Link for documention -import externalLinks from "constants/externalLinks"; - // Helper Functions -import { logout, isAuth, getUserName, isAdmin } from "shared/authHelper"; -import { getLocalStorage, setLocalStorage } from "shared/storageHelper"; -import { getNameInitials } from "shared/helper"; - -// Dark Theme Toggle Button -import DarkThemeToggle from "../DarkThemeToggle/DarkThemeToggle"; +import { isAuth, isAdmin } from "shared/authHelper"; + +// Custom Dropdowns +import UploadNavDropdown from "./NavDropdowns/UploadNavDropdown"; +import JobsNavDropdown from "./NavDropdowns/JobsNavDropdown"; +import OrganizeNavDropdown from "./NavDropdowns/OrganizeNavDropdown"; +import AdminNavDropdown from "./NavDropdowns/AdminNavDropdown"; +import HelpPagesDropdown from "./Dropdowns/HelpPagesDropdown"; +import UserInfoDropdown from "./Dropdowns/UserInfoDropdown"; +import HeaderNavLink from "./HeaderNavLink"; +import ThemeToggleDropdown from "./Dropdowns/ThemeToggleDropdown"; const Header = () => { - const [currentGroup, setCurrentGroup] = useState( - getLocalStorage("currentGroup") || getLocalStorage("user")?.default_group - ); - const history = useHistory(); - const location = useLocation(); - const handleLogin = () => { - history.push(routes.home); - }; - const handleGroupChange = (e) => { - setLocalStorage("currentGroup", e.target.innerText); - setCurrentGroup(e.target.innerText); - }; return ( <> { - - - - - + + {/* Toggle Theme Dropdown */} + + {/* Help Pages */} - - - - - - - About - - - Getting Started - - - License Browser - - - Documentation - - - Third Party Licenses - - - + {/* User Info */} - {getAllGroups() && ( - - - - - - {getAllGroups().map((group) => ( - - {group.name} - - ))} - - - )} - - - - - {isAuth() ? ( - - - User: {getUserName()} - - - logout(null)}> - Log out - - - - ) : ( - - Log in - - - )} - + diff --git a/src/components/Table/PaginationTable.jsx b/src/components/Table/PaginationTable.jsx new file mode 100644 index 000000000..cdae3b11b --- /dev/null +++ b/src/components/Table/PaginationTable.jsx @@ -0,0 +1,117 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import React from "react"; +import "./index.css"; +import { PropTypes } from "prop-types"; + +const PaginationTable = ({ + canPreviousPage, + canNextPage, + length, + pageCount, + gotoPage, + nextPage, + previousPage, + setPageSize, + pageIndex, + pageSize, +}) => { + return ( + <> +
+ {" "} + {" "} + {" "} + {" "} + + Page{" "} + + {pageIndex + 1} of {length} + {" "} + + + | Go to page:{" "} + { + const pageNumber = e.target.value + ? Number(e.target.value) - 1 + : 0; + gotoPage(pageNumber); + }} + style={{ width: "100px" }} + /> + {" "} + +
+ + ); +}; + +PaginationTable.propTypes = { + canPreviousPage: PropTypes.bool.isRequired, + canNextPage: PropTypes.bool.isRequired, + length: PropTypes.number, + pageCount: PropTypes.number, + gotoPage: PropTypes.func, + nextPage: PropTypes.func, + previousPage: PropTypes.func, + setPageSize: PropTypes.func, + pageIndex: PropTypes.number, + pageSize: PropTypes.number, +}; + +export default PaginationTable; diff --git a/src/components/Table/TableUI.jsx b/src/components/Table/TableUI.jsx new file mode 100644 index 000000000..33d719ca4 --- /dev/null +++ b/src/components/Table/TableUI.jsx @@ -0,0 +1,106 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import React from "react"; +import CloseIcon from "assets/images/close.png"; +import "./index.css"; +import { PropTypes } from "prop-types"; + +const TableUI = ({ + getTableProps, + getTableBodyProps, + headerGroups, + prepareRow, + page, +}) => { + return ( + <> + + + {headerGroups.map((headerGroup) => ( + + {headerGroup.headers.map((column) => ( + + ))} + + ))} + + + {page.map((row) => { + prepareRow(row); + return ( + + {row.cells.map((cell) => { + if (cell.column.id === "delete") { + return ( + + ); + } + return ( + + ); + })} + + ); + })} + +
+ {column.render("Header")} + + {/* eslint-disable no-nested-ternary */} + {column.isSorted + ? column.isSortedDesc + ? " 🔽" + : " 🔼" + : ""} + +
+ + + {cell.render("Cell")}
+ + ); +}; + +TableUI.propTypes = { + getTableProps: PropTypes.func, + getTableBodyProps: PropTypes.func, + headerGroups: PropTypes.arrayOf(PropTypes.object), + prepareRow: PropTypes.func, + page: PropTypes.arrayOf(PropTypes.object), +}; + +export default TableUI; diff --git a/src/components/Table/index.jsx b/src/components/Table/index.jsx index c4b177783..d7da950d2 100644 --- a/src/components/Table/index.jsx +++ b/src/components/Table/index.jsx @@ -1,5 +1,6 @@ /* Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) SPDX-License-Identifier: GPL-2.0 @@ -18,9 +19,11 @@ import React from "react"; import { useTable, usePagination, useRowSelect, useSortBy } from "react-table"; -import CloseIcon from "assets/images/close.png"; import IndeterminateCheckbox from "./IndeterminateCheckbox"; -import "./index.css"; + +// custom components +import PaginationTable from "./PaginationTable"; +import TableUI from "./TableUI"; /* eslint-disable react/prop-types */ const Table = ({ columns, data }) => { @@ -76,128 +79,25 @@ const Table = ({ columns, data }) => { // Render the UI for your table return ( <> - - - {headerGroups.map((headerGroup) => ( - - {headerGroup.headers.map((column) => ( - - ))} - - ))} - - - {page.map((row) => { - prepareRow(row); - return ( - - {row.cells.map((cell) => { - if (cell.column.id === "delete") { - return ( - - ); - } - return ( - - ); - })} - - ); - })} - -
- {column.render("Header")} - - {/* eslint-disable no-nested-ternary */} - {column.isSorted - ? column.isSortedDesc - ? " 🔽" - : " 🔼" - : ""} - -
- - - {cell.render("Cell")}
-
- {" "} - {" "} - {" "} - {" "} - - Page{" "} - - {pageIndex + 1} of {pageOptions.length} - {" "} - - - | Go to page:{" "} - { - const pageNumber = e.target.value - ? Number(e.target.value) - 1 - : 0; - gotoPage(pageNumber); - }} - style={{ width: "100px" }} - /> - {" "} - -
+ + ); }; diff --git a/src/components/Upload/CommonFields/UploadReuse/Containers/CheckboxInputContainers.jsx b/src/components/Upload/CommonFields/UploadReuse/Containers/CheckboxInputContainers.jsx new file mode 100644 index 000000000..cdda9418c --- /dev/null +++ b/src/components/Upload/CommonFields/UploadReuse/Containers/CheckboxInputContainers.jsx @@ -0,0 +1,86 @@ +/* + Copyright (C) 2021 Shruti Agarwal (mail2shruti.ag@gmail.com), Aman Dwivedi (aman.dwivedi5@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import React from "react"; + +// Widgets +import { InputContainer, Tooltip } from "components/Widgets"; + +import { PropTypes } from "prop-types"; + +const CheckboxInputContainers = ({ reuse, handleChange }) => { + return ( + <> + + Enhanced reuse (slower) + + + + Reuse main license/s + + + + Reuse report configuration settings + + + + Reuse edited and deactivated copyrights + + + + ); +}; + +CheckboxInputContainers.propTypes = { + reuse: PropTypes.shape({ + reuseUpload: PropTypes.number.isRequired, + reuseGroup: PropTypes.string.isRequired, + reuseMain: PropTypes.bool.isRequired, + reuseEnhanced: PropTypes.bool.isRequired, + reuseReport: PropTypes.bool.isRequired, + reuseCopyright: PropTypes.bool.isRequired, + }).isRequired, + handleChange: PropTypes.func, +}; + +export default CheckboxInputContainers; diff --git a/src/components/Upload/CommonFields/UploadReuse/Containers/SelectInputContainers.jsx b/src/components/Upload/CommonFields/UploadReuse/Containers/SelectInputContainers.jsx new file mode 100644 index 000000000..7665a4bde --- /dev/null +++ b/src/components/Upload/CommonFields/UploadReuse/Containers/SelectInputContainers.jsx @@ -0,0 +1,131 @@ +/* + Copyright (C) 2021 Shruti Agarwal (mail2shruti.ag@gmail.com), Aman Dwivedi (aman.dwivedi5@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import React, { useState, useEffect } from "react"; + +// Widgets +import { InputContainer } from "components/Widgets"; + +// Required services for calling APIs +import { getAllFolders } from "services/folders"; +import { getUploadsFolderId } from "services/organizeUploads"; +import { getAllGroups } from "services/groups"; + +import { PropTypes } from "prop-types"; + +import messages from "constants/messages"; + +// required data +import { + initialGroupList, + initialFolderList, + initialUploadList, +} from "../data"; + +const SelectInputContainers = ({ reuse, handleChange }) => { + const [reuseData, setReuseData] = useState({ + groupList: initialGroupList, + folderList: initialFolderList, + uploadList: initialUploadList, + reuseFolder: 1, + }); + + useEffect(() => { + setReuseData((prevData) => ({ ...prevData, groupList: getAllGroups() })); + }, []); + + useEffect(() => { + getAllFolders(reuse.reuseGroup) + .then((res) => { + setReuseData((prevData) => ({ ...prevData, folderList: res })); + }) + .catch(() => {}); + }, [reuse.reuseGroup]); + + useEffect(() => { + getUploadsFolderId(reuseData.reuseFolder, reuse.reuseGroup) + .then((res) => { + setReuseData((prevData) => ({ ...prevData, uploadList: res })); + }) + .catch(() => {}); + }, [reuse.reuseGroup, reuseData.reuseFolder]); + + const handleReuseDataChange = (e) => { + setReuseData((prevData) => ({ + ...prevData, + [e.target.name]: e.target.value, + })); + }; + return ( + <> + + Select the reuse group: + + + Select the reuse folder: + + + Select the reuse upload: + + + ); +}; + +SelectInputContainers.propTypes = { + reuse: PropTypes.shape({ + reuseUpload: PropTypes.number.isRequired, + reuseGroup: PropTypes.string.isRequired, + reuseMain: PropTypes.bool.isRequired, + reuseEnhanced: PropTypes.bool.isRequired, + reuseReport: PropTypes.bool.isRequired, + reuseCopyright: PropTypes.bool.isRequired, + }).isRequired, + handleChange: PropTypes.func, +}; + +export default SelectInputContainers; diff --git a/src/components/Upload/CommonFields/UploadReuse/data.js b/src/components/Upload/CommonFields/UploadReuse/data.js new file mode 100644 index 000000000..0cb9ba6f7 --- /dev/null +++ b/src/components/Upload/CommonFields/UploadReuse/data.js @@ -0,0 +1,41 @@ +/* + Copyright (C) 2021 Aman Dwivedi (aman.dwivedi5@gmail.com), Shruti Agarwal (mail2shruti.ag@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) + + SPDX-License-Identifier: GPL-2.0 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +// Data used by "./Containers/SelectInputContainers.jsx" +const initialGroupList = [{ id: 3, name: "fossy" }]; + +const initialFolderList = [ + { + id: 1, + name: "Software Repository", + description: "Top Folder", + parent: null, + }, +]; + +const initialUploadList = [ + { + folderId: 1, + uploadId: null, + uploadName: "", + uploadDescription: "", + }, +]; + +export { initialGroupList, initialFolderList, initialUploadList }; diff --git a/src/components/Upload/CommonFields/UploadReuse/index.jsx b/src/components/Upload/CommonFields/UploadReuse/index.jsx index cd77da9ab..901baba87 100644 --- a/src/components/Upload/CommonFields/UploadReuse/index.jsx +++ b/src/components/Upload/CommonFields/UploadReuse/index.jsx @@ -1,5 +1,6 @@ /* Copyright (C) 2021 Shruti Agarwal (mail2shruti.ag@gmail.com), Aman Dwivedi (aman.dwivedi5@gmail.com) + Copyright (C) 2022 Raunak Kumar (raunakk728@gmail.com) SPDX-License-Identifier: GPL-2.0 @@ -16,155 +17,24 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import React, { useState, useEffect } from "react"; +import React from "react"; import PropTypes from "prop-types"; // Widgets -import { InputContainer, Tooltip } from "components/Widgets"; +import { Tooltip } from "components/Widgets"; -// Required services for calling APIs -import { getAllFolders } from "services/folders"; -import { getUploadsFolderId } from "services/organizeUploads"; -import { getAllGroups } from "services/groups"; - -import messages from "constants/messages"; +import SelectInputContainers from "./Containers/SelectInputContainers"; +import CheckboxInputContainers from "./Containers/CheckboxInputContainers"; const UploadReuse = ({ reuse, handleChange }) => { - const initialGroupList = [{ id: 3, name: "fossy" }]; - const initialFolderList = [ - { - id: 1, - name: "Software Repository", - description: "Top Folder", - parent: null, - }, - ]; - const initialUploadList = [ - { - folderId: 1, - uploadId: null, - uploadName: "", - uploadDescription: "", - }, - ]; - const [reuseData, setReuseData] = useState({ - groupList: initialGroupList, - folderList: initialFolderList, - uploadList: initialUploadList, - reuseFolder: 1, - }); - - useEffect(() => { - setReuseData((prevData) => ({ ...prevData, groupList: getAllGroups() })); - }, []); - - useEffect(() => { - getAllFolders(reuse.reuseGroup) - .then((res) => { - setReuseData((prevData) => ({ ...prevData, folderList: res })); - }) - .catch(() => {}); - }, [reuse.reuseGroup]); - - useEffect(() => { - getUploadsFolderId(reuseData.reuseFolder, reuse.reuseGroup) - .then((res) => { - setReuseData((prevData) => ({ ...prevData, uploadList: res })); - }) - .catch(() => {}); - }, [reuse.reuseGroup, reuseData.reuseFolder]); - - const handleReuseDataChange = (e) => { - setReuseData((prevData) => ({ - ...prevData, - [e.target.name]: e.target.value, - })); - }; - return (

(Optional) Reuse

- - Select the reuse group: - - - Select the reuse folder: - - - Select the reuse upload: - - - Enhanced reuse (slower) - - - - Reuse main license/s - - - - Reuse report configuration settings - - - - Reuse edited and deactivated copyrights - - + +
); };