From bf6d8ad17557169403c848ab2736032d0fb62406 Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Wed, 2 Nov 2022 09:17:57 -0400 Subject: [PATCH] Update license headers and address review comments Signed-off-by: Craig Perkins --- .../public/lib/filter_query.test.ts | 8 +------- .../public/lib/filter_query.ts | 14 +++++--------- .../public/lib/get_saved_object_counts.ts | 2 +- .../saved_objects_management/public/lib/index.ts | 2 +- .../objects_table/saved_objects_table.tsx | 13 +++++++------ 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/plugins/saved_objects_management/public/lib/filter_query.test.ts b/src/plugins/saved_objects_management/public/lib/filter_query.test.ts index 0cbaa0318d68..ed0a133ed2b0 100644 --- a/src/plugins/saved_objects_management/public/lib/filter_query.test.ts +++ b/src/plugins/saved_objects_management/public/lib/filter_query.test.ts @@ -1,12 +1,6 @@ /* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Any modifications Copyright OpenSearch Contributors. See - * GitHub history for details. */ import { filterQuery } from './filter_query'; diff --git a/src/plugins/saved_objects_management/public/lib/filter_query.ts b/src/plugins/saved_objects_management/public/lib/filter_query.ts index bd18b006fddd..4194aba5f9e4 100644 --- a/src/plugins/saved_objects_management/public/lib/filter_query.ts +++ b/src/plugins/saved_objects_management/public/lib/filter_query.ts @@ -1,15 +1,11 @@ /* + * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Any modifications Copyright OpenSearch Contributors. See - * GitHub history for details. */ -export function filterQuery(allowedVals: string[], requestedVals: string[]): string[] { - const filteredVals = allowedVals.filter((val) => !requestedVals || requestedVals.includes(val)); +export function filterQuery(allowedVals: string[], requestedVals?: string[]): string[] { + const filteredVals = requestedVals + ? allowedVals.filter((val) => requestedVals.includes(val)) + : allowedVals; return filteredVals; } diff --git a/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts b/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts index 698c86b163ab..6eaaac7d35f2 100644 --- a/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts +++ b/src/plugins/saved_objects_management/public/lib/get_saved_object_counts.ts @@ -30,7 +30,7 @@ import { HttpStart } from 'src/core/public'; -interface SavedObjectCountOptions { +export interface SavedObjectCountOptions { typesToInclude: string[]; namespacesToInclude?: string[]; searchString?: string; diff --git a/src/plugins/saved_objects_management/public/lib/index.ts b/src/plugins/saved_objects_management/public/lib/index.ts index 83f29b7c70fe..fae58cad3eb2 100644 --- a/src/plugins/saved_objects_management/public/lib/index.ts +++ b/src/plugins/saved_objects_management/public/lib/index.ts @@ -32,7 +32,7 @@ export { fetchExportByTypeAndSearch } from './fetch_export_by_type_and_search'; export { fetchExportObjects } from './fetch_export_objects'; export { canViewInApp } from './in_app_url'; export { getRelationships } from './get_relationships'; -export { getSavedObjectCounts } from './get_saved_object_counts'; +export { getSavedObjectCounts, SavedObjectCountOptions } from './get_saved_object_counts'; export { getSavedObjectLabel } from './get_saved_object_label'; export { importFile } from './import_file'; export { importLegacyFile } from './import_legacy_file'; diff --git a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx index 01f46afd6d93..2f78f307d165 100644 --- a/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx +++ b/src/plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx @@ -71,6 +71,7 @@ import { IndexPatternsContract } from '../../../../data/public'; import { parseQuery, getSavedObjectCounts, + SavedObjectCountOptions, getRelationships, getSavedObjectLabel, fetchExportObjects, @@ -186,12 +187,12 @@ export class SavedObjectsTable extends Component ns.id) || []; - const filteredCountOptions = { + const filteredCountOptions: SavedObjectCountOptions = { typesToInclude: filteredTypes, searchString: queryText, }; - if (availableNamespaces?.length) { + if (availableNamespaces.length) { const filteredNamespaces = filterQuery(availableNamespaces, visibleNamespaces); filteredCountOptions.namespacesToInclude = filteredNamespaces; } @@ -218,12 +219,12 @@ export class SavedObjectsTable extends Component ns.id) || []; - if (availableNamespaces?.length) { + if (availableNamespaces.length) { const filteredNamespaces = filterQuery(availableNamespaces, visibleNamespaces); findOptions.namespaces = filteredNamespaces; } @@ -822,7 +823,7 @@ export class SavedObjectsTable extends Component { return {