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ACN,EAAae,MAEViB,GAAuBC,EAAAA,EAAAA,UAC3B,KAAMC,EAAAA,EAAAA,UAAShB,EAAa,IAAK,CAAEiB,SAAS,EAAMC,UAAU,KAC5D,CAAClB,IAOH,OACE,UAAC,EAAAmB,MAAD,CAAOZ,MAAM,0BAA0B1B,UAAWA,EAAWuC,gBAAiBvC,EAAWwC,QAAM,EAA/F,WACE,iBAAKC,UAAWtC,EAAOuC,UAAvB,UACiB,IAAdlC,EAAA,OACC,2GACE,KACHA,EAAY,GACX,iCACE,uDAC8B,KAC5B,8BACGA,EADH,IACeA,EAAY,EAAI,aAAe,eAHhD,2DAOA,SAAC,EAAAmC,YAAD,CACEC,aAAW,EACXC,UAAWvC,EACXwC,gBAAgB,EAChB3B,YAAac,EACbc,SAAUpC,EACVqC,YAAY,uCACZC,iBAAiB,2BAGnB,SAEN,UAAC,EAAAX,MAAA,UAAD,YACE,SAAC,EAAAY,OAAD,CAAQC,QAAQ,YAAYxD,QAASK,EAAWoD,KAAK,UAArD,qBAGA,SAAC,EAAAF,OAAD,CAAQvD,QApCO0D,IAAqC,MACxDA,EAAEC,iBACFC,EAAAA,gBAAAA,KAAqBC,EAAAA,QAAAA,UAAmB,MAAK9C,MAAAA,GAAN,UAAMA,EAAQqB,aAAd,aAAM,EAAef,MAAO,MAkCjCyC,UAAWC,QAAQhD,GAAjD,SACGA,EAAU,iBAAgBA,MAAAA,OAAjB,EAAiBA,EAAQoB,WAAa,qCAkB1D,SAASzB,EAAUsD,GACjB,MAAO,CACLjB,UAAWkB,EAAAA,GAAI","sources":["webpack://grafana/./public/app/features/library-panels/LibraryPanelsPage.tsx","webpack://grafana/./public/app/features/library-panels/components/OpenLibraryPanelModal/OpenLibraryPanelModal.tsx"],"sourcesContent":["import React, { FC, useState } from 'react';\nimport { connect, ConnectedProps } from 'react-redux';\n\nimport Page from '../../core/components/Page/Page';\nimport { GrafanaRouteComponentProps } from '../../core/navigation/types';\nimport { getNavModel } from '../../core/selectors/navModel';\nimport { StoreState } from '../../types';\n\nimport { LibraryPanelsSearch } from './components/LibraryPanelsSearch/LibraryPanelsSearch';\nimport { OpenLibraryPanelModal } from './components/OpenLibraryPanelModal/OpenLibraryPanelModal';\nimport { LibraryElementDTO } from './types';\n\nconst mapStateToProps = (state: StoreState) => ({\n navModel: getNavModel(state.navIndex, 'library-panels'),\n});\n\nconst connector = connect(mapStateToProps, undefined);\n\ninterface OwnProps extends GrafanaRouteComponentProps {}\n\ntype Props = OwnProps & ConnectedProps;\n\nexport const LibraryPanelsPage: FC = ({ navModel }) => {\n const [selected, setSelected] = useState(undefined);\n\n return (\n \n \n \n {selected ? setSelected(undefined)} libraryPanel={selected} /> : null}\n \n \n );\n};\n\nexport default connect(mapStateToProps)(LibraryPanelsPage);\n","import { css } from '@emotion/css';\nimport { debounce } from 'lodash';\nimport React, { MouseEvent, useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { GrafanaTheme2, SelectableValue, urlUtil } from '@grafana/data';\nimport { locationService } from '@grafana/runtime';\nimport { AsyncSelect, Button, Modal, useStyles2 } from '@grafana/ui';\n\nimport { DashboardSearchHit } from '../../../search/types';\nimport { getConnectedDashboards, getLibraryPanelConnectedDashboards } from '../../state/api';\nimport { LibraryElementDTO } from '../../types';\n\nexport interface OpenLibraryPanelModalProps {\n onDismiss: () => void;\n libraryPanel: LibraryElementDTO;\n}\n\nexport function OpenLibraryPanelModal({ libraryPanel, onDismiss }: OpenLibraryPanelModalProps): JSX.Element {\n const styles = useStyles2(getStyles);\n const [loading, setLoading] = useState(false);\n const [connected, setConnected] = useState(0);\n const [option, setOption] = useState | undefined>(undefined);\n useEffect(() => {\n const getConnected = async () => {\n const connectedDashboards = await getLibraryPanelConnectedDashboards(libraryPanel.uid);\n setConnected(connectedDashboards.length);\n };\n getConnected();\n }, [libraryPanel.uid]);\n const loadOptions = useCallback(\n (searchString: string) => loadOptionsAsync(libraryPanel.uid, searchString, setLoading),\n [libraryPanel.uid]\n );\n const debouncedLoadOptions = useMemo(\n () => debounce(loadOptions, 300, { leading: true, trailing: true }),\n [loadOptions]\n );\n const onViewPanel = (e: MouseEvent) => {\n e.preventDefault();\n locationService.push(urlUtil.renderUrl(`/d/${option?.value?.uid}`, {}));\n };\n\n return (\n \n
\n {connected === 0 ? (\n Panel is not linked to a dashboard. Add the panel to a dashboard and retry.\n ) : null}\n {connected > 0 ? (\n <>\n

\n This panel is being used in{' '}\n \n {connected} {connected > 1 ? 'dashboards' : 'dashboard'}\n \n .Please choose which dashboard to view the panel in:\n

\n \n \n ) : null}\n
\n \n \n \n \n
\n );\n}\n\nasync function loadOptionsAsync(uid: string, searchString: string, setLoading: (loading: boolean) => void) {\n setLoading(true);\n const searchHits = await getConnectedDashboards(uid);\n const options = searchHits\n .filter((d) => d.title.toLowerCase().includes(searchString.toLowerCase()))\n .map((d) => ({ label: d.title, value: d }));\n setLoading(false);\n\n return options;\n}\n\nfunction getStyles(theme: GrafanaTheme2) {\n return {\n container: css``,\n };\n}\n"],"names":["mapStateToProps","state","navModel","getNavModel","navIndex","LibraryPanelsPage","connect","undefined","selected","setSelected","useState","onClick","showSecondaryActions","showSort","showPanelFilter","showFolderFilter","onDismiss","libraryPanel","OpenLibraryPanelModal","styles","useStyles2","getStyles","loading","setLoading","connected","setConnected","option","setOption","useEffect","async","connectedDashboards","getLibraryPanelConnectedDashboards","uid","length","getConnected","loadOptions","useCallback","searchString","options","getConnectedDashboards","filter","d","title","toLowerCase","includes","map","label","value","loadOptionsAsync","debouncedLoadOptions","useMemo","debounce","leading","trailing","Modal","onClickBackdrop","isOpen","className","container","AsyncSelect","isClearable","isLoading","defaultOptions","onChange","placeholder","noOptionsMessage","Button","variant","fill","e","preventDefault","locationService","urlUtil","disabled","Boolean","theme","css"],"sourceRoot":""}