Skip to content

Commit

Permalink
DQD
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Feb 19, 2025
1 parent 85e319c commit c6e83ee
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
* 2.0.
*/

import { EuiButtonEmpty, EuiButtonIcon, EuiToolTip } from '@elastic/eui';
import { EuiButtonEmpty, EuiButtonIcon, EuiLink, EuiToolTip } from '@elastic/eui';
import React, { useCallback, useMemo } from 'react';

import * as i18n from './translations';

export interface Props {
/** Optionally render new chat as a link */
asLink?: boolean;
children?: React.ReactNode;
showAssistantOverlay: (show: boolean) => void;
/** Defaults to `discuss`. If null, the button will not have an icon */
Expand All @@ -20,6 +22,7 @@ export interface Props {
}

const NewChatByTitleComponent: React.FC<Props> = ({
asLink = false,
children = i18n.NEW_CHAT,
showAssistantOverlay,
iconType,
Expand All @@ -40,7 +43,11 @@ const NewChatByTitleComponent: React.FC<Props> = ({

return useMemo(
() =>
iconOnly ? (
asLink ? (
<EuiLink data-test-subj="newChatLink" onClick={showOverlay}>
{children}
</EuiLink>
) : iconOnly ? (
<EuiToolTip content={i18n.NEW_CHAT}>
<EuiButtonIcon
data-test-subj="newChatByTitle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { FC, useCallback } from 'react';
import { NewChat } from '@kbn/elastic-assistant';
import { NewChatByTitle, useAssistantOverlay } from '@kbn/elastic-assistant';
import { css } from '@emotion/react';
import { useEuiTheme } from '@elastic/eui';

Expand All @@ -32,32 +32,32 @@ const useStyles = () => {
};

interface Props {
chatTitle?: string;
markdownComment: string;
indexName: string;
}

const ChatActionComponent: FC<Props> = ({ indexName, markdownComment }) => {
const ChatActionComponent: FC<Props> = ({ indexName, markdownComment, chatTitle }) => {
const styles = useStyles();
const { isAssistantEnabled } = useDataQualityContext();
const getPromptContext = useCallback(async () => markdownComment, [markdownComment]);

const { showAssistantOverlay } = useAssistantOverlay(
'data-quality-dashboard',
chatTitle ?? DATA_QUALITY_DASHBOARD_CONVERSATION_ID,
DATA_QUALITY_PROMPT_CONTEXT_PILL(indexName),
getPromptContext,
null,
DATA_QUALITY_SUGGESTED_USER_PROMPT,
DATA_QUALITY_PROMPT_CONTEXT_PILL_TOOLTIP,
isAssistantEnabled
);
return (
<NewChat
asLink={true}
category="data-quality-dashboard"
conversationId={DATA_QUALITY_DASHBOARD_CONVERSATION_ID}
description={DATA_QUALITY_PROMPT_CONTEXT_PILL(indexName)}
getPromptContext={getPromptContext}
suggestedUserPrompt={DATA_QUALITY_SUGGESTED_USER_PROMPT}
tooltip={DATA_QUALITY_PROMPT_CONTEXT_PILL_TOOLTIP}
isAssistantEnabled={isAssistantEnabled}
iconType={null}
>
<NewChatByTitle asLink showAssistantOverlay={showAssistantOverlay} iconType={null}>
<span css={styles.linkText}>
<AssistantIcon />
{ASK_ASSISTANT}
</span>
</NewChat>
</NewChatByTitle>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CopyToClipboardAction } from './copy_to_clipboard';
import { AddToNewCaseAction } from './add_to_new_case';

export interface Props {
chatTitle?: string;
markdownComment: string;
indexName?: string;
showAddToNewCaseAction?: boolean;
Expand All @@ -21,6 +22,7 @@ export interface Props {
}

const ActionsComponent: React.FC<Props> = ({
chatTitle,
showAddToNewCaseAction,
showCopyToClipboardAction,
showChatAction,
Expand Down Expand Up @@ -48,7 +50,11 @@ const ActionsComponent: React.FC<Props> = ({

{showChatAction && indexName && (
<EuiFlexItem grow={false}>
<ChatAction indexName={indexName} markdownComment={markdownComment} />
<ChatAction
chatTitle={chatTitle}
indexName={indexName}
markdownComment={markdownComment}
/>
</EuiFlexItem>
)}
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const HistoricalCheckFieldsComponent: React.FC<Props> = ({ indexName, historical
ecsFieldCount,
customFieldCount,
totalFieldCount,
checkedAt,
} = historicalResult;

const tabs = useMemo(
Expand All @@ -47,6 +48,7 @@ const HistoricalCheckFieldsComponent: React.FC<Props> = ({ indexName, historical
badgeCount: incompatibleFieldCount,
content: (
<IncompatibleTab
checkedAt={checkedAt}
docsCount={docsCount}
ilmPhase={ilmPhase}
indexName={indexName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { EuiSpacer } from '@elastic/eui';
import React, { useMemo } from 'react';

import { getFormattedCheckTime } from '../utils/get_formatted_check_time';
import { Actions } from '../../../../../actions';
import { getAllIncompatibleMarkdownComments } from '../../../../../utils/markdown';
import { IncompatibleCallout } from '../incompatible_callout';
Expand All @@ -26,6 +27,7 @@ import {
import { CheckSuccessEmptyPrompt } from '../check_success_empty_prompt';

interface Props {
checkedAt: number;
docsCount: number;
ilmPhase: IlmPhase | undefined;
indexName: string;
Expand All @@ -41,6 +43,7 @@ interface Props {
}

const IncompatibleTabComponent: React.FC<Props> = ({
checkedAt,
docsCount,
ilmPhase,
indexName,
Expand Down Expand Up @@ -95,6 +98,10 @@ const IncompatibleTabComponent: React.FC<Props> = ({
]
);

const chatTitle = useMemo(() => {
return `${indexName} - ${getFormattedCheckTime(checkedAt)}`;
}, [checkedAt, indexName]);

return (
<div data-test-subj="incompatibleTabContent">
{incompatibleFieldCount > 0 ? (
Expand Down Expand Up @@ -132,6 +139,7 @@ const IncompatibleTabComponent: React.FC<Props> = ({
<EuiSpacer size="m" />
{hasStickyActions ? (
<StickyActions
chatTitle={chatTitle}
markdownComment={markdownComment}
indexName={indexName}
showChatAction={true}
Expand All @@ -140,6 +148,7 @@ const IncompatibleTabComponent: React.FC<Props> = ({
/>
) : (
<Actions
chatTitle={chatTitle}
markdownComment={markdownComment}
indexName={indexName}
showChatAction={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export const IndexCheckFlyoutComponent: React.FC<Props> = ({
{selectedTabId === LATEST_CHECK_TAB_ID ? (
<>
<LatestResults
checkedAt={indexResult?.checkedAt ?? 0}
indexName={indexName}
stats={stats}
ilmExplain={ilmExplain}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ import {
} from '../translations';

export interface Props {
checkedAt: number;
ilmExplain: Record<string, IlmExplainLifecycleLifecycleExplain> | null;
indexName: string;
patternRollup: PatternRollup | undefined;
stats: Record<string, MeteringStatsIndex> | null;
}

const LatestResultsComponent: React.FC<Props> = ({
checkedAt,
indexName,
patternRollup,
stats,
Expand Down Expand Up @@ -80,6 +82,7 @@ const LatestResultsComponent: React.FC<Props> = ({
<IndexStatsPanel docsCount={docsCount} sizeInBytes={sizeInBytes ?? 0} ilmPhase={ilmPhase} />
<EuiSpacer />
<LatestCheckFields
checkedAt={checkedAt}
docsCount={docsCount}
ilmPhase={ilmPhase}
indexName={indexName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ const styles = {
};

export interface Props {
checkedAt: number;
indexName: string;
patternRollup: PatternRollup | undefined;
ilmPhase: IlmPhase | undefined;
docsCount: number;
}

const LatestCheckFieldsComponent: React.FC<Props> = ({
checkedAt,
indexName,
patternRollup,
ilmPhase,
Expand Down Expand Up @@ -95,6 +97,7 @@ const LatestCheckFieldsComponent: React.FC<Props> = ({
badgeCount: incompatibleFieldsCount,
content: (
<IncompatibleTab
checkedAt={checkedAt}
docsCount={docsCount}
ilmPhase={ilmPhase}
indexName={indexName}
Expand Down Expand Up @@ -165,6 +168,7 @@ const LatestCheckFieldsComponent: React.FC<Props> = ({
[
allFields,
allFieldsCount,
checkedAt,
customFields,
customFieldsCount,
docsCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { css } from '@emotion/react';
import { Actions } from '../../../../../../../actions';

interface Props {
chatTitle?: string;
markdownComment: string;
showAddToNewCaseAction?: boolean;
showCopyToClipboardAction?: boolean;
Expand All @@ -36,6 +37,7 @@ const useStyles = () => {
};

const StickyActionsComponent: FC<Props> = ({
chatTitle,
indexName,
markdownComment,
showCopyToClipboardAction,
Expand All @@ -47,6 +49,7 @@ const StickyActionsComponent: FC<Props> = ({
return (
<div css={styles.stickyContainer}>
<Actions
chatTitle={chatTitle}
indexName={indexName}
markdownComment={markdownComment}
showChatAction={showChatAction}
Expand Down

0 comments on commit c6e83ee

Please sign in to comment.