Skip to content

Commit

Permalink
Merge branch 'main' into table-polish
Browse files Browse the repository at this point in the history
  • Loading branch information
ananzh authored Feb 16, 2023
2 parents 2783572 + 7177fe3 commit e9c5838
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ module.exports = {
* Files that run BEFORE node version check
*/
{
files: ['scripts/**/*.js', 'src/setup_node_env/**/*.js'],
files: ['scripts/**/*.js', 'src/setup_node_env/**/!(*.test).js'],
rules: {
'import/no-commonjs': 'off',
'prefer-object-spread/prefer-object-spread': 'off',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Apply 'untriaged' label during issue lifecycle

on:
issues:
types: [opened, reopened, transferred]

jobs:
apply-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['untriaged']
})
name: Apply 'untriaged' label during issue lifecycle

on:
issues:
types: [opened, reopened, transferred]

jobs:
apply-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['untriaged']
})
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [CVE-2022-35256] Bumps node version from 14.20.0 to 14.20.1 [#3166](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3166))
- [CVE-2022-46175] Bumps json5 version from 1.0.1 and 2.2.1 to 1.0.2 and 2.2.3 ([#3201](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3201))
- [CVE-2022-25860] Bumps simple-git from 3.15.1 to 3.16.0 ([#3345](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3345))
- [Security] Bumps hapi/statehood to 7.0.4 ([#3411](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3411))
- [CVE-2023-25166] Bump formula to 3.0.1 ([#3416](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3416))

### 📈 Features/Enhancements

Expand Down Expand Up @@ -94,6 +96,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [VisBuilder] Fixes pipeline aggs ([#3137](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3137))
- [Region Maps] Fixes bug that prevents selected join field to be used ([#3213](Fix bug that prevents selected join field to be used))
- [Multi DataSource]Update test connection button text([#3247](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3247))
- [Region Maps] Add ui setting to configure custom vector map's size parameter([#3399](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3399))
- [Search Telemetry] Fixes search telemetry's observable object that won't be GC-ed([#3390](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3390))

### 🚞 Infrastructure

Expand All @@ -116,6 +120,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Doc] Add readme for global query persistence ([#3001](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3001))
- Updates NOTICE file, adds validation to GitHub CI ([#3051](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3051))
- [Doc] Add current plugin persistence implementation readme ([#3081](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3081))
- Correct copyright date range of NOTICE file and notice generator ([#3308](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3308))

### 🛠 Maintenance

Expand All @@ -124,6 +129,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Remove `github-checks-reporter`, an unused dependency ([#3126](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3126))
- Upgrade `vega-lite` dependency to ^5.6.0 ([#3076](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3076))
- Bumps `re2` and `supertest` ([3018](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3018))
- Bump `vega-tooltip` version from ^0.24.2 to ^0.30.0 ([#3358](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3358))

### 🪛 Refactoring

Expand All @@ -143,6 +149,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Tests] Bumps `chromedriver` to v107 ([#3017](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3017))
- [Vis Builder] Adds field unit tests ([#3211](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3211))
- [BWC Tests] Add BWC tests for 2.6.0 ([#3356](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3356))
- Prevent primitive linting limitations from being applied to unit tests found under `src/setup_node_env` ([#3403](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3403))

## [2.x]

Expand All @@ -162,6 +169,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [CVE-2022-37599] Bump loader-utils to 2.0.4 ([#3031](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3031))
- [CVE-2022-37603] Bump loader-utils to 2.0.4 ([#3031](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3031))
- [WS-2021-0638][security] bump mocha to 10.1.0 ([#2711](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2711))
- [CVE-2022-25881] Resolve http-cache-semantics to 4.1.1 ([#3409](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3409))

### 📈 Features/Enhancements

Expand Down
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Copyright OpenSearch Contributors

This product includes software, including Kibana source code,
developed by Elasticsearch (http://www.elastic.co).
Copyright 2009-2018 Elasticsearch B.V.
Copyright 2009-2021 Elasticsearch B.V.

This product includes software developed by The Apache Software
Foundation (http://www.apache.org/)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@
"vega-interpreter": "npm:@amoo-miki/[email protected]",
"vega-lite": "^5.6.0",
"vega-schema-url-parser": "^2.1.0",
"vega-tooltip": "^0.24.2",
"vega-tooltip": "^0.30.0",
"vinyl-fs": "^3.0.3",
"xml2js": "^0.4.22",
"xmlbuilder": "13.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/dev/notice/generate_notice_from_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const NOTICE_TEXT = `Copyright OpenSearch Contributors
This product includes software, including Kibana source code,
developed by Elasticsearch (http://www.elastic.co).
Copyright 2009-2018 Elasticsearch B.V.
Copyright 2009-2021 Elasticsearch B.V.
This product includes software developed by The Apache Software
Foundation (http://www.apache.org/)
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class DataServerPlugin
this.autocompleteService = new AutocompleteService(initializerContext);
}

public setup(
public async setup(
core: CoreSetup<DataPluginStartDependencies, DataPluginStart>,
{ expressions, usageCollection, dataSource }: DataPluginSetupDependencies
) {
Expand All @@ -108,7 +108,7 @@ export class DataServerPlugin

core.uiSettings.register(getUiSettings());

const searchSetup = this.searchService.setup(core, {
const searchSetup = await this.searchService.setup(core, {
registerFunction: expressions.registerFunction,
usageCollection,
dataSource,
Expand Down
12 changes: 2 additions & 10 deletions src/plugins/data/server/search/collectors/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
* under the License.
*/

import { CoreSetup, PluginInitializerContext } from 'opensearch-dashboards/server';
import { first } from 'rxjs/operators';
import { CoreSetup } from 'opensearch-dashboards/server';
import { Usage } from './register';
import { ConfigSchema } from '../../../config';

Expand All @@ -40,16 +39,9 @@ export interface SearchUsage {
trackSuccess(duration: number): Promise<void>;
}

export function usageProvider(
core: CoreSetup,
initializerContext: PluginInitializerContext<ConfigSchema>
): SearchUsage {
export function usageProvider(core: CoreSetup, config: ConfigSchema): SearchUsage {
const getTracker = (eventType: keyof Usage) => {
return async (duration?: number) => {
const config = await initializerContext.config
.create<ConfigSchema>()
.pipe(first())
.toPromise();
if (config?.search?.usageTelemetry?.enabled) {
const repository = await core
.getStartServices()
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/server/search/search_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Search service', () => {

describe('setup()', () => {
it('exposes proper contract', async () => {
const setup = plugin.setup(mockCoreSetup, ({
const setup = await plugin.setup(mockCoreSetup, ({
packageInfo: { version: '8' },
registerFunction: jest.fn(),
} as unknown) as SearchServiceSetupDependencies);
Expand Down
10 changes: 7 additions & 3 deletions src/plugins/data/server/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,15 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
private readonly logger: Logger
) {}

public setup(
public async setup(
core: CoreSetup<{}, DataPluginStart>,
{ registerFunction, usageCollection, dataSource }: SearchServiceSetupDependencies
): ISearchSetup {
const usage = usageCollection ? usageProvider(core, this.initializerContext) : undefined;
): Promise<ISearchSetup> {
const config = await this.initializerContext.config
.create<ConfigSchema>()
.pipe(first())
.toPromise();
const usage = usageCollection ? usageProvider(core, config) : undefined;

const router = core.http.createRouter();
const routeDependencies = {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/region_map/common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

export const DEFAULT_MAP_CHOICE = 'default';
export const CUSTOM_MAP_CHOICE = 'custom';
export const CUSTOM_VECTOR_MAP_MAX_SIZE_SETTING = 'visualization:regionmap:customVectorMapMaxSize';
8 changes: 6 additions & 2 deletions src/plugins/region_map/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { DEFAULT_MAP_CHOICE, CUSTOM_MAP_CHOICE } from './constants/shared';
import {
DEFAULT_MAP_CHOICE,
CUSTOM_MAP_CHOICE,
CUSTOM_VECTOR_MAP_MAX_SIZE_SETTING,
} from './constants/shared';

export { DEFAULT_MAP_CHOICE, CUSTOM_MAP_CHOICE };
export { DEFAULT_MAP_CHOICE, CUSTOM_MAP_CHOICE, CUSTOM_VECTOR_MAP_MAX_SIZE_SETTING };
19 changes: 14 additions & 5 deletions src/plugins/region_map/public/choropleth_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ import { getNotifications } from './opensearch_dashboards_services';
import { colorUtil, OpenSearchDashboardsMapLayer } from '../../maps_legacy/public';
import { truncatedColorMaps } from '../../charts/public';
import { getServices } from './services';
import { DEFAULT_MAP_CHOICE, CUSTOM_MAP_CHOICE } from '../common';
import {
DEFAULT_MAP_CHOICE,
CUSTOM_MAP_CHOICE,
CUSTOM_VECTOR_MAP_MAX_SIZE_SETTING,
} from '../common';

const EMPTY_STYLE = {
weight: 1,
Expand Down Expand Up @@ -94,7 +98,8 @@ export class ChoroplethLayer extends OpenSearchDashboardsMapLayer {
serviceSettings,
leaflet,
layerChosenByUser,
http
http,
uiSettings
) {
super();
this._serviceSettings = serviceSettings;
Expand All @@ -112,6 +117,7 @@ export class ChoroplethLayer extends OpenSearchDashboardsMapLayer {
this._layerChosenByUser = layerChosenByUser;
this._http = http;
this._visParams = null;
this._uiSettings = uiSettings;

// eslint-disable-next-line no-undef
this._leafletLayer = this._leaflet.geoJson(null, {
Expand Down Expand Up @@ -241,7 +247,8 @@ CORS configuration of the server permits requests from the OpenSearch Dashboards
// fetch data from index and transform it to feature collection
try {
const services = getServices(this._http);
const result = await services.getIndexData(this._layerName);
const indexSize = this._uiSettings.get(CUSTOM_VECTOR_MAP_MAX_SIZE_SETTING);
const result = await services.getIndexData(this._layerName, indexSize);

const finalResult = {
type: 'FeatureCollection',
Expand Down Expand Up @@ -337,7 +344,8 @@ CORS configuration of the server permits requests from the OpenSearch Dashboards
serviceSettings,
leaflet,
layerChosenByUser,
http
http,
uiSettings
) {
const clonedLayer = new ChoroplethLayer(
name,
Expand All @@ -349,7 +357,8 @@ CORS configuration of the server permits requests from the OpenSearch Dashboards
serviceSettings,
leaflet,
layerChosenByUser,
http
http,
uiSettings
);
clonedLayer.setJoinField(this._joinField);
clonedLayer.setColorRamp(this._colorRamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import './map_choice_options.scss';
import React, { useCallback, useMemo, useState } from 'react';
import React, { useCallback, useMemo } from 'react';
import {
EuiPanel,
EuiSpacer,
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/region_map/public/region_map_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ export function createRegionMapVisualization({
await getServiceSettings(),
(await lazyLoadMapsLegacyModules()).L,
this._params.layerChosenByUser,
http
http,
uiSettings
);
} else {
const { ChoroplethLayer } = await import('./choropleth_layer');
Expand All @@ -244,7 +245,8 @@ export function createRegionMapVisualization({
await getServiceSettings(),
(await lazyLoadMapsLegacyModules()).L,
this._params.layerChosenByUser,
http
http,
uiSettings
);
}
this._choroplethLayer.setLayerChosenByUser(this._params.layerChosenByUser);
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/region_map/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CoreStart, HttpFetchError } from 'opensearch-dashboards/public';

export interface Services {
getCustomIndices: () => Promise<undefined | HttpFetchError>;
getIndexData: (indexName: string) => Promise<undefined | HttpFetchError>;
getIndexData: (indexName: string, size: number) => Promise<undefined | HttpFetchError>;
getIndexMapping: (indexName: string) => Promise<undefined | HttpFetchError>;
}

Expand All @@ -25,11 +25,12 @@ export function getServices(http: CoreStart['http']): Services {
return e;
}
},
getIndexData: async (indexName: string) => {
getIndexData: async (indexName: string, size: number) => {
try {
const response = await http.post('../api/geospatial/_search', {
body: JSON.stringify({
index: indexName,
size,
}),
});
return response;
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/region_map/server/routes/opensearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ export function registerGeospatialRoutes(router: IRouter) {
validate: {
body: schema.object({
index: schema.string(),
size: schema.number(),
}),
},
},
async (context, req, res) => {
const client = context.core.opensearch.client.asCurrentUser;
try {
const { index } = req.body;
const params = { index, body: {} };
const { index, size } = req.body;
const params = { index, body: {}, size };
const results = await client.search(params);
return res.ok({
body: {
Expand Down
16 changes: 16 additions & 0 deletions src/plugins/region_map/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import { i18n } from '@osd/i18n';
import { UiSettingsParams } from 'opensearch-dashboards/server';
import { schema } from '@osd/config-schema';
import { CUSTOM_VECTOR_MAP_MAX_SIZE_SETTING } from '../common';

export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
return {
Expand All @@ -49,5 +50,20 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
schema: schema.boolean(),
category: ['visualization'],
},
[CUSTOM_VECTOR_MAP_MAX_SIZE_SETTING]: {
name: i18n.translate('regionMap.advancedSettings.visualization.customVectorMapDefaultSize', {
defaultMessage: 'Custom vector map size',
}),
value: 1000,
description: i18n.translate(
'regionMap.advancedSettings.visualization.customVectorMapDefaultSizeText',
{
defaultMessage:
'The maximum number of features to load from custom vector map. A higher number might have negative impact on browser rendering performance.',
}
),
schema: schema.number(),
category: ['visualization'],
},
};
}
Loading

0 comments on commit e9c5838

Please sign in to comment.