Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tab activation on link generator #132

Merged
merged 1 commit into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions docs/_static/link_gen/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function generateCanvasUrl(hubUrl, urlPath, repoUrl, branch) {
return url.toString();
}

function generateMyBinderUrl(hubUrl, userName, repoName, branch, urlPath,
function generateBinderUrl(hubUrl, userName, repoName, branch, urlPath,
contentRepoUrl, contentRepoBranch) {

var url = new URL(hubUrl);
Expand Down Expand Up @@ -93,7 +93,7 @@ function changeTab(div) {
var content_branch = document.getElementById("content-branch-group");
var id = div.id;

if (id.includes("mybinder")) {
if (id.includes("binder")) {
hub.placeholder = "https://mybinder.org";
hub.value = "https://mybinder.org";
hub_help_text.hidden = true;
Expand Down Expand Up @@ -146,7 +146,7 @@ function displayLink() {
document.getElementById('canvas-link').value = generateCanvasUrl(
hubUrl, urlPath, repoUrl, branch
);
document.getElementById('mybinder-link').value = generateMyBinderUrl(
document.getElementById('binder-link').value = generateBinderUrl(
hubUrl, userName, repoName, branch, urlPath, contentRepoUrl, contentRepoBranch
);
}
Expand Down Expand Up @@ -219,8 +219,18 @@ function main() {

populateFromQueryString();

// Activate tabs based on search parameters
var params = new URL(window.location).searchParams;
if (params.get("tab")) {
if (params.get("tab") === "binder") {
$("#tab-auth-binder").click()
} else if (params.get("tab") === "canvas") {
$("#tab-auth-canvas").click()
}
}

// Do an initial render, to make sure our disabled / enabled properties are correctly set
render();
}

window.onload = main;
window.onload = main;
19 changes: 14 additions & 5 deletions docs/link.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Use the following form to create your own ``nbgitpuller`` links.
<ul class="nav nav-tabs justify-content-end" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="tab-auth-default" data-toggle="tab" role="tab" href="#auth-default" aria-controls="auth-default" onclick="changeTab(this)">
<small>Default</small>
<small>JupyterHub</small>
</a>
</li>
<li class="nav-item">
Expand All @@ -22,8 +22,8 @@ Use the following form to create your own ``nbgitpuller`` links.
</a>
</li>
<li class="nav-item">
<a class="nav-link" id="tab-auth-mybinder" data-toggle="tab" role="tab" href="#auth-mybinder" aria-controls="auth-mybinder" onclick="changeTab(this)">
<small>mybinder.org</small>
<a class="nav-link" id="tab-auth-binder" data-toggle="tab" role="tab" href="#auth-binder" aria-controls="auth-binder" onclick="changeTab(this)">
<small>Binder</small>
</a>
</li>
</ul>
Expand All @@ -35,8 +35,8 @@ Use the following form to create your own ``nbgitpuller`` links.
<div class="tab-pane fade" id="auth-canvas" role="tabpanel" aria-labelledby="tab-auth-canvas">
<input type="text" readonly class="form-control form-control" id="canvas-link" name="auth-canvas-link" placeholder="Generated canvas 'external app' link appears here...">
</div>
<div class="tab-pane fade" id="auth-mybinder" role="tabpanel" aria-labelledby="tab-auth-mybinder">
<input type="text" readonly class="form-control form-control" id="mybinder-link" name="auth-mybinder-link" placeholder="Generated mybinder.org link appears here...">
<div class="tab-pane fade" id="auth-binder" role="tabpanel" aria-labelledby="tab-auth-binder">
<input type="text" readonly class="form-control form-control" id="binder-link" name="auth-binder-link" placeholder="Generated Binder link appears here...">
</div>
</div>
</ul>
Expand Down Expand Up @@ -163,3 +163,12 @@ For example, the following URL will pre-populate the form with the
UC Berkeley DataHub as the JupyterHub::

https://jupyterhub.github.io/nbgitpuller/link?hub=https://datahub.berkeley.edu


**Activating a tab when someone lands on this page**

You can also activate one of the tabs in the form above by default when a user lands
on this page. To do so, use the ``tab=`` REST parameter. Here are the possible values:

* ``?tab=binder`` - activates the Binder tab
* ``?tab=canvas`` - activates the Canvas tab.