Skip to content

Commit

Permalink
Rename discover plugin (#37) (#124)
Browse files Browse the repository at this point in the history
* Rename discover plugin (#37)

Signed-off-by: Bishoy Boktor <[email protected]>
  • Loading branch information
boktorbb authored and kavilla committed Mar 20, 2021
1 parent eba0768 commit 6cf7020
Show file tree
Hide file tree
Showing 135 changed files with 587 additions and 684 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"id": "discover",
"version": "kibana",
"version": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": [
"charts",
"data",
"embeddable",
"inspector",
"kibanaLegacy",
"opensearchDashboardsLegacy",
"urlForwarding",
"navigation",
"uiActions",
"visualizations"
],
"optionalPlugins": ["home", "share"],
"requiredBundles": [
"kibanaUtils",
"opensearchDashboardsUtils",
"home",
"savedObjects",
"kibanaReact"
"opensearchDashboardsReact"
]
}
4 changes: 2 additions & 2 deletions src/plugins/discover/public/application/_discover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ discover-app {
padding-top: $euiSizeXS;
background-color: $euiColorEmptyShade;

.kbn-table {
.osd-table {
margin-bottom: 0;
}
}
Expand Down Expand Up @@ -81,7 +81,7 @@ discover-app {
overflow: auto;

// SASSTODO: add a monospace modifier to the doc-table component
.kbnDocTable__row {
.osdDocTable__row {
font-family: $euiCodeFontFamily;
font-size: $euiFontSizeXS;
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/discover/public/application/angular/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import { CONTEXT_DEFAULT_SIZE_SETTING } from '../../../common';
import { getAngularModule, getServices } from '../../kibana_services';
import { getAngularModule, getServices } from '../../opensearch_dashboards_services';
import './context_app';
import { getState } from './context_state';
import contextAppRouteTemplate from './context.html';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ employed in some cases, e.g. when dealing with the isolate scope bindings in
app as loosely as possible. This means using pure functions whenever possible
and isolating the angular directives diligently. To that end, the app has been
implemented as the independent `ContextApp` directive in [app.js](app.js). It
does not access the Kibana `AppState` directly but communicates only via its
does not access the OpenSearch Dashboards `AppState` directly but communicates only via its
directive properties. The binding of these attributes to the state and thereby
to the route is performed by the `CreateAppRouteController`in
[index.js](index.js). Similarly, the `SizePicker` directive only communicates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';

export function fetchAnchorProvider(indexPatterns, searchSource) {
return async function fetchAnchor(indexPatternId, anchorId, sort) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import moment from 'moment';
import { get, last } from 'lodash';
import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';
import { fetchContextProvider } from './context';
import { setServices } from '../../../../kibana_services';
import { setServices } from '../../../../opensearch_dashboards_services';

const MS_PER_DAY = 24 * 60 * 60 * 1000;
const ANCHOR_TIMESTAMP = new Date(MS_PER_DAY).toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import moment from 'moment';
import { get, last } from 'lodash';

import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs';
import { setServices } from '../../../../kibana_services';
import { setServices } from '../../../../opensearch_dashboards_services';

import { fetchContextProvider } from './context';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ import { reverseSortDir, SortDirection } from './utils/sorting';
import { extractNanos, convertIsoToMillis } from './utils/date_conversion';
import { fetchHitsInInterval } from './utils/fetch_hits_in_interval';
import { generateIntervals } from './utils/generate_intervals';
import { getEsQuerySearchAfter } from './utils/get_es_query_search_after';
import { getEsQuerySort } from './utils/get_es_query_sort';
import { getServices } from '../../../../kibana_services';
import { getOpenSearchQuerySearchAfter } from './utils/get_opensearch_query_search_after';
import { getOpenSearchQuerySort } from './utils/get_opensearch_query_sort';
import { getServices } from '../../../../opensearch_dashboards_services';

export type SurrDocType = 'successors' | 'predecessors';
export interface EsHitRecord {
export interface OpenSearchHitRecord {
fields: Record<string, any>;
sort: number[];
_source: Record<string, any>;
_id: string;
}
export type EsHitRecordList = EsHitRecord[];
export type OpenSearchHitRecordList = OpenSearchHitRecord[];

const DAY_MILLIS = 24 * 60 * 60 * 1000;

Expand All @@ -50,18 +50,18 @@ function fetchContextProvider(indexPatterns: IndexPatternsContract) {
*
* @param {SurrDocType} type - `successors` or `predecessors`
* @param {string} indexPatternId
* @param {EsHitRecord} anchor - anchor record
* @param {OpenSearchHitRecord} anchor - anchor record
* @param {string} timeField - name of the timefield, that's sorted on
* @param {string} tieBreakerField - name of the tie breaker, the 2nd sort field
* @param {SortDirection} sortDir - direction of sorting
* @param {number} size - number of records to retrieve
* @param {Filter[]} filters - to apply in the elastic query
* @param {Filter[]} filters - to apply in the query
* @returns {Promise<object[]>}
*/
async function fetchSurroundingDocs(
type: SurrDocType,
indexPatternId: string,
anchor: EsHitRecord,
anchor: OpenSearchHitRecord,
timeField: string,
tieBreakerField: string,
sortDir: SortDirection,
Expand All @@ -80,7 +80,7 @@ function fetchContextProvider(indexPatterns: IndexPatternsContract) {
nanos !== '' ? convertIsoToMillis(anchor._source[timeField]) : anchor.sort[0];

const intervals = generateIntervals(LOOKUP_OFFSETS, timeValueMillis, type, sortDir);
let documents: EsHitRecordList = [];
let documents: OpenSearchHitRecordList = [];

for (const interval of intervals) {
const remainingSize = size - documents.length;
Expand All @@ -89,9 +89,9 @@ function fetchContextProvider(indexPatterns: IndexPatternsContract) {
break;
}

const searchAfter = getEsQuerySearchAfter(type, documents, timeField, anchor, nanos);
const searchAfter = getOpenSearchQuerySearchAfter(type, documents, timeField, anchor, nanos);

const sort = getEsQuerySort(timeField, tieBreakerField, sortDirToApply);
const sort = getOpenSearchQuerySort(timeField, tieBreakerField, sortDirToApply);

const hits = await fetchHitsInInterval(
searchSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ISearchSource, EsQuerySortValue, SortDirection } from '../../../../../../../data/public';
import { ISearchSource, OpenSearchQuerySortValue, SortDirection } from '../../../../../../../data/public';
import { convertTimeValueToIso } from './date_conversion';
import { EsHitRecordList, EsHitRecord } from '../context';
import { OpenSearchHitRecordList, OpenSearchHitRecord } from '../context';
import { IntervalValue } from './generate_intervals';
import { EsQuerySearchAfter } from './get_es_query_search_after';
import { OpenSearchQuerySearchAfter } from './get_opensearch_query_search_after';

interface RangeQuery {
format: string;
Expand All @@ -38,14 +38,14 @@ interface RangeQuery {
export async function fetchHitsInInterval(
searchSource: ISearchSource,
timeField: string,
sort: [EsQuerySortValue, EsQuerySortValue],
sort: [OpenSearchQuerySortValue, OpenSearchQuerySortValue],
sortDir: SortDirection,
interval: IntervalValue[],
searchAfter: EsQuerySearchAfter,
searchAfter: OpenSearchQuerySearchAfter,
maxCount: number,
nanosValue: string,
anchorId: string
): Promise<EsHitRecordList> {
): Promise<OpenSearchHitRecordList> {
const range: RangeQuery = {
format: 'strict_date_optional_time',
};
Expand Down Expand Up @@ -86,6 +86,6 @@ export async function fetchHitsInInterval(
.setField('version', true)
.fetch();

// TODO: There's a difference in the definition of SearchResponse and EsHitRecord
return ((response.hits?.hits as unknown) as EsHitRecord[]) || [];
// TODO: There's a difference in the definition of SearchResponse and OpenSearchHitRecord
return ((response.hits?.hits as unknown) as OpenSearchHitRecord[]) || [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function* asPairs(iterable: Iterable<IntervalValue>): IterableIterator<In
}

/**
* Returns a iterable containing intervals `[start,end]` for Elasticsearch date range queries
* Returns a iterable containing intervals `[start,end]` for OpenSearch date range queries
* depending on type (`successors` or `predecessors`) and sort (`asc`, `desc`) these are ascending or descending intervals.
*/
export function generateIntervals(
Expand All @@ -46,7 +46,7 @@ export function generateIntervals(
): IterableIterator<IntervalValue[]> {
const offsetSign =
(sort === SortDirection.asc && type === 'successors') ||
(sort === SortDirection.desc && type === 'predecessors')
(sort === SortDirection.desc && type === 'predecessors')
? 1
: -1;
// ending with `null` opens the last interval
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SurrDocType, EsHitRecordList, EsHitRecord } from '../context';
import { SurrDocType, OpenSearchHitRecordList, OpenSearchHitRecord } from '../context';

export type EsQuerySearchAfter = [string | number, string | number];
export type OpenSearchQuerySearchAfter = [string | number, string | number];

/**
* Get the searchAfter query value for elasticsearch
* Get the searchAfter query value for opensearch
* When there are already documents available, which means successors or predecessors
* were already fetched, the new searchAfter for the next fetch has to be the sort value
* of the first (prececessor), or last (successor) of the list
*/
export function getEsQuerySearchAfter(
export function getOpenSearchQuerySearchAfter(
type: SurrDocType,
documents: EsHitRecordList,
documents: OpenSearchHitRecordList,
timeFieldName: string,
anchor: EsHitRecord,
anchor: OpenSearchHitRecord,
nanoSeconds: string
): EsQuerySearchAfter {
): OpenSearchQuerySearchAfter {
if (documents.length) {
// already surrounding docs -> first or last record is used
const afterTimeRecIdx = type === 'successors' && documents.length ? documents.length - 1 : 0;
Expand All @@ -41,6 +41,6 @@ export function getEsQuerySearchAfter(
return [afterTimeValue, afterTimeDoc.sort[1]];
}
// if data_nanos adapt timestamp value for sorting, since numeric value was rounded by browser
// ES search_after also works when number is provided as string
// OpenSearch search_after also works when number is provided as string
return [nanoSeconds ? anchor._source[timeFieldName] : anchor.sort[0], anchor.sort[1]];
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
* under the License.
*/

import { EsQuerySortValue, SortDirection } from '../../../../../kibana_services';
import { OpenSearchQuerySortValue, SortDirection } from '../../../../../opensearch_dashboards_services';

/**
* Returns `EsQuerySort` which is used to sort records in the ES query
* Returns `OpenSearchQuerySort` which is used to sort records in the OpenSearch query
* https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html
* @param timeField
* @param tieBreakerField
* @param sortDir
*/
export function getEsQuerySort(
export function getOpenSearchQuerySort(
timeField: string,
tieBreakerField: string,
sortDir: SortDirection
): [EsQuerySortValue, EsQuerySortValue] {
): [OpenSearchQuerySortValue, OpenSearchQuerySortValue] {
return [{ [timeField]: sortDir }, { [tieBreakerField]: sortDir }];
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { IndexPattern } from '../../../../../kibana_services';
import { IndexPattern } from '../../../../../opensearch_dashboards_services';

export enum SortDirection {
asc = 'asc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/
import React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
import { i18n } from '@osd/i18n';
import { FormattedMessage, I18nProvider } from '@osd/i18n/react';
import {
EuiButtonEmpty,
EuiFieldNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { getAngularModule } from '../../../../../kibana_services';
import { getAngularModule } from '../../../../../opensearch_dashboards_services';
import { ActionBar } from './action_bar';

getAngularModule().directive('contextActionBar', function (reactDirective: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { FormattedMessage } from '@osd/i18n/react';
import { EuiCallOut } from '@elastic/eui';
import { SurrDocType } from '../../api/context';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import React from 'react';
import { getServices } from '../../../../kibana_services';
import { getServices } from '../../../../opensearch_dashboards_services';

import { fetchAnchorProvider } from '../api/anchor';
import { fetchContextProvider } from '../api/context';
import { getQueryParameterActions } from '../query_parameters';
import { FAILURE_REASONS, LOADING_STATUS } from './constants';
import { MarkdownSimple } from '../../../../../../kibana_react/public';
import { MarkdownSimple } from '../../../../../../opensearch_dashboards_react/public';

export function QueryActionsProvider(Promise) {
const { filterManager, indexPatterns, data } = getServices();
Expand All @@ -38,21 +38,21 @@ export function QueryActionsProvider(Promise) {
);

const setFailedStatus = (state) => (subject, details = {}) =>
(state.loadingStatus[subject] = {
status: LOADING_STATUS.FAILED,
reason: FAILURE_REASONS.UNKNOWN,
...details,
});
(state.loadingStatus[subject] = {
status: LOADING_STATUS.FAILED,
reason: FAILURE_REASONS.UNKNOWN,
...details,
});

const setLoadedStatus = (state) => (subject) =>
(state.loadingStatus[subject] = {
status: LOADING_STATUS.LOADED,
});
(state.loadingStatus[subject] = {
status: LOADING_STATUS.LOADED,
});

const setLoadingStatus = (state) => (subject) =>
(state.loadingStatus[subject] = {
status: LOADING_STATUS.LOADING,
});
(state.loadingStatus[subject] = {
status: LOADING_STATUS.LOADING,
});

const fetchAnchorRow = (state) => () => {
const {
Expand Down Expand Up @@ -173,11 +173,11 @@ export function QueryActionsProvider(Promise) {
};

const setAllRows = (state) => (predecessorRows, anchorRow, successorRows) =>
(state.rows.all = [
...(predecessorRows || []),
...(anchorRow ? [anchorRow] : []),
...(successorRows || []),
]);
(state.rows.all = [
...(predecessorRows || []),
...(anchorRow ? [anchorRow] : []),
...(successorRows || []),
]);

return {
fetchAllRows,
Expand Down
Loading

0 comments on commit 6cf7020

Please sign in to comment.