Commit ccf731ca authored by Mark Ghiorso's avatar Mark Ghiorso

Added settings page and removed text widgets

parent eec1e964
{
"name": "jupyterlab_gitlab",
"name": "@jupyterlab/gitlab",
"version": "0.2.0",
"lockfileVersion": 1,
"requires": true,
......
{
"name": "jupyterlab_gitlab",
"name": "@jupyterlab/gitlab",
"version": "0.2.0",
"description": "A JupyterLab extension to access GitLab repositories",
"license": "BSD-3-Clause",
......@@ -14,6 +14,10 @@
"bugs": {
"url": "https://gitlab.com/ENKI-portal/jupyterlab_gitlab/issues"
},
"repository": {
"type": "git",
"url": "https://gitlab.com/ENKI-portal/jupyterlab_gitlab.git"
},
"scripts": {
"build": "tsc",
"clean": "rimraf lib",
......@@ -22,10 +26,12 @@
},
"files": [
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
"schema/*.json",
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
],
"jupyterlab": {
"extension": true
"extension": true,
"schemaDir": "schema"
},
"dependencies": {
"@jupyterlab/application": "^0.14.0",
......
{
"jupyter.lab.setting-icon-class": "jp-GitLab-tablogo",
"jupyter.lab.setting-icon-label": "GitLab",
"title": "GitLab",
"description": "Settings for the GitLab plugin.",
"properties": {
"userName": {
"type": "string", "title": "User Name", "default": ""
},
"userCode": {
"type": "string", "title": "User Code", "default": ""
},
"groupName": {
"type": "string", "title": "Group Name", "default": ""
}
},
"type": "object"
}
......@@ -36,7 +36,7 @@ class GitLabFileBrowser extends Widget {
static private_key: string;
static group_name: string;
constructor(browser: FileBrowser, drive: GitLabDrive) {
constructor(browser: FileBrowser, drive: GitLabDrive, initUser: string, initCode: string, initGroup: string) {
super();
//console.warn('Entering constructor for GitLabFileBrowser');
this.addClass('jp-GitLabBrowser');
......@@ -45,25 +45,29 @@ class GitLabFileBrowser extends Widget {
this._browser = browser;
this._drive = drive;
GitLabFileBrowser.user_name = initUser;
GitLabFileBrowser.private_key = initCode;
GitLabFileBrowser.group_name = initGroup;
// Create an editable name for the user name.
this.userName = new GitLabEditableName('', '<Edit User>');
this.userName.addClass('jp-GitLabEditableUserName');
this.userName.node.title = 'Click to edit user';
this._browser.toolbar.addItem('user', this.userName);
//this._browser.toolbar.addItem('user', this.userName);
this.userName.name.changed.connect(this._onUserChanged, this);
// Create an editable name for the user/org access code.
this.userCode = new GitLabEditableName('', '<Priv Code>');
this.userCode.addClass('jp-GitLabEditableUserCode');
this.userCode.node.title = 'Click to edit access code';
this._browser.toolbar.addItem('code', this.userCode);
//this._browser.toolbar.addItem('code', this.userCode);
this.userCode.name.changed.connect(this._onCodeChanged, this);
// Create an editable name for the group name.
this.groupName = new GitLabEditableName('', '<Edit Group>');
this.groupName.addClass('jp-GitLabEditableGroupName');
this.groupName.node.title = 'Click to edit group';
this._browser.toolbar.addItem('group', this.groupName);
//this._browser.toolbar.addItem('group', this.groupName);
this.groupName.name.changed.connect(this._onGroupChanged, this);
// Create a button that opens GitLab at the appropriate repo+directory.
......@@ -115,6 +119,7 @@ class GitLabFileBrowser extends Widget {
return;
}
this._changeGuard = true;
//console.warn("On user changed called.");
this._browser.model.cd(`/${args.newValue as string}`).then(() => {
this._changeGuard = false;
this._updateErrorPanel();
......
......@@ -18,6 +18,10 @@ import {
GitLabFileBrowser
} from './browser';
import {
ISettingRegistry
} from '@jupyterlab/coreutils';
import '../style/index.css';
/**
......@@ -29,8 +33,8 @@ const NAMESPACE = 'gitLab-filebrowser';
* The JupyterLab plugin for the GitLab Filebrowser.
*/
const fileBrowserPlugin: JupyterLabPlugin<void> = {
id: 'jupyterlab-gitLab:drive',
requires: [IDocumentManager, IFileBrowserFactory, ILayoutRestorer],
id: '@jupyterlab/gitlab:gitlab',
requires: [IDocumentManager, IFileBrowserFactory, ILayoutRestorer, ISettingRegistry],
activate: activateFileBrowser,
autoStart: true
};
......@@ -38,8 +42,9 @@ const fileBrowserPlugin: JupyterLabPlugin<void> = {
/**
* Activate the file browser.
*/
function activateFileBrowser(app: JupyterLab, manager: IDocumentManager, factory: IFileBrowserFactory, restorer: ILayoutRestorer): void {
function activateFileBrowser(app: JupyterLab, manager: IDocumentManager, factory: IFileBrowserFactory, restorer: ILayoutRestorer, settingRegistry: ISettingRegistry): void {
const { commands } = app;
const id = fileBrowserPlugin.id;
// Add the Google Drive backend to the contents manager.
const drive = new GitLabDrive(app.docRegistry);
......@@ -50,39 +55,28 @@ function activateFileBrowser(app: JupyterLab, manager: IDocumentManager, factory
driveName: drive.name
});
const gitLabBrowser = new GitLabFileBrowser(browser, drive);
browser.model.cd('/');
let userName = '';
let userCode = '';
let groupName = '';
settingRegistry.load(id).then(settings => {
userName = settings.get('userName').composite as string;
gitLabBrowser.userName.name.set(userName);
console.warn('User name = ' + userName);
userCode = settings.get('userCode').composite as string;
gitLabBrowser.userCode.name.set(userCode);
console.warn('User code = ' + userCode);
groupName = settings.get('groupName').composite as string;
gitLabBrowser.groupName.name.set(groupName);
console.warn('Group name = ' + groupName);
});
const gitLabBrowser = new GitLabFileBrowser(browser, drive, userName, userCode, groupName);
gitLabBrowser.title.iconClass = 'jp-GitLab-tablogo';
gitLabBrowser.id = 'gitLab-file-browser';
/*
// See if we have an user cached in the IStateDB.
// Warning: there is a potential race condition here: if the filebrowser
// tries to restore its directory before the user is reset, we will
// overwrite that cwd. Otherwise we will not.
const id = NAMESPACE;
state.fetch(id).then(args => {
//const user = (args && args['user'] as string) || '';
const user = (args && (args as ReadonlyJSONObject)['user'] as string) || '';
gitLabBrowser.userName.name.set(user);
const code = (args && args['code'] as string) || '';
gitLabBrowser.userCode.name.set(code);
const group = (args && args['group'] as string) || '';
gitLabBrowser.groupName.name.set(group);
});
// Keep the IStateDB updated.
gitLabBrowser.userName.name.changed.connect((sender, args) => {
state.save(id, { user: args.newValue as string });
});
gitLabBrowser.userCode.name.changed.connect((sender, args) => {
state.save(id, { code: args.newValue });
});
gitLabBrowser.groupName.name.changed.connect((sender, args) => {
state.save(id, { group: args.newValue });
});
*/
// Add the file browser widget to the application restorer.
restorer.add(gitLabBrowser, NAMESPACE);
app.shell.addToLeftArea(gitLabBrowser, { rank: 102 });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment