-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens][Visualizations] library annotation groups listing page (#157988)
- Loading branch information
1 parent
44bfd0c
commit 6553ebb
Showing
176 changed files
with
4,809 additions
and
2,414 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/content-management/tabbed_table_list_view/README.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
id: sharedUX/contentManagement/TabbedTableListView | ||
slug: /shared-ux/content-management/tabbed-table-list-view | ||
title: Tabbed table list view | ||
summary: A table to render user generated saved objects. | ||
tags: ['shared-ux', 'content-management'] | ||
date: 2022-08-09 | ||
--- | ||
|
||
The `<TabbedTableListView />` renders an eui page to display a list of user content saved object. | ||
|
||
**Uncomplete documentation**. Will be updated. | ||
|
||
## API | ||
|
||
TODO: https://github.com/elastic/kibana/issues/144402 | ||
|
||
## EUI Promotion Status | ||
|
||
This component is not currently considered for promotion to EUI. |
11 changes: 11 additions & 0 deletions
11
packages/content-management/tabbed_table_list_view/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { TabbedTableListView, type TableListTab, type TableListTabParentProps } from './src'; | ||
|
||
export type { UserContentCommonSchema } from '@kbn/content-management-table-list-view-table'; |
13 changes: 13 additions & 0 deletions
13
packages/content-management/tabbed_table_list_view/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../../..', | ||
roots: ['<rootDir>/packages/content-management/tabbed_table_list_view'], | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/content-management/tabbed_table_list_view/kibana.jsonc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/content-management-tabbed-table-list-view", | ||
"owner": "@elastic/appex-sharedux" | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/content-management/tabbed_table_list_view/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@kbn/content-management-tabbed-table-list-view", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/content-management/tabbed_table_list_view/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { | ||
TabbedTableListView, | ||
type TableListTab, | ||
type TableListTabParentProps, | ||
} from './tabbed_table_list_view'; |
128 changes: 128 additions & 0 deletions
128
packages/content-management/tabbed_table_list_view/src/tabbed_table_list_view.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { ReactWrapper, mount, shallow } from 'enzyme'; | ||
import { | ||
TabbedTableListView, | ||
TableListTabParentProps, | ||
TableListTab, | ||
} from './tabbed_table_list_view'; | ||
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template'; | ||
import { EuiPageTemplate } from '@elastic/eui'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
// Mock the necessary props for the component | ||
const title = 'Test Title'; | ||
const description = 'Test Description'; | ||
const headingId = 'test-heading-id'; | ||
const children = <div>Test Children</div>; | ||
|
||
const tableList1 = 'Test Table List 1'; | ||
const tableList2 = 'Test Table List 2'; | ||
|
||
const tabs: TableListTab[] = [ | ||
{ | ||
title: 'Tab 1', | ||
id: 'tab-1', | ||
getTableList: async (props: TableListTabParentProps) => <div>{tableList1}</div>, | ||
}, | ||
{ | ||
title: 'Tab 2', | ||
id: 'tab-2', | ||
getTableList: async (props: TableListTabParentProps) => <div>{tableList2}</div>, | ||
}, | ||
]; | ||
|
||
describe('TabbedTableListView', () => { | ||
it('should render without errors', () => { | ||
const wrapper = shallow( | ||
<TabbedTableListView | ||
title={title} | ||
description={description} | ||
headingId={headingId} | ||
children={children} | ||
tabs={tabs} | ||
activeTabId={'tab-1'} | ||
changeActiveTab={() => {}} | ||
/> | ||
); | ||
expect(wrapper.exists()).toBe(true); | ||
}); | ||
|
||
it('should render the correct title and description', () => { | ||
const wrapper = shallow( | ||
<TabbedTableListView | ||
title={title} | ||
description={description} | ||
headingId={headingId} | ||
children={children} | ||
tabs={tabs} | ||
activeTabId={'tab-1'} | ||
changeActiveTab={() => {}} | ||
/> | ||
); | ||
expect(wrapper.find(KibanaPageTemplate.Header).prop('pageTitle')).toMatchInlineSnapshot(` | ||
<span | ||
id="test-heading-id" | ||
> | ||
Test Title | ||
</span> | ||
`); | ||
expect(wrapper.find(KibanaPageTemplate.Header).prop('description')).toContain(description); | ||
}); | ||
|
||
it('should render the correct number of tabs', () => { | ||
const wrapper = shallow( | ||
<TabbedTableListView | ||
title={title} | ||
description={description} | ||
headingId={headingId} | ||
children={children} | ||
tabs={tabs} | ||
activeTabId={'tab-1'} | ||
changeActiveTab={() => {}} | ||
/> | ||
); | ||
|
||
expect(wrapper.find(EuiPageTemplate.Header).prop('tabs')).toHaveLength(2); | ||
}); | ||
|
||
it('should switch tabs when props change', async () => { | ||
const changeActiveTab = jest.fn(); | ||
|
||
let wrapper: ReactWrapper | undefined; | ||
await act(async () => { | ||
wrapper = mount( | ||
<TabbedTableListView | ||
title={title} | ||
description={description} | ||
headingId={headingId} | ||
children={children} | ||
tabs={tabs} | ||
activeTabId={'tab-1'} | ||
changeActiveTab={changeActiveTab} | ||
/> | ||
); | ||
}); | ||
|
||
if (!wrapper) { | ||
throw new Error("enzyme wrapper didn't initialize"); | ||
} | ||
|
||
expect(wrapper.find(EuiPageTemplate.Section).text()).toContain(tableList1); | ||
|
||
await act(async () => { | ||
wrapper?.setProps({ | ||
activeTabId: 'tab-2', | ||
}); | ||
}); | ||
|
||
expect(wrapper.find(EuiPageTemplate.Section).text()).toContain(tableList2); | ||
}); | ||
}); |
88 changes: 88 additions & 0 deletions
88
packages/content-management/tabbed_table_list_view/src/tabbed_table_list_view.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template'; | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import type { | ||
TableListViewTableProps, | ||
UserContentCommonSchema, | ||
} from '@kbn/content-management-table-list-view-table'; | ||
import type { TableListViewProps } from '@kbn/content-management-table-list-view'; | ||
|
||
export type TableListTabParentProps<T extends UserContentCommonSchema = UserContentCommonSchema> = | ||
Pick<TableListViewTableProps<T>, 'onFetchSuccess' | 'setPageDataTestSubject'>; | ||
|
||
export interface TableListTab<T extends UserContentCommonSchema = UserContentCommonSchema> { | ||
title: string; | ||
id: string; | ||
getTableList: ( | ||
propsFromParent: TableListTabParentProps<T> | ||
) => Promise<React.ReactNode> | React.ReactNode; | ||
} | ||
|
||
type TabbedTableListViewProps = Pick< | ||
TableListViewProps<UserContentCommonSchema>, | ||
'title' | 'description' | 'headingId' | 'children' | ||
> & { tabs: TableListTab[]; activeTabId: string; changeActiveTab: (id: string) => void }; | ||
|
||
export const TabbedTableListView = ({ | ||
title, | ||
description, | ||
headingId, | ||
children, | ||
tabs, | ||
activeTabId, | ||
changeActiveTab, | ||
}: TabbedTableListViewProps) => { | ||
const [hasInitialFetchReturned, setHasInitialFetchReturned] = useState(false); | ||
const [pageDataTestSubject, setPageDataTestSubject] = useState<string>(); | ||
|
||
const getActiveTab = useCallback( | ||
() => tabs.find((tab) => tab.id === activeTabId) ?? tabs[0], | ||
[activeTabId, tabs] | ||
); | ||
|
||
const [tableList, setTableList] = useState<React.ReactNode>(null); | ||
|
||
useEffect(() => { | ||
async function loadTableList() { | ||
const newTableList = await getActiveTab().getTableList({ | ||
onFetchSuccess: () => { | ||
if (!hasInitialFetchReturned) { | ||
setHasInitialFetchReturned(true); | ||
} | ||
}, | ||
setPageDataTestSubject, | ||
}); | ||
setTableList(newTableList); | ||
} | ||
|
||
loadTableList(); | ||
}, [hasInitialFetchReturned, activeTabId, tabs, getActiveTab]); | ||
|
||
return ( | ||
<KibanaPageTemplate panelled data-test-subj={pageDataTestSubject}> | ||
<KibanaPageTemplate.Header | ||
pageTitle={<span id={headingId}>{title}</span>} | ||
description={description} | ||
data-test-subj="top-nav" | ||
tabs={tabs.map((tab) => ({ | ||
onClick: () => changeActiveTab(tab.id), | ||
isSelected: tab.id === getActiveTab().id, | ||
label: tab.title, | ||
}))} | ||
/> | ||
<KibanaPageTemplate.Section aria-labelledby={hasInitialFetchReturned ? headingId : undefined}> | ||
{/* Any children passed to the component */} | ||
{children} | ||
|
||
{tableList} | ||
</KibanaPageTemplate.Section> | ||
</KibanaPageTemplate> | ||
); | ||
}; |
27 changes: 27 additions & 0 deletions
27
packages/content-management/tabbed_table_list_view/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types", | ||
"types": [ | ||
"jest", | ||
"node", | ||
"react", | ||
"@kbn/ambient-ui-types", | ||
"@kbn/ambient-storybook-types", | ||
"@emotion/react/types/css-prop" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
], | ||
"kbn_references": [ | ||
"@kbn/content-management-table-list-view", | ||
"@kbn/shared-ux-page-kibana-template", | ||
"@kbn/content-management-table-list-view-table", | ||
"@kbn/content-management-table-list-view", | ||
], | ||
"exclude": [ | ||
"target/**/*", | ||
] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { TableListView } from './src/table_list_view'; | ||
export type { TableListViewProps } from './src/table_list_view'; | ||
|
||
export type { UserContentCommonSchema } from '@kbn/content-management-table-list-view-table'; |
Oops, something went wrong.