-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cases] Convert remaining hooks to React Query #157254
Merged
Merged
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
615a0fd
Convert useCreateAttachments
cnasikas 5b96c98
Convert usePostPushToService
cnasikas 42ec0ab
Convert useUpdateCase
cnasikas b41526b
Convert useUpdateComment
cnasikas 7f5f203
Fix tests
cnasikas 81e4cee
Fixes
cnasikas 55375b3
Add query client to the cases context
cnasikas e10b9b7
Fix types
cnasikas 362a6a1
Merge branch 'main' into react_query_hooks
kibanamachine 03e46c3
Merge branch 'main' into react_query_hooks
cnasikas 27b08a4
Fix cypress tests
cnasikas b2f1105
Merge branch 'react_query_hooks' of github.com:cnasikas/kibana into r…
cnasikas e5dc03a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine e431f0d
Merge branch 'main' into react_query_hooks
cnasikas b5efd8b
Merge branch 'main' into react_query_hooks
cnasikas 4921e9f
Refresh when pushing
cnasikas 41e16dc
Delete connector after the end of the test
cnasikas c046e0a
Use function from library
cnasikas 6655997
Remove unused variable
cnasikas 49069b6
Bring toaster variable back
cnasikas fff79e1
Skip flaky test
cnasikas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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 |
---|---|---|
|
@@ -34,7 +34,6 @@ import { triggersActionsUiMock } from '@kbn/triggers-actions-ui-plugin/public/mo | |
import { registerConnectorsToMockActionRegistry } from '../../common/mock/register_connectors'; | ||
import { createStartServicesMock } from '../../common/lib/kibana/kibana_react.mock'; | ||
import { waitForComponentToUpdate } from '../../common/test_utils'; | ||
import { useCreateAttachments } from '../../containers/use_create_attachments'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not used anymore by the component. |
||
import { useGetSupportedActionConnectors } from '../../containers/configure/use_get_supported_action_connectors'; | ||
import { useGetTags } from '../../containers/use_get_tags'; | ||
import { useUpdateCase } from '../../containers/use_update_case'; | ||
|
@@ -45,7 +44,6 @@ import { useBulkGetUserProfiles } from '../../containers/user_profiles/use_bulk_ | |
import { useLicense } from '../../common/use_license'; | ||
import * as api from '../../containers/api'; | ||
|
||
jest.mock('../../containers/use_create_attachments'); | ||
jest.mock('../../containers/use_get_cases'); | ||
jest.mock('../../containers/use_get_action_license'); | ||
jest.mock('../../containers/use_get_tags'); | ||
|
@@ -66,7 +64,6 @@ const useGetCurrentUserProfileMock = useGetCurrentUserProfile as jest.Mock; | |
const useBulkGetUserProfilesMock = useBulkGetUserProfiles as jest.Mock; | ||
const useKibanaMock = useKibana as jest.MockedFunction<typeof useKibana>; | ||
const useGetConnectorsMock = useGetSupportedActionConnectors as jest.Mock; | ||
const useCreateAttachmentsMock = useCreateAttachments as jest.Mock; | ||
const useUpdateCaseMock = useUpdateCase as jest.Mock; | ||
const useLicenseMock = useLicense as jest.Mock; | ||
|
||
|
@@ -88,10 +85,6 @@ describe.skip('AllCasesListGeneric', () => { | |
const updateCaseProperty = jest.fn(); | ||
|
||
const emptyTag = getEmptyTagValue().props.children; | ||
useCreateAttachmentsMock.mockReturnValue({ | ||
status: { isLoading: false }, | ||
createAttachments: jest.fn(), | ||
}); | ||
|
||
const defaultGetCases = { | ||
...useGetCasesMockState, | ||
|
@@ -125,7 +118,7 @@ describe.skip('AllCasesListGeneric', () => { | |
useGetCurrentUserProfileMock.mockReturnValue({ data: userProfiles[0], isLoading: false }); | ||
useBulkGetUserProfilesMock.mockReturnValue({ data: userProfilesMap }); | ||
useGetConnectorsMock.mockImplementation(() => ({ data: connectorsMock, isLoading: false })); | ||
useUpdateCaseMock.mockReturnValue({ updateCaseProperty }); | ||
useUpdateCaseMock.mockReturnValue({ mutate: updateCaseProperty }); | ||
useLicenseMock.mockReturnValue({ isAtLeastPlatinum: () => false }); | ||
mockKibana(); | ||
moment.tz.setDefault('UTC'); | ||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might have been how it was before these changes, but it seems like other hooks like
useUpdateComment
leverages anonError
. Should the calls ofcreateAttachments
do the same?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it depends on the scenario. Most of the calls to
createAttachments
callmutateAsync
(which is of the formawait createAttachments(...)
) and are surrounded by a try/catch. In the scenario of adding a comment I think showing the error toaster (is being automatically by the hook) is enough. Do you have any scenarios in your mind where theonError
is needed?