Skip to content

Commit 0963625

Browse files
committed
fix: mobile ux
1 parent ef259eb commit 0963625

5 files changed

Lines changed: 37 additions & 20 deletions

File tree

packages/diracx-web-components/src/components/JobMonitor/JobDataTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { Delete, Clear } from "@mui/icons-material";
1414
import {
1515
useReactTable,
1616
getCoreRowModel,
17-
ColumnDef,
1817
ColumnPinningState,
1918
RowSelectionState,
2019
VisibilityState,
@@ -26,6 +25,7 @@ import type { ToolbarAction } from "../shared/DataTable/SplitActionButton";
2625
import { Job, JobHistory, SearchBody } from "../../types";
2726
import { useDiracxUrl } from "../../hooks/utils";
2827
import { JobHistoryDialog } from "./JobHistoryDialog";
28+
import { JobColumnDef } from "./JobMonitorContext";
2929

3030
import {
3131
deleteJobs,
@@ -48,7 +48,7 @@ interface JobDataTableProps {
4848
/** The function to call when the search body changes */
4949
setSearchBody: React.Dispatch<React.SetStateAction<SearchBody>>;
5050
/** Columns */
51-
columns: ColumnDef<Job, string | number | Date | null>[];
51+
columns: JobColumnDef[];
5252
/** Pagination */
5353
pagination: PaginationState;
5454
/** Set pagination */

packages/diracx-web-components/src/components/JobMonitor/JobMonitor.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717

1818
import { lighten, darken, useTheme, Box, Paper } from "@mui/material";
1919

20-
import { createColumnHelper, ColumnDef } from "@tanstack/react-table";
20+
import { createColumnHelper } from "@tanstack/react-table";
2121

2222
import { mutate } from "swr";
2323
import { useApplicationId } from "../../hooks/application";
@@ -31,6 +31,7 @@ import { getSearchJobUrl } from "./jobDataService";
3131
import {
3232
JobMonitorContext,
3333
JobMonitorState,
34+
JobColumnDef,
3435
jobMonitorReducer,
3536
defaultColumnVisibility,
3637
defaultPagination,
@@ -42,29 +43,34 @@ const rootSx = {
4243
flexDirection: "column",
4344
flexGrow: 1,
4445
overflow: "hidden",
46+
maxWidth: "100%",
4547
} as const;
4648

4749
const contentSx = {
4850
display: "flex",
4951
flexDirection: { xs: "column", md: "row" },
5052
flexGrow: 1,
51-
overflow: "hidden",
53+
overflow: { xs: "auto", md: "hidden" },
54+
minWidth: 0,
5255
} as const;
5356

5457
const tableSx = {
5558
flexGrow: 1,
5659
minWidth: 0,
60+
maxWidth: "100%",
5761
overflow: "auto",
5862
display: "flex",
5963
flexDirection: "column",
6064
} as const;
6165

6266
const pieChartPaperSx = {
63-
width: { md: 340 },
67+
width: { xs: "100%", md: 340 },
68+
maxWidth: "100%",
6469
flexShrink: 0,
6570
alignSelf: "flex-start",
6671
m: 1,
6772
borderRadius: 2,
73+
boxSizing: "border-box",
6874
} as const;
6975

7076
function loadInitialState(appId: string): JobMonitorState {
@@ -517,7 +523,7 @@ export function validateAndConvertState(state: string): [string, boolean] {
517523
*/
518524
export function fromHumanReadableText(
519525
name: string,
520-
columns: ColumnDef<Job, string | number | Date | null>[],
526+
columns: JobColumnDef[],
521527
): string {
522528
const index = columns.findIndex((column) => column.header === name);
523529
if (index !== -1) {

packages/diracx-web-components/src/components/JobMonitor/JobMonitorContext.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import {
1111
import { Filter } from "../../types/Filter";
1212
import { Job, SearchBody } from "../../types";
1313

14+
/**
15+
* TanStack Table's ColumnDef is invariant on TValue, so a heterogeneous
16+
* column array (mixing string, number, Date columns) cannot be typed with
17+
* a single concrete TValue. We use `any` here as an intentional escape hatch.
18+
*/
19+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20+
export type JobColumnDef = ColumnDef<Job, any>;
21+
1422
export interface JobMonitorState {
1523
filters: Filter[];
1624
searchBody: SearchBody;
@@ -48,11 +56,8 @@ export type JobMonitorAction =
4856
}
4957
| {
5058
type: "APPLY_FILTERS";
51-
columns: ColumnDef<Job, string | number | Date | null>[];
52-
fromHumanReadableText: (
53-
name: string,
54-
columns: ColumnDef<Job, string | number | Date | null>[],
55-
) => string;
59+
columns: JobColumnDef[];
60+
fromHumanReadableText: (name: string, columns: JobColumnDef[]) => string;
5661
};
5762

5863
export const defaultColumnVisibility: VisibilityState = {
@@ -146,7 +151,7 @@ export function jobMonitorReducer(
146151
interface JobMonitorContextValue {
147152
state: JobMonitorState;
148153
dispatch: React.Dispatch<JobMonitorAction>;
149-
columns: ColumnDef<Job, string | number | Date | null>[];
154+
columns: JobColumnDef[];
150155
statusColors: Record<string, string>;
151156
mutateJobs: () => void;
152157
}

packages/diracx-web-components/src/components/JobMonitor/JobPieChart.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { useState, useCallback, useMemo, memo } from "react";
33

44
import { useOidcAccessToken } from "@axa-fr/react-oidc";
5-
import { ColumnDef } from "@tanstack/react-table";
65
import {
76
Box,
87
Alert,
@@ -12,11 +11,12 @@ import {
1211
} from "@mui/material";
1312

1413
import { useDiracxUrl } from "../../hooks/utils";
15-
import type { SearchBody, Job, Filter, JobSummary } from "../../types";
14+
import type { SearchBody, Filter, JobSummary } from "../../types";
1615
import { useOIDCContext } from "../../hooks/oidcConfiguration";
1716
import { PieChart, PieChartItem } from "../shared/PieChart";
1817
import { useJobSummary } from "./jobDataService";
1918
import { fromHumanReadableText } from "./JobMonitor";
19+
import { JobColumnDef } from "./JobMonitorContext";
2020

2121
interface JobPieChartProps {
2222
/** The search body used for querying */
@@ -26,7 +26,7 @@ interface JobPieChartProps {
2626
/** Status color mapping */
2727
statusColors: Record<string, string>;
2828
/** Column definitions from the table */
29-
columns: ColumnDef<Job, string | number | Date | null>[];
29+
columns: JobColumnDef[];
3030
}
3131

3232
/**

packages/diracx-web-components/src/components/JobMonitor/JobSearchBar.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22

33
import { memo, useCallback, useEffect, useRef, useState } from "react";
4-
import { ColumnDef } from "@tanstack/react-table";
54
import { useOidcAccessToken } from "@axa-fr/react-oidc";
65
import { Box, IconButton, Popover, Typography, Tooltip } from "@mui/material";
76
import { HelpOutline } from "@mui/icons-material";
@@ -18,13 +17,13 @@ import {
1817
SearchBarToken,
1918
SearchBarTokenEquation,
2019
SearchBody,
21-
Job,
2220
Operators,
2321
SearchBarTokenNature,
2422
CategoryType,
2523
} from "../../types";
2624
import { getJobSummary } from "./jobDataService";
2725
import { fromHumanReadableText } from "./JobMonitor";
26+
import { JobColumnDef } from "./JobMonitorContext";
2827

2928
interface JobSearchBarProps {
3029
/** The filters */
@@ -36,7 +35,7 @@ interface JobSearchBarProps {
3635
/** The function to apply the filters */
3736
handleApplyFilters: () => void;
3837
/** The columns to display in the job monitor */
39-
columns: ColumnDef<Job, string | number | Date | null>[];
38+
columns: JobColumnDef[];
4039
/** Function to mutate the job data */
4140
mutateJobs: () => void;
4241
}
@@ -88,7 +87,14 @@ export const JobSearchBar = memo(function JobSearchBar({
8887
);
8988

9089
return (
91-
<Box sx={{ display: "flex", alignItems: "flex-start" }}>
90+
<Box
91+
sx={{
92+
display: "flex",
93+
alignItems: "flex-start",
94+
minWidth: 0,
95+
maxWidth: "100%",
96+
}}
97+
>
9298
<SearchBar
9399
filters={filters}
94100
setFilters={setFilters}
@@ -157,7 +163,7 @@ async function createSuggestions({
157163
accessToken: string | undefined;
158164
previousToken: SearchBarToken | undefined;
159165
previousEquation: SearchBarTokenEquation | undefined;
160-
columns: ColumnDef<Job, string | number | Date | null>[];
166+
columns: JobColumnDef[];
161167
searchBody?: SearchBody;
162168
searchBodyIndex?: number;
163169
}): Promise<SearchBarSuggestions> {

0 commit comments

Comments
 (0)