Skip to content

Commit

Permalink
refactor(ui): Selected job details
Browse files Browse the repository at this point in the history
  • Loading branch information
pando85 committed Jan 26, 2024
1 parent d846870 commit c85b121
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions server/web/ui/src/JobTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const renderPath = (isSmallScreen: boolean, path: string) => {
const JobTable: React.FC<JobTableProps> = ({ token, setShowJobTable }) => {
const [filteredJobs, setFilteredJobs] = useState<Job[]>([]);
const [selectedJob, setSelectedJob] = useState<Job | null>(null);
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); // For menu anchor
const [buttonsMenu, setButtonsMenu] = useState<null | HTMLElement>(null); // For menu anchor
const [nameFilter, setNameFilter] = useState<string>(''); // State for name filter
const [selectedStatusFilter, setSelectedStatus] = useState<string | string[]>([]);
const [selectedDateFilter, setSelectedDateFilter] = useState<string>('');
Expand Down Expand Up @@ -173,13 +173,17 @@ const JobTable: React.FC<JobTableProps> = ({ token, setShowJobTable }) => {
};

const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
setButtonsMenu(event.currentTarget);
};

const handleClose = () => {
setAnchorEl(null);
setButtonsMenu(null);
};

const handleCloseDetailsMenu = () => {
setDetailsMenuAnchor(null);
}

const handleMenuOptionClick = (job: Job | null, option: string) => {
if (job !== null) {
if (['delete', 'recreate'].includes(option)) {
Expand Down Expand Up @@ -383,20 +387,20 @@ const JobTable: React.FC<JobTableProps> = ({ token, setShowJobTable }) => {
<div className="row-menu">
{formatDateShort(job.last_update)}
<Button
className="simple-menu"
aria-controls="simple-menu"
className="buttons-menu"
aria-controls="buttons-menu"
aria-haspopup="true"
onClick={handleClick}
size="small"
>
<MoreVert />
</Button>
<Menu
id="simple-menu"
className="simple-menu"
anchorEl={anchorEl}
id="buttons-menu"
className="buttons-menu"
anchorEl={buttonsMenu}
keepMounted
open={Boolean(anchorEl)}
open={Boolean(buttonsMenu)}
onClose={handleClose}
>
<MenuItem title="Details" onClick={(event) => handleDetailedViewClick(event)}>
Expand All @@ -415,7 +419,7 @@ const JobTable: React.FC<JobTableProps> = ({ token, setShowJobTable }) => {
anchorEl={detailsMenuAnchor}
keepMounted
open={Boolean(detailsMenuAnchor)}
onClose={() => setDetailsMenuAnchor(null)}
onClose={handleCloseDetailsMenu}
>
{selectedJob && [
<MenuItem key="job-details">
Expand Down

0 comments on commit c85b121

Please sign in to comment.