fullQueryDescription.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import styled from '@emotion/styled';
  2. import {CodeSnippet} from 'sentry/components/codeSnippet';
  3. import LoadingIndicator from 'sentry/components/loadingIndicator';
  4. import {space} from 'sentry/styles/space';
  5. import {useFullSpanFromTrace} from 'sentry/views/starfish/queries/useFullSpanFromTrace';
  6. import {SQLishFormatter} from 'sentry/views/starfish/utils/sqlish/SQLishFormatter';
  7. const formatter = new SQLishFormatter();
  8. export function FullQueryDescription({group, shortDescription}: Props) {
  9. const {
  10. data: fullSpan,
  11. isLoading,
  12. isFetching,
  13. } = useFullSpanFromTrace(group, Boolean(group));
  14. const description = fullSpan?.description ?? shortDescription;
  15. if (!description) {
  16. return null;
  17. }
  18. return isLoading && isFetching ? (
  19. <PaddedSpinner>
  20. <LoadingIndicator mini hideMessage relative />
  21. </PaddedSpinner>
  22. ) : (
  23. <CodeSnippet language="sql">
  24. {formatter.toString(description, {maxLineLength: LINE_LENGTH})}
  25. </CodeSnippet>
  26. );
  27. }
  28. interface Props {
  29. group?: string;
  30. shortDescription?: string;
  31. }
  32. const LINE_LENGTH = 60;
  33. const PaddedSpinner = styled('div')`
  34. padding: ${space(0)} ${space(0.5)};
  35. `;