LibraryPanelsPage.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import React, { FC, useState } from 'react';
  2. import { connect, ConnectedProps } from 'react-redux';
  3. import Page from '../../core/components/Page/Page';
  4. import { GrafanaRouteComponentProps } from '../../core/navigation/types';
  5. import { getNavModel } from '../../core/selectors/navModel';
  6. import { StoreState } from '../../types';
  7. import { LibraryPanelsSearch } from './components/LibraryPanelsSearch/LibraryPanelsSearch';
  8. import { OpenLibraryPanelModal } from './components/OpenLibraryPanelModal/OpenLibraryPanelModal';
  9. import { LibraryElementDTO } from './types';
  10. const mapStateToProps = (state: StoreState) => ({
  11. navModel: getNavModel(state.navIndex, 'library-panels'),
  12. });
  13. const connector = connect(mapStateToProps, undefined);
  14. interface OwnProps extends GrafanaRouteComponentProps {}
  15. type Props = OwnProps & ConnectedProps<typeof connector>;
  16. export const LibraryPanelsPage: FC<Props> = ({ navModel }) => {
  17. const [selected, setSelected] = useState<LibraryElementDTO | undefined>(undefined);
  18. return (
  19. <Page navModel={navModel}>
  20. <Page.Contents>
  21. <LibraryPanelsSearch onClick={setSelected} showSecondaryActions showSort showPanelFilter showFolderFilter />
  22. {selected ? <OpenLibraryPanelModal onDismiss={() => setSelected(undefined)} libraryPanel={selected} /> : null}
  23. </Page.Contents>
  24. </Page>
  25. );
  26. };
  27. export default connect(mapStateToProps)(LibraryPanelsPage);