|
|
|
@ -5,6 +5,7 @@ import React, { MouseEvent, useCallback, useEffect, useMemo, useState } from 're |
|
|
|
|
import { GrafanaTheme2, SelectableValue, urlUtil } from '@grafana/data'; |
|
|
|
|
import { locationService } from '@grafana/runtime'; |
|
|
|
|
import { AsyncSelect, Button, Modal, useStyles2 } from '@grafana/ui'; |
|
|
|
|
import { t, Trans } from 'app/core/internationalization'; |
|
|
|
|
|
|
|
|
|
import { DashboardSearchItem } from '../../../search/types'; |
|
|
|
|
import { getConnectedDashboards, getLibraryPanelConnectedDashboards } from '../../state/api'; |
|
|
|
@ -38,19 +39,27 @@ export function OpenLibraryPanelModal({ libraryPanel, onDismiss }: OpenLibraryPa |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Modal title="View panel in dashboard" onDismiss={onDismiss} onClickBackdrop={onDismiss} isOpen> |
|
|
|
|
<Modal |
|
|
|
|
title={t('library-panels.modal.title', 'View panel in dashboard')} |
|
|
|
|
onDismiss={onDismiss} |
|
|
|
|
onClickBackdrop={onDismiss} |
|
|
|
|
isOpen |
|
|
|
|
> |
|
|
|
|
<div className={styles.container}> |
|
|
|
|
{connected === 0 ? ( |
|
|
|
|
<span>Panel is not linked to a dashboard. Add the panel to a dashboard and retry.</span> |
|
|
|
|
<span> |
|
|
|
|
<Trans i18nKey={'library-panels.modal.panel-not-linked'}> |
|
|
|
|
Panel is not linked to a dashboard. Add the panel to a dashboard and retry. |
|
|
|
|
</Trans> |
|
|
|
|
</span> |
|
|
|
|
) : null} |
|
|
|
|
{connected > 0 ? ( |
|
|
|
|
<> |
|
|
|
|
<p> |
|
|
|
|
This panel is being used in{' '} |
|
|
|
|
<strong> |
|
|
|
|
{connected} {connected > 1 ? 'dashboards' : 'dashboard'} |
|
|
|
|
</strong> |
|
|
|
|
.Please choose which dashboard to view the panel in: |
|
|
|
|
<Trans i18nKey="library-panels.modal.body" count={connected}> |
|
|
|
|
This panel is being used in {{ count: connected }} dashboard. Please choose which dashboard to view the |
|
|
|
|
panel in: |
|
|
|
|
</Trans> |
|
|
|
|
</p> |
|
|
|
|
<AsyncSelect |
|
|
|
|
isClearable |
|
|
|
@ -58,18 +67,20 @@ export function OpenLibraryPanelModal({ libraryPanel, onDismiss }: OpenLibraryPa |
|
|
|
|
defaultOptions={true} |
|
|
|
|
loadOptions={debouncedLoadOptions} |
|
|
|
|
onChange={setOption} |
|
|
|
|
placeholder="Start typing to search for dashboard" |
|
|
|
|
noOptionsMessage="No dashboards found" |
|
|
|
|
placeholder={t('library-panels.modal.select-placeholder', 'Start typing to search for dashboard')} |
|
|
|
|
noOptionsMessage={t('library-panels.modal.select-no-options-message', 'No dashboards found')} |
|
|
|
|
/> |
|
|
|
|
</> |
|
|
|
|
) : null} |
|
|
|
|
</div> |
|
|
|
|
<Modal.ButtonRow> |
|
|
|
|
<Button variant="secondary" onClick={onDismiss} fill="outline"> |
|
|
|
|
Cancel |
|
|
|
|
<Trans i18nKey={'library-panels.modal.button-cancel'}>Cancel</Trans> |
|
|
|
|
</Button> |
|
|
|
|
<Button onClick={onViewPanel} disabled={!Boolean(option)}> |
|
|
|
|
{option ? `View panel in ${option?.label}...` : 'View panel in dashboard...'} |
|
|
|
|
{option |
|
|
|
|
? t('library-panels.modal.button-view-panel1', 'View panel in {{label}}...', { label: option?.label }) |
|
|
|
|
: t('library-panels.modal.button-view-panel2', 'View panel in dashboard...')} |
|
|
|
|
</Button> |
|
|
|
|
</Modal.ButtonRow> |
|
|
|
|
</Modal> |
|
|
|
|