Skip to content

Commit

Permalink
Revise New and Edit search buttons (#386)
Browse files Browse the repository at this point in the history
Two things: First, clear sessionStorage before sending to search form,
thus fixing a bug in the implementation. Second, clear query string
when search form is reloaded similar to sessionStorage (#481).

Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
  • Loading branch information
yeban committed Nov 30, 2020
1 parent 6244cd1 commit 262069e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions public/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $.webshims.polyfill('forms');
*/
if (performance.navigation.type == performance.navigation.TYPE_RELOAD) {
sessionStorage.clear();
history.replaceState(null, '', location.href.split('?')[0]);
}

var Page = React.createClass({
Expand Down
19 changes: 16 additions & 3 deletions public/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import AlignmentExporter from './alignment_exporter'; // to download textual ali
* Renders links for navigating to each query.
*/
export default React.createClass({
/**
* Clear sessionStorage - useful to initiate a new search in the same tab.
* Passing sessionStorage.clear directly as onclick callback didn't work
* (on macOS Chrome).
*/
clearSession: function () {
sessionStorage.clear();
},

/**
* Event-handler for downloading fasta of all hits.
*/
Expand Down Expand Up @@ -92,8 +101,11 @@ export default React.createClass({

topPanelJSX: function () {
var path = location.pathname.split('/');
// Get job id.
var job_id = path.pop();
path = path.join('/');
// Deriving rootURL this way is required for subURI deployments
// - we cannot just send to '/'.
var rootURL = path.join('/');

return (
<div className="sidebar-top-panel">
Expand All @@ -103,11 +115,12 @@ export default React.createClass({
</h4>
</div>
<div>
<a href={`${path}/?job_id=${job_id}`}>
<a href={`${rootURL}/?job_id=${job_id}`}>
<i className="fa fa-pencil"></i> Edit search
</a>
<span className="line">|</span>
<a href={`${path}/`}>
<a href={`${rootURL}/`}
onClick={this.clearSession}>
<i className="fa fa-file-o"></i> New search
</a>
</div>
Expand Down

0 comments on commit 262069e

Please # to comment.