Skip to content

Commit

Permalink
Merge branch 'eql-sequence-suppression' of github.com:dhurley14/kiban…
Browse files Browse the repository at this point in the history
…a into eql-sequence-suppression
  • Loading branch information
dhurley14 committed Dec 2, 2024
2 parents 5bcdf9f + 9c35d5e commit 98a9c11
Show file tree
Hide file tree
Showing 33 changed files with 279 additions and 109 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"@elastic/numeral": "^2.5.1",
"@elastic/react-search-ui": "^1.20.2",
"@elastic/react-search-ui-views": "^1.20.2",
"@elastic/request-converter": "^8.16.1",
"@elastic/request-converter": "^8.16.2",
"@elastic/request-crypto": "^2.0.3",
"@elastic/search-ui": "^1.20.2",
"@elastic/search-ui-app-search-connector": "^1.20.2",
Expand Down Expand Up @@ -1030,7 +1030,7 @@
"@langchain/langgraph": "0.2.19",
"@langchain/openai": "^0.3.11",
"@langtrase/trace-attributes": "^3.0.8",
"@launchdarkly/node-server-sdk": "^9.7.1",
"@launchdarkly/node-server-sdk": "^9.7.2",
"@launchdarkly/openfeature-node-server": "^1.0.0",
"@loaders.gl/core": "^3.4.7",
"@loaders.gl/json": "^3.4.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('useLoadConnectorTypes', () => {
useLoadConnectorTypes({
http,
includeSystemActions: true,
featureId: 'alerting',
}),
{ wrapper }
);
Expand All @@ -68,6 +69,11 @@ describe('useLoadConnectorTypes', () => {
supportedFeatureIds: ['alerting'],
},
]);
expect(http.get).toHaveBeenCalledWith('/internal/actions/connector_types', {
query: {
feature_id: 'alerting',
},
});
});

