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

Update sort and filter defaults #44855

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion airflow/ui/src/components/TimeRangeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const defaultTimeOptions = createListCollection({
{ label: "Last 1 hour", value: "1" },
{ label: "Last 12 hours", value: "12" },
{ label: "Last 24 hours", value: "24" },
{ label: "Last week", value: "168" },
{ label: "Past week", value: "168" },
],
});

Expand Down
2 changes: 1 addition & 1 deletion airflow/ui/src/pages/Dag/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import TimeRangeSelector from "src/components/TimeRangeSelector";
import { TrendCountButton } from "src/components/TrendCountButton";
import { stateColor } from "src/utils/stateColor";

const defaultHour = "12";
const defaultHour = "168";
tirkarthi marked this conversation as resolved.
Show resolved Hide resolved

export const Overview = () => {
const { dagId } = useParams();
Expand Down
9 changes: 8 additions & 1 deletion airflow/ui/src/pages/Dag/Runs/Runs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ export const Runs = () => {

const [searchParams, setSearchParams] = useSearchParams();

const { setTableURLState, tableURLState } = useTableURLState();
const { setTableURLState, tableURLState } = useTableURLState({
sorting: [
{
desc: true,
id: "start_date",
},
],
});
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
const orderBy = sort ? `${sort.desc ? "-" : ""}${sort.id}` : undefined;
Expand Down
20 changes: 15 additions & 5 deletions airflow/ui/src/pages/DagsList/DagsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ const columns: Array<ColumnDef<DAGWithLatestDagRunsResponse>> = [
nextDagrunCreateAfter={original.next_dagrun_create_after}
/>
) : undefined,
enableSorting: false,
header: "Next Dag Run",
},
{
accessorKey: "latest_dag_runs",
accessorKey: "last_run_start_date",
cell: ({ row: { original } }) =>
original.latest_dag_runs[0] ? (
<DagRunInfo
Expand All @@ -115,7 +114,6 @@ const columns: Array<ColumnDef<DAGWithLatestDagRunsResponse>> = [
state={original.latest_dag_runs[0].state}
/>
) : undefined,
enableSorting: false,
header: "Last Dag Run",
},
{
Expand Down Expand Up @@ -171,7 +169,15 @@ export const DagsList = () => {
) as DagRunState;
const selectedTags = searchParams.getAll(TAGS_PARAM);

const { setTableURLState, tableURLState } = useTableURLState();
const { setTableURLState, tableURLState } = useTableURLState({
sorting: [
{
desc: true,
id: "last_run_start_date",
},
],
});

const { pagination, sorting } = tableURLState;
const [dagDisplayNamePattern, setDagDisplayNamePattern] = useState(
searchParams.get(NAME_PATTERN_PARAM) ?? undefined,
Expand Down Expand Up @@ -254,7 +260,11 @@ export const DagsList = () => {
<DataTable
cardDef={cardDef}
columns={columns}
data={data.dags}
// We need to rename latest_dag_runs so that react-table can handle the sort correctly
data={data.dags.map((dag) => ({
...dag,
last_run_start_date: dag.latest_dag_runs,
bbovenzi marked this conversation as resolved.
Show resolved Hide resolved
}))}
displayMode={display}
errorMessage={<ErrorAlert error={error} />}
initialState={tableURLState}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { DagRunMetrics } from "./DagRunMetrics";
import { MetricSectionSkeleton } from "./MetricSectionSkeleton";
import { TaskInstanceMetrics } from "./TaskInstanceMetrics";

const defaultHour = "12";
const defaultHour = "168";

export const HistoricalMetrics = () => {
const now = dayjs();
Expand Down
9 changes: 8 additions & 1 deletion airflow/ui/src/pages/Run/TaskInstances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ const columns: Array<ColumnDef<TaskInstanceResponse>> = [

export const TaskInstances = () => {
const { dagId = "", runId = "" } = useParams();
const { setTableURLState, tableURLState } = useTableURLState();
const { setTableURLState, tableURLState } = useTableURLState({
sorting: [
{
desc: true,
id: "start_date",
},
],
});
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
const orderBy = sort ? `${sort.desc ? "-" : ""}${sort.id}` : undefined;
Expand Down
9 changes: 8 additions & 1 deletion airflow/ui/src/pages/Task/Instances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ const columns = (

export const Instances = () => {
const { dagId = "", taskId } = useParams();
const { setTableURLState, tableURLState } = useTableURLState();
const { setTableURLState, tableURLState } = useTableURLState({
sorting: [
{
desc: true,
id: "start_date",
},
],
});
const { pagination, sorting } = tableURLState;
const [sort] = sorting;
const orderBy = sort ? `${sort.desc ? "-" : ""}${sort.id}` : undefined;
Expand Down