Skip to content

Commit

Permalink
Add listType flag to useListWorkflows
Browse files Browse the repository at this point in the history
  • Loading branch information
adhityamamallan committed Dec 30, 2024
1 parent 14008e9 commit 0557475
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function DomainWorkflowsHeader({ domain, cluster }: Props) {
const { refetch, isFetching } = useListWorkflows({
domain,
cluster,
listType: 'default',
pageSize: DOMAIN_WORKFLOWS_PAGE_SIZE,
inputType: queryParams.inputType,
search: queryParams.search,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function DomainWorkflowsTable({ domain, cluster }: Props) {
} = useListWorkflows({
domain,
cluster,
listType: 'default',
pageSize: DOMAIN_WORKFLOWS_PAGE_SIZE,
inputType: queryParams.inputType,
search: queryParams.search,
Expand Down
24 changes: 15 additions & 9 deletions src/views/shared/hooks/use-list-workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@ export default function useListWorkflows({
domain,
cluster,
pageSize,
inputType,
search,
status,
timeRangeStart,
timeRangeEnd,
sortColumn,
sortOrder,
query,
listType,
...filtersValues
}: UseListWorkflowsParams) {
const {
inputType,
search,
status,
timeRangeStart,
timeRangeEnd,
sortColumn,
sortOrder,
query,
} = filtersValues;

const requestQueryParams = {
inputType,
...(inputType === 'query'
Expand Down Expand Up @@ -53,7 +58,8 @@ export default function useListWorkflows({
url: `/api/domains/${domain}/${cluster}/workflows`,
query: {
...requestQueryParams,
listType: 'default',
listType: listType,
timeColumn: listType === 'archived' ? 'CloseTime' : 'StartTime',
pageSize: pageSize.toString(),
nextPage: pageParam as string,
} as const satisfies ListWorkflowsRequestQueryParams,
Expand Down
14 changes: 10 additions & 4 deletions src/views/shared/hooks/use-list-workflows.types.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { type RouteParams as ListWorkflowsRouteParams } from '@/route-handlers/list-workflows/list-workflows.types';
import {
type ListWorkflowsRequestQueryParams,
type RouteParams as ListWorkflowsRouteParams,
} from '@/route-handlers/list-workflows/list-workflows.types';
import { type SortOrder } from '@/utils/sort-by';

import { type WorkflowStatus } from '../workflow-status-tag/workflow-status-tag.types';
import { type WorkflowsHeaderInputType } from '../workflows-header/workflows-header.types';

export type ListType = ListWorkflowsRequestQueryParams['listType'];

export type UseListWorkflowsParams = ListWorkflowsRouteParams & {
pageSize: number;
inputType: WorkflowsHeaderInputType;
listType: ListType;
search?: string;
status?: WorkflowStatus;
timeRangeStart?: Date;
timeRangeEnd?: Date;
sortColumn: string;
sortOrder: SortOrder;
query: string;
sortColumn?: string;
sortOrder?: SortOrder;
query?: string;
};

0 comments on commit 0557475

Please sign in to comment.