accountNotificationFineTuningController.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import type {RouteComponentProps} from 'react-router';
  2. import LoadingIndicator from 'sentry/components/loadingIndicator';
  3. import type {Organization} from 'sentry/types';
  4. import withOrganizations from 'sentry/utils/withOrganizations';
  5. import AccountNotificationFineTuning from './accountNotificationFineTuning';
  6. import AccountNotificationFineTuningV2 from './accountNotificationFineTuningV2';
  7. interface AccountNotificationFineTuningControllerProps
  8. extends RouteComponentProps<{fineTuneType: string}, {}> {
  9. organizations: Organization[];
  10. organizationsLoading?: boolean;
  11. }
  12. export function AccountNotificationFineTuningController({
  13. organizations,
  14. organizationsLoading,
  15. ...props
  16. }: AccountNotificationFineTuningControllerProps) {
  17. if (organizationsLoading) {
  18. return <LoadingIndicator />;
  19. }
  20. // check if feature is enabled for any organization
  21. const hasFeature = organizations.some(org =>
  22. org.features.includes('notification-settings-v2')
  23. );
  24. return hasFeature ? (
  25. <AccountNotificationFineTuningV2 {...props} />
  26. ) : (
  27. <AccountNotificationFineTuning {...props} />
  28. );
  29. }
  30. export default withOrganizations(AccountNotificationFineTuningController);