@jupyterlab/git
Version:
A JupyterLab extension for version control using git
39 lines (38 loc) • 1.37 kB
JavaScript
import { nullTranslator } from '@jupyterlab/translation';
import { Widget } from '@lumino/widgets';
/**
* The UI for the commit author form
*/
export class GitAuthorForm extends Widget {
constructor({ author, trans }) {
super();
this._populateForm(author, trans);
}
_populateForm(author, trans) {
trans !== null && trans !== void 0 ? trans : (trans = nullTranslator.load('jupyterlab_git'));
const nameLabel = document.createElement('label');
nameLabel.textContent = trans.__('Committer name:');
const emailLabel = document.createElement('label');
emailLabel.textContent = trans.__('Committer email:');
this._name = nameLabel.appendChild(document.createElement('input'));
this._email = emailLabel.appendChild(document.createElement('input'));
this._name.placeholder = 'Name';
this._email.type = 'text';
this._email.placeholder = 'Email';
this._email.type = 'email';
this._name.value = author.name;
this._email.value = author.email;
this.node.appendChild(nameLabel);
this.node.appendChild(emailLabel);
}
/**
* Returns the input value.
*/
getValue() {
const credentials = {
name: this._name.value,
email: this._email.value
};
return credentials;
}
}