Skip to content

Commit

Permalink
Merge branch 'main' into 199964-obsux-inventory-remove-open-in-discov…
Browse files Browse the repository at this point in the history
…er-button
  • Loading branch information
jennypavlova authored Nov 18, 2024
2 parents 50b6b85 + b6c5423 commit ee00950
Show file tree
Hide file tree
Showing 109 changed files with 1,464 additions and 424 deletions.
10 changes: 9 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ packages/core/security/core-security-server @elastic/kibana-core
packages/core/security/core-security-server-internal @elastic/kibana-core
packages/core/security/core-security-server-mocks @elastic/kibana-core
packages/core/status/core-status-common @elastic/kibana-core
packages/core/status/core-status-common-internal @elastic/kibana-core
packages/core/status/core-status-server @elastic/kibana-core
packages/core/status/core-status-server-internal @elastic/kibana-core
packages/core/status/core-status-server-mocks @elastic/kibana-core
Expand Down Expand Up @@ -1283,6 +1282,9 @@ x-pack/test_serverless/**/test_suites/observability/ai_assistant @elastic/obs-ai
/x-pack/test_serverless/**/test_suites/observability/infra/ @elastic/obs-ux-infra_services-team

# Elastic Stack Monitoring
/x-pack/test/monitoring_api_integration @elastic/stack-monitoring
/x-pack/test/functional/page_objects/monitoring_page.ts @elastic/stack-monitoring
/x-pack/test/functional/es_archives/monitoring @elastic/stack-monitoring
/x-pack/test/functional/services/monitoring @elastic/stack-monitoring
/x-pack/test/functional/apps/monitoring @elastic/stack-monitoring
/x-pack/test/api_integration/apis/monitoring @elastic/stack-monitoring
Expand Down Expand Up @@ -1350,6 +1352,12 @@ x-pack/test_serverless/**/test_suites/observability/ai_assistant @elastic/obs-ai
/src/plugins/unified_doc_viewer/public/components/doc_viewer_logs_overview @elastic/obs-ux-logs-team
/x-pack/test/api_integration/apis/logs_shared @elastic/obs-ux-logs-team

# Observability-ui
/x-pack/test_serverless/api_integration/test_suites/observability/index.ts @elastic/observability-ui
/x-pack/test/functional_solution_sidenav/tests/observability_sidenav.ts @elastic/observability-ui
/x-pack/test/functional/page_objects/observability_page.ts @elastic/observability-ui
/x-pack/test_serverless/**/test_suites/observability/config.ts @elastic/observability-ui

