move apiRequest to reduce circular dependencies
Change-Id: I60446bd1e2141160b8fcbc0e13973b89bfe31d07 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/335751 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Michael Hulse <michael.hulse@instructure.com> QA-Review: Aaron Shafovaloff <ashafovaloff@instructure.com> Product-Review: Aaron Shafovaloff <ashafovaloff@instructure.com>
This commit is contained in:
parent
f56735663d
commit
dc4f0a11c9
|
@ -18,7 +18,7 @@
|
|||
|
||||
import React from 'react'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
import type {HandleCheckboxChange} from '../../../types'
|
||||
import CheckboxTemplate from './CheckboxTemplate'
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import React from 'react'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import type {CustomColumn, HandleCheckboxChange, TeacherNotes} from '../../../types'
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
import CheckboxTemplate from './CheckboxTemplate'
|
||||
|
||||
const I18n = useI18nScope('enhanced_individual_gradebook')
|
||||
|
|
|
@ -30,13 +30,13 @@ import {
|
|||
} from './fixtures'
|
||||
import {GRADEBOOK_SUBMISSION_COMMENTS} from '../../../../queries/Queries'
|
||||
import {MockedProvider} from '@apollo/react-testing'
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
import type {
|
||||
AssignmentConnection,
|
||||
GradebookUserSubmissionDetails,
|
||||
} from 'features/enhanced_individual_gradebook/types'
|
||||
|
||||
jest.mock('@canvas/util/apiRequest', () => ({
|
||||
jest.mock('@canvas/do-fetch-api-effect/apiRequest', () => ({
|
||||
executeApiRequest: jest.fn(),
|
||||
}))
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ import userSettings from '@canvas/user-settings'
|
|||
import {GradebookSortOrder} from '../../../types/gradebook.d'
|
||||
import * as ReactRouterDom from 'react-router-dom'
|
||||
import doFetchApi from '@canvas/do-fetch-api-effect'
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
|
||||
jest.mock('axios') // mock axios for final grade override helper API call
|
||||
jest.mock('@canvas/do-fetch-api-effect', () => jest.fn()) // mock doFetchApi for final grade override helper API call
|
||||
jest.mock('@canvas/util/apiRequest', () => ({
|
||||
jest.mock('@canvas/do-fetch-api-effect/apiRequest', () => ({
|
||||
executeApiRequest: jest.fn(),
|
||||
}))
|
||||
const mockedAxios = axios as jest.Mocked<typeof axios>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import {useCallback, useEffect, useState} from 'react'
|
||||
import {useQuery} from 'react-apollo'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
|
||||
import {GRADEBOOK_SUBMISSION_COMMENTS} from '../../queries/Queries'
|
||||
import {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import {useEffect, useState} from 'react'
|
||||
import type {CustomColumn} from '../../types'
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
|
||||
export const useCustomColumns = (getCustomColumnsUrl?: string | null) => {
|
||||
const [customColumns, setCustomColumns] = useState<CustomColumn[] | null>(null)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
import {useCallback, useState} from 'react'
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
|
||||
import {ApiCallStatus, type SubmissionGradeChange} from '../../types'
|
||||
import {mapToSubmissionGradeChange} from '../../utils/gradebookUtils'
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import {useEffect, useState} from 'react'
|
||||
import {ApiCallStatus, type CustomColumnDatum} from '../../types'
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
|
||||
const I18n = useI18nScope('enhanced_individual_gradebook_submit_score')
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {executeApiRequest} from '@canvas/util/apiRequest'
|
||||
import {executeApiRequest} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
import GradeFormatHelper from '@canvas/grading/GradeFormatHelper'
|
||||
import {useScope as useI18nScope} from '@canvas/i18n'
|
||||
import numberHelper from '@canvas/i18n/numberHelper'
|
||||
|
|
|
@ -37,7 +37,7 @@ import useStore from '../stores'
|
|||
import {gradeOverrideCustomStatus} from '../FinalGradeOverrides/FinalGradeOverride.utils'
|
||||
import {useFinalGradeOverrideCustomStatus} from '../hooks/useFinalGradeOverrideCustomStatus'
|
||||
import {showFlashError} from '@canvas/alerts/react/FlashAlert'
|
||||
import {ApiCallStatus} from '@canvas/util/apiRequest'
|
||||
import {ApiCallStatus} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
|
||||
const I18n = useI18nScope('gradebook')
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import React from 'react'
|
|||
import {render, fireEvent} from '@testing-library/react'
|
||||
|
||||
import GradeOverrideEntry from '@canvas/grading/GradeEntry/GradeOverrideEntry'
|
||||
import {ApiCallStatus} from '@canvas/util/apiRequest'
|
||||
import {ApiCallStatus} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
import {TotalGradeOverrideTray, type TotalGradeOverrideTrayProps} from '../TotalGradeOverrideTray'
|
||||
import useStore from '../../stores'
|
||||
import * as FinalGradeOverrideHooks from '../../hooks/useFinalGradeOverrideCustomStatus'
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import {useState} from 'react'
|
||||
import {useMutation} from 'react-apollo'
|
||||
import gql from 'graphql-tag'
|
||||
import {ApiCallStatus} from '@canvas/util/apiRequest'
|
||||
import {ApiCallStatus} from '@canvas/do-fetch-api-effect/apiRequest'
|
||||
|
||||
const SET_OVERRIDE_STATUS_MUTATION = gql`
|
||||
mutation SetOverrideStatusMutation(
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import doFetchApi from '@canvas/do-fetch-api-effect'
|
||||
import doFetchApi from './index'
|
||||
|
||||
export type ApiResponse<T> = {
|
||||
data: T
|
||||
|
@ -36,6 +36,7 @@ export type ApiRequest = {
|
|||
}
|
||||
|
||||
export async function executeApiRequest<T>(request: ApiRequest): Promise<ApiResponse<T>> {
|
||||
// @ts-expect-error
|
||||
const {json, response, link} = await doFetchApi(request)
|
||||
|
||||
return {
|
Loading…
Reference in New Issue