Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
edbb765
Move download a file functionality to a new file
abhinavohri Aug 28, 2024
62660ec
Fix download a file button on duplication page
abhinavohri Aug 28, 2024
b81dc55
Rename duplication table component
abhinavohri Aug 29, 2024
923f861
Remove unused props
abhinavohri Sep 2, 2024
be2a7f4
Add custom toasts to categorization page
abhinavohri Sep 2, 2024
4dd07cf
Add toast to all three pages
abhinavohri Sep 3, 2024
9cda41b
Create a separate page component to reduce redundancy
abhinavohri Sep 3, 2024
cdf186a
Add app context for toast state variables
abhinavohri Sep 3, 2024
2e4e144
Rename currentId to currentTaskId
abhinavohri Sep 3, 2024
2dac132
Add custom toasts to upload paged
abhinavohri Sep 3, 2024
0e376a8
Cleanup the toast
abhinavohri Sep 5, 2024
0c7c3c6
Confirm before leaving a page during a process
abhinavohri Sep 5, 2024
b89d20f
Move run pacman api call to separate file
abhinavohri Sep 7, 2024
21a4870
Restructure match rev page with api calls restructuring
abhinavohri Sep 9, 2024
e36a865
Restructuing toasts and admin dashboard
abhinavohri Sep 10, 2024
363f80e
Shift APi calls to separate file
abhinavohri Sep 12, 2024
accd168
Update toast css
abhinavohri Sep 13, 2024
17b0095
Update username tests
abhinavohri Sep 13, 2024
2a6f7d2
Fix run name error
abhinavohri Sep 13, 2024
cc27ead
Add check for positive number
abhinavohri Sep 16, 2024
bc9c26a
Fix font family
abhinavohri Sep 16, 2024
1e65201
Fix show password icon spacing
abhinavohri Sep 16, 2024
74b55c2
fix landing page after reload issue
abhinavohri Sep 16, 2024
4e66abe
remove redundant code
abhinavohri Sep 17, 2024
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
15 changes: 7 additions & 8 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body {
font-family: 'Manrope';
font-family: Manrope;
}

