utils.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import isObject from 'lodash/isObject';
  2. import {EventGroupComponent} from 'sentry/types';
  3. export function hasNonContributingComponent(component: EventGroupComponent | undefined) {
  4. if (component === undefined) {
  5. return false;
  6. }
  7. if (!component.contributes) {
  8. return true;
  9. }
  10. for (const value of component.values) {
  11. if (isObject(value) && hasNonContributingComponent(value)) {
  12. return true;
  13. }
  14. }
  15. return false;
  16. }
  17. export function shouldInlineComponentValue(component: EventGroupComponent) {
  18. return (component.values as EventGroupComponent[]).every(value => !isObject(value));
  19. }
  20. export function groupingComponentFilter(
  21. value: EventGroupComponent | string,
  22. showNonContributing: boolean
  23. ) {
  24. if (isObject(value)) {
  25. // no point rendering such nodes at all, we never show them
  26. if (!value.contributes && !value.hint && value.values.length === 0) {
  27. return false;
  28. }
  29. // non contributing values are otherwise optional
  30. if (!showNonContributing && !value.contributes) {
  31. return false;
  32. }
  33. }
  34. return true;
  35. }