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

[Table list view] Integrate package into visualizations, maps, graphs #140040

Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1c1ba58
Integrate package into visualizations plugin
sebelga Sep 5, 2022
93b7d66
Integrate package into maps plugin
sebelga Sep 5, 2022
06c3b44
Add unique id to tables
sebelga Sep 6, 2022
b4b610d
Fix i18n issue
sebelga Sep 6, 2022
dc56612
Integrate package into graph plugin
sebelga Sep 6, 2022
1fa743e
Fix missing description attribute
sebelga Sep 6, 2022
7296a66
Update findMaps() handler
sebelga Sep 6, 2022
732d577
Fix i18n issue
sebelga Sep 6, 2022
4314565
Add "onClickTitle" prop to navigate to details view
sebelga Sep 6, 2022
cef4d8a
Remove component from kibana-react plugin
sebelga Sep 6, 2022
8287766
Fix visualisation editItem handler
sebelga Sep 7, 2022
3d6db3c
Add unique id to graph table
sebelga Sep 7, 2022
65f97fe
Fix i18n issue
sebelga Sep 7, 2022
7703f5c
Fix link rendering when vis type is unknown
sebelga Sep 7, 2022
70ed7d3
Fix TS issue
sebelga Sep 7, 2022
b3e5737
Remove getApplication from maps kibana services
sebelga Sep 7, 2022
8faa861
Merge branch 'table-list-view/enhance-ux' into table-list-view/integr…
kibanamachine Sep 8, 2022
73b6ba9
Use RedirectAppLinks to prevent full page reload
sebelga Sep 8, 2022
2e54695
Merge branch 'table-list-view/integrate-package-vis-map-graph' of git…
sebelga Sep 8, 2022
9c032e9
Merge branch 'table-list-view/enhance-ux' into table-list-view/integr…
kibanamachine Sep 8, 2022
36365fa
Fix TS issues
sebelga Sep 8, 2022
510aa18
Merge branch 'table-list-view/integrate-package-vis-map-graph' of git…
sebelga Sep 8, 2022
411bb6c
Update to the new EuiPageTemplate component
sebelga Sep 8, 2022
737a4f7
Fix functional tests
sebelga Sep 9, 2022
656eb9c
Merge branch 'table-list-view/enhance-ux' into table-list-view/integr…
kibanamachine Sep 13, 2022
ddfe96e
[CI] Auto-commit changed files from 'node scripts/generate packages_b…
kibanamachine Sep 13, 2022
435c721
Fix functional tests
sebelga Sep 13, 2022
b91722c
Merge branch 'table-list-view/integrate-package-vis-map-graph' of git…
sebelga Sep 13, 2022
636b2d2
Merge branch 'table-list-view/enhance-ux' into table-list-view/integr…
kibanamachine Sep 13, 2022
1195d6c
Revert "[CI] Auto-commit changed files from 'node scripts/generate pa…
sebelga Sep 13, 2022
a2a3e9a
Merge branch 'table-list-view/integrate-package-vis-map-graph' of git…
sebelga Sep 13, 2022
cb1e243
Add kibana.jsonc
sebelga Sep 13, 2022
5697063
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Sep 13, 2022
42421b3
Merge branch 'table-list-view/enhance-ux' into table-list-view/integr…
kibanamachine Sep 13, 2022
4a030f7
Merge branch 'table-list-view/enhance-ux' into table-list-view/integr…
kibanamachine Sep 13, 2022
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
65 changes: 55 additions & 10 deletions packages/content-management/table_list/src/table_list_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
* Side Public License, v 1.
*/