test('should call the correct endpoint if system actions is true', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ export interface UseLoadConnectorTypesProps {
http: HttpStart;
includeSystemActions?: boolean;
enabled?: boolean;
featureId?: string;
}

export const useLoadConnectorTypes = (props: UseLoadConnectorTypesProps) => {
const { http, includeSystemActions, enabled = true } = props;
const { http, includeSystemActions, enabled = true, featureId } = props;

const queryFn = () => {
return fetchConnectorTypes({ http, includeSystemActions });
return fetchConnectorTypes({ http, featureId, includeSystemActions });
};

const { data, isLoading, isFetching, isInitialLoading } = useQuery({
queryKey: ['useLoadConnectorTypes', includeSystemActions],
queryKey: ['useLoadConnectorTypes', includeSystemActions, featureId],
queryFn,
refetchOnWindowFocus: false,
enabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface CreateRuleFormProps {
ruleTypeId: string;
plugins: RuleFormPlugins;
consumer?: string;
connectorFeatureId?: string;
multiConsumerSelection?: RuleCreationValidConsumer | null;
hideInterval?: boolean;
validConsumers?: RuleCreationValidConsumer[];
Expand All @@ -52,6 +53,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
ruleTypeId,
plugins,
consumer = 'alerts',
connectorFeatureId = 'alerting',
multiConsumerSelection,
validConsumers = DEFAULT_VALID_CONSUMERS,
filteredRuleTypes = [],
Expand Down Expand Up @@ -107,6 +109,7 @@ export const CreateRuleForm = (props: CreateRuleFormProps) => {
consumer,
validConsumers,
filteredRuleTypes,
connectorFeatureId,
});

const onSave = useCallback(
Expand Down
11 changes: 10 additions & 1 deletion packages/kbn-alerts-ui-shared/src/rule_form/edit_rule_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ export interface EditRuleFormProps {
id: string;
plugins: RuleFormPlugins;
showMustacheAutocompleteSwitch?: boolean;
connectorFeatureId?: string;
onCancel?: () => void;
onSubmit?: (ruleId: string) => void;
}

export const EditRuleForm = (props: EditRuleFormProps) => {
const { id, plugins, showMustacheAutocompleteSwitch = false, onCancel, onSubmit } = props;
const {
id,
plugins,
showMustacheAutocompleteSwitch = false,
connectorFeatureId = 'alerting',
onCancel,
onSubmit,
} = props;
const { http, notifications, docLinks, ruleTypeRegistry, i18n, theme, application } = plugins;
const { toasts } = notifications;

Expand Down Expand Up @@ -80,6 +88,7 @@ export const EditRuleForm = (props: EditRuleFormProps) => {
capabilities: plugins.application.capabilities,
ruleTypeRegistry,
id,
connectorFeatureId,
});

const onSave = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface UseLoadDependencies {
ruleTypeId?: string;
validConsumers?: RuleCreationValidConsumer[];
filteredRuleTypes?: string[];
connectorFeatureId?: string;
}

export const useLoadDependencies = (props: UseLoadDependencies) => {
Expand All @@ -46,6 +47,7 @@ export const useLoadDependencies = (props: UseLoadDependencies) => {
ruleTypeId,
capabilities,
filteredRuleTypes = [],
connectorFeatureId,
} = props;

const canReadConnectors = !!capabilities.actions?.show;
Expand Down Expand Up @@ -113,6 +115,7 @@ export const useLoadDependencies = (props: UseLoadDependencies) => {
http,
includeSystemActions: true,
enabled: canReadConnectors,
featureId: connectorFeatureId,
});

const {
Expand Down
32 changes: 19 additions & 13 deletions x-pack/packages/kbn-ai-assistant/src/chat/chat_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

import {
EuiCallOut,
euiCanAnimate,
EuiFlexGroup,
EuiFlexItem,
EuiHorizontalRule,
EuiPanel,
euiScrollBarStyles,
EuiSpacer,
useEuiTheme,
UseEuiTheme,
} from '@elastic/eui';
import { css, keyframes } from '@emotion/css';
import { i18n } from '@kbn/i18n';
Expand All @@ -28,7 +30,6 @@ import {
type Feedback,
} from '@kbn/observability-ai-assistant-plugin/public';
import type { AuthenticatedUser } from '@kbn/security-plugin/common';
import { euiThemeVars } from '@kbn/ui-theme';
import { findLastIndex } from 'lodash';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import type { UseKnowledgeBaseResult } from '../hooks/use_knowledge_base';
Expand Down Expand Up @@ -56,14 +57,16 @@ const timelineClassName = (scrollBarStyles: string) => css`
${scrollBarStyles}
`;

const promptEditorClassname = css`
const promptEditorClassname = (euiTheme: UseEuiTheme['euiTheme']) => css`
overflow: hidden;
transition: height ${euiThemeVars.euiAnimSpeedFast} ${euiThemeVars.euiAnimSlightResistance};
${euiCanAnimate} {
transition: height ${euiTheme.animation.fast} ${euiTheme.animation.resistance};
}
`;

const incorrectLicenseContainer = css`
const incorrectLicenseContainer = (euiTheme: UseEuiTheme['euiTheme']) => css`
height: 100%;
padding: ${euiThemeVars.euiPanelPaddingModifiers.paddingMedium};
padding: ${euiTheme.size.base};
`;

const chatBodyContainerClassNameWithError = css`
Expand All @@ -86,11 +89,13 @@ const fadeInAnimation = keyframes`
}
`;

const animClassName = css`
const animClassName = (euiTheme: UseEuiTheme['euiTheme']) => css`
height: 100%;
opacity: 0;
animation: ${fadeInAnimation} ${euiThemeVars.euiAnimSpeedNormal}
${euiThemeVars.euiAnimSlightBounce} ${euiThemeVars.euiAnimSpeedNormal} forwards;
${euiCanAnimate} {
animation: ${fadeInAnimation} ${euiTheme.animation.normal} ${euiTheme.animation.bounce}
${euiTheme.animation.normal} forwards;
}
`;

const containerClassName = css`
Expand Down Expand Up @@ -127,8 +132,9 @@ export function ChatBody({
}) {
const license = useLicense();
const hasCorrectLicense = license?.hasAtLeast('enterprise');
const euiTheme = useEuiTheme();
const scrollBarStyles = euiScrollBarStyles(euiTheme);
const theme = useEuiTheme();
const scrollBarStyles = euiScrollBarStyles(theme);
const { euiTheme } = theme;

const chatService = useAIAssistantChatService();

Expand Down Expand Up @@ -310,7 +316,7 @@ export function ChatBody({
if (!hasCorrectLicense && !initialConversationId) {
footer = (
<>
<EuiFlexItem grow className={incorrectLicenseContainer}>
<EuiFlexItem grow className={incorrectLicenseContainer(euiTheme)}>
<IncorrectLicensePanel />
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down Expand Up @@ -347,7 +353,7 @@ export function ChatBody({
hasBorder={false}
hasShadow={false}
paddingSize="m"
className={animClassName}
className={animClassName(euiTheme)}
>
{connectors.connectors?.length === 0 || messages.length === 1 ? (
<WelcomeMessage
Expand Down Expand Up @@ -400,7 +406,7 @@ export function ChatBody({

<EuiFlexItem
grow={false}
className={promptEditorClassname}
className={promptEditorClassname(euiTheme)}
style={{ height: promptEditorHeight }}
>
<EuiHorizontalRule margin="none" />
Expand Down
4 changes: 3 additions & 1 deletion x-pack/packages/kbn-ai-assistant/src/chat/chat_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export function ChatHeader({
size={breakpoint === 'xs' ? 'xs' : 's'}
value={newTitle}
className={css`
color: ${!!title ? theme.euiTheme.colors.text : theme.euiTheme.colors.subduedText};
color: ${!!title
? theme.euiTheme.colors.textParagraph
: theme.euiTheme.colors.textSubdued};
`}
inputAriaLabel={i18n.translate('xpack.aiAssistant.chatHeader.editConversationInput', {
defaultMessage: 'Edit conversation',
Expand Down
7 changes: 5 additions & 2 deletions x-pack/packages/kbn-ai-assistant/src/chat/chat_item_title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
* 2.0.
*/

import { euiThemeVars } from '@kbn/ui-theme';
import React, { ReactNode } from 'react';
import { css } from '@emotion/react';
import { useEuiTheme } from '@elastic/eui';

interface ChatItemTitleProps {
actionsTrigger?: ReactNode;
title: string;
}

export function ChatItemTitle({ actionsTrigger, title }: ChatItemTitleProps) {
const { euiTheme } = useEuiTheme();

const containerCSS = css`
position: absolute;
top: 2;
right: ${euiThemeVars.euiSizeS};
right: ${euiTheme.size.s};
`;

return (
<>
{title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ import {
EuiPanel,
EuiText,
EuiTitle,
useEuiTheme,
} from '@elastic/eui';
import { css } from '@emotion/css';
import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-theme';
import { elasticAiAssistantImage } from '@kbn/observability-ai-assistant-plugin/public';
import { UPGRADE_LICENSE_TITLE } from '../i18n';
import { useLicenseManagementLocator } from '../hooks/use_license_management_locator';

const incorrectLicenseContainer = css`
height: 100%;
padding: ${euiThemeVars.euiPanelPaddingModifiers.paddingMedium};
`;

export function IncorrectLicensePanel() {
const handleNavigateToLicenseManagement = useLicenseManagementLocator();
const { euiTheme } = useEuiTheme();

const incorrectLicenseContainer = css`
height: 100%;
padding: ${euiTheme.size.base};
`;

return (
<EuiPanel hasBorder hasShadow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import {
EuiSpacer,
EuiText,
EuiIconTip,
useEuiTheme,
euiCanAnimate,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-theme';
import { isHttpFetchError } from '@kbn/core-http-browser';
import type { UseGenAIConnectorsResult } from '../hooks/use_genai_connectors';

Expand All @@ -30,17 +31,21 @@ const fadeInAnimation = keyframes`
}
`;

const fadeInClassName = css`
animation: ${fadeInAnimation} ${euiThemeVars.euiAnimSpeedNormal} ease-in-out;
`;

export function WelcomeMessageConnectors({
connectors,
onSetupConnectorClick,
}: {
connectors: UseGenAIConnectorsResult;
onSetupConnectorClick?: () => void;
}) {
const { euiTheme } = useEuiTheme();

const fadeInClassName = css`
${euiCanAnimate} {
animation: ${fadeInAnimation} ${euiTheme.animation.normal} ease-in-out;
}
`;

if (connectors.error) {
const isForbiddenError =
isHttpFetchError(connectors.error) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiSpacer, useEuiTheme } from '@elastic/eui';
import { css } from '@emotion/css';
import { euiThemeVars } from '@kbn/ui-theme';
import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom';
import type { AssistantScope } from '@kbn/ai-assistant-common';
Expand Down Expand Up @@ -105,7 +104,7 @@ export const ConversationView: React.FC<ConversationViewProps> = ({
const conversationListContainerName = css`
min-width: 250px;
width: 250px;
border-right: solid 1px ${euiThemeVars.euiColorLightShade};
border-right: solid 1px ${euiTheme.border.color};
`;

const sidebarContainerClass = css`
Expand All @@ -117,8 +116,8 @@ export const ConversationView: React.FC<ConversationViewProps> = ({
height: calc(100% - 56px);
background-color: ${euiTheme.colors.lightestShade};
width: ${isSecondSlotVisible ? SECOND_SLOT_CONTAINER_WIDTH : 0}px;
border-top: solid 1px ${euiThemeVars.euiColorLightShade};
border-left: solid 1px ${euiThemeVars.euiColorLightShade};
border-top: solid 1px ${euiTheme.border.color};
border-left: solid 1px ${euiTheme.border.color};
.euiFlyoutHeader {
padding: ${euiTheme.size.m};
Expand Down
1 change: 0 additions & 1 deletion x-pack/packages/kbn-ai-assistant/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@kbn/triggers-actions-ui-plugin",
"@kbn/actions-plugin",
"@kbn/i18n-react",
"@kbn/ui-theme",
"@kbn/core",
"@kbn/observability-ai-assistant-plugin",
"@kbn/security-plugin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { categories } from '../../containers/mock';
import { MAX_CATEGORY_LENGTH } from '../../../common/constants';
import { FormTestComponent } from '../../common/test_utils';

describe('Category', () => {
// Failing: See https://github.com/elastic/kibana/issues/177791
describe.skip('Category', () => {
const onSubmit = jest.fn();

it('renders the category field correctly', async () => {
Expand Down
Loading

0 comments on commit 98a9c11

Please sign in to comment.