# Observability onboarding tour
/x-pack/plugins/observability_solution/observability_shared/public/components/tour @elastic/appex-sharedux
/x-pack/test/functional/apps/infra/tour.ts @elastic/appex-sharedux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const FinderApp = (props: {
<ContentClientProvider contentClient={props.contentClient}>
<I18nProvider>
<SavedObjectFinder
id="cmFinderApp"
showFilter={true}
services={{
savedObjectsTagging: props.savedObjectsTagging.getTaggingApi(),
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@
"@kbn/core-security-server-internal": "link:packages/core/security/core-security-server-internal",
"@kbn/core-security-server-mocks": "link:packages/core/security/core-security-server-mocks",
"@kbn/core-status-common": "link:packages/core/status/core-status-common",
"@kbn/core-status-common-internal": "link:packages/core/status/core-status-common-internal",
"@kbn/core-status-server": "link:packages/core/status/core-status-server",
"@kbn/core-status-server-internal": "link:packages/core/status/core-status-server-internal",
"@kbn/core-test-helpers-deprecations-getters": "link:packages/core/test-helpers/core-test-helpers-deprecations-getters",
Expand Down
20 changes: 20 additions & 0 deletions packages/content-management/table_list_view_table/src/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import React from 'react';
import { from } from 'rxjs';
import type { IStorage } from '@kbn/kibana-utils-plugin/public';

import type { Services, TagListProps } from './services';

Expand Down Expand Up @@ -149,3 +150,22 @@ export const getStoryArgTypes = () => ({
defaultValue: false,
},
});

export const localStorageMock = (): IStorage => {
let store: Record<string, unknown> = {};

return {
getItem: (key: string) => {
return store[key] || null;
},
setItem: (key: string, value: unknown) => {
store[key] = value;
},
clear() {
store = {};
},
removeItem(key: string) {
delete store[key];
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { LocationDescriptor, History } from 'history';
import type { UserContentCommonSchema } from '@kbn/content-management-table-list-view-common';

import { WithServices } from './__jest__';
import { getTagList } from './mocks';
import { getTagList, localStorageMock } from './mocks';
import { TableListViewTable, type TableListViewTableProps } from './table_list_view_table';
import { getActions } from './table_list_view.test.helpers';
import type { Services } from './services';
Expand Down Expand Up @@ -335,6 +335,12 @@ describe('TableListView', () => {
const totalItems = 30;
const updatedAt = new Date().toISOString();

beforeEach(() => {
Object.defineProperty(window, 'localStorage', {
value: localStorageMock(),
});
});

const hits: UserContentCommonSchema[] = [...Array(totalItems)].map((_, i) => ({
id: `item${i}`,
type: 'dashboard',
Expand Down Expand Up @@ -429,6 +435,54 @@ describe('TableListView', () => {
expect(firstRowTitle).toBe('Item 20');
expect(lastRowTitle).toBe('Item 29');
});

test('should persist the number of rows in the table', async () => {
let testBed: TestBed;

const tableId = 'myTable';

await act(async () => {
testBed = await setup({
initialPageSize,
findItems: jest.fn().mockResolvedValue({ total: hits.length, hits: [...hits] }),
id: tableId,
});
});

{
const { component, table, find } = testBed!;
component.update();

const { tableCellsValues } = table.getMetaData('itemsInMemTable');
expect(tableCellsValues.length).toBe(20); // 20 by default

let storageValue = localStorage.getItem(`tablePersist:${tableId}`);
expect(storageValue).toBe(null);

find('tablePaginationPopoverButton').simulate('click');
find('tablePagination-10-rows').simulate('click');

storageValue = localStorage.getItem(`tablePersist:${tableId}`);
expect(storageValue).not.toBe(null);
expect(JSON.parse(storageValue!).pageSize).toBe(10);
}

// Mount a second table and verify that is shows only 10 rows
{
await act(async () => {
testBed = await setup({
initialPageSize,
findItems: jest.fn().mockResolvedValue({ total: hits.length, hits: [...hits] }),
id: tableId,
});
});

const { component, table } = testBed!;
component.update();
const { tableCellsValues } = table.getMetaData('itemsInMemTable');
expect(tableCellsValues.length).toBe(10); // 10 items this time
}
});
});

describe('column sorting', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
ContentInsightsProvider,
useContentInsightsServices,
} from '@kbn/content-management-content-insights-public';
import { useEuiTablePersist } from '@kbn/shared-ux-table-persist';

import {
Table,
Expand Down Expand Up @@ -443,7 +444,7 @@ function TableListViewTableComp<T extends UserContentCommonSchema>({
hasUpdatedAtMetadata,
hasCreatedByMetadata,
hasRecentlyAccessedMetadata,
pagination,
pagination: _pagination,
tableSort,
tableFilter,
} = state;
Expand Down Expand Up @@ -903,7 +904,7 @@ function TableListViewTableComp<T extends UserContentCommonSchema>({
[updateTableSortFilterAndPagination]
);

const onTableChange = useCallback(
const customOnTableChange = useCallback(
(criteria: CriteriaWithPagination<T>) => {
const data: {
sort?: State<T>['tableSort'];
Expand Down Expand Up @@ -1038,6 +1039,20 @@ function TableListViewTableComp<T extends UserContentCommonSchema>({
);
}, [entityName, fetchError]);

const { pageSize, onTableChange } = useEuiTablePersist({
tableId: listingId,
initialPageSize,
customOnTableChange,
pageSizeOptions: uniq([10, 20, 50, initialPageSize]).sort(),
});

const pagination = useMemo<Pagination>(() => {
return {
..._pagination,
pageSize,
};
}, [_pagination, pageSize]);

// ------------
// Effects
// ------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"@kbn/content-management-user-profiles",
"@kbn/recently-accessed",
"@kbn/content-management-content-insights-public",
"@kbn/content-management-favorites-public"
"@kbn/content-management-favorites-public",
"@kbn/kibana-utils-plugin",
"@kbn/shared-ux-table-persist"
],
"exclude": [
"target/**/*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import React from 'react';
import { shallow } from 'enzyme';
import type { StatusInfoServiceStatus as ServiceStatus } from '@kbn/core-status-common-internal';
import type { StatusInfoServiceStatus as ServiceStatus } from '@kbn/core-status-common';
import { StatusTable } from './status_table';

const state = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import React from 'react';
import { mountWithIntl, findTestSubject } from '@kbn/test-jest-helpers';
import type { ServerVersion } from '@kbn/core-status-common-internal';
import type { ServerVersion } from '@kbn/core-status-common';
import { VersionHeader } from './version_header';

const buildServerVersion = (parts: Partial<ServerVersion> = {}): ServerVersion => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import React, { FC } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { ServerVersion } from '@kbn/core-status-common-internal';
import type { ServerVersion } from '@kbn/core-status-common';

interface VersionHeaderProps {
version: ServerVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { httpServiceMock } from '@kbn/core-http-browser-mocks';
import type { StatusResponse } from '@kbn/core-status-common-internal';
import type { StatusResponse } from '@kbn/core-status-common';
import { notificationServiceMock } from '@kbn/core-notifications-browser-mocks';
import { mocked } from '@kbn/core-metrics-collectors-server-mocks';
import { loadStatus } from './load_status';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
import type { HttpSetup } from '@kbn/core-http-browser';
import type { NotificationsSetup } from '@kbn/core-notifications-browser';
import type { ServiceStatusLevelId } from '@kbn/core-status-common';
import type {
ServiceStatusLevelId,
StatusResponse,
StatusInfoServiceStatus as ServiceStatus,
} from '@kbn/core-status-common-internal';
} from '@kbn/core-status-common';
import type { DataType } from './format_number';

interface MetricMeta {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { StatusInfoServiceStatus as ServiceStatus } from '@kbn/core-status-common-internal';
import type { StatusInfoServiceStatus as ServiceStatus } from '@kbn/core-status-common';
import { getLevelSortValue, groupByLevel, getHighestStatus } from './status_level';
import { FormattedStatus, StatusState } from './load_status';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@kbn/core-application-browser",
"@kbn/core-application-browser-internal",
"@kbn/core-mount-utils-browser-internal",
"@kbn/core-status-common-internal",
"@kbn/core-http-browser-internal",
"@kbn/core-application-browser-mocks",
"@kbn/core-notifications-browser-mocks",
Expand Down
3 changes: 0 additions & 3 deletions packages/core/status/core-status-common-internal/README.md

This file was deleted.

17 changes: 0 additions & 17 deletions packages/core/status/core-status-common-internal/index.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/core/status/core-status-common-internal/jest.config.js

This file was deleted.

5 changes: 0 additions & 5 deletions packages/core/status/core-status-common-internal/kibana.jsonc

This file was deleted.

7 changes: 0 additions & 7 deletions packages/core/status/core-status-common-internal/package.json

This file was deleted.

17 changes: 0 additions & 17 deletions packages/core/status/core-status-common-internal/src/index.ts

This file was deleted.

22 changes: 0 additions & 22 deletions packages/core/status/core-status-common-internal/tsconfig.json

This file was deleted.

13 changes: 11 additions & 2 deletions packages/core/status/core-status-common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { ServiceStatusLevels } from './src';
export type { ServiceStatus, ServiceStatusLevel, ServiceStatusLevelId, CoreStatus } from './src';
export { ServiceStatusLevels } from './src/service_status';
export type { CoreStatus } from './src/core_status';
export type { ServiceStatus, ServiceStatusLevel, ServiceStatusLevelId } from './src/service_status';
export type {
StatusInfo,
StatusInfoCoreStatus,
StatusInfoServiceStatus,
StatusResponse,
ServerVersion,
ServerMetrics,
} from './src/status';
2 changes: 1 addition & 1 deletion packages/core/status/core-status-common/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/status/core-status-common-internal'],
roots: ['<rootDir>/packages/core/status/core-status-common'],
};
Loading

0 comments on commit ee00950

Please sign in to comment.