fullQueryDescription.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. interface Props {
  9. group?: string;
  10. shortDescription?: string;
  11. }
  12. export function FullQueryDescription({group, shortDescription}: Props) {
  13. const {
  14. data: fullSpan,
  15. isLoading,
  16. isFetching,
  17. } = useFullSpanFromTrace(group, Boolean(group));
  18. const description = fullSpan?.description ?? shortDescription;
  19. if (!description) {
  20. return null;
  21. }
  22. return isLoading && isFetching ? (
  23. <PaddedSpinner>
  24. <LoadingIndicator mini hideMessage relative />
  25. </PaddedSpinner>
  26. ) : (
  27. <CodeSnippet language="sql">{formatter.toString(description)}</CodeSnippet>
  28. );
  29. }
  30. const PaddedSpinner = styled('div')`
  31. padding: ${space(0)} ${space(0.5)};
  32. `;