-
Notifications
You must be signed in to change notification settings - Fork 8.5k
remove angular dependencies in SavedObjectClient #20384
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
57ef8f2
create saved object client that is native javascript
nreese 062bf3e
fix savedObjectClient unit tests
nreese d086830
get saved object client from chrome when being used outside of angular
nreese 56f92bb
update error handlers to pull status code from FetchError
nreese bda978b
add some debug messages to failing functional test
nreese 1ebfc8a
revert changes to management/_objects
nreese f1629f4
Merge branch 'master' of https://github.com/elastic/kibana into saved…
nreese ce30939
add clicks to import done in import objects test
nreese dc8509f
take screenshots of test only failing in CI
nreese 68a62bc
Merge branch 'master' of https://github.com/elastic/kibana into saved…
nreese 773a0cd
remove functional test screenshot code since test is passing in CI now
nreese b87a31a
remove unused file, clean up saved_objects_client test to not use glo…
nreese bcce492
add body to kfetch error
nreese 0eedca8
Merge branch 'master' of https://github.com/elastic/kibana into saved…
nreese 79dbabe
update savedObjectClient.bulkCreate
nreese e295c79
add bulkCreate wrapper to SavedObjectsClientProvider
nreese 1801eb0
Merge branch 'master' of https://github.com/elastic/kibana into saved…
nreese a8f5a1f
mark _createSavedObject and _processBatchQueue as private methods
nreese 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { SavedObjectsClient } from '../../saved_objects'; | ||
|
|
||
| export function initSavedObjectClient(chrome) { | ||
| const savedObjectClient = new SavedObjectsClient(); | ||
|
|
||
| chrome.getSavedObjectsClient = function () { | ||
| return savedObjectClient; | ||
| }; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
109 changes: 109 additions & 0 deletions
109
src/ui/public/error_auto_create_index/error_auto_create_index.test.js
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| jest.mock('../chrome', () => ({ | ||
| addBasePath: path => `myBase/${path}`, | ||
| })); | ||
| jest.mock('../metadata', () => ({ | ||
| metadata: { | ||
| version: 'my-version', | ||
| }, | ||
| })); | ||
|
|
||
| import fetchMock from 'fetch-mock'; | ||
| import { kfetch } from 'ui/kfetch'; | ||
| import { isAutoCreateIndexError } from './error_auto_create_index'; | ||
|
|
||
| describe('isAutoCreateIndexError correctly handles FetchError thrown by kfetch', () => { | ||
| describe('404', () => { | ||
| beforeEach(() => { | ||
| fetchMock.post({ | ||
| matcher: '*', | ||
| response: { | ||
| status: 404, | ||
| }, | ||
| }); | ||
| }); | ||
| afterEach(() => fetchMock.restore()); | ||
|
|
||
| test('should return false', async () => { | ||
| let gotError = false; | ||
|
Member
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. @nreese stumbled over this while updating |
||
| try { | ||
| await kfetch({ method: 'POST', pathname: 'my/path' }); | ||
| } catch (fetchError) { | ||
| gotError = true; | ||
| expect(isAutoCreateIndexError(fetchError)).toBe(false); | ||
| } | ||
|
|
||
| expect(gotError).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('503 error that is not ES_AUTO_CREATE_INDEX_ERROR', () => { | ||
| beforeEach(() => { | ||
| fetchMock.post({ | ||
| matcher: '*', | ||
| response: { | ||
| status: 503, | ||
| }, | ||
| }); | ||
| }); | ||
| afterEach(() => fetchMock.restore()); | ||
|
|
||
| test('should return false', async () => { | ||
| let gotError = false; | ||
| try { | ||
| await kfetch({ method: 'POST', pathname: 'my/path' }); | ||
| } catch (fetchError) { | ||
| gotError = true; | ||
| expect(isAutoCreateIndexError(fetchError)).toBe(false); | ||
| } | ||
|
|
||
| expect(gotError).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('503 error that is ES_AUTO_CREATE_INDEX_ERROR', () => { | ||
| beforeEach(() => { | ||
| fetchMock.post({ | ||
| matcher: '*', | ||
| response: { | ||
| body: { | ||
| code: 'ES_AUTO_CREATE_INDEX_ERROR' | ||
| }, | ||
| status: 503, | ||
| }, | ||
| }); | ||
| }); | ||
| afterEach(() => fetchMock.restore()); | ||
|
|
||
| test('should return true', async () => { | ||
| let gotError = false; | ||
| try { | ||
| await kfetch({ method: 'POST', pathname: 'my/path' }); | ||
| } catch (fetchError) { | ||
| gotError = true; | ||
| expect(isAutoCreateIndexError(fetchError)).toBe(true); | ||
| } | ||
|
|
||
| expect(gotError).toBe(true); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Was the original code incorrect, in which we were comparing
error.statusCode?Uh oh!
There was an error while loading. Please reload this page.
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.
The original code used the error produced in saved_object_client _request method. But kfetch creates its own error type. Just needed to update to handle the error thrown by kfetch.