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

Feature/sc 27385/publish settings #2123

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 19 additions & 32 deletions static/js/sheets/Sheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Sheet extends Component {
if (path.match(/^\/sheets\/\d+/)) {
e.preventDefault()
console.log();
this.props.onCitationClick(`Sheet ${path.slice(8)}`, `Sheet ${this.props.id}`, true)
this.props.onCitationClick(`Sheet ${path.slice(8)}`, `Sheet ${this.props.sheetID}`, true)
}

else if (Sefaria.isRef(path.slice(1))) {
Expand All @@ -73,23 +73,11 @@ class Sheet extends Component {
}
}
}
handleCollectionsChange() {
// when editing a sheet and user selects through SheetOptions to change the status of the collections for the sheet,
// update the user's collections and sheet cache. need to forceUpdate because sheet is stored not in this component's state
// but rather in Sefaria module's cache
Promise.all([
Sefaria.getUserCollections(Sefaria._uid),
Sefaria.getUserCollectionsForSheet(this.props.id)
])
.then(() => {
Sefaria.sheets._loadSheetByID[this.props.id].collections = Sefaria.getUserCollectionsForSheetFromCache(this.props.id);
this.forceUpdate();
});
}


render() {
const classes = classNames({sheetsInPanel: 1});
const sheet = this.getSheetFromCache();
const classes = classNames({sheetsInPanel: 1});
const editable = Sefaria._uid === sheet?.owner;
let content, editor;
if (!sheet) {
Expand All @@ -101,8 +89,7 @@ class Sheet extends Component {
sheetID={sheet.id}
historyObject={this.props.historyObject}
editable={editable}
authorUrl={sheet.ownerProfileUrl}
handleCollectionsChange={editable && this.handleCollectionsChange}/>;
authorUrl={sheet.ownerProfileUrl}/>;
const sidebar = <SheetContentSidebar
authorStatement={sheet.ownerName}
authorUrl={sheet.ownerProfileUrl}
Expand Down Expand Up @@ -142,21 +129,21 @@ class Sheet extends Component {
handleClick={this.handleClick}
sheetSourceClick={this.props.onSegmentClick}
highlightedNode={this.props.highlightedNode} // for example, "3" -- the third node in the sheet
highlightedRefs={this.props.highlightedRefs} // for example, ["Genesis 1:1"] or ["sheet 4:3"] -- the actual source
highlightedRefsInSheet={this.props.highlightedRefsInSheet}
scrollToHighlighted={this.props.scrollToHighlighted}
editable={editable}
setSelectedWords={this.props.setSelectedWords}
sheetNumbered={sheet.options.numbered}
hideImages={!!sheet.hideImages}
sheetID={sheet.id}
authorStatement={sheet.ownerName}
authorID={sheet.owner}
authorUrl={sheet.ownerProfileUrl}
authorImage={sheet.ownerImageUrl}
summary={sheet.summary}
toggleSignUpModal={this.props.toggleSignUpModal}
historyObject={this.props.historyObject}
highlightedRefs={this.props.highlightedRefs} // for example, ["Genesis 1:1"] or ["Sheet 4:3"] -- the actual source
highlightedRefsInSheet={this.props.highlightedRefsInSheet}
scrollToHighlighted={this.props.scrollToHighlighted}
editable={editable}
setSelectedWords={this.props.setSelectedWords}
sheetNumbered={sheet.options.numbered}
hideImages={!!sheet.hideImages}
sheetID={sheet.id}
authorStatement={sheet.ownerName}
authorID={sheet.owner}
authorUrl={sheet.ownerProfileUrl}
authorImage={sheet.ownerImageUrl}
summary={sheet.summary}
toggleSignUpModal={this.props.toggleSignUpModal}
historyObject={this.props.historyObject}
/>
{sidebar}
</div>
Expand Down
13 changes: 5 additions & 8 deletions static/js/sheets/SheetOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {InterfaceText, SaveButtonWithText} from "../Misc";
import Modal from "../common/modal";
import {ShareBox} from "../ConnectionsPanel";
import Sefaria from "../sefaria/sefaria";
import $ from "../sefaria/sefariaJquery";
import {SignUpModalKind} from "../sefaria/signupModalContent";
import {AddToSourceSheetBox} from "../AddToSourceSheet";
import {CollectionsWidget} from "../CollectionsWidget";
Expand All @@ -20,7 +21,7 @@ const getExportingStatus = () => {
return urlHashObject === "exportToDrive";
}

const SheetOptions = ({historyObject, toggleSignUpModal, sheetID, editable, authorUrl, handleCollectionsChange}) => {
const SheetOptions = ({historyObject, toggleSignUpModal, sheetID, editable, authorUrl}) => {
// `editable` -- whether the sheet belongs to the current user
const [sharingMode, setSharingMode] = useState(false); // Share Modal open or closed
const [collectionsMode, setCollectionsMode] = useState(false); // Collections Modal open or closed
Expand Down Expand Up @@ -56,11 +57,7 @@ const SheetOptions = ({historyObject, toggleSignUpModal, sheetID, editable, auth
return <ShareModal sheetID={sheetID} isOpen={sharingMode} close={() => setSharingMode(false)}/>;
}
else if (collectionsMode) {
return <CollectionsModal
isOpen={collectionsMode}
close={() => setCollectionsMode(false)}
handleCollectionsChange={handleCollectionsChange}
sheetID={sheetID}/>;
return <CollectionsModal isOpen={collectionsMode} close={() => setCollectionsMode(false)} sheetID={sheetID}/>;
}
else if (copyingMode) {
return <CopyModal close={() => setCopyingMode(false)} sheetID={sheetID}/>;
Expand Down Expand Up @@ -145,9 +142,9 @@ const ShareModal = ({sheetID, close}) => {
/>
</Modal>;
}
const CollectionsModal = ({close, sheetID, handleCollectionsChange, editable}) => {
const CollectionsModal = ({close, sheetID}) => {
return <Modal isOpen={true} close={close}>
<CollectionsWidget sheetID={sheetID} close={close} handleCollectionsChange={handleCollectionsChange} />
<CollectionsWidget sheetID={sheetID} close={close} />
</Modal>;
}

Expand Down
Loading