This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Share querystring logic with tabs & breakpoints sidebar (#7206)
- Loading branch information
Showing
9 changed files
with
127 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/components/SecondaryPanes/Breakpoints/BreakpointHeading.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* 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/>. */ | ||
|
||
// @flow | ||
import React, { PureComponent } from "react"; | ||
import { connect } from "react-redux"; | ||
import actions from "../../../actions"; | ||
import { | ||
getTruncatedFileName, | ||
getDisplayPath, | ||
getSourceQueryString, | ||
getFileURL | ||
} from "../../../utils/source"; | ||
import { getHasSiblingOfSameName } from "../../../selectors"; | ||
|
||
import SourceIcon from "../../shared/SourceIcon"; | ||
|
||
import type { Source } from "../../../types"; | ||
|
||
type Props = { | ||
sources: Source[], | ||
source: Source, | ||
hasSiblingOfSameName: boolean, | ||
selectSource: string => void | ||
}; | ||
|
||
class BreakpointHeading extends PureComponent<Props> { | ||
render() { | ||
const { sources, source, hasSiblingOfSameName, selectSource } = this.props; | ||
|
||
const path = getDisplayPath(source, sources); | ||
const query = hasSiblingOfSameName ? getSourceQueryString(source) : ""; | ||
|
||
return ( | ||
<div | ||
className="breakpoint-heading" | ||
title={getFileURL(source, false)} | ||
onClick={() => selectSource(source.id)} | ||
> | ||
<SourceIcon | ||
source={source} | ||
shouldHide={icon => ["file", "javascript"].includes(icon)} | ||
/> | ||
<div className="filename"> | ||
{getTruncatedFileName(source, query)} | ||
{path && <span>{`../${path}/..`}</span>} | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToProps = (state, { source }) => ({ | ||
hasSiblingOfSameName: getHasSiblingOfSameName(state, source) | ||
}); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
{ selectSource: actions.selectSource } | ||
)(BreakpointHeading); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters