Skip to content

Commit

Permalink
Merge pull request #1991 from broadinstitute/development
Browse files Browse the repository at this point in the history
Release 1.67.0
  • Loading branch information
jlchang authored Mar 13, 2024
2 parents 078c23c + 4833ae3 commit 81b271f
Show file tree
Hide file tree
Showing 18 changed files with 1,241 additions and 597 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.1.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '6.1.7.6'
gem 'rails', '6.1.7.7'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Use CoffeeScript for .coffee assets and views
Expand Down
126 changes: 63 additions & 63 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,60 +32,60 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
actioncable (6.1.7.7)
actionpack (= 6.1.7.7)
activesupport (= 6.1.7.7)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionmailbox (6.1.7.7)
actionpack (= 6.1.7.7)
activejob (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
mail (>= 2.7.1)
actionmailer (6.1.7.6)
actionpack (= 6.1.7.6)
actionview (= 6.1.7.6)
activejob (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionmailer (6.1.7.7)
actionpack (= 6.1.7.7)
actionview (= 6.1.7.7)
activejob (= 6.1.7.7)
activesupport (= 6.1.7.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.7.6)
actionview (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionpack (6.1.7.7)
actionview (= 6.1.7.7)
activesupport (= 6.1.7.7)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.7.6)
actionpack (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
actiontext (6.1.7.7)
actionpack (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
nokogiri (>= 1.8.5)
actionview (6.1.7.6)
activesupport (= 6.1.7.6)
actionview (6.1.7.7)
activesupport (= 6.1.7.7)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.1.7.6)
activesupport (= 6.1.7.6)
activejob (6.1.7.7)
activesupport (= 6.1.7.7)
globalid (>= 0.3.6)
activemodel (6.1.7.6)
activesupport (= 6.1.7.6)
activerecord (6.1.7.6)
activemodel (= 6.1.7.6)
activesupport (= 6.1.7.6)
activestorage (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
activerecord (= 6.1.7.6)
activesupport (= 6.1.7.6)
activemodel (6.1.7.7)
activesupport (= 6.1.7.7)
activerecord (6.1.7.7)
activemodel (= 6.1.7.7)
activesupport (= 6.1.7.7)
activestorage (6.1.7.7)
actionpack (= 6.1.7.7)
activejob (= 6.1.7.7)
activerecord (= 6.1.7.7)
activesupport (= 6.1.7.7)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.6)
activesupport (6.1.7.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -126,10 +126,10 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
crass (1.0.6)
daemons (1.4.0)
date (3.3.3)
date (3.3.4)
declarative (0.0.20)
delayed_job (4.1.10)
activesupport (>= 3.0, < 8.0)
Expand Down Expand Up @@ -255,7 +255,7 @@ GEM
listen (3.5.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.21.4)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
macaddr (1.7.2)
Expand Down Expand Up @@ -320,7 +320,7 @@ GEM
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
net-protocol (0.2.2)
timeout
net-smtp (0.4.0)
net-protocol
Expand Down Expand Up @@ -363,7 +363,7 @@ GEM
puma (5.6.8)
nio4r (~> 2.0)
racc (1.7.3)
rack (2.2.8)
rack (2.2.8.1)
rack-brotli (1.1.0)
brotli (>= 0.1.7)
rack (>= 1.4)
Expand All @@ -375,20 +375,20 @@ GEM
rack
rack-test (2.1.0)
rack (>= 1.3)
rails (6.1.7.6)
actioncable (= 6.1.7.6)
actionmailbox (= 6.1.7.6)
actionmailer (= 6.1.7.6)
actionpack (= 6.1.7.6)
actiontext (= 6.1.7.6)
actionview (= 6.1.7.6)
activejob (= 6.1.7.6)
activemodel (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
rails (6.1.7.7)
actioncable (= 6.1.7.7)
actionmailbox (= 6.1.7.7)
actionmailer (= 6.1.7.7)
actionpack (= 6.1.7.7)
actiontext (= 6.1.7.7)
actionview (= 6.1.7.7)
activejob (= 6.1.7.7)
activemodel (= 6.1.7.7)
activerecord (= 6.1.7.7)
activestorage (= 6.1.7.7)
activesupport (= 6.1.7.7)
bundler (>= 1.15.0)
railties (= 6.1.7.6)
railties (= 6.1.7.7)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
Expand All @@ -397,14 +397,14 @@ GEM
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
railties (6.1.7.7)
actionpack (= 6.1.7.7)
activesupport (= 6.1.7.7)
method_source
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.1.1)
rake (13.0.6)
rake (13.1.0)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand Down Expand Up @@ -494,11 +494,11 @@ GEM
json (>= 1.8)
test-unit (3.4.1)
power_assert
thor (1.2.2)
thor (1.3.1)
tilt (2.0.10)
time_difference (0.5.0)
activesupport
timeout (0.4.0)
timeout (0.4.1)
trailblazer-option (0.1.2)
truncate_html (0.9.3)
tzinfo (2.0.6)
Expand Down Expand Up @@ -529,7 +529,7 @@ GEM
will_paginate_mongoid (2.0.1)
mongoid
will_paginate (~> 3.0)
zeitwerk (2.6.12)
zeitwerk (2.6.13)

PLATFORMS
arm64-darwin-21
Expand Down Expand Up @@ -586,7 +586,7 @@ DEPENDENCIES
puma
rack-brotli
rack-mini-profiler
rails (= 6.1.7.6)
rails (= 6.1.7.7)
rest-client
rubocop
rubocop-rails
Expand Down
74 changes: 66 additions & 8 deletions app/javascript/components/bookmarks/BookmarkManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useLocation } from '@reach/router'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faLink, faUndo } from '@fortawesome/free-solid-svg-icons'
import useErrorMessage from '~/lib/error-message'
import useResizeEffect from '~/hooks/useResizeEffect'
import { log } from '~/lib/metrics-api'

/**
Expand All @@ -31,6 +32,8 @@ export default function BookmarkManager({bookmarks, studyAccession, clearExplore
path: getBookmarkPath()
}

const formRef = useRef('bookmarkForm')

/** copies the url to the clipboard */
function copyLink() {
navigator.clipboard.writeText(location.href)
Expand Down Expand Up @@ -86,11 +89,64 @@ export default function BookmarkManager({bookmarks, studyAccession, clearExplore
setCurrentBookmark(findExistingBookmark())
}

/** whenever the user changes a cluster/annotation, reset the bookmark form with the current URL params */
/** close open form if changing tabs */
function closeBookmarkForm() {
if (isUserLoggedIn() && formRef.current?.state?.show) {
formRef.current.handleHide()
}
}

/** wrapper to close both bookmark form & modal */
function closeAllComponents() {
closeBookmarkForm()
setShowBookmarksModal(false)
}

/** close form/modal on escape key press */
function closeOnEscape(event) {
if (event.keyCode === 27) {
closeAllComponents()
}
}

/** close and reopen bookmark form to fix positioning issues */
function reopenBookmarkForm() {
formRef.current.handleToggle()
formRef.current.handleToggle()
}

/* keep track of opened top-level tab */
const [hash, setHash] = useState(window.location.hash)
function handleSetHash() {
setHash(window.location.hash)
}

/** whenever the user changes a cluster/annotation, reset the bookmark form with the current URL params
* also add listeners for keydown & click to handle closing form on certain events
*/
useEffect(() => {
resetForm()
document.addEventListener("keydown", closeOnEscape, false)
// use a click listener as hashchange does not reliably fire
window.addEventListener("click", handleSetHash, false)
// remove listeners on unmount
return () => {
document.removeEventListener("keydown", closeOnEscape, false)
window.removeEventListener("click", handleSetHash, false)
}
}, [location.pathname, location.search])

/** close form if use changes to different top-level tab */
useEffect(() => {
if (hash !== '#study-visualize') {
closeBookmarkForm()
}
},[hash])

useResizeEffect(() => {
reopenBookmarkForm()
}, 50)

/** convenience handler for performing formState updates */
function handleFormUpdate(event) {
const value = event.target.value
Expand Down Expand Up @@ -120,6 +176,7 @@ export default function BookmarkManager({bookmarks, studyAccession, clearExplore
const errorMessage = formatErrorMessages(error)
setError(errorMessage)
setShowError(true)
reopenBookmarkForm()
}

/** format errors object into comma-delimited message */
Expand Down Expand Up @@ -147,8 +204,8 @@ export default function BookmarkManager({bookmarks, studyAccession, clearExplore
const bookmark = await saveFunc(...saveProps)
enableSaveButton(true)
setShowError(false)
resetForm()
updateBookmarkList(bookmark)
resetForm()
log(logEvent)
} catch (error) {
enableSaveButton(true)
Expand Down Expand Up @@ -182,11 +239,12 @@ export default function BookmarkManager({bookmarks, studyAccession, clearExplore
const [serverBookmarksLoaded, setServerBookmarksLoaded] = useState(false)
const [showBookmarksModal, setShowBookmarksModal] = useState(false)

/** toggle bookmarks modal open/close */
const toggleBookmarkModal = () => {
setShowBookmarksModal(!showBookmarksModal)
}

/** load all user bookmarks from server */
/** load all user bookmarks from server and open/close modal */
async function loadServerBookmarks() {
toggleBookmarkModal()
if (!serverBookmarksLoaded) {
Expand All @@ -205,15 +263,14 @@ export default function BookmarkManager({bookmarks, studyAccession, clearExplore
const loginNotice = <a href='/single_cell/users/auth/google_oauth2' data-method='post'
className={`fa-lg action far fa-star`} data-analytics-name='bookmark-login-notice'
id='bookmark-login-notice' data-toggle='tooltip' data-placement='left'
data-original-title='Click to sign in, then bookmark this view' />
data-original-title='Click to sign in, then bookmark this view'/>

const formRef = useRef('bookmarkForm')
const bookmarkForm = <Popover data-analytics-name='bookmark-form-popover' id='bookmark-form-popover'>
<form id='bookmark-form' onSubmit={handleSaveBookmark}>
{ ErrorComponent }
<div className="form-group">
<span className='fa fa-times action bookmark-form-close'
onClick={() => {formRef.current.handleHide()}}></span>
onClick={closeAllComponents}></span>
<label htmlFor='bookmark-name'>Bookmark name</label>
<br/>
<input className="form-control"
Expand Down Expand Up @@ -266,13 +323,14 @@ export default function BookmarkManager({bookmarks, studyAccession, clearExplore
<span data-analytics-name='manage-bookmarks'
data-testid='manage-bookmarks'
className='action' onClick={loadServerBookmarks}>
See bookmarks
All bookmarks
</span>
<BookmarksList serverBookmarks={serverBookmarks}
serverBookmarksLoaded={serverBookmarksLoaded}
studyAccession={studyAccession}
showModal={showBookmarksModal}
toggleModal={toggleBookmarkModal}/>
toggleModal={toggleBookmarkModal}
closeAllComponents={closeAllComponents}/>
</Popover>

const starClass = bookmarkSaved ? 'fas' : 'far'
Expand Down
Loading

0 comments on commit 81b271f

Please sign in to comment.