1- import { PageConfig } from " @jupyterlab/coreutils" ;
2- import { Dialog } from " @jupyterlab/apputils" ;
1+ import { PageConfig } from ' @jupyterlab/coreutils' ;
2+ import { Dialog } from ' @jupyterlab/apputils' ;
33import axios from 'axios' ;
44import { show_spinner } from './index' ;
55
66export const HTTP = axios . create ( {
7- baseURL : PageConfig . getBaseUrl ( )
7+ baseURL : PageConfig . getBaseUrl ( )
88} ) ;
99
10- HTTP . defaults . headers . post [ 'X-CSRFToken' ] = _get_cookie ( " _xsrf" )
10+ HTTP . defaults . headers . post [ 'X-CSRFToken' ] = _get_cookie ( ' _xsrf' ) ;
1111
1212function _get_cookie ( name : string ) {
13- // Source: https://blog.jupyter.org/security-release-jupyter-notebook-4-3-1-808e1f3bb5e2
14- var r = document . cookie . match ( " \\b" + name + " =([^;]*)\\b" ) ;
15- return r ? r [ 1 ] : undefined ;
13+ // Source: https://blog.jupyter.org/security-release-jupyter-notebook-4-3-1-808e1f3bb5e2
14+ const r = document . cookie . match ( ' \\b' + name + ' =([^;]*)\\b' ) ;
15+ return r ? r [ 1 ] : undefined ;
1616}
1717
18-
1918export function get_server_config ( ) {
20- return HTTP . get ( " gitplus/expanded_server_root" )
21- . then ( function ( response ) {
22- return response . data ;
23- } )
24- . catch ( function ( error ) {
25- console . log ( error )
26- } ) ;
19+ return HTTP . get ( ' gitplus/expanded_server_root' )
20+ . then ( response => {
21+ return response . data ;
22+ } )
23+ . catch ( error => {
24+ console . log ( error ) ;
25+ } ) ;
2726}
2827
29- export function get_modified_repositories ( data : { } , show_repository_selection_dialog : Function , command : string , show_repository_selection_failure_dialog : Function ) {
30- let repo_names : string [ ] [ ] = [ ]
31- return HTTP . post ( "gitplus/modified_repo" , data )
32- . then ( function ( response ) {
33- let repo_list = response . data ;
34- for ( const repo of repo_list ) {
35- let display_name = repo [ 'name' ] + ' (' + repo [ 'path' ] + ')' ;
36- repo_names . push ( [ display_name , repo [ 'path' ] ] )
37- }
38- show_repository_selection_dialog ( repo_names , command ) ;
39- } )
40- . catch ( function ( error ) {
41- show_repository_selection_failure_dialog ( )
42- console . log ( error )
43- } ) ;
28+ export function get_modified_repositories (
29+ data : { } ,
30+ show_repository_selection_dialog : Function ,
31+ command : string ,
32+ show_repository_selection_failure_dialog : Function
33+ ) {
34+ const repo_names : string [ ] [ ] = [ ] ;
35+ return HTTP . post ( 'gitplus/modified_repo' , data )
36+ . then ( response => {
37+ const repo_list = response . data ;
38+ for ( const repo of repo_list ) {
39+ const display_name = repo [ 'name' ] + ' (' + repo [ 'path' ] + ')' ;
40+ repo_names . push ( [ display_name , repo [ 'path' ] ] ) ;
41+ }
42+ show_repository_selection_dialog ( repo_names , command ) ;
43+ } )
44+ . catch ( error => {
45+ show_repository_selection_failure_dialog ( ) ;
46+ console . log ( error ) ;
47+ } ) ;
4448}
4549
46-
47- export function create_pull_request ( data : { } , show_pr_created_dialog : Function ) {
48- show_spinner ( ) ;
49- return HTTP . post ( "gitplus/pull_request" , data )
50- . then ( function ( response ) {
51- let result = response . data ;
52- let github_url = result [ 'github_url' ]
53- let reviewnb_url = result [ 'reviewnb_url' ]
54- Dialog . flush ( ) ; // remove spinner
55- show_pr_created_dialog ( github_url , reviewnb_url )
56- } )
57- . catch ( function ( error ) {
58- console . log ( error )
59- Dialog . flush ( ) ; // remove spinner
60- show_pr_created_dialog ( )
61- } ) ;
50+ export function create_pull_request (
51+ data : { } ,
52+ show_pr_created_dialog : Function
53+ ) {
54+ show_spinner ( ) ;
55+ return HTTP . post ( 'gitplus/pull_request' , data )
56+ . then ( response => {
57+ const result = response . data ;
58+ const github_url = result [ 'github_url' ] ;
59+ const reviewnb_url = result [ 'reviewnb_url' ] ;
60+ Dialog . flush ( ) ; // remove spinner
61+ show_pr_created_dialog ( github_url , reviewnb_url ) ;
62+ } )
63+ . catch ( error => {
64+ console . log ( error ) ;
65+ Dialog . flush ( ) ; // remove spinner
66+ show_pr_created_dialog ( ) ;
67+ } ) ;
6268}
6369
64-
65- export function create_and_push_commit ( data : { } , show_commit_pushed_dialog : Function ) {
66- show_spinner ( ) ;
67- return HTTP . post ( "gitplus/commit" , data )
68- . then ( function ( response ) {
69- let result = response . data ;
70- let github_url = result [ 'github_url' ]
71- let reviewnb_url = result [ 'reviewnb_url' ]
72- Dialog . flush ( ) ; // remove spinner
73- show_commit_pushed_dialog ( github_url , reviewnb_url )
74- } )
75- . catch ( function ( error ) {
76- console . log ( error )
77- Dialog . flush ( ) ; // remove spinner
78- show_commit_pushed_dialog ( )
79- } ) ;
80- }
70+ export function create_and_push_commit (
71+ data : { } ,
72+ show_commit_pushed_dialog : Function
73+ ) {
74+ show_spinner ( ) ;
75+ return HTTP . post ( 'gitplus/commit' , data )
76+ . then ( response => {
77+ const result = response . data ;
78+ const github_url = result [ 'github_url' ] ;
79+ const reviewnb_url = result [ 'reviewnb_url' ] ;
80+ Dialog . flush ( ) ; // remove spinner
81+ show_commit_pushed_dialog ( github_url , reviewnb_url ) ;
82+ } )
83+ . catch ( error => {
84+ console . log ( error ) ;
85+ Dialog . flush ( ) ; // remove spinner
86+ show_commit_pushed_dialog ( ) ;
87+ } ) ;
88+ }
0 commit comments