Skip to content

Commit

Permalink
[FEATURE] Create global state object for async requests opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#491

Signed-off-by: Jovan Cvetkovic <[email protected]>
  • Loading branch information
jovancvetkovic3006 committed Mar 26, 2023
1 parent 1b688fe commit 9daf6d9
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 127 deletions.
14 changes: 6 additions & 8 deletions public/pages/Main/components/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ import {
EuiLoadingSpinner,
} from '@elastic/eui';

export type TCalloutColor = 'primary' | 'success' | 'warning' | 'danger' | undefined;
export type TCalloutIcon = 'iInCircle' | 'check' | 'help' | 'alert' | undefined;
export type TCalloutColor = 'primary' | 'success' | 'warning' | 'danger';
export type TCalloutIcon = 'iInCircle' | 'check' | 'help' | 'alert';

interface ICalloutType {
color: TCalloutColor;
iconType: TCalloutIcon;
}

export interface ICalloutProps {
title: string;
title: string | JSX.Element;
message?: string | JSX.Element;
type?: ICalloutType | TCalloutColor;

closable?: boolean;
loading?: boolean;
closeHandler?: (callout?: ICalloutProps) => void;
Expand All @@ -40,15 +39,15 @@ export const CallOut = ({
closeHandler,
}: ICalloutProps) => {
const toastTypes: {
[Key in TCalloutColor]?: TCalloutIcon;
[Key in TCalloutColor]: TCalloutIcon;
} = {
primary: 'iInCircle',
success: 'check',
warning: 'help',
danger: 'alert',
};

const resolveType = (type?: ICalloutType | TCalloutColor | undefined): ICalloutType => {
const resolveType = (type?: ICalloutType | TCalloutColor): ICalloutType => {
if (type === undefined) {
return {
color: 'primary',
Expand All @@ -66,8 +65,6 @@ export const CallOut = ({
}
};

const { color, iconType } = resolveType(type);

const closeCallout = () => closeHandler && closeHandler(undefined);

const getTitle = (): JSX.Element => {
Expand All @@ -88,6 +85,7 @@ export const CallOut = ({
);
};

const { color, iconType } = resolveType(type);
return (
<>
<EuiCallOut
Expand Down
Loading

0 comments on commit 9daf6d9

Please sign in to comment.