Skip to content
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

Revert "feat: make the pr smaller" #16

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
522e2db
Adds developer docs web link (#6117)
ashwin-pc Mar 18, 2024
d404100
Update 2.12 changelog to reflect correct change list (#6168)
manasvinibs Mar 18, 2024
a9e874f
[BUG] Fix obsolete snapshots for test within data source management p…
BionIT Mar 18, 2024
bfab07c
Pass request headers when making application config calls (#6164)
tianleh Mar 19, 2024
db9806d
[Discover] options button in canvas to toggle legacy mode (#6170)
kavilla Mar 19, 2024
daccae7
add version number to newly created datasource object (#6178)
ZilongX Mar 19, 2024
d2347ca
Add set default datasource (#6186)
zhyuanqi Mar 19, 2024
8975381
[Multiple Datasource] Use data source filter function before renderin…
BionIT Mar 19, 2024
73652f7
Add release notes for 2.13.0 (#6194)
manasvinibs Mar 19, 2024
4a77617
[CVE-2024-28849] Bump follow-redirects from 1.15.4 to 1.15.6 (#6201)
ashwin-pc Mar 19, 2024
1f74ab3
Update release notes for 2.13 (#6209)
manasvinibs Mar 19, 2024
de978d4
[MDS] Add Vega support for importing saved objects (#6123)
huyaboo Mar 19, 2024
f103b7e
[Admin] Add @xinruiba as a maintainer (#6217)
Flyingliuhub Mar 20, 2024
73cf593
feat: validate if workspace exists when setup inside a workspace
SuZhou-Joe Mar 15, 2024
b4ebc8b
feat: add CHANGELOG
SuZhou-Joe Mar 15, 2024
0300d10
fix: unit test
SuZhou-Joe Mar 15, 2024
3547286
feat: optimize import order
SuZhou-Joe Mar 15, 2024
8350bef
feat: add protection
SuZhou-Joe Mar 20, 2024
2e9385a
Apply suggestions from code review
SuZhou-Joe Mar 20, 2024
fc570f3
feat: jump to landing page
SuZhou-Joe Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @ananzh @kavilla @AMoo-Miki @ashwin-pc @joshuarrrr @abbyhu2000 @zengyan-amazon @zhongnansu @manasvinibs @ZilongX @Flyingliuhub @BSFishy @curq @bandinib-amzn @SuZhou-Joe @ruanyl @BionIT
* @ananzh @kavilla @AMoo-Miki @ashwin-pc @joshuarrrr @abbyhu2000 @zengyan-amazon @zhongnansu @manasvinibs @ZilongX @Flyingliuhub @BSFishy @curq @bandinib-amzn @SuZhou-Joe @ruanyl @BionIT @xinruiba
63 changes: 37 additions & 26 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ This guide applies to all development within the OpenSearch Dashboards project a
- [React](#react)
- [API endpoints](#api-endpoints)

> To view these docs and all the readme's in this repository as webpages, visit https://opensearch-project.github.io/OpenSearch-Dashboards/docs/index.html#/

## Getting started guide

This guide is for any developer who wants a running local development environment where you can make, see, and test changes. It's opinionated to get you running as quickly and easily as possible, but it's not the only way to set up a development environment.
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
| Su Zhou | [SuZhou-Joe](https://github.com/SuZhou-Joe) | Amazon |
| Yulong Ruan | [ruanyl](https://github.com/ruanyl) | Amazon |
| Lu Yu | [BionIT](https://github.com/BionIT) | Amazon |
| Xinrui Bai | [xinruiba](https://github.com/xinruiba) | Amazon |

## Emeritus

Expand Down
59 changes: 59 additions & 0 deletions release-notes/opensearch-dashboards.release-notes-2.13.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## Version 2.13.0 Release Notes

### 🛡 Security

- Support dynamic CSP rules to mitigate Clickjacking https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5641
- [CVE-2020-36604] Employ a patched version of hoek `6.1.3` ([#6148](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6148))
- [CVE-2024-27088] Bump es5-ext from `0.10.59` to `0.10.64` ([#6021](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6021))
- [CVE-2024-28849] Bump follow-redirect from `1.15.4` to `1.15.6` ([#6199](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6201))

### 📈 Features/Enhancements

- [MD]Change cluster selector component name to data source selector ([#6042](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6042))
- [Multiple Datasource] Add interfaces to register add-on authentication method from plug-in module ([#5851](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5851))
- [Multiple Datasource] Able to Hide "Local Cluster" option from datasource DropDown ([#5827](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5827))
- [Multiple Datasource] Add api registry and allow it to be added into client config in data source plugin ([#5895](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5895))
- [Multiple Datasource] Concatenate data source name with index pattern name and change delimiter to double colon ([#5907](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5907))
- [Multiple Datasource] Refactor client and legacy client to use authentication registry ([#5881](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5881))
- [Multiple Datasource] Improved error handling for the search API when a null value is passed for the dataSourceId ([#5882](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5882))
- [Multiple Datasource] Hide/Show authentication method in multi data source plugin based on configuration ([#5916](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5916))
- [Dynamic Configurations] Add support for dynamic application configurations ([#5855](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5855))
- [Multiple Datasource] Refactoring create and edit form to use authentication registry ([#6002](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6002))
- [Multiple Datasource] Handles auth methods from auth registry in DataSource SavedObjects Client Wrapper ([#6062](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6062))
- [Multiple Datasource] Expose a few properties for customize the appearance of the data source selector component ([#6057](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6057))
- [Multiple Datasource] Handle form values(request payload) if the selected type is available in the authentication registry ([#6049](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6049))
- [Multiple Datasource] Adds a session token to AWS credentials ([#6103](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6103))
- [Multiple Datasource] Test connection schema validation for registered auth types ([#6109](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6109))
- [Multiple DataSource] DataSource creation and edition page improvement to better support registered auth types ([#6122](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6122))
- [Multiple Datasource] Export DataSourcePluginRequestContext at top level for plugins to use ([#6108](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6108))
- [Multiple Datasource] Improves connection pooling support for AWSSigV4 clients in data sources ([#6135](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6135))
- [Multiple Datasource] Add datasource version number to newly created data source object([#6178](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6178))
- [Multiple Datasource] Add default functionality for customer to choose default datasource ([#6186](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6186))
- Implement new home page ([#6065](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6065))
- Add sidecar service ([#5920](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5920))
- [Dynamic Configurations] Pass request headers when making application config calls ([#6164](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6164))
- [Discover] Options button to configure legacy mode and remove the top navigation option ([#6170](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6170))

### 🐛 Bug Fixes

- [BUG][Discover] Allow saved sort from search embeddable to load in Dashboard ([#5934](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5934))
- [BUG][Discover] Add key to index pattern options for support deplicate index pattern names([#5946](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5946))
- [Discover] Fix table cell content overflowing in Safari ([#5948](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5948))
- [BUG][MD]Fix schema for test connection to separate validation based on auth type ([#5997](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5997))
- [Discover] Enable 'Back to Top' Feature in Discover for scrolling to top ([#6008](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6008))
- [BUG][Discover] Allow saved sort from search embeddable to load in Dashboard ([#5934](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5934))
- [osd/std] Add additional recovery from false-positives in handling of long numerals ([#5956](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5956))
- [BUG][Multiple Datasource] Fix missing customApiRegistryPromise param for test connection ([#5944](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5944))
- [BUG][Multiple Datasource] Add a migration function for datasource to add migrationVersion field ([#6025](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6025))
- [BUG][MD]Expose picker using function in data source management plugin setup([#6030](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6030))
- [BUG][Multiple Datasource] Fix data source filter bug and add tests ([#6152](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6152))

### 📝 Documentation

- Fix link to documentation for geoHash precision ([#5967](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5967))

### 🛠 Maintenance

- Bump `chromedriver` dependency to `121.0.1"` ([#5926](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5926))
- Add @ruanyl as a maintainer ([#5982](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5982))
- Add @BionIT as a maintainer ([#5988](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5988))
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { mockUuidv4 } from './__mocks__';
import { SavedObjectReference, SavedObjectsImportRetry } from 'opensearch-dashboards/public';
import { SavedObject } from '../types';
import { SavedObject, SavedObjectsClientContract } from '../types';
import { SavedObjectsErrorHelpers } from '..';
import {
checkConflictsForDataSource,
Expand All @@ -24,6 +24,45 @@ const createObject = (type: string, id: string): SavedObjectType => ({
references: (Symbol() as unknown) as SavedObjectReference[],
});

const createVegaVisualizationObject = (id: string): SavedObjectType => {
const visState =
id.split('_').length > 1
? '{"title":"some-title","type":"vega","aggs":[],"params":{"spec":"{\\n data: {\\n url: {\\n index: example_index\\n data_source_name: old-datasource-title\\n }\\n }\\n}"}}'
: '{"title":"some-title","type":"vega","aggs":[],"params":{"spec":"{\\n data: {\\n url: {\\n index: example_index\\n }\\n }\\n}"}}';
return {
type: 'visualization',
id,
attributes: { title: 'some-title', visState },
references:
id.split('_').length > 1
? [{ id: id.split('_')[0], type: 'data-source', name: 'dataSource' }]
: [],
} as SavedObjectType;
};

const getSavedObjectClient = (): SavedObjectsClientContract => {
const savedObject = {} as SavedObjectsClientContract;
savedObject.get = jest.fn().mockImplementation((type, id) => {
if (type === 'data-source' && id === 'old-datasource-id') {
return Promise.resolve({
attributes: {
title: 'old-datasource-title',
},
});
} else if (type === 'data-source') {
return Promise.resolve({
attributes: {
title: 'some-datasource-title',
},
});
}

return Promise.resolve(undefined);
});

return savedObject;
};

const getResultMock = {
conflict: (type: string, id: string) => {
const error = SavedObjectsErrorHelpers.createConflictError(type, id).output.payload;
Expand Down Expand Up @@ -56,6 +95,7 @@ describe('#checkConflictsForDataSource', () => {
retries?: SavedObjectsImportRetry[];
createNewCopies?: boolean;
dataSourceId?: string;
savedObjectsClient?: SavedObjectsClientContract;
}): ConflictsForDataSourceParams => {
return { ...partial };
};
Expand Down Expand Up @@ -140,4 +180,123 @@ describe('#checkConflictsForDataSource', () => {
importIdMap: new Map(),
});
});

/*
Vega test cases
*/
it('will attach datasource name to Vega spec when importing from local to datasource', async () => {
const vegaSavedObject = createVegaVisualizationObject('some-object-id');
const params = setupParams({
objects: [vegaSavedObject],
ignoreRegularConflicts: true,
dataSourceId: 'some-datasource-id',
savedObjectsClient: getSavedObjectClient(),
});
const checkConflictsForDataSourceResult = await checkConflictsForDataSource(params);

expect(params.savedObjectsClient?.get).toHaveBeenCalledWith(
'data-source',
'some-datasource-id'
);
expect(checkConflictsForDataSourceResult).toEqual(
expect.objectContaining({
filteredObjects: [
{
...vegaSavedObject,
attributes: {
title: 'some-title',
visState:
'{"title":"some-title","type":"vega","aggs":[],"params":{"spec":"{\\n data: {\\n url: {\\n index: example_index\\n data_source_name: some-datasource-title\\n }\\n }\\n}"}}',
},
id: 'some-datasource-id_some-object-id',
references: [
{
id: 'some-datasource-id',
type: 'data-source',
name: 'dataSource',
},
],
},
],
errors: [],
importIdMap: new Map([
[
`visualization:some-object-id`,
{ id: 'some-datasource-id_some-object-id', omitOriginId: true },
],
]),
})
);
});

it('will not change Vega spec when importing from datasource to different datasource', async () => {
const vegaSavedObject = createVegaVisualizationObject('old-datasource-id_some-object-id');
const params = setupParams({
objects: [vegaSavedObject],
ignoreRegularConflicts: true,
dataSourceId: 'some-datasource-id',
savedObjectsClient: getSavedObjectClient(),
});
const checkConflictsForDataSourceResult = await checkConflictsForDataSource(params);

expect(params.savedObjectsClient?.get).toHaveBeenCalledWith(
'data-source',
'some-datasource-id'
);
expect(checkConflictsForDataSourceResult).toEqual(
expect.objectContaining({
filteredObjects: [
{
...vegaSavedObject,
attributes: {
title: 'some-title',
visState:
'{"title":"some-title","type":"vega","aggs":[],"params":{"spec":"{\\n data: {\\n url: {\\n index: example_index\\n data_source_name: old-datasource-title\\n }\\n }\\n}"}}',
},
id: 'some-datasource-id_some-object-id',
},
],
errors: [],
importIdMap: new Map([
[
`visualization:some-object-id`,
{ id: 'some-datasource-id_some-object-id', omitOriginId: true },
],
]),
})
);
});

it('will not change Vega spec when dataSourceTitle is undefined', async () => {
const vegaSavedObject = createVegaVisualizationObject('old-datasource-id_some-object-id');
const params = setupParams({
objects: [vegaSavedObject],
ignoreRegularConflicts: true,
dataSourceId: 'nonexistent-datasource-title-id',
savedObjectsClient: getSavedObjectClient(),
});
const checkConflictsForDataSourceResult = await checkConflictsForDataSource(params);

expect(params.savedObjectsClient?.get).toHaveBeenCalledWith(
'data-source',
'nonexistent-datasource-title-id'
);
expect(checkConflictsForDataSourceResult).toEqual(
expect.objectContaining({
filteredObjects: [
{
...vegaSavedObject,
id: 'nonexistent-datasource-title-id_some-object-id',
},
],
errors: [],
importIdMap: new Map([
[
`visualization:some-object-id`,
{ id: 'nonexistent-datasource-title-id_some-object-id', omitOriginId: true },
],
]),
})
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { SavedObject, SavedObjectsImportError, SavedObjectsImportRetry } from '../types';
import {
SavedObject,
SavedObjectsClientContract,
SavedObjectsImportError,
SavedObjectsImportRetry,
} from '../types';
import {
extractVegaSpecFromSavedObject,
getDataSourceTitleFromId,
updateDataSourceNameInVegaSpec,
} from './utils';

export interface ConflictsForDataSourceParams {
objects: Array<SavedObject<{ title?: string }>>;
ignoreRegularConflicts?: boolean;
retries?: SavedObjectsImportRetry[];
dataSourceId?: string;
savedObjectsClient?: SavedObjectsClientContract;
}

interface ImportIdMapEntry {
Expand All @@ -31,6 +42,7 @@ export async function checkConflictsForDataSource({
ignoreRegularConflicts,
retries = [],
dataSourceId,
savedObjectsClient,
}: ConflictsForDataSourceParams) {
const filteredObjects: Array<SavedObject<{ title?: string }>> = [];
const errors: SavedObjectsImportError[] = [];
Expand All @@ -43,6 +55,12 @@ export async function checkConflictsForDataSource({
(acc, cur) => acc.set(`${cur.type}:${cur.id}`, cur),
new Map<string, SavedObjectsImportRetry>()
);

const dataSourceTitle =
!!dataSourceId && !!savedObjectsClient
? await getDataSourceTitleFromId(dataSourceId, savedObjectsClient)
: undefined;

objects.forEach((object) => {
const {
type,
Expand Down Expand Up @@ -74,6 +92,33 @@ export async function checkConflictsForDataSource({
/**
* Only update importIdMap and filtered objects
*/

// Some visualization types will need special modifications, like Vega visualizations
if (object.type === 'visualization') {
const vegaSpec = extractVegaSpecFromSavedObject(object);

if (!!vegaSpec && !!dataSourceTitle) {
const updatedVegaSpec = updateDataSourceNameInVegaSpec({
spec: vegaSpec,
newDataSourceName: dataSourceTitle,
});

// @ts-expect-error
const visStateObject = JSON.parse(object.attributes?.visState);
visStateObject.params.spec = updatedVegaSpec;

// @ts-expect-error
object.attributes.visState = JSON.stringify(visStateObject);
if (!!dataSourceId) {
object.references.push({
id: dataSourceId,
name: 'dataSource',
type: 'data-source',
});
}
}
}

const omitOriginId = ignoreRegularConflicts;
importIdMap.set(`${type}:${id}`, { id: `${dataSourceId}_${rawId}`, omitOriginId });
filteredObjects.push({ ...object, id: `${dataSourceId}_${rawId}` });
Expand Down
Loading
Loading