Skip to content

Commit

Permalink
Update license headers and address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <cwperx@amazon.com>
  • Loading branch information
cwperks committed Nov 2, 2022
1 parent 57b98b0 commit bf6d8ad
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
14 changes: 5 additions & 9 deletions src/plugins/saved_objects_management/public/lib/filter_query.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import { HttpStart } from 'src/core/public';

interface SavedObjectCountOptions {
export interface SavedObjectCountOptions {
typesToInclude: string[];
namespacesToInclude?: string[];
searchString?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/saved_objects_management/public/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import { IndexPatternsContract } from '../../../../data/public';
import {
parseQuery,
getSavedObjectCounts,
SavedObjectCountOptions,
getRelationships,
getSavedObjectLabel,
fetchExportObjects,
Expand Down Expand Up @@ -186,12 +187,12 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb

const availableNamespaces = namespaceRegistry.getAll()?.map((ns) => 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;
}
Expand All @@ -218,12 +219,12 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
exportAllSelectedOptions[id] = true;
});

const countOptions = {
const countOptions: SavedObjectCountOptions = {
typesToInclude: allowedTypes,
searchString: queryText,
};

if (availableNamespaces?.length) {
if (availableNamespaces.length) {
countOptions.namespacesToInclude = availableNamespaces;
}

Expand Down Expand Up @@ -263,7 +264,7 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
};

const availableNamespaces = namespaceRegistry.getAll()?.map((ns) => ns.id) || [];
if (availableNamespaces?.length) {
if (availableNamespaces.length) {
const filteredNamespaces = filterQuery(availableNamespaces, visibleNamespaces);
findOptions.namespaces = filteredNamespaces;
}
Expand Down Expand Up @@ -822,7 +823,7 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
];

const availableNamespaces = namespaceRegistry.getAll() || [];
if (availableNamespaces?.length) {
if (availableNamespaces.length) {
const nsCounts = savedObjectCounts.namespaces || {};
const nsFilterOptions = availableNamespaces.map((ns) => {
return {
Expand Down

0 comments on commit bf6d8ad

Please sign in to comment.