{
// In the SourceTree, extension files should use the file-extension based icon,
// whereas we use the extension icon in other Components (eg. source tabs and breakpoints pane).
if (icon === "extension") {
return (
sourceTypes[source.displayURL.fileExtension] || "javascript"
);
}
return icon + (this.props.isOverridden ? " override" : "");
}}
/>
);
}
return null;
}
renderItemName(depth) {
const { item } = this.props;
if (item.type == "thread") {
const { thread } = item;
return (
thread.name +
(thread.serviceWorkerStatus ? ` (${thread.serviceWorkerStatus})` : "")
);
}
if (item.type == "group") {
return safeDecodeItemName(item.groupName);
}
if (item.type == "directory") {
const parentItem = this.props.getParent(item);
return safeDecodeItemName(
item.path.replace(parentItem.path, "").replace(/^\//, "")
);
}
if (item.type == "source") {
const { displayURL } = item.source;
const name =
displayURL.filename + (displayURL.search ? displayURL.search : "");
return safeDecodeItemName(name);
}
return null;
}
renderItemTooltip() {
const { item } = this.props;
if (item.type == "thread") {
return item.thread.name;
}
if (item.type == "group") {
return item.groupName;
}
if (item.type == "directory") {
return item.path;
}
if (item.type == "source") {
return item.source.url;
}
return null;
}
render() {
const {
item,
depth,
focused,
hasMatchingGeneratedSource,
hideIgnoredSources,
} = this.props;
if (hideIgnoredSources && item.isBlackBoxed) {
return null;
}
const suffix = hasMatchingGeneratedSource ? (
{L10N.getStr("sourceFooter.mappedSuffix")}
) : null;
return (
{this.renderItemArrow()}
{this.renderIcon(item, depth)}
{this.renderItemName(depth)}
{suffix}
);
}
}
function getHasMatchingGeneratedSource(state, source) {
if (!source || !source.isOriginal) {
return false;
}
return !!getGeneratedSourceByURL(state, source.url);
}
const mapStateToProps = (state, props) => {
const { item } = props;
if (item.type == "source") {
const { source } = item;
return {
cx: getContext(state),
hasMatchingGeneratedSource: getHasMatchingGeneratedSource(state, source),
getFirstSourceActorForGeneratedSource: (sourceId, threadId) =>
getFirstSourceActorForGeneratedSource(state, sourceId, threadId),
isOverridden: isSourceOverridden(state, source),
hideIgnoredSources: getHideIgnoredSources(state),
isSourceOnIgnoreList:
isSourceMapIgnoreListEnabled(state) &&
isSourceOnSourceMapIgnoreList(state, source),
};
}
return {
cx: getContext(state),
getFirstSourceActorForGeneratedSource: (sourceId, threadId) =>
getFirstSourceActorForGeneratedSource(state, sourceId, threadId),
};
};
export default connect(mapStateToProps, {
setProjectDirectoryRoot: actions.setProjectDirectoryRoot,
clearProjectDirectoryRoot: actions.clearProjectDirectoryRoot,
toggleBlackBox: actions.toggleBlackBox,
loadSourceText: actions.loadSourceText,
blackBoxSources: actions.blackBoxSources,
setBlackBoxAllOutside: actions.setBlackBoxAllOutside,
setOverrideSource: actions.setOverrideSource,
removeOverrideSource: actions.removeOverrideSource,
})(SourceTreeItem);