Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -427,6 +427,7 @@ class TableListView extends React.Component<TableListViewProps, TableListViewSta
),
icon: 'pencil',
type: 'icon',
enabled: ({ error }: { error: string }) => !error,
onClick: this.props.editItem,
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { TriggerContextMapping } from '../../../ui_actions/public';
export interface VisualizationListItem {
editUrl: string;
editApp?: string;
error?: string;
icon: string;
id: string;
stage: 'experimental' | 'beta' | 'production';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export const VisualizeListing = () => {
.findListItems(filter, listingLimit)
.then(({ total, hits }: { total: number; hits: object[] }) => ({
total,
hits: hits.filter((result: any) => isLabsEnabled || result.type.stage !== 'experimental'),
hits: hits.filter(
(result: any) => isLabsEnabled || result.type?.stage !== 'experimental'
),
}));
},
[listingLimit, savedVisualizations, uiSettings]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React from 'react';
import { History } from 'history';
import { EuiBetaBadge, EuiButton, EuiEmptyPrompt, EuiIcon, EuiLink } from '@elastic/eui';
import { EuiBetaBadge, EuiButton, EuiEmptyPrompt, EuiIcon, EuiLink, EuiBadge } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

Expand Down Expand Up @@ -87,34 +87,43 @@ export const getTableColumns = (application: ApplicationStart, history: History)
defaultMessage: 'Title',
}),
sortable: true,
render: (field: string, { editApp, editUrl, title }: VisualizationListItem) => (
<EuiLink
onClick={() => {
if (editApp) {
application.navigateToApp(editApp, { path: editUrl });
} else if (editUrl) {
history.push(editUrl);
}
}}
data-test-subj={`visListingTitleLink-${title.split(' ').join('-')}`}
>
{field}
</EuiLink>
),
render: (field: string, { editApp, editUrl, title, error }: VisualizationListItem) =>
// In case an error occurs i.e. the vis has wrong type, we render the vis but without the link
!error ? (
<EuiLink
onClick={() => {
if (editApp) {
application.navigateToApp(editApp, { path: editUrl });
} else if (editUrl) {
history.push(editUrl);
}
}}
data-test-subj={`visListingTitleLink-${title.split(' ').join('-')}`}
>
{field}
</EuiLink>
) : (
field
),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would render a string stating "Unknown Type" into the type column, to clarify what happened, together with a "warning" icon.

Might even consider adding a tooltip with more details.

Other than that looks good.

{
field: 'typeTitle',
name: i18n.translate('visualize.listing.table.typeColumnName', {
defaultMessage: 'Type',
}),
sortable: true,
render: (field: string, record: VisualizationListItem) => (
<span>
{renderItemTypeIcon(record)}
{record.typeTitle}
{getBadge(record)}
</span>
),
render: (field: string, record: VisualizationListItem) =>
!record.error ? (
<span>
{renderItemTypeIcon(record)}
{record.typeTitle}
{getBadge(record)}
</span>
) : (
<EuiBadge iconType="alert" color="warning">
{record.error}
</EuiBadge>
),
},
{
field: 'description',
Expand Down