#root {
Expand Down Expand Up @@ -53,7 +53,7 @@ body {
#log-container>* {
color: white;
font-size: 13px;
font-family: "Monospace", sans-serif !important;
font-family: Monospace, sans-serif !important;
font-weight: 400;
font-style: normal !important;
}
Expand Down Expand Up @@ -273,7 +273,7 @@ th {

.required{
border: 2px solid red !important;
font-family: 'manrope';
font-family: Manrope;
}

.expanded {
Expand Down Expand Up @@ -599,6 +599,9 @@ padding-left: 0;
background: transparent;
border: none;
cursor: pointer;
height: 100%;
width: 50px;
background-color: transparent !important;
}
.password-feedback-container {
margin-top: 8px;
Expand All @@ -616,10 +619,6 @@ padding-left: 0;
height: 20px;
}

.show-password-btn{
background-color: transparent !important;
}

.search-bar-wrapper{
flex-grow: 1;
margin-right: 1rem;
Expand Down Expand Up @@ -755,7 +754,7 @@ padding-left: 0;

/*Form Label*/
.form-control{
font-family: 'Manrope';
font-family: Manrope;
font-size: 1rem;
font-weight: bold;
}
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/MatchReviewers/MatchReviewersForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,23 @@ const MatchReviewersForm = ({
updateInputFieldsErrors("selectedModal", "Required");
noError = false;
}

if (!inputFields.numberOfTopReviewers) {
updateInputFieldsErrors("numberOfTopReviewers", "Required");
noError = false;
} else if (isNaN(inputFields.numberOfTopReviewers) || inputFields.numberOfTopReviewers < 0) {
updateInputFieldsErrors("numberOfTopReviewers", "Must be a valid positive number.");
noError = false;
}

if (!inputFields.closeCollaboratorTimeFrame) {
updateInputFieldsErrors("closeCollaboratorTimeFrame", "Required");
noError = false;
} else if (isNaN(inputFields.closeCollaboratorTimeFrame) || inputFields.closeCollaboratorTimeFrame < 0) {
updateInputFieldsErrors("closeCollaboratorTimeFrame", "Must be a valid positive number.");
noError = false;
}

if (textAreaError) {
setTextAreaError("Required");
noError = false;
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/util/Logs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const Logs = ({
preventClick,
setShowLogs,
mode,
usePrompt,
currentCycle,
currentTaskId,
}) => {
Expand All @@ -41,8 +40,6 @@ const Logs = ({
? "Process Successful!"
: "Process Failed!";

usePrompt("A process is running. Do you really want to leave?", progressPercentage < 100);

return (
<>
<ProgressBar
Expand Down
94 changes: 54 additions & 40 deletions frontend/src/components/util/PageComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Logs from "./Logs.jsx";
import { UNSAFE_NavigationContext as NavigationContext } from "react-router-dom";
import { fetchTableData, terminateCurrentProcess } from "./Api.jsx";
import ToastContext from "../../context/ToastContext.jsx";
import { useNavigate, useLocation } from "react-router-dom";

const PageComponent = ({
allCycles,
Expand All @@ -31,6 +32,9 @@ const PageComponent = ({
const logContainerRef = useRef(null);
const [loading, setLoading] = useState(false);

const navigate = useNavigate();
const location = useLocation();

// Function for showing toasts
const { showToastMessage } = useContext(ToastContext);

Expand Down Expand Up @@ -157,55 +161,66 @@ const PageComponent = ({
[setInputFields]
);

function useConfirmExit(confirmExit, when = true) {
const { navigator } = useContext(NavigationContext);

function useCustomBlocker(progressPercentage, message) {
useEffect(() => {
if (!when) {
return;
}

const push = navigator.push;

navigator.push = (...args) => {
const result = confirmExit();
if (result !== false) {
push(...args);
if (progressPercentage <= 0 || progressPercentage >= 100) return;

const handlePopState = async(event) => {
event.preventDefault();
const stay = window.confirm(message);
if (stay) {
// If user chooses to stay, do nothing
window.history.pushState(null, "", location.pathname); // This keeps them on the current page
} else {
// If they choose to leave, you can handle any cleanup here
await terminateAllProcesses();
navigate(-1);
}
};


window.addEventListener("popstate", handlePopState);

return () => {
navigator.push = push;
window.removeEventListener("popstate", handlePopState);
};
}, [navigator, confirmExit, when]);
}

function usePrompt(message, when = true) {
}, [progressPercentage, message]);

useEffect(() => {
const handleBeforeUnload = async (event) => {
event.preventDefault();
event.returnValue = message;
await terminateAllProcesses();
return "";
};
if (when) {
if (progressPercentage > 0 && progressPercentage < 100) {
let isLeaving = false;

const handleBeforeUnload = (event) => {
event.preventDefault();
event.returnValue = message;
};

const handleUnload = async () => {
if (isLeaving) {
await terminateAllProcesses();
}
};

const handleConfirmLeave = () => {
isLeaving = true;
};

window.addEventListener("beforeunload", handleBeforeUnload);
window.addEventListener("unload", handleUnload);
window.addEventListener("beforeunload", handleConfirmLeave);

return () => {
window.removeEventListener("beforeunload", handleBeforeUnload);
window.removeEventListener("unload", handleUnload);
window.removeEventListener("beforeunload", handleConfirmLeave);
};
}
return () => {
window.removeEventListener("beforeunload", handleBeforeUnload);
};
}, [message, when]);

const confirmExit = useCallback(() => {
const confirm = window.confirm(message);
if (confirm) {
terminateAllProcesses();
}
return confirm;
}, [message]);
useConfirmExit(confirmExit, when);
}, [progressPercentage, message]);
}

useCustomBlocker(progressPercentage,
"A process is running. Do you really want to leave?"
);

return (
<>
{renderFormComponent({
Expand Down Expand Up @@ -238,7 +253,6 @@ const PageComponent = ({
) : showLogs ? (
<Logs
currentTaskId={currentTaskId}
usePrompt={usePrompt}
currentCycle={inputFields["currentCycle"]}
setShowTable={setShowTable}
terminateAllProcesses={terminateAllProcesses}
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/components/util/PasswordInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const PasswordInput = ({ label, value, setValue, error, desc, disabled }) => {
{label}
</label>
</div>
<div className={`input-group`}>
<div className="input-group" style={{ position: 'relative' }}>
<input
type={showPassword ? "text" : "password"}
value={value}
Expand All @@ -38,6 +38,7 @@ const PasswordInput = ({ label, value, setValue, error, desc, disabled }) => {
}${disabled ? "disabled" : ""}`}
disabled={disabled}
autoFocus
style={{ paddingRight: '40px' }} // Adjust padding to make space for the button
/>
{error && (
<img
Expand All @@ -51,7 +52,10 @@ const PasswordInput = ({ label, value, setValue, error, desc, disabled }) => {
type="button"
className="show-password-btn"
disabled={disabled}
style={{ right: error ? "45px" : "" }}
style={{
position: 'absolute',
right: '1px',
}}
>
<img
src={showPassword ? HidePasswordIcon : ShowPasswordIcon}
Expand Down