Skip to content

Commit

Permalink
Merge branch 'main' into d/2023-09-14-project-name
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Sep 18, 2023
2 parents 579be42 + faf8774 commit 002f33d
Show file tree
Hide file tree
Showing 187 changed files with 1,620 additions and 987 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@
"object-hash": "^1.3.1",
"object-path-immutable": "^3.1.1",
"openai": "^3.3.0",
"openpgp": "5.3.0",
"openpgp": "5.10.1",
"opn": "^5.5.0",
"ora": "^4.0.4",
"p-limit": "^3.0.1",
Expand Down Expand Up @@ -1098,6 +1098,7 @@
"@jest/reporters": "^29.6.1",
"@jest/transform": "^29.6.1",
"@jest/types": "^29.6.1",
"@kayahr/text-encoding": "^1.2.0",
"@kbn/alerting-api-integration-helpers": "link:x-pack/test/alerting_api_integration/packages/helpers",
"@kbn/ambient-common-types": "link:packages/kbn-ambient-common-types",
"@kbn/ambient-ftr-types": "link:packages/kbn-ambient-ftr-types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ export const TagFilterPanel: FC<Props> = ({

<EuiFlexItem css={saveBtnWrapperCSS}>
<EuiButton onClick={closePopover}>
{i18n.translate('contentManagement.tableList.tagFilterPanel.applyButtonLabel', {
defaultMessage: 'Apply',
{i18n.translate('contentManagement.tableList.tagFilterPanel.doneButtonLabel', {
defaultMessage: 'Done',
})}
</EuiButton>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@ function kibanaHeaders() {
Accept: 'application/json',
'Content-Type': 'application/json',
'kbn-xsrf': 'kibana',
'elastic-api-version': '2023-10-31',
};
}
6 changes: 3 additions & 3 deletions packages/kbn-test/src/jest/setup/polyfills.jsdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ if (!global.URL.hasOwnProperty('createObjectURL')) {

// https://github.com/jsdom/jsdom/issues/2524
if (!global.hasOwnProperty('TextEncoder')) {
const { TextEncoder, TextDecoder } = require('util');
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
const customTextEncoding = require('@kayahr/text-encoding');
global.TextEncoder = customTextEncoding.TextEncoder;
global.TextDecoder = customTextEncoding.TextDecoder;
}

// NOTE: We should evaluate removing this once we upgrade to Node 18 and find out if loaders.gl already fixed this usage
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-ui-shared-deps-npm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ RUNTIME_DEPS = [
"@npm//tslib",
"@npm//uuid",
"@npm//io-ts",
"@npm//@reduxjs/toolkit",
"@npm//redux",
"@npm//react-redux",
"@npm//immer",
"@npm//reselect"
]

webpack_cli(
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-ui-shared-deps-npm/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ module.exports = (_, argv) => {
'@emotion/cache',
'@emotion/react',
'@hello-pangea/dnd/dist/dnd.js',
'@reduxjs/toolkit',
'redux',
'react-redux',
'immer',
'@tanstack/react-query',
'@tanstack/react-query-devtools',
'classnames',
Expand All @@ -103,6 +107,7 @@ module.exports = (_, argv) => {
'react-router-dom-v5-compat',
'react-router',
'react',
'reselect',
'rxjs',
'rxjs/operators',
'styled-components',
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-ui-shared-deps-src/src/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const externals = {
// this is how plugins/consumers from npm load monaco
'monaco-editor/esm/vs/editor/editor.api': '__kbnSharedDeps__.MonacoBarePluginApi',
'io-ts': '__kbnSharedDeps__.IoTs',
'@reduxjs/toolkit': '__kbnSharedDeps__.ReduxjsToolkit',
'react-redux': '__kbnSharedDeps__.ReactRedux',
redux: '__kbnSharedDeps__.Redux',
immer: '__kbnSharedDeps__.Immer',
reselect: '__kbnSharedDeps__.Reselect',

/**
* big deps which are locked to a single version
Expand Down
5 changes: 5 additions & 0 deletions packages/kbn-ui-shared-deps-src/src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export const ElasticEuiLibServicesFormat = require('@elastic/eui/optimize/es/ser
export const ElasticEuiChartsTheme = require('@elastic/eui/dist/eui_charts_theme');
export const KbnDatemath = require('@kbn/datemath');
export const HelloPangeaDnd = require('@hello-pangea/dnd/dist/dnd');
export const ReduxjsToolkit = require('@reduxjs/toolkit');
export const ReactRedux = require('react-redux');
export const Redux = require('redux');
export const Immer = require('immer');
export const Reselect = require('reselect');

export const Lodash = require('lodash');
export const LodashFp = require('lodash/fp');
Expand Down
5 changes: 3 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@
"tough-cookie",
"@types/tough-cookie",
"xml-crypto",
"@types/xml-crypto"
"@types/xml-crypto",
"@kayahr/text-encoding"
],
"reviewers": [
"team:kibana-security"
Expand Down Expand Up @@ -611,4 +612,4 @@
"enabled": true
}
]
}
}
2 changes: 1 addition & 1 deletion src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const DEV_ONLY_LICENSE_ALLOWED = ['MPL-2.0'];
// there are some licenses which should not be globally allowed
// but can be brought in on a per-package basis
export const PER_PACKAGE_ALLOWED_LICENSES = {
'openpgp@5.3.0': ['LGPL-3.0+'],
'openpgp@5.10.1': ['LGPL-3.0+'],
};
// Globally overrides a license for a given package@version
export const LICENSE_OVERRIDES = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ export const DiscoverContainerInternal = ({
css={discoverContainerWrapperCss}
data-test-subj="discover-container-internal-wrapper"
>
<EuiFlexItem>
<EuiFlexItem
css={css`
width: 100%;
`}
>
<KibanaContextProvider services={services}>
<DiscoverMainRoute
customizationCallbacks={customizationCallbacks}
Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export class CommonPageObject extends FtrService {
const navSuccessful = currentUrl
.replace(':80/', '/')
.replace(':443/', '/')
.startsWith(appUrl);
.startsWith(appUrl.replace(':80/', '/').replace(':443/', '/'));

if (!navSuccessful) {
const msg = `App failed to load: ${appName} in ${this.defaultFindTimeout}ms appUrl=${appUrl} currentUrl=${currentUrl}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('AssistantOverlay', () => {
it('renders when isAssistantEnabled prop is true and keyboard shortcut is pressed', () => {
const { getByTestId } = render(
<TestProviders providerContext={{ assistantTelemetry }}>
<AssistantOverlay isAssistantEnabled={true} />
<AssistantOverlay />
</TestProviders>
);
fireEvent.keyDown(document, { key: ';', ctrlKey: true });
Expand All @@ -34,7 +34,7 @@ describe('AssistantOverlay', () => {
it('modal closes when close button is clicked', () => {
const { getByLabelText, queryByTestId } = render(
<TestProviders>
<AssistantOverlay isAssistantEnabled={true} />
<AssistantOverlay />
</TestProviders>
);
fireEvent.keyDown(document, { key: ';', ctrlKey: true });
Expand All @@ -47,7 +47,7 @@ describe('AssistantOverlay', () => {
it('Assistant invoked from shortcut tracking happens on modal open only (not close)', () => {
render(
<TestProviders providerContext={{ assistantTelemetry }}>
<AssistantOverlay isAssistantEnabled={true} />
<AssistantOverlay />
</TestProviders>
);
fireEvent.keyDown(document, { key: ';', ctrlKey: true });
Expand All @@ -63,7 +63,7 @@ describe('AssistantOverlay', () => {
it('modal closes when shortcut is pressed and modal is already open', () => {
const { queryByTestId } = render(
<TestProviders>
<AssistantOverlay isAssistantEnabled={true} />
<AssistantOverlay />
</TestProviders>
);
fireEvent.keyDown(document, { key: ';', ctrlKey: true });
Expand All @@ -75,7 +75,7 @@ describe('AssistantOverlay', () => {
it('modal does not open when incorrect shortcut is pressed', () => {
const { queryByTestId } = render(
<TestProviders>
<AssistantOverlay isAssistantEnabled={true} />
<AssistantOverlay />
</TestProviders>
);
fireEvent.keyDown(document, { key: 'a', ctrlKey: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ const StyledEuiModal = styled(EuiModal)`
min-width: 95vw;
min-height: 25vh;
`;
interface Props {
isAssistantEnabled: boolean;
}

/**
* Modal container for Elastic AI Assistant conversations, receiving the page contents as context, plus whatever
* component currently has focus and any specific context it may provide through the SAssInterface.
*/
export const AssistantOverlay = React.memo<Props>(({ isAssistantEnabled }) => {
export const AssistantOverlay = React.memo(() => {
const [isModalVisible, setIsModalVisible] = useState(false);
const [conversationId, setConversationId] = useState<string | undefined>(
WELCOME_CONVERSATION_TITLE
Expand Down Expand Up @@ -103,11 +100,7 @@ export const AssistantOverlay = React.memo<Props>(({ isAssistantEnabled }) => {
<>
{isModalVisible && (
<StyledEuiModal onClose={handleCloseModal} data-test-subj="ai-assistant-modal">
<Assistant
isAssistantEnabled={isAssistantEnabled}
conversationId={conversationId}
promptContextId={promptContextId}
/>
<Assistant conversationId={conversationId} promptContextId={promptContextId} />
</StyledEuiModal>
)}
</>
Expand Down
33 changes: 22 additions & 11 deletions x-pack/packages/kbn-elastic-assistant/impl/assistant/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { WELCOME_CONVERSATION_TITLE } from './use_conversation/translations';
import { useLocalStorage } from 'react-use';
import { PromptEditor } from './prompt_editor';
import { QuickPrompts } from './quick_prompts/quick_prompts';
import { TestProviders } from '../mock/test_providers/test_providers';
import { mockAssistantAvailability, TestProviders } from '../mock/test_providers/test_providers';

jest.mock('../connectorland/use_load_connectors');
jest.mock('../connectorland/connector_setup');
Expand All @@ -46,10 +46,10 @@ const getInitialConversations = (): Record<string, Conversation> => ({
},
});

const renderAssistant = (extraProps = {}) =>
const renderAssistant = (extraProps = {}, providerProps = {}) =>
render(
<TestProviders getInitialConversations={getInitialConversations}>
<Assistant isAssistantEnabled {...extraProps} />
<TestProviders getInitialConversations={getInitialConversations} {...providerProps}>
<Assistant {...extraProps} />
</TestProviders>
);

Expand Down Expand Up @@ -110,9 +110,10 @@ describe('Assistant', () => {
data: connectors,
} as unknown as UseQueryResult<ActionConnector[], IHttpFetchError>);

const { getByLabelText } = render(
<TestProviders
getInitialConversations={() => ({
const { getByLabelText } = renderAssistant(
{},
{
getInitialConversations: () => ({
[WELCOME_CONVERSATION_TITLE]: {
id: WELCOME_CONVERSATION_TITLE,
messages: [],
Expand All @@ -124,10 +125,8 @@ describe('Assistant', () => {
apiConfig: {},
excludeFromLastConversationStorage: true,
},
})}
>
<Assistant isAssistantEnabled />
</TestProviders>
}),
}
);

expect(persistToLocalStorage).toHaveBeenCalled();
Expand Down Expand Up @@ -176,4 +175,16 @@ describe('Assistant', () => {
expect(persistToLocalStorage).toHaveBeenLastCalledWith(WELCOME_CONVERSATION_TITLE);
});
});

describe('when not authorized', () => {
it('should be disabled', async () => {
const { queryByTestId } = renderAssistant(
{},
{
assistantAvailability: { ...mockAssistantAvailability, isAssistantEnabled: false },
}
);
expect(queryByTestId('prompt-textarea')).toHaveProperty('disabled');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import { ConnectorMissingCallout } from '../connectorland/connector_missing_call

export interface Props {
conversationId?: string;
isAssistantEnabled: boolean;
promptContextId?: string;
shouldRefocusPrompt?: boolean;
showTitle?: boolean;
Expand All @@ -64,7 +63,6 @@ export interface Props {
*/
const AssistantComponent: React.FC<Props> = ({
conversationId,
isAssistantEnabled,
promptContextId = '',
shouldRefocusPrompt = false,
showTitle = true,
Expand All @@ -73,6 +71,7 @@ const AssistantComponent: React.FC<Props> = ({
const {
assistantTelemetry,
augmentMessageCodeBlocks,
assistantAvailability: { isAssistantEnabled },
conversations,
defaultAllow,
defaultAllowReplacement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ window.HTMLElement.prototype.scrollIntoView = jest.fn();

const mockGetInitialConversations = () => ({});

const mockAssistantAvailability: AssistantAvailability = {
export const mockAssistantAvailability: AssistantAvailability = {
hasAssistantPrivilege: false,
hasConnectorsAllPrivilege: true,
hasConnectorsReadPrivilege: true,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/packages/kbn-elastic-assistant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// happens in the root of your app. Optionally provide a custom title for the assistant:

/** provides context (from the app) to the assistant, and injects Kibana services, like `http` */
export { AssistantProvider } from './impl/assistant_context';
export { AssistantProvider, useAssistantContext } from './impl/assistant_context';

// Step 2: Add the `AssistantOverlay` component to your app. This component displays the assistant
// overlay in a modal, bound to a shortcut key:
Expand Down
12 changes: 12 additions & 0 deletions x-pack/plugins/fleet/common/services/agent_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ export function buildKueryForUpdatingAgents(): string {
export function buildKueryForInactiveAgents() {
return 'status:inactive';
}

export const AGENT_UPDATING_TIMEOUT_HOURS = 2;

export function isStuckInUpdating(agent: Agent): boolean {
return (
agent.status === 'updating' &&
!!agent.upgrade_started_at &&
!agent.upgraded_at &&
Date.now() - Date.parse(agent.upgrade_started_at) >
AGENT_UPDATING_TIMEOUT_HOURS * 60 * 60 * 1000
);
}
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/common/types/rest_spec/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface PostAgentUpgradeRequest {
body: {
source_uri?: string;
version: string;
force?: boolean;
};
}

Expand All @@ -111,6 +112,7 @@ export interface PostBulkAgentUpgradeRequest {
version: string;
rollout_duration_seconds?: number;
start_time?: string;
force?: boolean;
};
}

Expand Down
Loading

0 comments on commit 002f33d

Please sign in to comment.