-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INN 2962 Add status filter to runs (#1295)
* Add empty state * Add Skeleton * Add status filter * Adjust code * Format duration * Use remix icons * Wire api * Add status filter to query * Fix * Simplify html
- Loading branch information
1 parent
61d7151
commit 6c37b6a
Showing
8 changed files
with
355 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
...rganization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/mockedRuns.ts
This file was deleted.
Oops, something went wrong.
92 changes: 68 additions & 24 deletions
92
...pp/(organization-active)/(dashboard)/env/[environmentSlug]/functions/[slug]/runs/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,82 @@ | ||
'use client'; | ||
|
||
// import { useQuery } from 'urql'; | ||
import { Button } from '@inngest/components/Button'; | ||
import { RiLoopLeftLine } from '@remixicon/react'; | ||
import { useQuery } from 'urql'; | ||
|
||
// import { useEnvironment } from '@/app/(organization-active)/(dashboard)/env/[environmentSlug]/environment-context'; | ||
// import { graphql } from '@/gql'; | ||
import { useEnvironment } from '@/app/(organization-active)/(dashboard)/env/[environmentSlug]/environment-context'; | ||
import { graphql } from '@/gql'; | ||
import { FunctionRunStatus } from '@/gql/graphql'; | ||
import { useStringArraySearchParam } from '@/utils/useSearchParam'; | ||
import StatusFilter from '../logs/StatusFilter'; | ||
import RunsTable from './RunsTable'; | ||
import { mockedRuns } from './mockedRuns'; | ||
|
||
// const GetRunsDocument = graphql(` | ||
// query GetRuns($environmentID: ID!) { | ||
// workspace(id: $environmentID) { | ||
// runs { | ||
// } | ||
// } | ||
// } | ||
// `); | ||
const GetRunsDocument = graphql(` | ||
query GetRuns($environmentID: ID!, $startTime: Time!, $status: [FunctionRunStatus!]) { | ||
environment: workspace(id: $environmentID) { | ||
runs( | ||
filter: { from: $startTime, status: $status } | ||
orderBy: [{ field: QUEUED_AT, direction: ASC }] | ||
) { | ||
edges { | ||
node { | ||
id | ||
queuedAt | ||
endedAt | ||
durationMS | ||
status | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`); | ||
|
||
export default function RunsPage() { | ||
// const environment = useEnvironment(); | ||
// const [{ data, fetching: fetchingRuns }] = useQuery({ | ||
// query: GetRunsDocument, | ||
// variables: { | ||
// environmentID: environment.id, | ||
// // filter: filtering, | ||
// }, | ||
// }); | ||
const [filteredStatus, setFilteredStatus, removeFilteredStatus] = | ||
useStringArraySearchParam('filterStatus'); | ||
|
||
const runs = mockedRuns; | ||
function handleStatusesChange(statuses: FunctionRunStatus[]) { | ||
if (statuses.length > 0) { | ||
setFilteredStatus(statuses); | ||
} else { | ||
removeFilteredStatus(); | ||
} | ||
} | ||
|
||
const environment = useEnvironment(); | ||
const [{ data, fetching: fetchingRuns }, refetch] = useQuery({ | ||
query: GetRunsDocument, | ||
variables: { | ||
environmentID: environment.id, | ||
startTime: '2024-04-19T11:26:03.203Z', | ||
status: filteredStatus ? (filteredStatus as FunctionRunStatus[]) : null, | ||
}, | ||
}); | ||
|
||
{ | ||
/* TODO: This is a temp parser */ | ||
} | ||
const runs = data?.environment.runs.edges.map((edge) => ({ | ||
id: edge.node.id, | ||
queuedAt: edge.node.queuedAt, | ||
endedAt: edge.node.endedAt, | ||
durationMS: edge.node.durationMS, | ||
status: edge.node.status, | ||
})); | ||
|
||
return ( | ||
<main className="bg-white"> | ||
<div className="m-8 flex gap-2">{/* TODO: filters */}</div> | ||
<main className="h-full min-h-0 overflow-y-auto bg-white"> | ||
<div className="flex justify-between gap-2 bg-slate-50 px-8 py-2"> | ||
<StatusFilter | ||
selectedStatuses={filteredStatus ? (filteredStatus as FunctionRunStatus[]) : []} | ||
onStatusesChange={handleStatusesChange} | ||
/> | ||
{/* TODO: wire button */} | ||
<Button label="Refresh" appearance="text" btnAction={refetch} icon={<RiLoopLeftLine />} /> | ||
</div> | ||
{/* @ts-ignore */} | ||
<RunsTable data={runs} /> | ||
<RunsTable data={runs} isLoading={fetchingRuns} /> | ||
</main> | ||
); | ||
} |
Oops, something went wrong.