FolderAlerting.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import React from 'react';
  2. import { useDispatch, useSelector } from 'react-redux';
  3. import { useAsync } from 'react-use';
  4. import Page from 'app/core/components/Page/Page';
  5. import { GrafanaRouteComponentProps } from 'app/core/navigation/types';
  6. import { getNavModel } from 'app/core/selectors/navModel';
  7. import { StoreState } from 'app/types';
  8. import { AlertsFolderView } from '../alerting/unified/AlertsFolderView';
  9. import { getFolderByUid } from './state/actions';
  10. import { getLoadingNav } from './state/navModel';
  11. export interface OwnProps extends GrafanaRouteComponentProps<{ uid: string }> {}
  12. const FolderAlerting = ({ match }: OwnProps) => {
  13. const dispatch = useDispatch();
  14. const navIndex = useSelector((state: StoreState) => state.navIndex);
  15. const folder = useSelector((state: StoreState) => state.folder);
  16. const uid = match.params.uid;
  17. const navModel = getNavModel(navIndex, `folder-alerting-${uid}`, getLoadingNav(1));
  18. const { loading } = useAsync(async () => dispatch(getFolderByUid(uid)), [getFolderByUid, uid]);
  19. return (
  20. <Page navModel={navModel}>
  21. <Page.Contents isLoading={loading}>
  22. <AlertsFolderView folder={folder} />
  23. </Page.Contents>
  24. </Page>
  25. );
  26. };
  27. export default FolderAlerting;