Skip to content

Commit

Permalink
Merge branch 'feature/sc-27825/add-to-sheet' into feature/sc-27826/st…
Browse files Browse the repository at this point in the history
…yling
  • Loading branch information
stevekaplan123 committed Nov 12, 2024
2 parents 8b74a02 + ea901a8 commit d98244c
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions static/js/sheets/SheetOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,69 +22,69 @@ const getExportingStatus = () => {

const SheetOptions = ({historyObject, toggleSignUpModal, sheetID, editable}) => {
// `editable` -- whether the sheet belongs to the current user
const [isSharing, setSharing] = useState(false); // Share Modal open or closed
const [isCollectionsMode, setCollectionsMode] = useState(false); // Collections Modal open or closed
const [isCopying, setCopying] = useState(false);
const [isSaving, setSaving] = useState(false);
const [isExporting, setExporting] = useState(getExportingStatus());
const [sharingMode, setSharingMode] = useState(false); // Share Modal open or closed
const [collectionsMode, setCollectionsMode] = useState(false); // Collections Modal open or closed
const [copyingMode, setCopyingMode] = useState(false);
const [savingMode, setSavingMode] = useState(false);
const [exportingMode, setExportingMode] = useState(getExportingStatus());
const historyObjectForSheet = modifyHistoryObjectForSheetOptions(historyObject);
const getSignUpModalKind = () => {
if (isSaving) {
if (savingMode) {
return SignUpModalKind.Save;
}
else if (isCollectionsMode) {
else if (collectionsMode) {
return SignUpModalKind.AddToSheet;
}
else if (isCopying) {
else if (copyingMode) {
return SignUpModalKind.AddToSheet;
}
else if (isExporting) {
else if (exportingMode) {
return SignUpModalKind.Default;
}
}
useEffect(() => {
if ((isCollectionsMode || isSaving || isCopying || isExporting) && !Sefaria._uid) {
if ((collectionsMode || savingMode || copyingMode || exportingMode) && !Sefaria._uid) {
toggleSignUpModal(getSignUpModalKind());
setCopying(false);
setCopyingMode(false);
setCollectionsMode(false);
setSaving(false);
setExporting(false);
setSavingMode(false);
setExportingMode(false);
}
}, [isCollectionsMode, isSaving, isCopying, isExporting]);
if (isSharing) {
return <ShareModal sheetID={sheetID} isOpen={isSharing} close={() => setSharing(false)}/>;
}, [collectionsMode, savingMode, copyingMode, exportingMode]);
if (sharingMode) {
return <ShareModal sheetID={sheetID} isOpen={sharingMode} close={() => setSharingMode(false)}/>;
}
else if (isCollectionsMode) {
return <CollectionsModal isOpen={isCollectionsMode} close={() => setCollectionsMode(false)} sheetID={sheetID}/>;
else if (collectionsMode) {
return <CollectionsModal isOpen={collectionsMode} close={() => setCollectionsMode(false)} sheetID={sheetID}/>;
}
else if (isCopying) {
return <CopyModal close={() => setCopying(false)} sheetID={sheetID}/>;
else if (copyingMode) {
return <CopyModal close={() => setCopyingMode(false)} sheetID={sheetID}/>;
}
else if (isSaving) {
return <SaveModal historyObject={historyObjectForSheet} close={() => setSaving(false)}/>;
else if (savingMode) {
return <SaveModal historyObject={historyObjectForSheet} close={() => setSavingMode(false)}/>;
}
else if (isExporting) {
return <GoogleDocExportModal close={() => setExporting(false)} sheetID={sheetID}/>;
else if (exportingMode) {
return <GoogleDocExportModal close={() => setExportingMode(false)} sheetID={sheetID}/>;
}
return (
<DropdownMenu menu_icon={"/static/icons/ellipses.svg"}>
<DropdownMenuItem>
<SaveButtonWithText
historyObject={historyObjectForSheet}
onClick={() => setSaving(true)}
onClick={() => setSavingMode(true)}
/>
</DropdownMenuItem>
<DropdownMenuItem>
<CopyButton onClick={() => setCopying(true)}/>
<CopyButton onClick={() => setCopyingMode(true)}/>
</DropdownMenuItem>
<DropdownMenuItem>
<CollectionsButton setCollectionsMode={setCollectionsMode} editable={editable}/>
</DropdownMenuItem>
<DropdownMenuItem>
<GoogleDocExportButton sheetID={sheetID} onClick={() => setExporting(true)}/>
<GoogleDocExportButton sheetID={sheetID} onClick={() => setExportingMode(true)}/>
</DropdownMenuItem>
<DropdownMenuItem>
<ShareButton onClick={() => setSharing(true)}/>
<ShareButton onClick={() => setSharingMode(true)}/>
</DropdownMenuItem>
</DropdownMenu>
);
Expand Down

0 comments on commit d98244c

Please sign in to comment.