Skip to content

Commit

Permalink
DEVPROD-6448: Update task duration links to route to latest execution…
Browse files Browse the repository at this point in the history
… (fixed) (#310)
  • Loading branch information
sophiabarness authored Aug 14, 2024
1 parent 83b9c64 commit 3f769db
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 70 deletions.
96 changes: 50 additions & 46 deletions apps/spruce/src/pages/version/taskDuration/TaskDurationTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
SortingState,
getFacetedMinMaxValues,
useLeafyGreenTable,
LGColumnDef,
LeafyGreenTable,
} from "@leafygreen-ui/table";
import { useParams } from "react-router-dom";
import { useVersionAnalytics } from "analytics";
Expand All @@ -19,13 +21,17 @@ import { VersionTaskDurationsQuery, SortDirection } from "gql/generated/types";
import { useTaskStatuses } from "hooks";
import { useQueryParams } from "hooks/useQueryParam";
import { PatchTasksQueryParams } from "types/task";
import { Unpacked } from "types/utils";
import { TaskDurationCell } from "./TaskDurationCell";

const { getDefaultOptions: getDefaultFiltering } = ColumnFiltering;
const { getDefaultOptions: getDefaultSorting } = RowSorting;

type TaskDurationData = Unpacked<
VersionTaskDurationsQuery["version"]["tasks"]["data"]
>;
interface Props {
tasks: VersionTaskDurationsQuery["version"]["tasks"]["data"];
tasks: TaskDurationData[];
loading: boolean;
numLoadingRows: number;
}
Expand All @@ -48,7 +54,6 @@ export const TaskDurationTable: React.FC<Props> = ({
[], // eslint-disable-line react-hooks/exhaustive-deps
);

// @ts-expect-error: FIXME. This comment was added by an automated script.
const setFilters = (f: ColumnFiltersState) =>
// @ts-expect-error: FIXME. This comment was added by an automated script.
getDefaultFiltering(table).onColumnFiltersChange(f);
Expand Down Expand Up @@ -93,7 +98,7 @@ export const TaskDurationTable: React.FC<Props> = ({
setQueryParams(updatedParams);
};

const columns = useMemo(
const columns: LGColumnDef<TaskDurationData>[] = useMemo(
() => [
{
id: PatchTasksQueryParams.TaskName,
Expand All @@ -102,13 +107,17 @@ export const TaskDurationTable: React.FC<Props> = ({
size: 250,
enableColumnFilter: true,
cell: ({
// @ts-expect-error: FIXME. This comment was added by an automated script.
getValue,
row: {
// @ts-expect-error: FIXME. This comment was added by an automated script.
original: { id },
original: { execution, id },
},
}) => <TaskLink taskId={id} taskName={getValue()} />,
}) => (
<TaskLink
taskId={id}
taskName={getValue() as string}
execution={execution}
/>
),
meta: {
search: {
"data-cy": "task-name-filter-popover",
Expand Down Expand Up @@ -150,19 +159,16 @@ export const TaskDurationTable: React.FC<Props> = ({
enableSorting: true,
size: 250,
cell: ({
// @ts-expect-error: FIXME. This comment was added by an automated script.
column,
// @ts-expect-error: FIXME. This comment was added by an automated script.
getValue,
row: {
// @ts-expect-error: FIXME. This comment was added by an automated script.
original: { status },
},
}) => (
<TaskDurationCell
status={status}
maxTimeTaken={column.getFacetedMinMaxValues()?.[1] ?? 0}
timeTaken={getValue()}
timeTaken={getValue() as number}
/>
),
},
Expand All @@ -171,44 +177,42 @@ export const TaskDurationTable: React.FC<Props> = ({
);

const tableContainerRef = useRef<HTMLDivElement>(null);
// @ts-expect-error: FIXME. This comment was added by an automated script.
const table = useLeafyGreenTable<
VersionTaskDurationsQuery["version"]["tasks"]["data"][0]
>({
columns,
containerRef: tableContainerRef,
// @ts-expect-error: FIXME. This comment was added by an automated script.
data: tasks ?? [],
defaultColumn: {
// Handle bug in sorting order
// https://github.com/TanStack/table/issues/4289
sortDescFirst: false,
},
getFacetedMinMaxValues: getFacetedMinMaxValues(),
initialState: {
columnFilters: initialFilters,
sorting: initialSort,
},
manualFiltering: true,
manualPagination: true,
manualSorting: true,
onColumnFiltersChange: onChangeHandler<ColumnFiltersState>(
const table: LeafyGreenTable<TaskDurationData> =
useLeafyGreenTable<TaskDurationData>({
columns,
containerRef: tableContainerRef,
// @ts-expect-error: FIXME. This comment was added by an automated script.
setFilters,
(updatedState) => {
updateFilters(updatedState);
table.resetRowSelection();
data: tasks ?? [],
defaultColumn: {
// Handle bug in sorting order
// https://github.com/TanStack/table/issues/4289
sortDescFirst: false,
},
),
onSortingChange: onChangeHandler<SortingState>(
// @ts-expect-error: FIXME. This comment was added by an automated script.
setSorting,
(updatedState) => {
updateSort(updatedState);
table.resetRowSelection();
getFacetedMinMaxValues: getFacetedMinMaxValues(),
initialState: {
columnFilters: initialFilters,
sorting: initialSort,
},
),
});
manualFiltering: true,
manualPagination: true,
manualSorting: true,
onColumnFiltersChange: onChangeHandler<ColumnFiltersState>(
// @ts-expect-error: FIXME. This comment was added by an automated script.
setFilters,
(updatedState) => {
updateFilters(updatedState);
table.resetRowSelection();
},
),
onSortingChange: onChangeHandler<SortingState>(
// @ts-expect-error: FIXME. This comment was added by an automated script.
setSorting,
(updatedState) => {
updateSort(updatedState);
table.resetRowSelection();
},
),
});

return (
<BaseTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
</button>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_model_distro_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_model_distro_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -316,7 +316,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/mongodb_mongo_master_enterprise_rhel_80_64_bit_dynamic_all_feature_flags_required_and_cqf_enabled_sharding_last_continuous_01_linux_enterprise_patch_5cab129eb5c35c3ad61ed9e5156539556d85dcd1_65241908850e61e75776c5c2_23_10_09_15_17_56"
href="/task/mongodb_mongo_master_enterprise_rhel_80_64_bit_dynamic_all_feature_flags_required_and_cqf_enabled_sharding_last_continuous_01_linux_enterprise_patch_5cab129eb5c35c3ad61ed9e5156539556d85dcd1_65241908850e61e75776c5c2_23_10_09_15_17_56?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -393,7 +393,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/mongodb_mongo_master_enterprise_rhel_80_64_bit_dynamic_all_feature_flags_required_and_cqf_enabled_sharding_last_continuous_02_linux_enterprise_patch_5cab129eb5c35c3ad61ed9e5156539556d85dcd1_65241908850e61e75776c5c2_23_10_09_15_17_56"
href="/task/mongodb_mongo_master_enterprise_rhel_80_64_bit_dynamic_all_feature_flags_required_and_cqf_enabled_sharding_last_continuous_02_linux_enterprise_patch_5cab129eb5c35c3ad61ed9e5156539556d85dcd1_65241908850e61e75776c5c2_23_10_09_15_17_56?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -477,7 +477,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_rest_data_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_rest_data_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -567,7 +567,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_agent_internal_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_agent_internal_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -657,7 +657,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_evergreen_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_evergreen_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -747,7 +747,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_model_artifact_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_model_artifact_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -837,7 +837,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_thirdparty_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_thirdparty_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -927,7 +927,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_model_event_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_model_event_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -1017,7 +1017,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_model_testresult_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_model_testresult_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -1107,7 +1107,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_model_alertrecord_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_model_alertrecord_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down Expand Up @@ -1197,7 +1197,7 @@
>
<a
class="lg-ui-0001 css-1gw3cuq-StyledLink leafygreen-ui-sv8tvj"
href="/task/evg_ubuntu1604_container_test_model_patch_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18"
href="/task/evg_ubuntu1604_container_test_model_patch_fd73e06c7bc6c5dcdf7a671dece0153916e64212_23_01_04_16_01_18?execution=0"
>
<span>
<span
Expand Down
Loading

0 comments on commit 3f769db

Please sign in to comment.