Skip to content

Commit

Permalink
Revert "Show warning in UI when duplicate installations of DevTools e…
Browse files Browse the repository at this point in the history
…xtension are detected (facebook#22563)"

This reverts commit 930c9e7.
  • Loading branch information
Juan Tejada committed Oct 19, 2021
1 parent b3b3291 commit 4e00783
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 115 deletions.
16 changes: 4 additions & 12 deletions packages/react-devtools-extensions/src/background.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
// @flow strict-local
/* global chrome */

'use strict';

declare var chrome: any;

const ports: {
[tab: string]: {|devtools: any, 'content-script': any|},
} = {};
const ports = {};

const IS_FIREFOX = navigator.userAgent.indexOf('Firefox') >= 0;

import {
EXTENSION_INSTALL_CHECK,
SHOW_DUPLICATE_EXTENSION_WARNING,
} from './constants';
import {EXTENSION_INSTALL_CHECK_MESSAGE} from './constants';

chrome.runtime.onConnect.addListener(function(port) {
let tab = null;
Expand Down Expand Up @@ -127,9 +120,8 @@ chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {

chrome.runtime.onMessageExternal.addListener(
(request, sender, sendResponse) => {
if (request === EXTENSION_INSTALL_CHECK) {
if (request === EXTENSION_INSTALL_CHECK_MESSAGE) {
sendResponse(true);
chrome.runtime.sendMessage(SHOW_DUPLICATE_EXTENSION_WARNING);
}
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ declare var chrome: any;

import {__DEBUG__} from 'react-devtools-shared/src/constants';
import {
EXTENSION_INSTALL_CHECK,
EXTENSION_INSTALL_CHECK_MESSAGE,
EXTENSION_INSTALLATION_TYPE,
INTERNAL_EXTENSION_ID,
LOCAL_EXTENSION_ID,
} from './constants';

const UNRECOGNIZED_EXTENSION_ERROR =
const UNRECOGNIZED_EXTENSION_WARNING =
'React Developer Tools: You are running an unrecognized installation of the React Developer Tools extension, which might conflict with other versions of the extension installed in your browser. ' +
'Please make sure you only have a single version of the extension installed or enabled. ' +
'If you are developing this extension locally, make sure to build the extension using the `yarn build:<browser>:local` command.';
Expand Down Expand Up @@ -68,9 +68,9 @@ export function checkForDuplicateInstallations(callback: boolean => void) {
// detect if there are other installations of DevTools present.
// In this case, assume there are no duplicate exensions and show a warning about
// potential conflicts.
console.error(UNRECOGNIZED_EXTENSION_ERROR);
console.error(UNRECOGNIZED_EXTENSION_WARNING);
chrome.devtools.inspectedWindow.eval(
`console.error("${UNRECOGNIZED_EXTENSION_ERROR}")`,
`console.error("${UNRECOGNIZED_EXTENSION_WARNING}")`,
);
callback(false);
break;
Expand All @@ -80,9 +80,9 @@ export function checkForDuplicateInstallations(callback: boolean => void) {
// are other installations of DevTools present.
// In this case, assume there are no duplicate exensions and show a warning about
// potential conflicts.
console.error(UNRECOGNIZED_EXTENSION_ERROR);
console.error(UNRECOGNIZED_EXTENSION_WARNING);
chrome.devtools.inspectedWindow.eval(
`console.error("${UNRECOGNIZED_EXTENSION_ERROR}")`,
`console.error("${UNRECOGNIZED_EXTENSION_WARNING}")`,
);
callback(false);
break;
Expand All @@ -105,7 +105,7 @@ function checkForInstalledExtension(extensionId: string): Promise<boolean> {
return new Promise(resolve => {
chrome.runtime.sendMessage(
extensionId,
EXTENSION_INSTALL_CHECK,
EXTENSION_INSTALL_CHECK_MESSAGE,
response => {
if (__DEBUG__) {
console.log(
Expand Down
4 changes: 1 addition & 3 deletions packages/react-devtools-extensions/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ declare var chrome: any;

export const CURRENT_EXTENSION_ID = chrome.runtime.id;

export const EXTENSION_INSTALL_CHECK = 'extension-install-check';
export const SHOW_DUPLICATE_EXTENSION_WARNING =
'show-duplicate-extension-warning';
export const EXTENSION_INSTALL_CHECK_MESSAGE = 'extension-install-check';

export const CHROME_WEBSTORE_EXTENSION_ID = 'fmkadmapgofadopljbjfkapdkoienihi';
export const INTERNAL_EXTENSION_ID = 'dnjnjgbfilfphmojnmhliehogmojhclc';
Expand Down
35 changes: 1 addition & 34 deletions packages/react-devtools-extensions/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ import {
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';
import {__DEBUG__} from 'react-devtools-shared/src/constants';
import {logEvent} from 'react-devtools-shared/src/Logger';
import {
CURRENT_EXTENSION_ID,
EXTENSION_INSTALLATION_TYPE,
SHOW_DUPLICATE_EXTENSION_WARNING,
} from './constants';
import {CURRENT_EXTENSION_ID, EXTENSION_INSTALLATION_TYPE} from './constants';
import {checkForDuplicateInstallations} from './checkForDuplicateInstallations';

const LOCAL_STORAGE_SUPPORTS_PROFILING_KEY =
Expand Down Expand Up @@ -112,39 +108,11 @@ function createPanelIfReactLoaded() {
let mostRecentOverrideTab = null;
let render = null;
let root = null;
let warnIfDuplicateInstallation = false;

const tabId = chrome.devtools.inspectedWindow.tabId;

registerDevToolsEventLogger('extension');

function onDuplicateExtensionMessage(message) {
if (message === SHOW_DUPLICATE_EXTENSION_WARNING) {
chrome.runtime.onMessage.removeListener(
onDuplicateExtensionMessage,
);

if (warnIfDuplicateInstallation === true) {
return;
}
warnIfDuplicateInstallation = true;
const errorMessage =
'React Developer Tools: We detected that there are multiple versions of React Developer Tools ' +
'installed and enabled in your browser at the same time, which will cause ' +
'issues while using the extension. ' +
'Please ensure that you have installed and enabled only a single ' +
'version of React Developer Tools before proceeding.';
console.error(errorMessage);
chrome.devtools.inspectedWindow.eval(
`console.error("${errorMessage}")`,
);
if (render != null) {
render();
}
}
}
chrome.runtime.onMessage.addListener(onDuplicateExtensionMessage);

function initBridgeAndStore() {
const port = chrome.runtime.connect({
name: String(tabId),
Expand Down Expand Up @@ -406,7 +374,6 @@ function createPanelIfReactLoaded() {
hookNamesModuleLoaderFunction,
overrideTab,
profilerPortalContainer,
warnIfDuplicateInstallation,
showTabBar: false,
store,
warnIfUnsupportedVersionDetected: true,
Expand Down
4 changes: 0 additions & 4 deletions packages/react-devtools-shared/src/devtools/views/DevTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {SchedulingProfilerContextController} from 'react-devtools-scheduling-pro
import {ModalDialogContextController} from './ModalDialog';
import ReactLogo from './ReactLogo';
import UnsupportedBridgeProtocolDialog from './UnsupportedBridgeProtocolDialog';
import DuplicateInstallationDialog from './DuplicateInstallationDialog';
import UnsupportedVersionDialog from './UnsupportedVersionDialog';
import WarnIfLegacyBackendDetected from './WarnIfLegacyBackendDetected';
import {useLocalStorage} from './hooks';
Expand Down Expand Up @@ -74,7 +73,6 @@ export type Props = {|
enabledInspectedElementContextMenu?: boolean,
showTabBar?: boolean,
store: Store,
warnIfDuplicateInstallation?: boolean,
warnIfLegacyBackendDetected?: boolean,
warnIfUnsupportedVersionDetected?: boolean,
viewAttributeSourceFunction?: ?ViewAttributeSource,
Expand Down Expand Up @@ -134,7 +132,6 @@ export default function DevTools({
profilerPortalContainer,
showTabBar = false,
store,
warnIfDuplicateInstallation = false,
warnIfLegacyBackendDetected = false,
warnIfUnsupportedVersionDetected = false,
viewAttributeSourceFunction,
Expand Down Expand Up @@ -322,7 +319,6 @@ export default function DevTools({
</ViewElementSourceContext.Provider>
</SettingsContextController>
<UnsupportedBridgeProtocolDialog />
{warnIfDuplicateInstallation && <DuplicateInstallationDialog />}
{warnIfLegacyBackendDetected && <WarnIfLegacyBackendDetected />}
{warnIfUnsupportedVersionDetected && <UnsupportedVersionDialog />}
</ModalDialogContextController>
Expand Down

This file was deleted.

0 comments on commit 4e00783

Please sign in to comment.