зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1751032 - [devtools] Migrate all tabs selectors to a selector module. r=bomsy
Differential Revision: https://phabricator.services.mozilla.com/D136399
This commit is contained in:
Родитель
6688d3c8fb
Коммит
d3c1ec720d
|
@ -10,7 +10,7 @@
|
|||
import { isOriginalId } from "devtools-source-map";
|
||||
|
||||
import { getSourceFromId, getSourceWithContent } from "../../reducers/sources";
|
||||
import { tabExists } from "../../reducers/tabs";
|
||||
import { tabExists } from "../../selectors/tabs";
|
||||
import { setSymbols } from "./symbols";
|
||||
import { setInScopeLines } from "../ast";
|
||||
import { closeActiveSearch, updateActiveFileSearch } from "../ui";
|
||||
|
|
|
@ -7,19 +7,11 @@
|
|||
* @module reducers/tabs
|
||||
*/
|
||||
|
||||
import { createSelector } from "reselect";
|
||||
import { isOriginalId } from "devtools-source-map";
|
||||
|
||||
import { isSimilarTab, persistTabs } from "../utils/tabs";
|
||||
import { makeShallowQuery } from "../utils/resource";
|
||||
import { getPrettySourceURL } from "../utils/source";
|
||||
|
||||
import {
|
||||
getSource,
|
||||
getSpecificSourceByURL,
|
||||
getSources,
|
||||
resourceAsSourceBase,
|
||||
} from "./sources";
|
||||
import { getSource, getSpecificSourceByURL } from "./sources";
|
||||
|
||||
export function initialTabState() {
|
||||
return { tabs: [] };
|
||||
|
@ -249,34 +241,4 @@ function moveTab(tabs, currentIndex, newIndex) {
|
|||
return { tabs: newTabs };
|
||||
}
|
||||
|
||||
// Selectors
|
||||
|
||||
export const getTabs = state => state.tabs.tabs;
|
||||
|
||||
export const getSourceTabs = createSelector(
|
||||
state => state.tabs,
|
||||
({ tabs }) => tabs.filter(tab => tab.sourceId)
|
||||
);
|
||||
|
||||
export const getSourcesForTabs = state => {
|
||||
const tabs = getSourceTabs(state);
|
||||
const sources = getSources(state);
|
||||
return querySourcesForTabs(sources, tabs);
|
||||
};
|
||||
|
||||
const querySourcesForTabs = makeShallowQuery({
|
||||
filter: (_, tabs) => tabs.map(({ sourceId }) => sourceId),
|
||||
map: resourceAsSourceBase,
|
||||
reduce: items => items,
|
||||
});
|
||||
|
||||
export function tabExists(state, sourceId) {
|
||||
return !!getSourceTabs(state).find(tab => tab.sourceId == sourceId);
|
||||
}
|
||||
|
||||
export function hasPrettyTab(state, sourceUrl) {
|
||||
const prettyUrl = getPrettySourceURL(sourceUrl);
|
||||
return !!getSourceTabs(state).find(tab => tab.url === prettyUrl);
|
||||
}
|
||||
|
||||
export default update;
|
||||
|
|
|
@ -53,6 +53,7 @@ export {
|
|||
getSelectedFrames,
|
||||
getVisibleSelectedFrame,
|
||||
} from "./pause";
|
||||
export * from "./tabs";
|
||||
export * from "./threads";
|
||||
|
||||
import { objectInspector } from "devtools/client/shared/components/reps/index";
|
||||
|
|
|
@ -15,6 +15,7 @@ CompiledModules(
|
|||
"isLineInScope.js",
|
||||
"isSelectedFrameVisible.js",
|
||||
"pause.js",
|
||||
"tabs.js",
|
||||
"threads.js",
|
||||
"visibleBreakpoints.js",
|
||||
"visibleColumnBreakpoints.js",
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { createSelector } from "reselect";
|
||||
import { makeShallowQuery } from "../utils/resource";
|
||||
import { getPrettySourceURL } from "../utils/source";
|
||||
|
||||
import { getSources, resourceAsSourceBase } from "../reducers/sources";
|
||||
|
||||
export const getTabs = state => state.tabs.tabs;
|
||||
|
||||
export const getSourceTabs = createSelector(
|
||||
state => state.tabs,
|
||||
({ tabs }) => tabs.filter(tab => tab.sourceId)
|
||||
);
|
||||
|
||||
export const getSourcesForTabs = state => {
|
||||
const tabs = getSourceTabs(state);
|
||||
const sources = getSources(state);
|
||||
return querySourcesForTabs(sources, tabs);
|
||||
};
|
||||
|
||||
const querySourcesForTabs = makeShallowQuery({
|
||||
filter: (_, tabs) => tabs.map(({ sourceId }) => sourceId),
|
||||
map: resourceAsSourceBase,
|
||||
reduce: items => items,
|
||||
});
|
||||
|
||||
export function tabExists(state, sourceId) {
|
||||
return !!getSourceTabs(state).find(tab => tab.sourceId == sourceId);
|
||||
}
|
||||
|
||||
export function hasPrettyTab(state, sourceUrl) {
|
||||
const prettyUrl = getPrettySourceURL(sourceUrl);
|
||||
return !!getSourceTabs(state).find(tab => tab.url === prettyUrl);
|
||||
}
|
Загрузка…
Ссылка в новой задаче