/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/api-queries/src/github.ts
150 строк
4 KB
Philip Jackson
Dashboard: name mutation failure stats using meta.statId (#112718)
21 июл 2026, 02:52
Не верифицирован
21 июл 2026, 02:52
a08c7c0
Код
Авторство
О чём код?
import { createGithubWorkflow, fetchGithubInstallations, fetchGithubRepositories, fetchGithubRepositoryBranches, fetchGithubRepositoryChecks, fetchGithubWorkflowChecks, fetchGithubWorkflows, fetchGithubWorkflowTemplates, type CreateWorkflowRequest, saveGithubCredentials, } from '@automattic/api-core'; import { queryOptions, mutationOptions } from '@tanstack/react-query'; import { queryClient } from './query-client'; export const githubInstallationsQuery = () => queryOptions( { queryKey: [ 'github', 'installations' ], queryFn: () => fetchGithubInstallations(), meta: { persist: false, }, } ); export const githubRepositoriesQuery = ( installationId: number ) => queryOptions( { queryKey: [ 'github', 'installation', installationId, 'repositories' ], queryFn: () => fetchGithubRepositories( installationId ), meta: { persist: false, }, } ); export const githubRepositoryBranchesQuery = ( installationId: number, repositoryOwner: string, repositoryName: string ) => queryOptions( { queryKey: [ 'github', 'installation', installationId, 'repository', repositoryOwner, repositoryName, 'branches', ], queryFn: () => fetchGithubRepositoryBranches( installationId, repositoryOwner, repositoryName ), meta: { persist: false, }, } ); export const githubRepositoryChecksQuery = ( installationId: number, repositoryOwner: string, repositoryName: string, repositoryBranch: string ) => queryOptions( { queryKey: [ 'github', 'repository-checks', installationId, repositoryOwner, repositoryName, repositoryBranch, ], queryFn: () => fetchGithubRepositoryChecks( installationId, repositoryOwner, repositoryName, repositoryBranch ), meta: { persist: false, }, } ); export const githubWorkflowChecksQuery = ( repositoryOwner: string, repositoryName: string, repositoryBranch: string, workflowFilename: string ) => queryOptions( { queryKey: [ 'github', 'repository-workflow-checks', repositoryOwner, repositoryName, repositoryBranch, workflowFilename, ], queryFn: () => fetchGithubWorkflowChecks( repositoryOwner, repositoryName, repositoryBranch, workflowFilename ), meta: { persist: false, }, } ); export const saveGithubCredentialsMutation = () => mutationOptions( { meta: { statId: 'github-credentials-save' }, mutationFn: ( { accessToken }: { accessToken: string } ) => saveGithubCredentials( accessToken ), onSuccess: () => { queryClient.invalidateQueries( githubInstallationsQuery() ); }, } ); export const githubWorkflowTemplatesQuery = ( repositoryBranch: string, template: 'simple' | 'with_composer' ) => queryOptions( { queryKey: [ 'github', 'repository-workflow-template', repositoryBranch, template ], queryFn: () => fetchGithubWorkflowTemplates( repositoryBranch, template ), } ); export const githubWorkflowsQuery = ( repositoryOwner: string, repositoryName: string, branchName: string ) => queryOptions( { queryKey: [ 'github', 'repository-workflows', repositoryOwner, repositoryName, branchName ], queryFn: () => fetchGithubWorkflows( repositoryOwner, repositoryName, branchName ), meta: { persist: false, }, } ); export const createGithubWorkflowMutation = () => mutationOptions( { meta: { statId: 'github-workflow-create' }, mutationFn: ( request: CreateWorkflowRequest ) => createGithubWorkflow( request ), onSuccess: () => { queryClient.invalidateQueries( { queryKey: [ 'github', 'repository-workflows' ], } ); }, } );