Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens][Visualizations] library annotation groups listing page #157988

Merged
Merged
Show file tree
Hide file tree
Changes from 209 commits
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
22fa4b5
merge martas work
drewdaemon Feb 28, 2023
f32c013
saving annotation group to library
drewdaemon Feb 28, 2023
d398395
unit test save action
drewdaemon Mar 1, 2023
89b38a7
extract annotation group references for persistence
drewdaemon Mar 1, 2023
a47d143
library annotation groups removed from lens saved object and loaded a…
drewdaemon Mar 2, 2023
e47c17b
report data views used by annotation groups
drewdaemon Mar 2, 2023
ad14b60
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Mar 2, 2023
968cb74
support by-ref annotation groups in embeddable
drewdaemon Mar 2, 2023
c27a6a3
improve saved object reference names and schema
drewdaemon Mar 2, 2023
568b89c
reverting a few name changes
drewdaemon Mar 2, 2023
10bb53d
show saved title in layer panel header
drewdaemon Mar 3, 2023
3a87ab7
save annotations in modal instead of flyout
drewdaemon Mar 7, 2023
26aff6f
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Mar 7, 2023
dd6ef59
functional test: saving an annotation group
drewdaemon Mar 8, 2023
b47030c
better abstractions in the save action modal setup
drewdaemon Mar 8, 2023
b6c7c02
updating and copying existing annotation group
drewdaemon Mar 8, 2023
45c6ca2
improve object type message
drewdaemon Mar 9, 2023
eb4ba12
simplifying annotation layer actions logic
drewdaemon Mar 9, 2023
685645d
introduce linked by-value annotation layers
drewdaemon Mar 9, 2023
b10e5a7
more accurate typings
drewdaemon Mar 10, 2023
ec2f544
leave functional testing note
drewdaemon Mar 10, 2023
32af469
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Mar 10, 2023
899f6ee
refactor components to use SavedObjectsFinder
drewdaemon Mar 10, 2023
c1964ad
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Mar 20, 2023
8c4abb8
add missing type refs
drewdaemon Mar 20, 2023
d18c833
add existing annotation groups from library
drewdaemon Mar 20, 2023
f149af6
add append annotation layer unit tests
drewdaemon Mar 21, 2023
8f0cb7c
functional test for add from library
drewdaemon Mar 21, 2023
9c37ce4
unlink action
drewdaemon Mar 21, 2023
15d8ec7
revert action
drewdaemon Mar 22, 2023
130777a
fix extra annotation group bug
drewdaemon Mar 22, 2023
2d3fda8
fix some type errors
drewdaemon Mar 22, 2023
d02132d
remove annotation layers if library group has been deleted
drewdaemon Mar 23, 2023
c2f1b78
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Mar 23, 2023
ae5486c
Add missing group functional test
drewdaemon Mar 23, 2023
0abb991
warn users only when they're discarding annotation changes
drewdaemon Mar 24, 2023
1e80420
support saving and loading groups with ad-hoc data views
drewdaemon Mar 29, 2023
7778006
add ad-hoc data view to lens when annotation group added
drewdaemon Mar 29, 2023
ffd9a1d
fix some types
drewdaemon Mar 29, 2023
dda256c
add annotation listing page v1
drewdaemon Mar 30, 2023
8f8b118
add delete capabilities
drewdaemon Mar 31, 2023
b00cf55
store tags as references
drewdaemon Mar 31, 2023
32d17c4
finish link from save toast
drewdaemon Mar 31, 2023
f17afb5
don't include fields when saving ad-hoc data view
drewdaemon Mar 31, 2023
0a16665
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Apr 3, 2023
35af891
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon Apr 3, 2023
f6b95a3
add some missing type references
drewdaemon Apr 3, 2023
09db787
fix a type problem
drewdaemon Apr 3, 2023
5c558d2
editing basic group metadata
drewdaemon Apr 4, 2023
6148054
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Apr 17, 2023
1f0685f
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon Apr 17, 2023
e4c341c
remove null return
drewdaemon Apr 17, 2023
ab0ee8c
update table list view unit test
drewdaemon Apr 17, 2023
9bf9feb
TabbedTableListView on visualize page
drewdaemon Apr 17, 2023
613c00d
tabbed table list view
drewdaemon Apr 17, 2023
b67b401
URL navigation between tabs
drewdaemon Apr 18, 2023
b318744
restore create button
drewdaemon Apr 18, 2023
c401994
some minor cosmetic fixes to visualization listing page
drewdaemon Apr 18, 2023
f2ce71a
restore table list to main state
drewdaemon Apr 19, 2023
a084c44
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Apr 19, 2023
4711f68
merge branch
drewdaemon Apr 19, 2023
07334eb
refresh bouncer
drewdaemon Apr 19, 2023
b5e0638
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Apr 25, 2023
a68e4f3
Merge parent branch
drewdaemon Apr 26, 2023
5cb5523
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon Apr 26, 2023
270960b
translate strings
drewdaemon Apr 26, 2023
3d83fba
add data view editing to annotation group listing page
drewdaemon Apr 26, 2023
f59f517
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Apr 27, 2023
2c6e100
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon Apr 27, 2023
61963ee
layer the group editing architecture
drewdaemon Apr 28, 2023
de55ebd
Partial annotation appearance editing
drewdaemon Apr 29, 2023
dc3b844
add text decoration setting
drewdaemon May 1, 2023
6f2e8c8
add tooltip section
drewdaemon May 1, 2023
5430f41
add manual annotation controls
drewdaemon May 1, 2023
4022e8f
add query-based annotation control
drewdaemon May 1, 2023
e71dd26
some clean up
drewdaemon May 1, 2023
09a8e25
some renaming
drewdaemon May 1, 2023
8bfa4a1
use annotation editor controls in Lens
drewdaemon May 2, 2023
e293105
filtering non-compatible data view fields
drewdaemon May 2, 2023
a0e7ef8
create new annotations from library
drewdaemon May 2, 2023
69b6210
allow user to go back to group editing
drewdaemon May 3, 2023
1434f48
move dimension trigger styles to component
drewdaemon May 3, 2023
6516050
moving more empty dimension button styling inline
drewdaemon May 3, 2023
114d5f7
move dimension trigger and empty dimension button to shared plugin
drewdaemon May 3, 2023
f00e349
move dimension button styles inline
drewdaemon May 4, 2023
7fc428c
correct border-radius on empty button
drewdaemon May 4, 2023
10714c6
restore remove button
drewdaemon May 4, 2023
d6aeae7
move more styles to dimension_button
drewdaemon May 4, 2023
d8baa41
restore empty button drag drop behavior
drewdaemon May 4, 2023
38f60f8
move palette dimension button styles inline
drewdaemon May 4, 2023
40a4570
drag and drop sort of working
drewdaemon May 4, 2023
43910e5
apply annotation changes to group
drewdaemon May 4, 2023
c4b37b1
remove annotations
drewdaemon May 4, 2023
c7a359c
scroll to top when view changes
drewdaemon May 4, 2023
c66d403
fix adding new annotation
drewdaemon May 4, 2023
cbfb390
drag-and-drop reordering (only mouse)
drewdaemon May 5, 2023
2bb4542
move annotation list to own component
drewdaemon May 5, 2023
ae31280
drag drop to create new annotation
drewdaemon May 5, 2023
4abe2db
closing flyout first closes annotation editing
drewdaemon May 5, 2023
9cdc146
make query popover wide
drewdaemon May 5, 2023
baf870a
Merge branch '141054/library-annotation-groups' of github.com:drewdae…
drewdaemon May 15, 2023
65ff507
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon May 15, 2023
5e66b99
remove superfluous hide parameter
drewdaemon May 15, 2023
6770eab
remove simpleView parameter from everywhere outside expression genera…
drewdaemon May 15, 2023
5450241
Merge branch 'main' into 141054/library-annotation-groups
kibanamachine May 15, 2023
ecb1a2f
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 15, 2023
61115b4
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon May 15, 2023
ca19a55
put annotation groups in the analytics index
drewdaemon May 15, 2023
63b95ea
Merge branch '141054/library-annotation-groups' of github.com:drewdae…
drewdaemon May 15, 2023
1cb7fb3
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine May 15, 2023
cded3e9
Merge branch '141054/library-annotation-groups' of github.com:drewdae…
drewdaemon May 16, 2023
8a28c3d
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 16, 2023
78f89d1
fix linting problem
drewdaemon May 16, 2023
3cad5f6
fix config panel test
drewdaemon May 16, 2023
e73de35
Merge branch '141054/library-annotation-groups' of github.com:drewdae…
drewdaemon May 16, 2023
d8bade5
limit
drewdaemon May 16, 2023
8887e81
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon May 16, 2023
95d1253
hide individual annotation editing
drewdaemon May 16, 2023
4930591
update integration test snapshot
drewdaemon May 16, 2023
fbecd34
remove some commented code
drewdaemon May 16, 2023
4cec332
update integration test snapshot
drewdaemon May 16, 2023
8be8e92
remove event annotation saved object type
drewdaemon May 16, 2023
afc0972
fix annotation library link
drewdaemon May 16, 2023
831e519
update snapshot
drewdaemon May 16, 2023
6e577cc
saved objects library link
drewdaemon May 17, 2023
86de06c
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon May 17, 2023
7171e7c
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 17, 2023
c0f7b67
clean up flyout
drewdaemon May 18, 2023
c78559e
logical improvement
drewdaemon May 18, 2023
59e9823
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 18, 2023
2097012
removing unnecessary initialize parameter
drewdaemon May 22, 2023
33e95c3
Merge branch '141054/library-annotation-groups' of github.com:drewdae…
drewdaemon May 22, 2023
d21c380
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon May 22, 2023
b379a9f
clean up some comments and improve some imports
drewdaemon May 22, 2023
5321a62
remove ignore global filters action
drewdaemon May 22, 2023
8d436eb
a couple of small logical changes
drewdaemon May 22, 2023
0b52e1d
change icon
drewdaemon May 22, 2023
729b593
use changeIndexPattern action to load new ad-hoc data view
drewdaemon May 23, 2023
3b493c6
always ensure index pattern is loaded before adding library annotatio…
drewdaemon May 23, 2023
302d329
save index pattern references for linked layers
drewdaemon May 23, 2023
5f9f3b4
use flag icon for saved objects management
drewdaemon May 23, 2023
dc1ed29
fix dirty state bug, clean up addLayer
drewdaemon May 24, 2023
7e9a62b
fix extra dimension bug
drewdaemon May 25, 2023
07083cb
remove unused translations
drewdaemon May 25, 2023
889cc7a
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon May 25, 2023
0cb229c
dont assume index-pattern reference when by-ref annotation layer
drewdaemon May 25, 2023
38955ff
a little extra error handling protection
drewdaemon May 25, 2023
3d621ab
don't show search interface when no library groups
drewdaemon May 25, 2023
39e38c8
disable, don't hide, revert changes action
drewdaemon May 25, 2023
10d1fea
add body to the revert confirmation toast
drewdaemon May 25, 2023
2d825ed
Change confirmation modal widths
drewdaemon May 25, 2023
230e6db
unsaved changes indicator
drewdaemon May 25, 2023
8947971
Update x-pack/plugins/lens/public/visualizations/xy/add_layer.tsx
drewdaemon May 25, 2023
246cd01
Update x-pack/plugins/lens/public/visualizations/xy/annotations/actio…
drewdaemon May 25, 2023
37a77a4
impose ordering on layer actions
drewdaemon May 25, 2023
00c7370
show save action outside context menu
drewdaemon May 25, 2023
d7d9517
Merge branch '141054/library-annotation-groups' of github.com:drewdae…
drewdaemon May 25, 2023
04f92d6
update snapshot
drewdaemon May 25, 2023
8744114
update snapshot
drewdaemon May 26, 2023
3dc6ced
some code style feedback
drewdaemon May 26, 2023
766a3d7
Update x-pack/plugins/lens/public/editor_frame_service/editor_frame/s…
drewdaemon May 26, 2023
23566c9
Update x-pack/plugins/lens/public/editor_frame_service/editor_frame/s…
drewdaemon May 26, 2023
7fb46cf
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 26, 2023
2823824
fix action ordering
drewdaemon May 26, 2023
d278eb0
Merge branch '141054/library-annotation-groups' of github.com:drewdae…
drewdaemon May 26, 2023
63d9b3a
fix library annotation loading
drewdaemon May 26, 2023
9df5131
update size and format of save modal
drewdaemon May 26, 2023
60f1956
hold off on validation until submit has been attempted
drewdaemon May 26, 2023
5e7814a
change save modal copy
drewdaemon May 26, 2023
f8cdd41
marking optional fields optional
drewdaemon May 26, 2023
3a3b53d
Merge branch 'main' into 141054/library-annotation-groups
stratoula May 29, 2023
e223128
Fix CI
stratoula May 29, 2023
91c2db4
new annotation from empty annotation library
drewdaemon May 30, 2023
9b23bef
Merge branch '141054/library-annotation-groups' of github.com:drewdae…
drewdaemon May 30, 2023
7e53a71
make unsaved changes indicator accessible
drewdaemon May 31, 2023
5f3be56
Merge branch 'main' into 141054/library-annotation-groups
kibanamachine May 31, 2023
03136fc
Merge branch '141054/library-annotation-groups' into 141054/library-a…
drewdaemon May 31, 2023
fb6f3ef
update library annotation strings
drewdaemon May 31, 2023
e3a08ad
skip annotation editing tests
drewdaemon May 31, 2023
18a84ca
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon May 31, 2023
a747da0
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon May 31, 2023
a8f9773
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 31, 2023
7036e0c
clean up inadvertant changes
drewdaemon Jun 1, 2023
e08e493
Merge branch '141054/library-annotation-groups-listing-page' of githu…
drewdaemon Jun 1, 2023
9e84b4d
update table list view invocations
drewdaemon Jun 1, 2023
a7cd08a
update i18n string
drewdaemon Jun 1, 2023
a417b01
update more translations
drewdaemon Jun 1, 2023
ed31373
fix tag saving
drewdaemon Jun 1, 2023
4f810dc
remove superfluous service
drewdaemon Jun 1, 2023
f432a9e
maybe fix some functional tests
drewdaemon Jun 1, 2023
e729a93
add placeholder test
drewdaemon Jun 1, 2023
6edd240
fix layer panel unit tests
drewdaemon Jun 2, 2023
5bed6f4
fix some test subjects
drewdaemon Jun 2, 2023
594a342
update unit tests
drewdaemon Jun 2, 2023
1c780eb
update test
drewdaemon Jun 2, 2023
9999542
fix export
drewdaemon Jun 2, 2023
c992874
update snapshot
drewdaemon Jun 2, 2023
f239ebe
reinstate test selector
drewdaemon Jun 2, 2023
6f3171e
move module location to resolve jest error
drewdaemon Jun 2, 2023
6e27746
make annotation editor controls lazy
drewdaemon Jun 2, 2023
4fb3291
reduce bundle size
drewdaemon Jun 5, 2023
25d0263
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 5, 2023
7ad9ada
fix lazy loading
drewdaemon Jun 5, 2023
4f416f2
Merge branch '141054/library-annotation-groups-listing-page' of githu…
drewdaemon Jun 5, 2023
2264aac
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 5, 2023
517d782
Merge branch 'main' into 141054/library-annotation-groups-listing-page
kibanamachine Jun 5, 2023
9496074
Merge branch 'main' into 141054/library-annotation-groups-listing-page
stratoula Jun 6, 2023
b654bff
Merge branch 'main' into 141054/library-annotation-groups-listing-page
dej611 Jun 6, 2023
f368da4
translate string
drewdaemon Jun 6, 2023
f1187a7
clean up comment
drewdaemon Jun 6, 2023
a69f659
hide data view picker
drewdaemon Jun 6, 2023
b5471b3
mark type imports
drewdaemon Jun 6, 2023
3feea0a
use app name
drewdaemon Jun 6, 2023
8a2d3cd
fix import
drewdaemon Jun 6, 2023
3e98134
update limit
drewdaemon Jun 6, 2023
03787d7
remove unused translations
drewdaemon Jun 6, 2023
c6f0e6c
change to type import
drewdaemon Jun 7, 2023
b89454b
move TableListView to own package
drewdaemon Jun 7, 2023
080b200
move TabbedTableListView to own package
drewdaemon Jun 7, 2023
21116fc
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 7, 2023
2831fee
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jun 7, 2023
1a41890
fix types
drewdaemon Jun 8, 2023
261ec57
fix dashboard listing tests
drewdaemon Jun 8, 2023
968eda9
Merge branch '141054/library-annotation-groups-listing-page' of githu…
drewdaemon Jun 8, 2023
ecee63a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 8, 2023
bf19d54
Merge branch 'main' into 141054/library-annotation-groups-listing-page
kibanamachine Jun 8, 2023
b9472f0
update snapshot
drewdaemon Jun 9, 2023
f95e8d4
some design feedback
drewdaemon Jun 9, 2023
bb22768
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Jun 9, 2023
1905208
show success toast when group is saved
drewdaemon Jun 9, 2023
baee87c
prevent saving group without title
drewdaemon Jun 9, 2023
92e7da4
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 9, 2023
bc5c7f1
data views column
drewdaemon Jun 9, 2023
d7a9347
Merge branch '141054/library-annotation-groups-listing-page' of githu…
drewdaemon Jun 9, 2023
6acc649
Merge branch 'main' of github.com:elastic/kibana into 141054/library-…
drewdaemon Jun 9, 2023
08603c2
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 9, 2023
b642b30
scope down content attributes
drewdaemon Jun 12, 2023
499c620
Merge branch '141054/library-annotation-groups-listing-page' of githu…
drewdaemon Jun 12, 2023
4fc045c
better empty state
drewdaemon Jun 12, 2023
49eb9b1
Merge branch 'main' into 141054/library-annotation-groups-listing-page
kibanamachine Jun 12, 2023
2e7b014
improve tests
drewdaemon Jun 12, 2023
1ec1a83
remove comment
drewdaemon Jun 12, 2023
31ee962
Merge branch '141054/library-annotation-groups-listing-page' of githu…
drewdaemon Jun 12, 2023
e149188
remove snapshot test
drewdaemon Jun 12, 2023
d87ebb5
fix type
drewdaemon Jun 12, 2023
4259be3
delete through library in functional tests
drewdaemon Jun 12, 2023
3a44c86
Merge branch 'main' into 141054/library-annotation-groups-listing-page
stratoula Jun 13, 2023
6d11a38
reenable annotation controls unit test
drewdaemon Jun 13, 2023
e43132d
Merge branch '141054/library-annotation-groups-listing-page' of githu…
drewdaemon Jun 13, 2023
42ec107
fix test selector
drewdaemon Jun 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const MSearchTable = () => {
initialPageSize={50}
entityName={`ContentItem`}
entityNamePlural={`ContentItems`}
tableListTitle={`MSearch Demo`}
title={`MSearch Demo`}
urlStateEnabled={false}
emptyPrompt={<>No data found. Try to install some sample data first.</>}
onClickTitle={(item) => {
Expand Down
16 changes: 14 additions & 2 deletions packages/content-management/table_list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@
* Side Public License, v 1.
*/

export { TableListView, TableListViewProvider, TableListViewKibanaProvider } from './src';
export {
TableListView,
TabbedTableListView,
TableList,
TableListViewProvider,
TableListViewKibanaProvider,
} from './src';

export type {
UserContentCommonSchema,
TableListTab,
TableListTabParentProps,
RowActions,
} from './src';

export type { UserContentCommonSchema, RowActions } from './src';
export type { TableListViewKibanaDependencies } from './src/services';
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';

import type { Tag } from '../types';
import { useServices } from '../services';
import type { UserContentCommonSchema, Props as TableListViewProps } from '../table_list_view';
import type { UserContentCommonSchema, TableListViewProps } from '../table_list_view';
import { TagBadge } from './tag_badge';

type InheritedProps<T extends UserContentCommonSchema> = Pick<
Expand Down
12 changes: 8 additions & 4 deletions packages/content-management/table_list/src/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
SearchFilterConfig,
Direction,
Query,
Search,
type EuiTableSelectionType,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
Expand All @@ -25,7 +26,7 @@ import { useServices } from '../services';
import type { Action } from '../actions';
import type {
State as TableListViewState,
Props as TableListViewProps,
TableListProps,
UserContentCommonSchema,
} from '../table_list_view';
import type { TableItemsRowActions } from '../types';
Expand Down Expand Up @@ -53,8 +54,9 @@ interface Props<T extends UserContentCommonSchema> extends State<T>, TagManageme
tableCaption: string;
tableColumns: Array<EuiBasicTableColumn<T>>;
hasUpdatedAtMetadata: boolean;
deleteItems: TableListViewProps<T>['deleteItems'];
deleteItems: TableListProps<T>['deleteItems'];
tableItemsRowActions: TableItemsRowActions;
renderCreateButton: () => React.ReactElement | undefined;
onSortChange: (column: SortColumnField, direction: Direction) => void;
onTableChange: (criteria: CriteriaWithPagination<T>) => void;
onTableSearchChange: (arg: { query: Query | null; queryText: string }) => void;
Expand All @@ -76,6 +78,7 @@ export function Table<T extends UserContentCommonSchema>({
tagsToTableItemMap,
tableItemsRowActions,
deleteItems,
renderCreateButton,
tableCaption,
onTableChange,
onTableSearchChange,
Expand Down Expand Up @@ -201,18 +204,19 @@ export function Table<T extends UserContentCommonSchema>({
return [tableSortSelectFilter, tagFilterPanel];
}, [tableSortSelectFilter, tagFilterPanel]);

const search = useMemo(() => {
const search = useMemo((): Search => {
return {
onChange: onTableSearchChange,
toolsLeft: renderToolsLeft(),
toolsRight: renderCreateButton(),
query: searchQuery.query ?? undefined,
box: {
incremental: true,
'data-test-subj': 'tableListSearchBox',
},
filters: searchFilters,
};
}, [onTableSearchChange, renderToolsLeft, searchFilters, searchQuery.query]);
}, [onTableSearchChange, renderCreateButton, renderToolsLeft, searchFilters, searchQuery.query]);

const noItemsMessage = (
<FormattedMessage
Expand Down
10 changes: 8 additions & 2 deletions packages/content-management/table_list/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
* Side Public License, v 1.
*/

export { TableListView } from './table_list_view';
export { TableListView, TableList } from './table_list_view';

export type {
Props as TableListViewProps,
TableListViewProps,
State as TableListViewState,
UserContentCommonSchema,
} from './table_list_view';

export {
TabbedTableListView,
type TableListTab,
type TableListTabParentProps,
} from './tabbed_table_list_view';

export { TableListViewProvider, TableListViewKibanaProvider } from './services';

export type { RowActions } from './types';
2 changes: 1 addition & 1 deletion packages/content-management/table_list/src/mocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const getStoryServices = (params: Params, action: ActionFn = () => {}) =>
* consuming component stories.
*/
export const getStoryArgTypes = () => ({
tableListTitle: {
title: {
control: {
type: 'text',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* 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 { shallow } from 'enzyme';
import {
TabbedTableListView,
TableListTabParentProps,
TableListTab,
} from './tabbed_table_list_view';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import { EuiTab } 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 tabs: TableListTab[] = [
{
title: 'Tab 1',
id: 'tab-1',
getTableList: async (props: TableListTabParentProps) => <div>Test Table List 1</div>,
},
{
title: 'Tab 2',
id: 'tab-2',
getTableList: async (props: TableListTabParentProps) => <div>Test Table List 2</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(EuiTab).length).toEqual(tabs.length);
});

it('should switch tabs when a tab is clicked', () => {
const changeActiveTab = jest.fn();

const wrapper = shallow(
<TabbedTableListView
title={title}
description={description}
headingId={headingId}
children={children}
tabs={tabs}
activeTabId={'tab-1'}
changeActiveTab={changeActiveTab}
/>
);

const getTab = (index: number) => wrapper.find(EuiTab).at(index);

expect(getTab(0).prop('isSelected')).toBeTruthy();
expect(getTab(1).prop('isSelected')).toBeFalsy();

act(() => {
getTab(1).simulate('click');
});

expect(changeActiveTab).toHaveBeenCalledWith('tab-2');

act(() => {
wrapper.setProps({
activeTabId: 'tab-2',
});
});

expect(getTab(0).prop('isSelected')).toBeFalsy();
expect(getTab(1).prop('isSelected')).toBeTruthy();
});
});
102 changes: 102 additions & 0 deletions packages/content-management/table_list/src/tabbed_table_list_view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* 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 { EuiTab, EuiTabs } from '@elastic/eui';
import { css } from '@emotion/react';
import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template';
import React, { useCallback, useEffect, useState } from 'react';
import type {
TableListProps,
TableListViewProps,
UserContentCommonSchema,
} from './table_list_view';

export type TableListTabParentProps<T extends UserContentCommonSchema = UserContentCommonSchema> =
Pick<TableListProps<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"
css={css`
.euiPageHeaderContent {
padding-bottom: 0;
}
`}
>
<EuiTabs>
{tabs.map((tab, index) => (
<EuiTab
key={index}
onClick={() => changeActiveTab(tab.id)}
isSelected={tab.id === getActiveTab().id}
>
{tab.title}
</EuiTab>
))}
</EuiTabs>
</KibanaPageTemplate.Header>
<KibanaPageTemplate.Section aria-labelledby={hasInitialFetchReturned ? headingId : undefined}>
{/* Any children passed to the component */}
{children}

{tableList}
</KibanaPageTemplate.Section>
</KibanaPageTemplate>
);
};
Loading