Skip to content

Commit

Permalink
[Discover] Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jughosta committed Aug 2, 2023
1 parent e640e68 commit fb6eafe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,33 @@ import { css } from '@emotion/react';
import { i18n } from '@kbn/i18n';
import type { SearchResponseInterceptedWarning } from '../../types';

/**
* SearchResponseWarnings component props
*/
export interface SearchResponseWarningsProps {
/**
* An array of warnings which can have actions
*/
interceptedWarnings?: SearchResponseInterceptedWarning[];

/**
* View variant
*/
variant: 'callout' | 'badge' | 'empty_prompt';

/**
* Custom data-test-subj value
*/
'data-test-subj': string;
}

/**
* SearchResponseWarnings component
* @param interceptedWarnings
* @param variant
* @param dataTestSubj
* @constructor
*/
export const SearchResponseWarnings = ({
interceptedWarnings,
variant,
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-search-response-warnings/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import type { ReactNode } from 'react';
import type { SearchResponseWarning } from '@kbn/data-plugin/public';

/**
* Search Response Warning type which also includes an action
*/
export interface SearchResponseInterceptedWarning {
originalWarning: SearchResponseWarning;
action?: ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import type { RequestAdapter } from '@kbn/inspector-plugin/common';
import type { CoreStart } from '@kbn/core-lifecycle-browser';
import type { SearchResponseInterceptedWarning } from '../types';

/**
* Intercepts warnings for a search source request
* @param services
* @param adapter
* @param options
*/
export const getSearchResponseInterceptedWarnings = ({
services,
adapter,
Expand Down Expand Up @@ -63,6 +69,10 @@ export const getSearchResponseInterceptedWarnings = ({
return removeInterceptedWarningDuplicates(interceptedWarnings);
};

/**
* Removes duplicated warnings
* @param interceptedWarnings
*/
export const removeInterceptedWarningDuplicates = (
interceptedWarnings: SearchResponseInterceptedWarning[] | undefined
): SearchResponseInterceptedWarning[] | undefined => {
Expand Down

0 comments on commit fb6eafe

Please sign in to comment.