forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ingest] Datastream list: add icons and dashboard links (elastic#65048)
* Read package saved objects in data stream handler. * Render package icon. * Make TableRowAction more generic * Add Actions column to data stream list * Disable dashboard link if no dashboards present. * Data stream list: link to first dashbord found * Update i18n strings * Add nested context menu to link to dashboards * introduces a separate TableRowActionsNested component * moves TableRowActions back into agent config components * Fix i18n label. * Re-add translated strings removed by mistake * Fix i18n issues * Add helper to read a saved object installed by EPM * Display titles from within dashboard saved objects
- Loading branch information
Showing
7 changed files
with
242 additions
and
10 deletions.
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
...ingest_manager/public/applications/ingest_manager/components/table_row_actions_nested.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,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { useCallback, useState } from 'react'; | ||
import { EuiButtonIcon, EuiContextMenu, EuiPopover } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { EuiContextMenuProps } from '@elastic/eui/src/components/context_menu/context_menu'; | ||
|
||
export const TableRowActionsNested = React.memo<{ panels: EuiContextMenuProps['panels'] }>( | ||
({ panels }) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const handleCloseMenu = useCallback(() => setIsOpen(false), [setIsOpen]); | ||
const handleToggleMenu = useCallback(() => setIsOpen(!isOpen), [isOpen]); | ||
|
||
return ( | ||
<EuiPopover | ||
anchorPosition="downRight" | ||
panelPaddingSize="none" | ||
button={ | ||
<EuiButtonIcon | ||
iconType="boxesHorizontal" | ||
onClick={handleToggleMenu} | ||
aria-label={i18n.translate('xpack.ingestManager.genericActionsMenuText', { | ||
defaultMessage: 'Open', | ||
})} | ||
/> | ||
} | ||
isOpen={isOpen} | ||
closePopover={handleCloseMenu} | ||
> | ||
<EuiContextMenu panels={panels} initialPanelId={0} /> | ||
</EuiPopover> | ||
); | ||
} | ||
); |
14 changes: 14 additions & 0 deletions
14
x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_kibana_link.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,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { useCore } from './'; | ||
|
||
const BASE_PATH = '/app/kibana'; | ||
|
||
export function useKibanaLink(path: string = '/') { | ||
const core = useCore(); | ||
return core.http.basePath.prepend(`${BASE_PATH}#${path}`); | ||
} |
82 changes: 82 additions & 0 deletions
82
...ions/ingest_manager/sections/data_stream/list_page/components/data_stream_row_actions.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,82 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { memo } from 'react'; | ||
|
||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { useKibanaLink } from '../../../../hooks/use_kibana_link'; | ||
import { DataStream } from '../../../../types'; | ||
import { TableRowActionsNested } from '../../../../components/table_row_actions_nested'; | ||
|
||
export const DataStreamRowActions = memo<{ datastream: DataStream }>(({ datastream }) => { | ||
const { dashboards } = datastream; | ||
const panels = []; | ||
const actionNameSingular = ( | ||
<FormattedMessage | ||
id="xpack.ingestManager.dataStreamList.viewDashboardActionText" | ||
defaultMessage="View dashboard" | ||
/> | ||
); | ||
const actionNamePlural = ( | ||
<FormattedMessage | ||
id="xpack.ingestManager.dataStreamList.viewDashboardsActionText" | ||
defaultMessage="View dashboards" | ||
/> | ||
); | ||
|
||
const panelTitle = i18n.translate('xpack.ingestManager.dataStreamList.viewDashboardsPanelTitle', { | ||
defaultMessage: 'View dashboards', | ||
}); | ||
|
||
if (!dashboards || dashboards.length === 0) { | ||
panels.push({ | ||
id: 0, | ||
items: [ | ||
{ | ||
icon: 'dashboardApp', | ||
disabled: true, | ||
name: actionNameSingular, | ||
}, | ||
], | ||
}); | ||
} else if (dashboards.length === 1) { | ||
panels.push({ | ||
id: 0, | ||
items: [ | ||
{ | ||
icon: 'dashboardApp', | ||
href: useKibanaLink(`/dashboard/${dashboards[0].id || ''}`), | ||
name: actionNameSingular, | ||
}, | ||
], | ||
}); | ||
} else { | ||
panels.push({ | ||
id: 0, | ||
items: [ | ||
{ | ||
icon: 'dashboardApp', | ||
panel: 1, | ||
name: actionNamePlural, | ||
}, | ||
], | ||
}); | ||
panels.push({ | ||
id: 1, | ||
title: panelTitle, | ||
items: dashboards.map(dashboard => { | ||
return { | ||
icon: 'dashboardApp', | ||
href: useKibanaLink(`/dashboard/${dashboard.id || ''}`), | ||
name: dashboard.title, | ||
}; | ||
}), | ||
}); | ||
} | ||
|
||
return <TableRowActionsNested panels={panels} />; | ||
}); |
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