Skip to content

Commit

Permalink
Fix checkbox styling and other errors for extension to be JupyterLab …
Browse files Browse the repository at this point in the history
…3.x compatible
  • Loading branch information
amit1rrr committed Jun 21, 2021
1 parent 0fd7a67 commit b928dd9
Show file tree
Hide file tree
Showing 7 changed files with 538 additions and 546 deletions.
117 changes: 36 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"author": "Amit Rathi",
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}",
"style/index.js"
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -50,6 +49,7 @@
"@jupyterlab/fileeditor": "^3.0.11",
"@jupyterlab/mainmenu": "^3.0.9",
"@jupyterlab/notebook": "^3.0.11",
"@lumino/application": "1.8.4",
"@lumino/disposable": "^1.4.3",
"axios": "^0.19.2"
},
Expand All @@ -73,6 +73,5 @@
"jupyterlab": {
"extension": true,
"outputDir": "jupyterlab_gitplus/labextension"
},
"styleModule": "style/index.js"
}
}
}
134 changes: 71 additions & 63 deletions src/api_client.ts
Original file line number Diff line number Diff line change
@@ -1,80 +1,88 @@
import { PageConfig } from "@jupyterlab/coreutils";
import { Dialog } from "@jupyterlab/apputils";
import { PageConfig } from '@jupyterlab/coreutils';
import { Dialog } from '@jupyterlab/apputils';
import axios from 'axios';
import { show_spinner } from './index';

export const HTTP = axios.create({
baseURL: PageConfig.getBaseUrl()
baseURL: PageConfig.getBaseUrl()
});

HTTP.defaults.headers.post['X-CSRFToken'] = _get_cookie("_xsrf")
HTTP.defaults.headers.post['X-CSRFToken'] = _get_cookie('_xsrf');

function _get_cookie(name: string) {
// Source: https://blog.jupyter.org/security-release-jupyter-notebook-4-3-1-808e1f3bb5e2
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
return r ? r[1] : undefined;
// Source: https://blog.jupyter.org/security-release-jupyter-notebook-4-3-1-808e1f3bb5e2
const r = document.cookie.match('\\b' + name + '=([^;]*)\\b');
return r ? r[1] : undefined;
}


export function get_server_config() {
return HTTP.get("gitplus/expanded_server_root")
.then(function (response) {
return response.data;
})
.catch(function (error) {
console.log(error)
});
return HTTP.get('gitplus/expanded_server_root')
.then(response => {
return response.data;
})
.catch(error => {
console.log(error);
});
}

export function get_modified_repositories(data: {}, show_repository_selection_dialog: Function, command: string, show_repository_selection_failure_dialog: Function) {
let repo_names: string[][] = []
return HTTP.post("gitplus/modified_repo", data)
.then(function (response) {
let repo_list = response.data;
for (const repo of repo_list) {
let display_name = repo['name'] + ' (' + repo['path'] + ')';
repo_names.push([display_name, repo['path']])
}
show_repository_selection_dialog(repo_names, command);
})
.catch(function (error) {
show_repository_selection_failure_dialog()
console.log(error)
});
export function get_modified_repositories(
data: {},
show_repository_selection_dialog: Function,
command: string,
show_repository_selection_failure_dialog: Function
) {
const repo_names: string[][] = [];
return HTTP.post('gitplus/modified_repo', data)
.then(response => {
const repo_list = response.data;
for (const repo of repo_list) {
const display_name = repo['name'] + ' (' + repo['path'] + ')';
repo_names.push([display_name, repo['path']]);
}
show_repository_selection_dialog(repo_names, command);
})
.catch(error => {
show_repository_selection_failure_dialog();
console.log(error);
});
}


export function create_pull_request(data: {}, show_pr_created_dialog: Function) {
show_spinner();
return HTTP.post("gitplus/pull_request", data)
.then(function (response) {
let result = response.data;
let github_url = result['github_url']
let reviewnb_url = result['reviewnb_url']
Dialog.flush(); // remove spinner
show_pr_created_dialog(github_url, reviewnb_url)
})
.catch(function (error) {
console.log(error)
Dialog.flush(); // remove spinner
show_pr_created_dialog()
});
export function create_pull_request(
data: {},
show_pr_created_dialog: Function
) {
show_spinner();
return HTTP.post('gitplus/pull_request', data)
.then(response => {
const result = response.data;
const github_url = result['github_url'];
const reviewnb_url = result['reviewnb_url'];
Dialog.flush(); // remove spinner
show_pr_created_dialog(github_url, reviewnb_url);
})
.catch(error => {
console.log(error);
Dialog.flush(); // remove spinner
show_pr_created_dialog();
});
}


export function create_and_push_commit(data: {}, show_commit_pushed_dialog: Function) {
show_spinner();
return HTTP.post("gitplus/commit", data)
.then(function (response) {
let result = response.data;
let github_url = result['github_url']
let reviewnb_url = result['reviewnb_url']
Dialog.flush(); // remove spinner
show_commit_pushed_dialog(github_url, reviewnb_url)
})
.catch(function (error) {
console.log(error)
Dialog.flush(); // remove spinner
show_commit_pushed_dialog()
});
}
export function create_and_push_commit(
data: {},
show_commit_pushed_dialog: Function
) {
show_spinner();
return HTTP.post('gitplus/commit', data)
.then(response => {
const result = response.data;
const github_url = result['github_url'];
const reviewnb_url = result['reviewnb_url'];
Dialog.flush(); // remove spinner
show_commit_pushed_dialog(github_url, reviewnb_url);
})
.catch(error => {
console.log(error);
Dialog.flush(); // remove spinner
show_commit_pushed_dialog();
});
}
Loading

0 comments on commit b928dd9

Please sign in to comment.