2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { KeyState } from 'Common/Enums';
|
|
|
|
import { selectElement } from 'Common/Utils';
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
import { popup } from 'Knoin/Knoin';
|
|
|
|
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-09-10 06:38:16 +08:00
|
|
|
@popup({
|
2016-08-17 06:01:20 +08:00
|
|
|
name: 'View/Popup/ViewOpenPgpKey',
|
2016-09-30 21:42:38 +08:00
|
|
|
templateID: 'PopupsViewOpenPgpKey'
|
2016-08-17 06:01:20 +08:00
|
|
|
})
|
2019-07-05 03:19:24 +08:00
|
|
|
class ViewOpenPgpKeyPopupView extends AbstractViewNext {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
|
|
|
super();
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.key = ko.observable('');
|
|
|
|
this.keyDom = ko.observable(null);
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.sDefaultKeyScope = KeyState.PopupViewOpenPGP;
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
clearPopup() {
|
|
|
|
this.key('');
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
selectKey() {
|
|
|
|
const el = this.keyDom();
|
2019-07-05 03:19:24 +08:00
|
|
|
if (el) {
|
2016-08-17 06:01:20 +08:00
|
|
|
selectElement(el);
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-09-30 21:42:38 +08:00
|
|
|
onShow(openPgpKey) {
|
2016-08-17 06:01:20 +08:00
|
|
|
this.clearPopup();
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
if (openPgpKey) {
|
2016-09-30 21:42:38 +08:00
|
|
|
this.key(openPgpKey.armor);
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-09-02 03:50:30 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
onBuild() {
|
|
|
|
key('ctrl+a, command+a', KeyState.PopupViewOpenPGP, () => {
|
|
|
|
this.selectKey();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
export { ViewOpenPgpKeyPopupView, ViewOpenPgpKeyPopupView as default };
|