-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add MDS support to TSVB Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor datasource picker component Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Allow picker to persist state Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactored picker component params Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add unit tests Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add to CHANGELOG Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor components to use hideLocalCluster Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Remove Picker wrapper Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Update selector component and rename field to index name Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Address comments Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor to use different decideClient Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add optional arg Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Remove hidelocalcluster as a setting Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Fixed case where local cluster is disabled but the datasource id could be local cluster Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add test for create data source picker handler Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> --------- Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> (cherry picked from commit be0f9d5) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
- Loading branch information
1 parent
9cbfa64
commit e2e04d3
Showing
25 changed files
with
250 additions
and
31 deletions.
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
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
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
49 changes: 49 additions & 0 deletions
49
...pe_timeseries/public/application/components/lib/create_data_source_change_handler.test.ts
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { createDataSourcePickerHandler } from './create_data_source_change_handler'; | ||
|
||
describe('createDataSourcePickerHandler()', () => { | ||
let handleChange: jest.Mock<any, any>; | ||
let changeHandler: (selectedOptions: []) => void; | ||
|
||
beforeEach(() => { | ||
handleChange = jest.fn(); | ||
changeHandler = createDataSourcePickerHandler(handleChange); | ||
}); | ||
|
||
test.each([ | ||
{ | ||
id: undefined, | ||
}, | ||
{}, | ||
])( | ||
'calls handleChange() and sets data_source_id to undefined if id cannot be found or is undefined', | ||
({ id }) => { | ||
// @ts-ignore | ||
changeHandler([{ id }]); | ||
expect(handleChange.mock.calls.length).toEqual(1); | ||
expect(handleChange.mock.calls[0][0]).toEqual({ | ||
data_source_id: undefined, | ||
}); | ||
} | ||
); | ||
|
||
test.each([ | ||
{ | ||
id: '', | ||
}, | ||
{ | ||
id: 'foo', | ||
}, | ||
])('calls handleChange() function with partial and updates the data_source_id', ({ id }) => { | ||
// @ts-ignore | ||
changeHandler([{ id }]); | ||
expect(handleChange.mock.calls.length).toEqual(1); | ||
expect(handleChange.mock.calls[0][0]).toEqual({ | ||
data_source_id: id, | ||
}); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
...is_type_timeseries/public/application/components/lib/create_data_source_change_handler.ts
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import _ from 'lodash'; | ||
|
||
import { PanelSchema } from 'src/plugins/vis_type_timeseries/common/types'; | ||
import { DATA_SOURCE_ID_KEY } from '../../../../common/constants'; | ||
|
||
export const createDataSourcePickerHandler = (handleChange: (e: PanelSchema) => void) => { | ||
return (selectedOptions: []): void => { | ||
return handleChange?.({ | ||
[DATA_SOURCE_ID_KEY]: _.get(selectedOptions, '[0].id', undefined), | ||
} as PanelSchema); | ||
}; | ||
}; |
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
Oops, something went wrong.