Skip to content

Commit 3995599

Browse files
Merge branch 'main' into auto-approve
2 parents 22df4cc + 83e814b commit 3995599

File tree

4 files changed

+68
-110
lines changed

4 files changed

+68
-110
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/git-proxy-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Command line interface tool for FINOS GitProxy.",
55
"bin": "./index.js",
66
"dependencies": {
7-
"axios": "^1.8.3",
7+
"axios": "^1.8.4",
88
"yargs": "^17.7.2",
99
"@finos/git-proxy": "file:../.."
1010
},

plugins/git-proxy-plugin-samples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"express": "^4.21.2"
1717
},
1818
"peerDependencies": {
19-
"@finos/git-proxy": "^1.9.2"
19+
"@finos/git-proxy": "^1.9.3"
2020
}
2121
}

src/ui/views/OpenPushRequests/components/PushesTable.jsx

Lines changed: 62 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -13,119 +13,81 @@ import Paper from '@material-ui/core/Paper';
1313
import styles from '../../../assets/jss/material-dashboard-react/views/dashboardStyle';
1414
import { getPushes } from '../../../services/git-push';
1515
import { KeyboardArrowRight } from '@material-ui/icons';
16-
import Search from '../../../components/Search/Search'; // Import the Search component
17-
import Pagination from '../../../components/Pagination/Pagination'; // Import Pagination component
16+
import Search from '../../../components/Search/Search';
17+
import Pagination from '../../../components/Pagination/Pagination';
1818

1919
export default function PushesTable(props) {
2020
const useStyles = makeStyles(styles);
2121
const classes = useStyles();
2222
const [data, setData] = useState([]);
23-
const [filteredData, setFilteredData] = useState([]); // State for filtered data
23+
const [filteredData, setFilteredData] = useState([]);
2424
const [isLoading, setIsLoading] = useState(false);
2525
const [isError, setIsError] = useState(false);
2626
const navigate = useNavigate();
2727
const [, setAuth] = useState(true);
28-
const [currentPage, setCurrentPage] = useState(1); // State for current page
28+
const [currentPage, setCurrentPage] = useState(1);
2929
const itemsPerPage = 5;
30-
const [searchTerm, setSearchTerm] = useState(''); // Define searchTerm state
30+
const [searchTerm, setSearchTerm] = useState('');
3131
const openPush = (push) => navigate(`/admin/push/${push}`, { replace: true });
3232

33-
34-
35-
3633
useEffect(() => {
3734
const query = {};
38-
3935
for (const k in props) {
40-
if (!k) continue;
41-
query[k] = props[k];
36+
if (k) query[k] = props[k];
4237
}
4338
getPushes(setIsLoading, setData, setAuth, setIsError, query);
4439
}, [props]);
4540

46-
47-
4841
useEffect(() => {
49-
// Initialize filtered data with full data on load
50-
const filtered = filterByStatus(data);
51-
setFilteredData(filtered);
52-
}, [props]);
53-
54-
const filterByStatus = (data) => {
55-
if (props.authorised) {
56-
return data.filter(item => item.status === 'approved');
57-
}
58-
if (props.rejected) {
59-
return data.filter(item => item.status === 'rejected');
60-
}
61-
if (props.canceled) {
62-
return data.filter(item => item.status === 'canceled');
63-
}
64-
if (props.blocked) {
65-
return data.filter(item => item.status === 'pending');
66-
}
67-
return data;
68-
};
42+
setFilteredData(data);
43+
}, [data]);
6944

70-
71-
// Apply search to the filtered data
7245
useEffect(() => {
73-
const filtered = filterByStatus(data); // Apply status filter first
74-
if (searchTerm) {
75-
const lowerCaseTerm = searchTerm.toLowerCase();
76-
const searchFiltered = filtered.filter((item) =>
77-
item.repo.toLowerCase().includes(lowerCaseTerm) ||
78-
item.commitTo.toLowerCase().includes(lowerCaseTerm) ||
79-
80-
item.commitData[0].message.toLowerCase().includes(lowerCaseTerm)
81-
);
82-
setFilteredData(searchFiltered);
83-
} else {
84-
setFilteredData(filtered); // Reset to filtered data after clearing search
85-
}
86-
setCurrentPage(1); // Reset pagination on search
87-
}, [searchTerm, props]); // Trigger on search or tab change
88-
89-
// Handler function for search input
90-
const handleSearch = (searchTerm) => {
91-
setSearchTerm(searchTerm); // Update search term state
92-
};
46+
const lowerCaseTerm = searchTerm.toLowerCase();
47+
const filtered = searchTerm
48+
? data.filter(
49+
(item) =>
50+
item.repo.toLowerCase().includes(lowerCaseTerm) ||
51+
item.commitTo.toLowerCase().includes(lowerCaseTerm) ||
52+
item.commitData[0].message.toLowerCase().includes(lowerCaseTerm),
53+
)
54+
: data;
55+
setFilteredData(filtered);
56+
setCurrentPage(1);
57+
}, [searchTerm, data]);
9358

59+
const handleSearch = (term) => setSearchTerm(term.trim());
9460

9561
const handlePageChange = (page) => {
96-
setCurrentPage(page); // Update current page
62+
setCurrentPage(page);
9763
};
9864

99-
// Logic for pagination (getting items for the current page)
100-
const indexOfLastItem = currentPage * itemsPerPage;
101-
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
102-
const currentItems = filteredData.slice(indexOfFirstItem, indexOfLastItem);
103-
104-
// Change page
105-
const paginate = (pageNumber) => setCurrentPage(pageNumber);
65+
const indexOfLastItem = currentPage * itemsPerPage;
66+
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
67+
const currentItems = filteredData.slice(indexOfFirstItem, indexOfLastItem);
68+
69+
const paginate = (pageNumber) => setCurrentPage(pageNumber);
10670

