Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added pagination and search component #783

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"react-dom": "^16.13.1",
"react-html-parser": "^2.0.2",
"react-router-dom": "6.26.2",
"simple-git": "^3.25.0",
"simple-git": "^3.27.0",
"uuid": "^10.0.0",
"yargs": "^17.7.2"
},
Expand Down
55 changes: 55 additions & 0 deletions src/ui/components/Filtering/Filtering.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.filtering-container {
position: relative;
display: inline-block;
padding-bottom: 10px;
}

.dropdown-toggle {
padding: 10px 10px;
padding-right: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #fff;
color: #333;
cursor: pointer;
font-size: 14px;
text-align: left;
width: 130px;
display: inline-flex;
align-items: center;
justify-content: space-between;
}

.dropdown-toggle:hover {
background-color: #f0f0f0;
}

.dropdown-arrow {
border: none;
background: none;
cursor: pointer;
font-size: 15px;
margin-left: 1px;
margin-right: 10px;
}

.dropdown-menu {
position: absolute;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
margin-top: 5px;
z-index: 1000;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.dropdown-item {
padding: 10px 15px;
cursor: pointer;
font-size: 14px;
color: #333;
}

.dropdown-item:hover {
background-color: #f0f0f0;
}
65 changes: 65 additions & 0 deletions src/ui/components/Filtering/Filtering.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { useState } from 'react';
import './Filtering.css';

const Filtering = ({ onFilterChange }) => {
const [isOpen, setIsOpen] = useState(false); // State to toggle dropdown open/close
const [selectedOption, setSelectedOption] = useState('Sort by'); // Initial state
const [sortOrder, setSortOrder] = useState('asc'); // Track sort order (asc/desc)

const toggleDropdown = () => {
setIsOpen(!isOpen); // Toggle dropdown open/close state
};

const toggleSortOrder = () => {
// Toggle sort order only if an option is selected
if (selectedOption !== 'Sort by') {
const newSortOrder = sortOrder === 'asc' ? 'desc' : 'asc';
setSortOrder(newSortOrder);
onFilterChange(selectedOption, newSortOrder); // Trigger filtering with new order
}
};

const handleOptionClick = (option) => {
// Handle filter option selection
setSelectedOption(option);
onFilterChange(option, sortOrder); // Call the parent function with selected filter and order
setIsOpen(false); // Collapse the dropdown after selection
};

return (
<div className="filtering-container">
<div className="dropdown">
{/* Make the entire button clickable for toggling dropdown */}
<button onClick={toggleDropdown} className="dropdown-toggle">
{selectedOption}
{/* Render the up/down arrow next to selected option */}
{selectedOption !== 'Sort by' && (
<span onClick={(e) => { e.stopPropagation(); toggleSortOrder(); }}>
{sortOrder === 'asc' ? ' ↑' : ' ↓'}
</span>
)}
<span className="dropdown-arrow">▼</span>
</button>

{isOpen && (
<div className="dropdown-menu">
<div onClick={() => handleOptionClick('Date Modified')} className="dropdown-item">
Date Modified
</div>
<div onClick={() => handleOptionClick('Date Created')} className="dropdown-item">
Date Created
</div>
<div onClick={() => handleOptionClick('Alphabetical')} className="dropdown-item">
Alphabetical
</div>
</div>
)}
</div>
</div>
);
};

export default Filtering;



28 changes: 28 additions & 0 deletions src/ui/components/Pagination/Pagination.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.paginationContainer {
display: flex;
justify-content: center;
padding: 1rem;
margin-top: 20px;
gap: 10px;
}

.pageButton {
padding: 8px 12px;
font-size: 14px;
color: #333;
border: 1px solid #ccc;
background-color: #f9f9f9;
cursor: pointer;
border-radius: 5px;
transition: background-color 0.3s ease;
}

.pageButton:hover {
background-color: #e2e6ea;
}

.activeButton {
background-color: #007bff;
color: #fff;
border-color: #007bff;
}
37 changes: 37 additions & 0 deletions src/ui/components/Pagination/Pagination.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import './Pagination.css';

export default function Pagination({ currentPage, totalItems = 0, itemsPerPage, onPageChange }) {

const totalPages = Math.ceil(totalItems / itemsPerPage);

const handlePageClick = (page) => {
if (page >= 1 && page <= totalPages) {
onPageChange(page);
}
};

return (
<div className='paginationContainer'>
<button
className='pageButton'
onClick={() => handlePageClick(currentPage - 1)}
disabled={currentPage === 1}
>
Previous
</button>

<span>
Page {currentPage} of {totalPages}
</span>

<button
className='pageButton'
onClick={() => handlePageClick(currentPage + 1)}
disabled={currentPage === totalPages}
>
Next
</button>
</div>
);
}
19 changes: 19 additions & 0 deletions src/ui/components/Search/Search.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.search-bar {
width: 100%;
max-width:100%;
margin: 0 auto 20px auto;
}

.search-input {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}

.search-input:focus {
border-color: #007bff;
}

37 changes: 37 additions & 0 deletions src/ui/components/Search/Search.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import { TextField } from '@material-ui/core';
import './Search.css';
import InputAdornment from '@material-ui/core/InputAdornment';
import SearchIcon from '@material-ui/icons/Search';


export default function Search({ onSearch }) {
const handleSearchChange = (event) => {
const query = event.target.value;
onSearch(query);
};

return (
<div style={{ margin: '20px 0' }}>
<TextField
label="Search"
variant="outlined"
fullWidth
margin="normal"
onChange={handleSearchChange}
placeholder="Search..."
InputProps={{
startAdornment: (
<InputAdornment position="start">
<SearchIcon />
</InputAdornment>
),
}}
/>
</div>
);
}




2 changes: 1 addition & 1 deletion src/ui/views/OpenPushRequests/OpenPushRequests.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ export default function Dashboard() {
</GridContainer>
</div>
);
}
}
4 changes: 4 additions & 0 deletions src/ui/views/OpenPushRequests/components/PushesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,7 @@ export default function PushesTable(props) {
</div>
);
}




3 changes: 2 additions & 1 deletion src/ui/views/RepoList/Components/RepoOverview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import GridContainer from '../../../components/Grid/GridContainer';
import GridItem from '../../../components/Grid/GridItem';
import { CodeReviewIcon, LawIcon, PeopleIcon } from '@primer/octicons-react';


const colors = {
'1C Enterprise': '#814CCC',
'2-Dimensional Array': '#38761D',
Expand Down Expand Up @@ -671,4 +672,4 @@ export default function Repositories(props) {
</TableCell>
</TableRow>
);
}
}
Loading
Loading