Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/sc 26322/click on commentary in search version name #2190

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions static/js/ConnectionsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ class ConnectionsPanel extends Component {

} else if (this.props.mode === "TextList" || this.props.mode === "EssayList") {
content = (<TextList
currVersions={this.props.currCommVersions[this.props.title] || {"en": null, "he": null}}
panelPosition={this.props.panelPosition}
srefs={this.checkSrefs(this.props.srefs)}
filter={this.props.filter}
Expand Down
11 changes: 9 additions & 2 deletions static/js/ReaderApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class ReaderApp extends Component {
connectionsMode: state.connectionsMode || "Resources",
connectionsCategory: state.connectionsCategory || null,
currVersions: state.currVersions || {en:null,he:null},
currCommVersions: state.currCommVersions || {},
highlightedRefs: state.highlightedRefs || [],
highlightedNode: state.highlightedNode || null,
scrollToHighlighted: state.scrollToHighlighted || false,
Expand Down Expand Up @@ -1533,11 +1534,17 @@ toggleSignUpModal(modalContentKind = SignUpModalKind.Default) {
makePanelWithConnectionsState(panelProps) {
// in the case of multipanel, create two panels based on panelProps
let connectionPanel; // in mobile, connectionPanel will remain undefined

// version is from commentary; don't try to use the version of the commentary for the base ref!
const currIndex = Sefaria.parseRef(panelProps.refs[0])?.index;
const currCommVersions = !!currIndex ? {[currIndex]: {...panelProps.currVersions}} : {};
panelProps.currVersions = {'en': null, 'he': null};

if (this.props.multiPanel) {
const connectionPanelProps = {...panelProps, mode: "Connections", connectionsMode: "TextList", connectionsCategory: "Commentary"};
const connectionPanelProps = {...panelProps, currCommVersions: currCommVersions, mode: "Connections", connectionsMode: "TextList", connectionsCategory: "Commentary"};
connectionPanel = this.makePanelState(connectionPanelProps);
} else {
panelProps = {...panelProps, mode: "TextAndConnections", connectionsMode: "TextList", connectionsCategory: "Commentary", highlightedRefs: panelProps.refs};
panelProps = {...panelProps, currCommVersions: currCommVersions, mode: "TextAndConnections", connectionsMode: "TextList", connectionsCategory: "Commentary", highlightedRefs: panelProps.refs};
}
const panel = this.makePanelState(panelProps);
panel.showHighlight = true;
Expand Down
1 change: 1 addition & 0 deletions static/js/ReaderPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ class ReaderPanel extends Component {
title={this.currentBook()}
currentlyVisibleRef={this.state.currentlyVisibleRef}
currVersions={this.state.currVersions}
currCommVersions={this.state.currCommVersions}
fullPanel={this.props.multiPanel}
multiPanel={this.props.multiPanel}
allOpenRefs={this.props.allOpenRefs}
Expand Down
13 changes: 9 additions & 4 deletions static/js/TextList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class TextList extends Component {
const classes = classNames({ textListTextRangeBox: 1, typeQF: link.type.startsWith('quotation_auto')});
return (<div className={classes} key={i + link.sourceRef}>
<TextRange
currVersions={this.props.currVersions}
panelPosition ={this.props.panelPosition}
sref={link.sourceRef}
hideTitle={hideTitle}
Expand All @@ -234,7 +235,10 @@ class TextList extends Component {
filterRef={this.props.filterRef}
/>
<ConnectionButtons>
<OpenConnectionTabButton srefs={[link.sourceRef]} openInTabCallback={this.props.onTextClick}/>
<OpenConnectionTabButton srefs={[link.sourceRef]}
openInTabCallback={this.props.onTextClick}
currVersions={this.props.currVersions}
/>
<AddConnectionToSheetButton srefs={[link.sourceRef]} addToSheetCallback={this.props.setConnectionsMode}/>
{Sefaria.is_moderator ?
<DeleteConnectionButton delUrl={"/api/links/" + link._id} connectionDeleteCallback={this.onDataChange}/> : null
Expand Down Expand Up @@ -279,7 +283,8 @@ TextList.propTypes = {
selectedWords: PropTypes.string,
checkVisibleSegments: PropTypes.func.isRequired,
translationLanguagePreference: PropTypes.string,
filterRef: PropTypes.string
filterRef: PropTypes.string,
currVersions: PropTypes.object,
};

const DeleteConnectionButton = ({delUrl, connectionDeleteCallback}) =>{
Expand Down Expand Up @@ -315,7 +320,7 @@ const DeleteConnectionButton = ({delUrl, connectionDeleteCallback}) =>{
}


const OpenConnectionTabButton = ({srefs, openInTabCallback, openStrings}) =>{
const OpenConnectionTabButton = ({srefs, openInTabCallback, openStrings, currVersions={'en': null, 'he': null}}) =>{
/*
ConnectionButton composite element. Goes inside a ConnectionButtons
Takes a ref(s) for opening as a link and callback for opening in-app
Expand All @@ -326,7 +331,7 @@ const OpenConnectionTabButton = ({srefs, openInTabCallback, openStrings}) =>{
if (openInTabCallback) {
event.preventDefault();
//Click on the body of the TextRange itself from TextList
openInTabCallback(srefs);
openInTabCallback(srefs, false, currVersions);
Sefaria.track.event("Reader", "Click Text from TextList", sref);
}
}
Expand Down
Loading