unsupportedAlert.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {useMemo} from 'react';
  2. import UnsupportedAlert from 'sentry/components/alerts/unsupportedAlert';
  3. import {ALL_ACCESS_PROJECTS} from 'sentry/constants/pageFilters';
  4. import {profiling} from 'sentry/data/platformCategories';
  5. import useProjects from 'sentry/utils/useProjects';
  6. interface ProfilingUnsupportedAlertProps {
  7. selectedProjects: Array<number>;
  8. }
  9. export function ProfilingUnsupportedAlert({
  10. selectedProjects,
  11. }: ProfilingUnsupportedAlertProps) {
  12. const {projects} = useProjects();
  13. const withoutProfilingSupport = useMemo((): boolean => {
  14. const projectsWithProfilingSupport = new Set(
  15. projects
  16. .filter(project => !project.platform || profiling.includes(project.platform))
  17. .map(project => project.id)
  18. );
  19. // if it's My Projects or All projects, only show banner if none of them
  20. // has profiling support
  21. if (selectedProjects.length === 0 || selectedProjects[0] === ALL_ACCESS_PROJECTS) {
  22. return projectsWithProfilingSupport.size === 0;
  23. }
  24. // if some projects are selected using the selector, show the banner if none of them
  25. // has profiling support
  26. return selectedProjects.every(
  27. project => !projectsWithProfilingSupport.has(String(project))
  28. );
  29. }, [selectedProjects, projects]);
  30. if (withoutProfilingSupport === false) return null;
  31. return <UnsupportedAlert featureName="Profiling" />;
  32. }