-
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.
Seperate out link logic to improve dashboard loading
- Loading branch information
Showing
6 changed files
with
98 additions
and
209 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
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
97 changes: 0 additions & 97 deletions
97
src/plugins/navigation_embeddable/public/components/navigation_embeddable_link_list.tsx
This file was deleted.
Oops, something went wrong.
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
80 changes: 80 additions & 0 deletions
80
...ugins/navigation_embeddable/public/components/navigation_embeddable_panel_editor_link.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,80 @@ | ||
/* | ||
* 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 useAsync from 'react-use/lib/useAsync'; | ||
|
||
import { | ||
EuiIcon, | ||
EuiPanel, | ||
EuiFlexItem, | ||
EuiFlexGroup, | ||
EuiButtonIcon, | ||
EuiSkeletonTitle, | ||
} from '@elastic/eui'; | ||
|
||
import { | ||
NavigationLinkInfo, | ||
DASHBOARD_LINK_TYPE, | ||
NavigationEmbeddableLink, | ||
} from '../embeddable/types'; | ||
import { fetchDashboard } from './dashboard_link/dashboard_link_tools'; | ||
|
||
export const NavigationEmbeddablePanelEditorLink = ({ | ||
link, | ||
editLink, | ||
deleteLink, | ||
}: { | ||
editLink: () => void; | ||
deleteLink: () => void; | ||
link: NavigationEmbeddableLink; | ||
}) => { | ||
const { value: linkLabel, loading: linkLabelLoading } = useAsync(async () => { | ||
let label = link.label; | ||
if (link.type === DASHBOARD_LINK_TYPE && !label) { | ||
const dashboard = await fetchDashboard(link.destination); | ||
label = dashboard.attributes.title; | ||
} | ||
return label || link.destination; | ||
}, [link]); | ||
|
||
return ( | ||
<EuiPanel hasBorder paddingSize="s" hasShadow={false} className="navEmbeddablePanelEditor"> | ||
<EuiFlexGroup gutterSize="s" responsive={false} wrap={false} alignItems="center"> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type={NavigationLinkInfo[link.type].icon} color="text" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem className="linkText"> | ||
<EuiSkeletonTitle | ||
size="xxxs" | ||
isLoading={linkLabelLoading} | ||
contentAriaLabel="Demo skeleton title" | ||
> | ||
<div className="wrapText">{linkLabel}</div> | ||
</EuiSkeletonTitle> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiFlexGroup gutterSize="none" className="navEmbeddable_hoverActions"> | ||
<EuiFlexItem> | ||
<EuiButtonIcon size="xs" iconType="pencil" aria-label="Edit" onClick={editLink} /> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiButtonIcon | ||
size="xs" | ||
iconType="trash" | ||
aria-label="Delete" | ||
color="danger" | ||
onClick={deleteLink} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
}; |
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