Skip to content

Commit

Permalink
Add a trusted notebook indicator, as discussed in jupyter#1146
Browse files Browse the repository at this point in the history
  • Loading branch information
Phyks committed Apr 1, 2016
1 parent a412557 commit 46a3e90
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions notebook/static/notebook/js/menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ define([
that.update_nbconvert_script(langinfo);
that.add_kernel_help_links(data.kernel.info_reply.help_links || []);
});
this.events.on('trust_changed.Notebook', function (event, trusted) {
that.set_trusted_indicator(trusted);
});
};

MenuBar.prototype._add_celltoolbar_list = function () {
Expand Down Expand Up @@ -416,5 +419,17 @@ define([

};

MenuBar.prototype.set_trusted_indicator = function (trusted) {
// TODO
var el = this.element.find('span.trusted-indicator');
if (trusted) {
el.text('Notebook is trusted.').removeClass("untrusted").addClass("trusted");
}
else {
el.text('Notebook is untrusted.').removeClass("trusted").addClass("untrusted");
}
};


return {'MenuBar': MenuBar};
});
14 changes: 14 additions & 0 deletions notebook/static/notebook/less/menubar.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@
.navbar-collapse {
clear: left;
}
.trusted-indicator {
position: relative;
display: block;
padding: 10px 15px;
padding-top: 6px;
padding-bottom: 6px;
font-weight: bold;
}
.trusted-indicator.trusted {
color: green;
}
.trusted-indicator.untrusted {
color: red;
}

}

Expand Down
4 changes: 4 additions & 0 deletions notebook/templates/notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<span id="notebook_name" class="filename"></span>
<span class="checkpoint_status"></span>
<span class="autosave_status"></span>
<span class="trusted_indicator"></span>
</span>

<span id="kernel_logo_widget">
Expand Down Expand Up @@ -302,6 +303,9 @@
{% endblock %}
</ul>
</li>
<li>
<span class="trusted-indicator"></span>
</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit 46a3e90

Please sign in to comment.