10771
if (isLoading) return <div>Loading...</div>;
10872
if (isError) return <div>Something went wrong ...</div>;
10973

11074
return (
11175
<div>
112-
<Search onSearch={handleSearch} /> {/* Use the Search component */}
113-
114-
76+
<Search onSearch={handleSearch} /> {}
11577
<TableContainer component={Paper}>
116-
<Table className={classes.table} aria-label="simple table">
78+
<Table className={classes.table} aria-label='simple table'>
11779
<TableHead>
11880
<TableRow>
119-
<TableCell align="left">Timestamp</TableCell>
120-
<TableCell align="left">Repository</TableCell>
121-
<TableCell align="left">Branch</TableCell>
122-
<TableCell align="left">Commit SHA</TableCell>
123-
<TableCell align="left">Committer</TableCell>
124-
<TableCell align="left">Author</TableCell>
125-
<TableCell align="left">Author E-mail</TableCell>
126-
<TableCell align="left">Commit Message</TableCell>
127-
<TableCell align="left">No. of Commits</TableCell>
128-
<TableCell align="right"></TableCell>
81+
<TableCell align='left'>Timestamp</TableCell>
82+
<TableCell align='left'>Repository</TableCell>
83+
<TableCell align='left'>Branch</TableCell>
84+
<TableCell align='left'>Commit SHA</TableCell>
85+
<TableCell align='left'>Committer</TableCell>
86+
<TableCell align='left'>Author</TableCell>
87+
<TableCell align='left'>Author E-mail</TableCell>
88+
<TableCell align='left'>Commit Message</TableCell>
89+
<TableCell align='left'>No. of Commits</TableCell>
90+
<TableCell align='right'></TableCell>
12991
</TableRow>
13092
</TableHead>
13193
<TableBody>
@@ -135,53 +97,53 @@ export default function PushesTable(props) {
13597

13698
return (
13799
<TableRow key={row.id}>
138-
<TableCell align="left">
100+
<TableCell align='left'>
139101
{moment
140102
.unix(row.commitData[0].commitTs || row.commitData[0].commitTimestamp)
141103
.toString()}
142104
</TableCell>
143-
<TableCell align="left">
144-
<a href={`https://github.com/${row.repo}`} rel="noreferrer" target="_blank">
105+
<TableCell align='left'>
106+
<a href={`https://github.com/${row.repo}`} rel='noreferrer' target='_blank'>
145107
{repoFullName}
146108
</a>
147109
</TableCell>
148-
<TableCell align="left">
110+
<TableCell align='left'>
149111
<a
150112
href={`https://github.com/${repoFullName}/tree/${repoBranch}`}
151-
rel="noreferrer"
152-
target="_blank"
113+
rel='noreferrer'
114+
target='_blank'
153115
>
154116
{repoBranch}
155117
</a>
156118
</TableCell>
157-
<TableCell align="left">
119+
<TableCell align='left'>
158120
<a
159121
href={`https://github.com/${repoFullName}/commit/${row.commitTo}`}
160-
rel="noreferrer"
161-
target="_blank"
122+
rel='noreferrer'
123+
target='_blank'
162124
>
163125
{row.commitTo.substring(0, 8)}
164126
</a>
165127
</TableCell>
166-
<TableCell align="left">
128+
<TableCell align='left'>
167129
<a
168130
href={`https://github.com/${row.commitData[0].committer}`}
169-
rel="noreferrer"
170-
target="_blank"
131+
rel='noreferrer'
132+
target='_blank'
171133
>
172134
{row.commitData[0].committer}
173135
</a>
174136
</TableCell>
175-
<TableCell align="left">
137+
<TableCell align='left'>
176138
<a
177139
href={`https://github.com/${row.commitData[0].author}`}
178-
rel="noreferrer"
179-
target="_blank"
140+
rel='noreferrer'
141+
target='_blank'
180142
>
181143
{row.commitData[0].author}
182144
</a>
183145
</TableCell>
184-
<TableCell align="left">
146+
<TableCell align='left'>
185147
{row.commitData[0].authorEmail ? (
186148
<a href={`mailto:${row.commitData[0].authorEmail}`}>
187149
{row.commitData[0].authorEmail}
@@ -190,10 +152,10 @@ export default function PushesTable(props) {
190152
'No data...'
191153
)}
192154
</TableCell>
193-
<TableCell align="left">{row.commitData[0].message}</TableCell>
194-
<TableCell align="left">{row.commitData.length}</TableCell>
195-
<TableCell component="th" scope="row">
196-
<Button variant="contained" color="primary" onClick={() => openPush(row.id)}>
155+
<TableCell align='left'>{row.commitData[0].message}</TableCell>
156+
<TableCell align='left'>{row.commitData.length}</TableCell>
157+
<TableCell component='th' scope='row'>
158+
<Button variant='contained' color='primary' onClick={() => openPush(row.id)}>
197159
<KeyboardArrowRight />
198160
</Button>
199161
</TableCell>
@@ -203,18 +165,14 @@ export default function PushesTable(props) {
203165
</TableBody>
204166
</Table>
205167
</TableContainer>
206-
{/* Pagination Component */}
207-
<Pagination
168+
{/* Pagination Component */}
169+
<Pagination
208170
itemsPerPage={itemsPerPage}
209171
totalItems={filteredData.length}
210172
paginate={paginate}
211173
currentPage={currentPage}
212-
onPageChange={handlePageChange}
174+
onPageChange={handlePageChange}
213175
/>
214176
</div>
215177
);
216178
}
217-
218-
219-
220-

0 commit comments

Comments
 (0)