mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 06:09:08 +03:00
* feat: workflow run logs * progress * adds logs modal * remove menu item * output raw text * update parseAs * accept text/plain * cleanup ui * feature flag new logs * fix types * fix condition * cleanup spacing * loading spacing * cheeky console.log * more log * split logs properly * add workflow logs to prod branches * address some feedback * Some UI tweaks * More UI tweak * More UI tweak --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
|
|
import { get, handleError } from 'data/fetchers'
|
|
import type { ResponseError } from 'types'
|
|
import { workflowRunKeys } from './keys'
|
|
|
|
export type WorkflowRunsVariables = {
|
|
projectRef?: string
|
|
}
|
|
|
|
export async function getWorkflowRuns({ projectRef }: WorkflowRunsVariables, signal?: AbortSignal) {
|
|
if (!projectRef) throw new Error('projectRef is required')
|
|
|
|
const { data, error } = await get(`/platform/workflow-runs`, {
|
|
params: {
|
|
query: {
|
|
project_ref: projectRef,
|
|
},
|
|
},
|
|
signal,
|
|
})
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type WorkflowRunsData = Awaited<ReturnType<typeof getWorkflowRuns>>
|
|
export type WorkflowRunsError = ResponseError
|
|
|
|
export const useWorkflowRunsQuery = <TData = WorkflowRunsData>(
|
|
{ projectRef }: WorkflowRunsVariables,
|
|
{ enabled = true, ...options }: UseQueryOptions<WorkflowRunsData, WorkflowRunsError, TData> = {}
|
|
) =>
|
|
useQuery<WorkflowRunsData, WorkflowRunsError, TData>(
|
|
workflowRunKeys.list(projectRef),
|
|
({ signal }) => getWorkflowRuns({ projectRef }, signal),
|
|
{ enabled: enabled && typeof projectRef !== 'undefined', staleTime: 0, ...options }
|
|
)
|