Skip to content

Commit

Permalink
removed non-related change
Browse files Browse the repository at this point in the history
Signed-off-by: Su <[email protected]>
  • Loading branch information
zhongnansu committed Mar 14, 2023
1 parent 085fda9 commit c402636
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 40 deletions.
10 changes: 1 addition & 9 deletions src/core/public/saved_objects/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,7 @@ export class SavedObjectsClient {
};

const renamedQuery = renameKeys<SavedObjectsFindOptions, any>(renameMap, options);
const query = pick.apply(null, [renamedQuery, ...Object.values<string>(renameMap)]) as Record<
string,
any
>;

// `has_references` is a structured object. we need to stringify it before sending
if (query.has_reference) {
query.has_reference = JSON.stringify(query.has_reference);
}
const query = pick.apply(null, [renamedQuery, ...Object.values<string>(renameMap)]);

const request: ReturnType<SavedObjectsApi['find']> = this.savedObjectsFetch(path, {
method: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/

import { i18n } from '@osd/i18n';
import { DataSourceAttributes } from 'src/plugins/data_source/common/data_sources';
import { SavedObjectsClientCommon } from '../..';
import { createIndexPatternCache } from '.';
import { IndexPattern } from './index_pattern';
Expand All @@ -54,7 +53,7 @@ import { FieldFormatsStartCommon } from '../../field_formats';
import { UI_SETTINGS, SavedObject } from '../../../common';
import { SavedObjectNotFound } from '../../../../opensearch_dashboards_utils/common';
import { IndexPatternMissingIndices } from '../lib';
import { findByTitle, getIndexPatternTitle } from '../utils';
import { findByTitle } from '../utils';
import { DuplicateIndexPatternError } from '../errors';

const indexPatternCache = createIndexPatternCache();
Expand Down Expand Up @@ -119,28 +118,8 @@ export class IndexPatternsService {
fields: ['title'],
perPage: 10000,
});

this.savedObjectsCache = await Promise.all(
this.savedObjectsCache.map(async (obj) => {
if (obj.type === 'index-pattern') {
const result = { ...obj };
result.attributes.title = await getIndexPatternTitle(
obj.attributes.title,
obj.references,
this.getDataSource
);
return result;
} else {
return obj;
}
})
);
}

getDataSource = async (id: string) => {
return await this.savedObjectsClient.get<DataSourceAttributes>('data-source', id);
};

/**
* Get list of index pattern ids
* @param refresh Force refresh of index pattern list
Expand Down Expand Up @@ -578,11 +557,7 @@ export class IndexPatternsService {
*/

async createSavedObject(indexPattern: IndexPattern, override = false) {
const dupe = await findByTitle(
this.savedObjectsClient,
indexPattern.title,
indexPattern.dataSourceRef?.id
);
const dupe = await findByTitle(this.savedObjectsClient, indexPattern.title);
if (dupe) {
if (override) {
await this.delete(dupe.id);
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/common/index_patterns/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export interface SavedObjectsClientCommonFindArgs {
perPage?: number;
search?: string;
searchFields?: string[];
hasReference?: { type: string; id: string };
}

export interface SavedObjectsClientCommon {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/index_patterns/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const getIndexPatternTitle = async (
indexPatternTitle: string,
references: SavedObjectReference[],
getDataSource: (id: string) => Promise<SavedObject<DataSourceAttributes>>
) => {
): Promise<string> => {
const DELIMITER = '.';
// If an index-pattern references datasource, prepend data source name with index pattern name for display purpose
if (Array.isArray(references) && references[0] && references[0].type === 'data-source') {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"ui": true,
"requiredPlugins": ["expressions", "uiActions"],
"optionalPlugins": ["usageCollection", "dataSource"],
"extraPublicDirs": ["common", "common/utils/abort_utils"],
"extraPublicDirs": ["common", "common/utils/abort_utils", "common/index_patterns/utils.ts"],
"requiredBundles": [
"usageCollection",
"opensearchDashboardsUtils",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
} from 'src/core/public';

import { DataSourceAttributes } from 'src/plugins/data_source/common/data_sources';
import { getIndexPatternTitle } from '../../../data/common';
import { getIndexPatternTitle } from '../../../data/common/index_patterns/utils';
import { LISTING_LIMIT_SETTING } from '../../common';

export interface SavedObjectMetaData<T = unknown> {
Expand Down

0 comments on commit c402636

Please sign in to comment.