Home / File/ OpenInEditorButton.js — react Source File

OpenInEditorButton.js — react Source File

Architecture documentation for OpenInEditorButton.js, a javascript file in the react codebase. 8 imports, 1 dependents.

File javascript BabelCompiler Validation 8 imports 1 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  5eb75744_619e_d7d3_c988_8d5803563f16["OpenInEditorButton.js"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c["EditorPane.js"]
  5eb75744_619e_d7d3_c988_8d5803563f16 --> 6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c
  df34d6bc_88ee_9d70_cb1b_fbe686dca6da["utils.js"]
  5eb75744_619e_d7d3_c988_8d5803563f16 --> df34d6bc_88ee_9d70_cb1b_fbe686dca6da
  3c81519b_a855_b45e_b91b_c1dcaaf5d5b9["checkConditions"]
  5eb75744_619e_d7d3_c988_8d5803563f16 --> 3c81519b_a855_b45e_b91b_c1dcaaf5d5b9
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  5eb75744_619e_d7d3_c988_8d5803563f16 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  e990a84d_b490_703b_26b3_fe044fc7bcf3["Button"]
  5eb75744_619e_d7d3_c988_8d5803563f16 --> e990a84d_b490_703b_26b3_fe044fc7bcf3
  0cbf34b0_8358_799e_95fa_64745d5111eb["ButtonIcon"]
  5eb75744_619e_d7d3_c988_8d5803563f16 --> 0cbf34b0_8358_799e_95fa_64745d5111eb
  1beba1f0_7c1b_da22_8678_4c06e2357ad8["ButtonLabel"]
  5eb75744_619e_d7d3_c988_8d5803563f16 --> 1beba1f0_7c1b_da22_8678_4c06e2357ad8
  d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"]
  5eb75744_619e_d7d3_c988_8d5803563f16 --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c["EditorPane.js"]
  6b10ae9e_a560_a310_ddb0_99f0d8e5ab0c --> 5eb75744_619e_d7d3_c988_8d5803563f16
  style 5eb75744_619e_d7d3_c988_8d5803563f16 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import * as React from 'react';

import Button from 'react-devtools-shared/src/devtools/views/Button';
import ButtonIcon from 'react-devtools-shared/src/devtools/views/ButtonIcon';
import ButtonLabel from 'react-devtools-shared/src/devtools/views/ButtonLabel';

import type {SourceSelection} from './EditorPane';
import type {ReactFunctionLocation} from 'shared/ReactTypes';

import {checkConditions} from './utils';

type Props = {
  editorURL: string,
  source: ?SourceSelection,
  className?: string,
};

function ActualOpenInEditorButton({
  editorURL,
  source,
  className,
}: Props): React.Node {
  let disable;
  if (source == null) {
    disable = true;
  } else {
    const staleLocation: ReactFunctionLocation = [
      '',
      source.url,
      // This is not live but we just use any line/column to validate whether this can be opened.
      // We'll call checkConditions again when we click it to get the latest line number.
      source.selectionRef.line,
      source.selectionRef.column,
    ];
    disable = checkConditions(editorURL, staleLocation).shouldDisableButton;
  }
  return (
    <Button
      disabled={disable}
      className={className}
      onClick={() => {
        if (source == null) {
          return;
        }
        const latestLocation: ReactFunctionLocation = [
          '',
          source.url,
          // These might have changed since we last read it.
          source.selectionRef.line,
          source.selectionRef.column,
        ];
        const {url, shouldDisableButton} = checkConditions(
          editorURL,
          latestLocation,
        );
        if (!shouldDisableButton) {
          window.open(url);
        }
      }}>
      <ButtonIcon type="editor" />
      <ButtonLabel>Open in editor</ButtonLabel>
    </Button>
  );
}

function OpenInEditorButton({editorURL, source, className}: Props): React.Node {
  return (
    <React.Suspense
      fallback={
        <Button disabled={true} className={className}>
          <ButtonIcon type="editor" />
          <ButtonLabel>Loading source maps...</ButtonLabel>
        </Button>
      }>
      <ActualOpenInEditorButton
        editorURL={editorURL}
        source={source}
        className={className}
      />
    </React.Suspense>
  );
}

export default OpenInEditorButton;

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does OpenInEditorButton.js do?
OpenInEditorButton.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in OpenInEditorButton.js?
OpenInEditorButton.js defines 2 function(s): ActualOpenInEditorButton, OpenInEditorButton.
What does OpenInEditorButton.js depend on?
OpenInEditorButton.js imports 8 module(s): Button, ButtonIcon, ButtonLabel, EditorPane.js, ReactTypes, checkConditions, react, utils.js.
What files import OpenInEditorButton.js?
OpenInEditorButton.js is imported by 1 file(s): EditorPane.js.
Where is OpenInEditorButton.js in the architecture?
OpenInEditorButton.js is located at packages/react-devtools-shared/src/devtools/views/Editor/OpenInEditorButton.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Editor).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free