Skip to content

Commit

Permalink
Merge branch 'main' into dismiss-getstarted-card
Browse files Browse the repository at this point in the history
  • Loading branch information
Hailong-am authored Dec 11, 2024
2 parents 8b27d2d + 85273e3 commit 1b996fa
Show file tree
Hide file tree
Showing 63 changed files with 2,357 additions and 728 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8611.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Bump url to 0.11.4 ([#8611](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8611))
2 changes: 2 additions & 0 deletions changelogs/fragments/8739.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- [Workspace] [Bug] Check if workspaces exists when creating saved objects. ([#8739](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8739))
2 changes: 2 additions & 0 deletions changelogs/fragments/8842.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- [Workspace]Fix error toasts in sample data page ([#8842](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8842))
2 changes: 2 additions & 0 deletions changelogs/fragments/8888.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
refactor:
- [Workspace] Isolate objects based on workspace when calling get/bulkGet ([#8888](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8888))
2 changes: 0 additions & 2 deletions changelogs/fragments/8915.yml

This file was deleted.

2 changes: 2 additions & 0 deletions changelogs/fragments/8926.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chore:
- Update cypress to v12 ([#8926](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8926))
2 changes: 2 additions & 0 deletions changelogs/fragments/8930.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Update saved search initialization logic to use current query instead of default query ([#8930](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8930))
2 changes: 2 additions & 0 deletions changelogs/fragments/8932.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Support custom logic to insert time filter based on dataset type ([#8932](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8932))
2 changes: 2 additions & 0 deletions changelogs/fragments/8935.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Use roundUp when converting timestamp for PPL ([#8935](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8935))
2 changes: 2 additions & 0 deletions changelogs/fragments/8993.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Support imports without extensions in cypress webpack build ([#8993](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8993))
65 changes: 65 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { defineConfig } from 'cypress';
import webpackPreprocessor from '@cypress/webpack-preprocessor';

module.exports = defineConfig({
defaultCommandTimeout: 60000,
requestTimeout: 60000,
responseTimeout: 60000,
viewportWidth: 2000,
viewportHeight: 1320,
env: {
openSearchUrl: 'http://localhost:9200',
SECURITY_ENABLED: false,
AGGREGATION_VIEW: false,
username: 'admin',
password: 'myStrongPassword123!',
ENDPOINT_WITH_PROXY: false,
MANAGED_SERVICE_ENDPOINT: false,
VISBUILDER_ENABLED: true,
DATASOURCE_MANAGEMENT_ENABLED: false,
ML_COMMONS_DASHBOARDS_ENABLED: true,
WAIT_FOR_LOADER_BUFFER_MS: 0,
},
e2e: {
baseUrl: 'http://localhost:5601',
specPattern: 'cypress/integration/**/*_spec.{js,jsx,ts,tsx}',
testIsolation: false,
setupNodeEvents,
},
});

function setupNodeEvents(
on: Cypress.PluginEvents,
config: Cypress.PluginConfigOptions
): Cypress.PluginConfigOptions {
const { webpackOptions } = webpackPreprocessor.defaultOptions;

/**
* By default, cypress' internal webpack preprocessor doesn't allow imports without file extensions.
* This makes our life a bit hard since if any file in our testing dependency graph has an import without
* the .js extension our cypress build will fail.
*
* This extra rule relaxes this a bit by allowing imports without file extension
* ex. import module from './module'
*/
webpackOptions!.module!.rules.unshift({
test: /\.m?js/,
resolve: {
enforceExtension: false,
},
});

on(
'file:preprocessor',
webpackPreprocessor({
webpackOptions,
})
);

return config;
}
21 changes: 0 additions & 21 deletions cypress.json

This file was deleted.

6 changes: 6 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import '../utils/commands';
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"**/trim": "^0.0.3",
"**/typescript": "4.6.4",
"**/unset-value": "^2.0.1",
"**/url": "^0.11.4",
"**/watchpack-chokidar2/chokidar": "^3.5.3",
"**/xml2js": "^0.5.0",
"**/yaml": "^2.2.2"
Expand Down Expand Up @@ -259,6 +260,7 @@
"@babel/plugin-transform-class-static-block": "^7.24.4",
"@babel/register": "^7.22.9",
"@babel/types": "^7.22.9",
"@cypress/webpack-preprocessor": "^5.17.1",
"@elastic/apm-rum": "^5.6.1",
"@elastic/charts": "31.1.0",
"@elastic/ems-client": "7.10.0",
Expand Down Expand Up @@ -383,7 +385,7 @@
"chromedriver": "^121.0.1",
"classnames": "^2.3.1",
"compare-versions": "3.5.1",
"cypress": "9.5.4",
"cypress": "12.17.4",
"d3": "3.5.17",
"d3-cloud": "1.2.5",
"dedent": "^0.7.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/opensearch-datemath/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ declare const datemath: {

/**
* Parses a string into a moment object. The string can be something like "now - 15m".
* @param options.roundUp - If true, rounds the parsed date to the end of the
* unit. Only works for string with "/" like "now/d".
* @param options.forceNow If this optional parameter is supplied, "now" will be treated as this
* date, rather than the real "now".
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormattedMessage, I18nProvider } from '@osd/i18n/react';
import { BrowserRouter as Router } from 'react-router-dom';

import {
EuiSmallButton,
EuiButton,
EuiHorizontalRule,
EuiPage,
EuiPageBody,
Expand Down
16 changes: 16 additions & 0 deletions release-notes/opensearch-dashboards.release-notes-1.3.20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Version 1.3.20 Release Notes

### 🛡 Security

- [CVE-2024-45590] Bump body-parser from 1.19.0 to 1.20.3 ([#9007](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9007))
- [CVE-2024-45296] Bump various version of path-to-regexp to required versions ([#9007](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9007))

### 📈 Features/Enhancements

### 🐛 Bug Fixes

### 🚞 Infrastructure

### 📝 Documentation

### 🛠 Maintenance
27 changes: 27 additions & 0 deletions src/plugins/data/common/data_frames/utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import datemath from '@opensearch/datemath';
import { formatTimePickerDate } from '.';

describe('formatTimePickerDate', () => {
const mockDateFormat = 'YYYY-MM-DD HH:mm:ss';

beforeEach(() => {
jest.clearAllMocks();
});

it('should handle date range with rounding', () => {
jest.spyOn(datemath, 'parse');

const result = formatTimePickerDate({ from: 'now/d', to: 'now/d' }, mockDateFormat);

expect(result.fromDate).not.toEqual(result.toDate);

expect(datemath.parse).toHaveBeenCalledTimes(2);
expect(datemath.parse).toHaveBeenCalledWith('now/d', { roundUp: undefined });
expect(datemath.parse).toHaveBeenCalledWith('now/d', { roundUp: true });
});
});
6 changes: 3 additions & 3 deletions src/plugins/data/common/data_frames/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ export const getTimeField = (
* the `dateFormat` parameter
*/
export const formatTimePickerDate = (dateRange: TimeRange, dateFormat: string) => {
const dateMathParse = (date: string) => {
const parsedDate = datemath.parse(date);
const dateMathParse = (date: string, roundUp?: boolean) => {
const parsedDate = datemath.parse(date, { roundUp });
return parsedDate ? parsedDate.utc().format(dateFormat) : '';
};

const fromDate = dateMathParse(dateRange.from);
const toDate = dateMathParse(dateRange.to);
const toDate = dateMathParse(dateRange.to, true);

return { fromDate, toDate };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const createSetupDatasetServiceMock = (): jest.Mocked<DatasetServiceContract> =>
fetchOptions: jest.fn(),
getRecentDatasets: jest.fn(),
addRecentDataset: jest.fn(),
clearCache: jest.fn(),
getLastCacheTime: jest.fn(),
removeFromRecentDatasets: jest.fn(),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ export interface DatasetTypeConfig {
id: string;
/** Human-readable title for the dataset type */
title: string;
languageOverrides?: {
[language: string]: {
/** The override transfers the responsibility of handling the input from
* the language interceptor to the dataset type search strategy. */
hideDatePicker?: boolean;
};
};
/** Metadata for UI representation */
meta: {
/** Icon to represent the dataset type */
Expand All @@ -51,7 +58,7 @@ export interface DatasetTypeConfig {
tooltip?: string;
/** Optional preference for search on page load else defaulted to true */
searchOnLoad?: boolean;
/** Optional supportsTimeFilter determines if a time filter is needed */
/** Optional supportsTimeFilter determines if a time field is supported */
supportsTimeFilter?: boolean;
/** Optional isFieldLoadAsync determines if field loads are async */
isFieldLoadAsync?: boolean;
Expand Down
72 changes: 68 additions & 4 deletions src/plugins/data/public/ui/dataset_selector/configurator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { Configurator } from './configurator';
import '@testing-library/jest-dom';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import { setQueryService, setIndexPatterns } from '../../services';
import { IntlProvider } from 'react-intl';
import { Query } from '../../../../data/public';
import { Dataset } from 'src/plugins/data/common';
import { Query } from '../../../../data/public';
import { setIndexPatterns, setQueryService } from '../../services';
import { Configurator } from './configurator';

const getQueryMock = jest.fn().mockReturnValue({
query: '',
Expand Down Expand Up @@ -358,4 +358,68 @@ describe('Configurator Component', () => {
expect(submitButton).toBeEnabled();
});
});

it('should show the date picker if supportsTimeFilter is undefined', async () => {
const mockDataset = {
...mockBaseDataset,
timeFieldName: undefined,
type: 'index',
};
const { container } = render(
<IntlProvider locale="en" messages={messages}>
<Configurator
services={mockServices}
baseDataset={mockDataset}
onConfirm={mockOnConfirm}
onCancel={mockOnCancel}
onPrevious={mockOnPrevious}
/>
</IntlProvider>
);

expect(
container.querySelector(`[data-test-subj="advancedSelectorTimeFieldSelect"]`)
).toBeTruthy();
});

it('should hide the date picker if supportsTimeFilter is false', async () => {
const mockDataset = {
...mockBaseDataset,
timeFieldName: undefined,
type: 'index',
};
const datasetTypeConfig = mockServices
.getQueryService()
.queryString.getDatasetService()
.getType();
mockServices
.getQueryService()
.queryString.getDatasetService()
.getType.mockReturnValue({
...datasetTypeConfig,
meta: {
supportsTimeFilter: false,
},
});
const { container } = render(
<IntlProvider locale="en" messages={messages}>
<Configurator
services={mockServices}
baseDataset={mockDataset}
onConfirm={mockOnConfirm}
onCancel={mockOnCancel}
onPrevious={mockOnPrevious}
/>
</IntlProvider>
);

expect(
container.querySelector(`[data-test-subj="advancedSelectorTimeFieldSelect"]`)
).toBeFalsy();

mockServices
.getQueryService()
.queryString.getDatasetService()
.getType.mockReturnValue(datasetTypeConfig);
});
});
Loading

0 comments on commit 1b996fa

Please sign in to comment.