Skip to content

Commit

Permalink
Disable action button when user is not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyichen committed May 22, 2021
1 parent e2083a8 commit 7a3450c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
9 changes: 1 addition & 8 deletions src/js/page_managers/three_column_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,11 @@ define([
$leftCol = this.$('#results-left-column');
$rightCol = this.$('#results-right-column');
$middleCol = this.$('#results-middle-column');
$action = this.$('#results-actions-toggle');

_.each(
[
['left', leftState, $leftCol],
['right', rightState, $rightCol, $action],
['right', rightState, $rightCol],
],
function(x) {
if (x[1] == 'open') {
Expand All @@ -139,14 +138,8 @@ define([
setTimeout(function() {
$col.children().show(0);
}, 200);
if (x[3]) {
x[3].removeClass('hidden');
}
} else {
x[2].addClass('hidden');
if (x[3]) {
x[3].addClass('hidden');
}
}
}
);
Expand Down
23 changes: 20 additions & 3 deletions src/js/wraps/results_page_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ define([

const ps = this.getPubSub();
ps.subscribe(ps.START_SEARCH, _.bind(this.onStartSearch, this));
ps.subscribe(ps.USER_ANNOUNCEMENT, _.bind(this.onUserUpdate, this));

// calls the sideBarManager mixin init handler
this.init();
Expand Down Expand Up @@ -111,6 +112,15 @@ define([
this.fullResultsTimer.start();
},

onUserUpdate: function(event) {
const user = this.getBeeHive().getObject('User');
if (event === user.USER_SIGNED_OUT) {
$('#results-actions-toggle').addClass('disabled');
$('#query-info-container').removeClass('show');
$('#results-actions-toggle').html('<i class="fa fa-book" alt="open actions"></i> Actions');
}
},

createView: function(options) {
options = options || {};
options.template = options.template || PageManagerTemplate;
Expand All @@ -120,7 +130,9 @@ define([
},

show: function() {

const isLoggedIn = this.getBeeHive()
.getObject('User')
.isLoggedIn();
var ret = PageManagerController.prototype.show.apply(this, arguments);
var self = this;
var button =
Expand All @@ -145,8 +157,13 @@ define([
}

// close any drawers
ret.$el.find('#results-actions-toggle')[0].innerHTML =
'<i class="fa fa-book" alt="open actions"></i> Actions';
const actionBtn = ret.$el.find('#results-actions-toggle')[0];
actionBtn.innerHTML = '<i class="fa fa-book" alt="open actions"></i> Actions';
if (!isLoggedIn) {
actionBtn.classList.add('disabled');
} else {
actionBtn.classList.remove('disabled');
}
ret.$el.find('#query-info-container')[0].classList.remove('show');

return ret;
Expand Down

0 comments on commit 7a3450c

Please sign in to comment.