import React, { useReducer, useCallback, useEffect, useRef, useMemo, ReactNode } from 'react';
import React, {
useReducer,
useCallback,
useEffect,
useRef,
useMemo,
ReactNode,
MouseEvent,
} from 'react';
import useDebounce from 'react-use/lib/useDebounce';
import {
EuiBasicTableColumn,
Expand Down Expand Up @@ -53,7 +61,10 @@ export interface Props<T extends UserContentCommonSchema = UserContentCommonSche
searchQuery: string,
references?: SavedObjectsFindOptionsReference[]
): Promise<{ total: number; hits: T[] }>;
getDetailViewLink(entity: T): string;
/** Handler to set the item title "href" value. If it returns undefined there won't be a link for this item. */
getDetailViewLink?: (entity: T) => string | undefined;
/** Handler to execute when clicking the item title */
onClickTitle?: (item: T) => void;
createItem?(): void;
deleteItems?(items: T[]): Promise<void>;
editItem?(item: T): void;
Expand Down Expand Up @@ -103,9 +114,22 @@ function TableListViewComp<T extends UserContentCommonSchema>({
editItem,
deleteItems,
getDetailViewLink,
onClickTitle,
id = 'userContent',
children,
}: Props<T>) {
if (!getDetailViewLink && !onClickTitle) {
throw new Error(
`[TableListView] One o["getDetailViewLink" or "onClickTitle"] prop must be provided.`
);
}

if (getDetailViewLink && onClickTitle) {
throw new Error(
`[TableListView] Either "getDetailViewLink" or "onClickTitle" can be provided. Not both.`
);
}

const isMounted = useRef(false);
const fetchIdx = useRef(0);

Expand Down Expand Up @@ -137,14 +161,35 @@ function TableListViewComp<T extends UserContentCommonSchema>({
defaultMessage: 'Title',
}),
sortable: true,
render: (field: keyof T, record: T) => (
<EuiLink
href={getDetailViewLink(record)}
data-test-subj={`${id}ListingTitleLink-${record.attributes.title.split(' ').join('-')}`}
>
{record.attributes.title}
</EuiLink>
),
render: (field: keyof T, record: T) => {
// The validation is handled at the top of the component
const href = getDetailViewLink ? getDetailViewLink(record) : undefined;

if (!href && !onClickTitle) {
// This item is not clickable
return <span>{record.attributes.title}</span>;
}

return (
// eslint-disable-next-line @elastic/eui/href-or-on-click
<EuiLink
href={getDetailViewLink ? getDetailViewLink(record) : undefined}
onClick={
onClickTitle
? (e: MouseEvent) => {
e.preventDefault();
onClickTitle(record);
}
: undefined
}
data-test-subj={`${id}ListingTitleLink-${record.attributes.title
.split(' ')
.join('-')}`}
>
{record.attributes.title}
</EuiLink>
);
},
},
{
field: 'attributes.description',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const SAVED_OBJECTS_PER_PAGE_SETTING = 'savedObjects:perPage';
interface DashboardSavedObjectUserContent extends UserContentCommonSchema {
attributes: {
title: string;
description?: string;
timeRestore: boolean;
};
}
Expand All @@ -61,6 +62,7 @@ const toTableListViewSavedObject = (
type: 'dashboard',
attributes: {
title: (savedObject.title as string) ?? '',
description: savedObject.description as string,
timeRestore: savedObject.timeRestore as boolean,
},
};
Expand Down
1 change: 0 additions & 1 deletion src/plugins/dashboard/public/services/kibana_react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export {
useKibana,
withKibana,
toMountPoint,
TableListView,
reactToUiComponent,
ExitFullScreenButton,
KibanaContextProvider,
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ export { useUiSetting, useUiSetting$ } from './ui_settings';

export { useExecutionContext } from './use_execution_context';

export type { TableListViewProps, TableListViewState } from './table_list_view';
export { TableListView } from './table_list_view';

export type { ToolbarButtonProps } from './toolbar_button';
export { POSITIONS, WEIGHTS, TOOLBAR_BUTTON_SIZES, ToolbarButton } from './toolbar_button';

Expand Down
61 changes: 0 additions & 61 deletions src/plugins/kibana_react/public/table_list_view/actions.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading