Skip to content

Commit 7063f61

Browse files
Merge pull request #253 from conjoon/dev
protocol handler
2 parents 11c9640 + 0e7e478 commit 7063f61

6 files changed

+149
-11
lines changed

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"creator": "Thorsten Suckow-Homberg <[email protected]>",
1717
"summary": "JavaScript Sencha ExtJS Webmail client.",
1818
"detailedDescription": "This package contains an email client to be used with the conjoon project.",
19-
"version": "0.2.1",
20-
"compatVersion": "0.2.1",
19+
"version": "0.3.0",
20+
"compatVersion": "0.3.0",
2121
"format": "1",
2222
"slicer": {
2323
"js": [
@@ -73,7 +73,7 @@
7373
"@coon-js/extjs-app-user": "^0.1.7",
7474
"@coon-js/extjs-comp-navport": "^0.2.4",
7575
"@coon-js/extjs-lib-comp": "^0.2.8",
76-
"@coon-js/extjs-lib-core": "^0.8.1",
76+
"@coon-js/extjs-lib-core": "^0.8.3",
7777
"@l8js/l8": "^0.7.2"
7878
},
7979
"devDependencies": {

resources/extjs-app-webmail.conf.json

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
}
1010
],
1111
"controller": [
12+
{
13+
"xclass": "conjoon.cn_mail.app.plugin.MailtoProtocolHandlerPlugin"
14+
},
1215
{
1316
"xclass": "conjoon.cn_mail.app.plugin.NewMessagesNotificationPlugin",
1417
"args": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* coon.js
3+
* extjs-app-webmail
4+
* Copyright (C) 2022 Thorsten Suckow-Homberg https://github.com/conjoon/extjs-app-webmail
5+
*
6+
* Permission is hereby granted, free of charge, to any person
7+
* obtaining a copy of this software and associated documentation
8+
* files (the "Software"), to deal in the Software without restriction,
9+
* including without limitation the rights to use, copy, modify, merge,
10+
* publish, distribute, sublicense, and/or sell copies of the Software,
11+
* and to permit persons to whom the Software is furnished to do so,
12+
* subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included
15+
* in all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23+
* USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
*/
25+
26+
/**
27+
* ControllerPlugin for registering mailto-links with extjs-app-webmail.
28+
*
29+
*/
30+
Ext.define("conjoon.cn_mail.app.plugin.MailtoProtocolHandlerPlugin", {
31+
32+
extend: "coon.core.app.plugin.ControllerPlugin",
33+
34+
/**
35+
* @inheritdoc
36+
*/
37+
run (controller) {
38+
"use strict";
39+
40+
const origin = window.location.origin;
41+
42+
navigator.registerProtocolHandler(
43+
"mailto",
44+
origin + "/#cn_mail/message/compose/%s",
45+
"mailto handler"
46+
);
47+
48+
return true;
49+
}
50+
51+
});

tests/groups.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export default [{
7878
{
7979
group: "plugin",
8080
items: [
81-
"src/app/plugin/NewMessagesNotificationPluginTest.js"
81+
"src/app/plugin/NewMessagesNotificationPluginTest.js",
82+
"src/app/plugin/MailtoProtocolHandlerPluginTest.js"
8283
]
8384
}
8485
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* conjoon
3+
* extjs-app-webmail
4+
* Copyright (C) 2022 Thorsten Suckow-Homberg https://github.com/conjoon/extjs-app-webmail
5+
*
6+
* Permission is hereby granted, free of charge, to any person
7+
* obtaining a copy of this software and associated documentation
8+
* files (the "Software"), to deal in the Software without restriction,
9+
* including without limitation the rights to use, copy, modify, merge,
10+
* publish, distribute, sublicense, and/or sell copies of the Software,
11+
* and to permit persons to whom the Software is furnished to do so,
12+
* subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included
15+
* in all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23+
* USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
*/
25+
26+
StartTest(t => {
27+
28+
let plugin;
29+
30+
31+
const create = (cfg) => {
32+
let plugin = Ext.create("conjoon.cn_mail.app.plugin.MailtoProtocolHandlerPlugin", cfg || {});
33+
34+
return plugin;
35+
};
36+
37+
38+
t.beforeEach(() => {
39+
plugin = create();
40+
41+
42+
});
43+
44+
t.afterEach(() => {
45+
if (plugin) {
46+
plugin.destroy();
47+
plugin = null;
48+
}
49+
});
50+
51+
// +-------------------------------------------
52+
// | Tests
53+
// +-------------------------------------------
54+
55+
t.it("constructor()", t => {
56+
t.isInstanceOf(plugin, "coon.core.app.plugin.ControllerPlugin");
57+
});
58+
59+
60+
t.it("run()", t => {
61+
62+
const
63+
ctrl = Ext.create("conjoon.cn_mail.app.PackageController");
64+
65+
66+
let registerProtocolHandler = function (){};
67+
68+
navigator.registerProtocolHandler = registerProtocolHandler;
69+
70+
let registerSpy = t.spyOn(navigator, "registerProtocolHandler").and.callFake(() => {});
71+
72+
t.expect(plugin.run(ctrl)).toBe(true);
73+
74+
t.expect(registerSpy.calls.mostRecent().args).toEqual([
75+
"mailto",
76+
window.location.origin + "/#cn_mail/message/compose/%s",
77+
"mailto handler"
78+
]);
79+
80+
registerSpy.remove();
81+
});
82+
83+
});

0 commit comments

Comments
 (0)