renderPipelineView.tsx 1014 B

1234567891011121314151617181920212223242526272829
  1. import {render} from 'react-dom';
  2. import {createRoot} from 'react-dom/client';
  3. import {ROOT_ELEMENT} from 'sentry/constants';
  4. import type {PipelineInitialData} from 'sentry/types';
  5. import PipelineView from 'sentry/views/integrationPipeline/pipelineView';
  6. function renderDom(pipelineName: string, props: PipelineInitialData['props']) {
  7. const rootEl = document.getElementById(ROOT_ELEMENT)!;
  8. // Types are for ConfigStore, the window object is from json and features is not a Set
  9. if (
  10. (window.__initialData.features as unknown as string[]).includes(
  11. 'organizations:react-concurrent-renderer-enabled'
  12. )
  13. ) {
  14. // Enable concurrent rendering
  15. const root = createRoot(rootEl);
  16. root.render(<PipelineView pipelineName={pipelineName} {...props} />);
  17. } else {
  18. // Legacy rendering
  19. render(<PipelineView pipelineName={pipelineName} {...props} />, rootEl);
  20. }
  21. }
  22. export function renderPipelineView() {
  23. const {name, props} = window.__pipelineInitialData;
  24. renderDom(name, props);
  25. }