@xwiki/cristal-authentication-nextcloud-ui 0.21.1 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -6
- package/api-extractor.json +4 -0
- package/dist/{NextcloudLoginMenu-CuRSwx4-.js → NextcloudLoginMenu-KxFlJo82.js} +19 -19
- package/dist/NextcloudLoginMenu-KxFlJo82.js.map +1 -0
- package/dist/NextcloudLoginMenuUIExtension.d.ts +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +12 -8
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/etc/cristal-authentication-nextcloud-ui.api.md +16 -0
- package/langs/translation-fr.json +8 -8
- package/package.json +17 -15
- package/src/NextcloudLoginMenuUIExtension.ts +1 -0
- package/src/index.ts +3 -0
- package/src/vue/NextcloudLoginMenu.vue +1 -1
- package/vitest.config.ts +1 -1
- package/dist/NextcloudLoginMenu-CuRSwx4-.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# @xwiki/cristal-authentication-nextcloud-ui
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Cristal 0.22 Release
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
|
-
- Cristal 0.21.1 Release
|
|
8
11
|
- Updated dependencies
|
|
9
|
-
- @xwiki/cristal-api@0.
|
|
10
|
-
- @xwiki/cristal-authentication-api@0.
|
|
11
|
-
- @xwiki/cristal-authentication-nextcloud-state@0.
|
|
12
|
-
- @xwiki/cristal-uiextension-api@0.
|
|
12
|
+
- @xwiki/cristal-api@0.22.0
|
|
13
|
+
- @xwiki/cristal-authentication-api@0.22.0
|
|
14
|
+
- @xwiki/cristal-authentication-nextcloud-state@0.22.0
|
|
15
|
+
- @xwiki/cristal-uiextension-api@0.22.0
|
|
13
16
|
|
|
14
17
|
## 0.21.0
|
|
15
18
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as C, inject as I, ref as L, watch as O, resolveComponent as
|
|
1
|
+
import { defineComponent as C, inject as I, ref as L, watch as O, resolveComponent as d, createBlock as h, openBlock as _, unref as e, isRef as f, withCtx as n, createVNode as r, createTextVNode as v, toDisplayString as b, createElementVNode as y, createCommentVNode as U } from "vue";
|
|
2
2
|
import { NextcloudAuthenticationState as M } from "@xwiki/cristal-authentication-nextcloud-state";
|
|
3
3
|
import { useI18n as z } from "vue-i18n";
|
|
4
4
|
const B = {
|
|
@@ -17,8 +17,8 @@ const B = {
|
|
|
17
17
|
"authentication.nextcloud.modal.password.label": "Mot de passe",
|
|
18
18
|
"authentication.nextcloud.modal.password.help": "Il n'est pas recommandé de saisir votre mot de passe personnel, vous devriez saisir un mot de passe d'application à la place.",
|
|
19
19
|
"authentication.nextcloud.modal.submit.label": "Se connecter",
|
|
20
|
-
"authentication.nextcloud.modal.error.invalid": "Nom d'utilisateur ou mot de passe
|
|
21
|
-
"authentication.nextcloud.modal.error.generic": "Échec
|
|
20
|
+
"authentication.nextcloud.modal.error.invalid": "Nom d'utilisateur ou mot de passe non valide.",
|
|
21
|
+
"authentication.nextcloud.modal.error.generic": "Échec d’authentification. Statut de la réponse : {status}."
|
|
22
22
|
}, R = {
|
|
23
23
|
en: B,
|
|
24
24
|
fr: E
|
|
@@ -27,28 +27,28 @@ const B = {
|
|
|
27
27
|
setup(c) {
|
|
28
28
|
const { t } = z({
|
|
29
29
|
messages: R
|
|
30
|
-
}), o = I("cristal").getContainer().get(M), l = o.modalOpened, p = o.username, x = o.password,
|
|
30
|
+
}), o = I("cristal").getContainer().get(M), l = o.modalOpened, p = o.username, x = o.password, s = L(void 0);
|
|
31
31
|
async function V() {
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const i = await o.callback();
|
|
33
|
+
i.success || (s.value = i.status);
|
|
34
34
|
}
|
|
35
35
|
return O(
|
|
36
36
|
o.modalOpened,
|
|
37
|
-
async (
|
|
38
|
-
|
|
37
|
+
async (i, a) => {
|
|
38
|
+
i && !a && (o.username.value = "", o.password.value = "", s.value = void 0);
|
|
39
39
|
}
|
|
40
|
-
), (
|
|
41
|
-
const w =
|
|
42
|
-
return
|
|
40
|
+
), (i, a) => {
|
|
41
|
+
const w = d("x-alert"), g = d("x-text-field"), N = d("x-form"), k = d("x-btn"), S = d("x-dialog");
|
|
42
|
+
return _(), h(S, {
|
|
43
43
|
modelValue: e(l),
|
|
44
|
-
"onUpdate:modelValue": a[2] || (a[2] = (
|
|
44
|
+
"onUpdate:modelValue": a[2] || (a[2] = (u) => f(l) ? l.value = u : null),
|
|
45
45
|
width: "auto",
|
|
46
46
|
title: e(t)("authentication.nextcloud.modal.title")
|
|
47
47
|
}, {
|
|
48
48
|
default: n(() => [
|
|
49
49
|
y("div", j, [
|
|
50
50
|
y("div", q, [
|
|
51
|
-
|
|
51
|
+
s.value === 401 ? (_(), h(w, {
|
|
52
52
|
key: 0,
|
|
53
53
|
type: "error"
|
|
54
54
|
}, {
|
|
@@ -56,13 +56,13 @@ const B = {
|
|
|
56
56
|
v(b(e(t)("authentication.nextcloud.modal.error.invalid")), 1)
|
|
57
57
|
]),
|
|
58
58
|
_: 1
|
|
59
|
-
})) :
|
|
59
|
+
})) : s.value !== void 0 ? (_(), h(w, {
|
|
60
60
|
key: 1,
|
|
61
61
|
type: "error"
|
|
62
62
|
}, {
|
|
63
63
|
default: n(() => [
|
|
64
64
|
v(b(e(t)("authentication.nextcloud.modal.error.generic", {
|
|
65
|
-
status:
|
|
65
|
+
status: s.value
|
|
66
66
|
})), 1)
|
|
67
67
|
]),
|
|
68
68
|
_: 1
|
|
@@ -76,7 +76,7 @@ const B = {
|
|
|
76
76
|
default: n(() => [
|
|
77
77
|
r(g, {
|
|
78
78
|
modelValue: e(p),
|
|
79
|
-
"onUpdate:modelValue": a[0] || (a[0] = (
|
|
79
|
+
"onUpdate:modelValue": a[0] || (a[0] = (u) => f(p) ? p.value = u : null),
|
|
80
80
|
label: e(t)("authentication.nextcloud.modal.username.label"),
|
|
81
81
|
help: e(t)("authentication.nextcloud.modal.username.help"),
|
|
82
82
|
autofocus: "",
|
|
@@ -84,7 +84,7 @@ const B = {
|
|
|
84
84
|
}, null, 8, ["modelValue", "label", "help"]),
|
|
85
85
|
r(g, {
|
|
86
86
|
modelValue: e(x),
|
|
87
|
-
"onUpdate:modelValue": a[1] || (a[1] = (
|
|
87
|
+
"onUpdate:modelValue": a[1] || (a[1] = (u) => f(x) ? x.value = u : null),
|
|
88
88
|
type: "password",
|
|
89
89
|
label: e(t)("authentication.nextcloud.modal.password.label"),
|
|
90
90
|
help: e(t)("authentication.nextcloud.modal.password.help")
|
|
@@ -114,8 +114,8 @@ const B = {
|
|
|
114
114
|
for (const [o, l] of t)
|
|
115
115
|
m[o] = l;
|
|
116
116
|
return m;
|
|
117
|
-
}, G = /* @__PURE__ */ D(A, [["__scopeId", "data-v-
|
|
117
|
+
}, G = /* @__PURE__ */ D(A, [["__scopeId", "data-v-9d125113"]]);
|
|
118
118
|
export {
|
|
119
119
|
G as default
|
|
120
120
|
};
|
|
121
|
-
//# sourceMappingURL=NextcloudLoginMenu-
|
|
121
|
+
//# sourceMappingURL=NextcloudLoginMenu-KxFlJo82.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NextcloudLoginMenu-KxFlJo82.js","sources":["../src/translations.ts","../src/vue/NextcloudLoginMenu.vue"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport en from \"../langs/translation-en.json\";\nimport fr from \"../langs/translation-fr.json\";\n\nconst translations = {\n en,\n fr,\n};\nexport default translations;\n","<!--\n See the LICENSE file distributed with this work for additional\n information regarding copyright ownership.\n\n This is free software; you can redistribute it and/or modify it\n under the terms of the GNU Lesser General Public License as\n published by the Free Software Foundation; either version 2.1 of\n the License, or (at your option) any later version.\n\n This software is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with this software; if not, write to the Free\n Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<script lang=\"ts\" setup>\nimport messages from \"../translations\";\nimport { NextcloudAuthenticationState } from \"@xwiki/cristal-authentication-nextcloud-state\";\nimport { inject, ref, watch } from \"vue\";\nimport { useI18n } from \"vue-i18n\";\nimport type { CristalApp } from \"@xwiki/cristal-api\";\nimport type { Ref } from \"vue\";\n\nconst { t } = useI18n({\n messages,\n});\n\nconst cristal = inject<CristalApp>(\"cristal\")!;\n\nconst authenticationState = cristal\n .getContainer()\n .get<NextcloudAuthenticationState>(NextcloudAuthenticationState);\nconst modalOpened: Ref<boolean> = authenticationState.modalOpened;\nconst username: Ref<string> = authenticationState.username;\nconst password: Ref<string> = authenticationState.password;\nconst errorStatus: Ref<number | undefined> = ref(undefined);\n\nasync function callback() {\n const response = await authenticationState.callback();\n if (!response.success) {\n errorStatus.value = response.status;\n }\n}\n\nwatch(\n authenticationState.modalOpened,\n async (newValue: boolean, oldValue: boolean) => {\n if (newValue && !oldValue) {\n authenticationState.username.value = \"\";\n authenticationState.password.value = \"\";\n errorStatus.value = undefined;\n }\n },\n);\n</script>\n\n<template>\n <x-dialog\n v-model=\"modalOpened\"\n width=\"auto\"\n :title=\"t('authentication.nextcloud.modal.title')\"\n >\n <template #default>\n <!-- We need 2 different divs to implement the following behavior:\n - Use max available width from the parent\n - Do not resize the parent if the content is larger -->\n <div class=\"alerts-wrapper\">\n <div class=\"alerts\">\n <x-alert v-if=\"errorStatus === 401\" type=\"error\">\n {{ t(\"authentication.nextcloud.modal.error.invalid\") }}\n </x-alert>\n <x-alert v-else-if=\"errorStatus !== undefined\" type=\"error\">\n {{\n t(\"authentication.nextcloud.modal.error.generic\", {\n status: errorStatus,\n })\n }}\n </x-alert>\n </div>\n </div>\n <x-form id=\"nextcloud-login-form\" @submit=\"callback\">\n <x-text-field\n v-model=\"username\"\n :label=\"t('authentication.nextcloud.modal.username.label')\"\n :help=\"t('authentication.nextcloud.modal.username.help')\"\n autofocus\n required\n ></x-text-field>\n <x-text-field\n v-model=\"password\"\n type=\"password\"\n :label=\"t('authentication.nextcloud.modal.password.label')\"\n :help=\"t('authentication.nextcloud.modal.password.help')\"\n ></x-text-field>\n </x-form>\n </template>\n <template #footer>\n <x-btn variant=\"primary\" type=\"submit\" form=\"nextcloud-login-form\">{{\n t(\"authentication.nextcloud.modal.submit.label\")\n }}</x-btn>\n </template>\n </x-dialog>\n</template>\n\n<style scoped>\n.alerts-wrapper {\n display: flex;\n}\n.alerts {\n flex-grow: 1;\n width: 0;\n}\n</style>\n"],"names":["translations","en","fr","useI18n","messages","authenticationState","inject","NextcloudAuthenticationState","modalOpened","username","password","errorStatus","ref","callback","response","watch","newValue","oldValue","_createBlock","_component_x_dialog","_unref","$event","_createElementVNode","_hoisted_1","_hoisted_2","_component_x_alert","_createVNode","_component_x_form","_component_x_text_field","_component_x_btn"],"mappings":";;;;;;;;;;;;;;;;;;;;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A,YAAwB,UAAQd;AAAA,UAAA;uBACzC,MAMgB;AAAA,cANhBa,EAMgBE,GAAA;AAAA,4BALLR,EAAAX,CAAA;AAAA,qEAAAA,EAAQ,QAAAY,IAAA;AAAA,gBAChB,OAAOD,EAAA,CAAA,EAAC,+CAAA;AAAA,gBACR,MAAMA,EAAA,CAAA,EAAC,8CAAA;AAAA,gBACR,WAAA;AAAA,gBACA,UAAA;AAAA,cAAA;cAEFM,EAKgBE,GAAA;AAAA,4BAJLR,EAAAV,CAAA;AAAA,qEAAAA,EAAQ,QAAAW,IAAA;AAAA,gBACjB,MAAK;AAAA,gBACJ,OAAOD,EAAA,CAAA,EAAC,+CAAA;AAAA,gBACR,MAAMA,EAAA,CAAA,EAAC,8CAAA;AAAA,cAAA;;;;;QAIH,UACT,MAEU;AAAA,UAFVM,EAEUG,GAAA;AAAA,YAFH,SAAQ;AAAA,YAAU,MAAK;AAAA,YAAS,MAAK;AAAA,UAAA;uBAAuB,MAEjE;AAAA,kBADAT,EAAA,CAAA,EAAC,6CAAA,CAAA,GAAA,CAAA;AAAA,YAAA;;;;;;;;;;;;;;"}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".alerts-wrapper[data-v-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".alerts-wrapper[data-v-9d125113]{display:flex}.alerts[data-v-9d125113]{flex-grow:1;width:0}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
2
|
import { injectable as s, inject as u } from "inversify";
|
|
3
|
-
var
|
|
4
|
-
for (var a = n > 1 ? void 0 : n ?
|
|
3
|
+
var d = Object.getOwnPropertyDescriptor, l = (t, e, i, n) => {
|
|
4
|
+
for (var a = n > 1 ? void 0 : n ? d(e, i) : e, r = t.length - 1, c; r >= 0; r--)
|
|
5
5
|
(c = t[r]) && (a = c(a) || a);
|
|
6
6
|
return a;
|
|
7
|
-
},
|
|
7
|
+
}, g = (t, e) => (i, n) => e(i, n, t);
|
|
8
8
|
let o = class {
|
|
9
9
|
constructor(t) {
|
|
10
|
-
this.authenticationManager = t
|
|
10
|
+
this.authenticationManager = t;
|
|
11
11
|
}
|
|
12
|
+
id = "sidebar.actions.nextcloudLoginMenu";
|
|
13
|
+
uixpName = "sidebar.actions";
|
|
14
|
+
order = 2100;
|
|
15
|
+
parameters = {};
|
|
12
16
|
async component() {
|
|
13
|
-
return (await import("./NextcloudLoginMenu-
|
|
17
|
+
return (await import("./NextcloudLoginMenu-KxFlJo82.js")).default;
|
|
14
18
|
}
|
|
15
19
|
async enabled() {
|
|
16
20
|
return !await this.authenticationManager.get()?.isAuthenticated();
|
|
17
21
|
}
|
|
18
22
|
};
|
|
19
|
-
o =
|
|
23
|
+
o = l([
|
|
20
24
|
s(),
|
|
21
|
-
|
|
25
|
+
g(0, u("AuthenticationManagerProvider"))
|
|
22
26
|
], o);
|
|
23
27
|
class p {
|
|
24
28
|
constructor(e) {
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/NextcloudLoginMenuUIExtension.ts","../src/index.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { inject, injectable } from \"inversify\";\nimport type {\n AuthenticationManager,\n AuthenticationManagerProvider,\n} from \"@xwiki/cristal-authentication-api\";\nimport type { UIExtension } from \"@xwiki/cristal-uiextension-api\";\nimport type { Component } from \"vue\";\n\n/**\n * Login {@link UIExtension} for the Nextcloud backend.\n *\n * @since 0.16\n */\n@injectable()\nexport class NextcloudLoginMenuUIExtension implements UIExtension {\n id = \"sidebar.actions.nextcloudLoginMenu\";\n uixpName = \"sidebar.actions\";\n order = 2100;\n parameters = {};\n\n constructor(\n @inject(\"AuthenticationManagerProvider\")\n private authenticationManager: AuthenticationManagerProvider,\n ) {}\n\n async component(): Promise<Component> {\n return (await import(\"./vue/NextcloudLoginMenu.vue\")).default;\n }\n\n async enabled(): Promise<boolean> {\n const authenticationManager: AuthenticationManager =\n this.authenticationManager.get()!;\n const authenticated: boolean =\n await authenticationManager?.isAuthenticated();\n return !authenticated;\n }\n}\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { NextcloudLoginMenuUIExtension } from \"./NextcloudLoginMenuUIExtension\";\nimport { Container } from \"inversify\";\nimport type { UIExtension } from \"@xwiki/cristal-uiextension-api\";\n\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<UIExtension>(\"UIExtension\")\n .to(NextcloudLoginMenuUIExtension)\n .inSingletonScope();\n }\n}\n"],"names":["NextcloudLoginMenuUIExtension","authenticationManager","__decorateClass","injectable","__decorateParam","ComponentInit","container"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/NextcloudLoginMenuUIExtension.ts","../src/index.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { inject, injectable } from \"inversify\";\nimport type {\n AuthenticationManager,\n AuthenticationManagerProvider,\n} from \"@xwiki/cristal-authentication-api\";\nimport type { UIExtension } from \"@xwiki/cristal-uiextension-api\";\nimport type { Component } from \"vue\";\n\n/**\n * Login {@link UIExtension} for the Nextcloud backend.\n *\n * @since 0.16\n * @beta\n */\n@injectable()\nexport class NextcloudLoginMenuUIExtension implements UIExtension {\n id = \"sidebar.actions.nextcloudLoginMenu\";\n uixpName = \"sidebar.actions\";\n order = 2100;\n parameters = {};\n\n constructor(\n @inject(\"AuthenticationManagerProvider\")\n private authenticationManager: AuthenticationManagerProvider,\n ) {}\n\n async component(): Promise<Component> {\n return (await import(\"./vue/NextcloudLoginMenu.vue\")).default;\n }\n\n async enabled(): Promise<boolean> {\n const authenticationManager: AuthenticationManager =\n this.authenticationManager.get()!;\n const authenticated: boolean =\n await authenticationManager?.isAuthenticated();\n return !authenticated;\n }\n}\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { NextcloudLoginMenuUIExtension } from \"./NextcloudLoginMenuUIExtension\";\nimport { Container } from \"inversify\";\nimport type { UIExtension } from \"@xwiki/cristal-uiextension-api\";\n\n/**\n * @beta\n */\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<UIExtension>(\"UIExtension\")\n .to(NextcloudLoginMenuUIExtension)\n .inSingletonScope();\n }\n}\n"],"names":["NextcloudLoginMenuUIExtension","authenticationManager","__decorateClass","injectable","__decorateParam","ComponentInit","container"],"mappings":";;;;;;AAmCO,IAAMA,IAAN,MAA2D;AAAA,EAMhE,YAEUC,GACR;AADQ,SAAA,wBAAAA;AAAA,EACP;AAAA,EARH,KAAK;AAAA,EACL,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,aAAa,CAAA;AAAA,EAOb,MAAM,YAAgC;AACpC,YAAQ,MAAM,OAAO,kCAA8B,GAAG;AAAA,EACxD;AAAA,EAEA,MAAM,UAA4B;AAKhC,WAAO,CADL,MAFA,KAAK,sBAAsB,IAAA,GAEE,gBAAA;AAAA,EAEjC;AACF;AAtBaD,IAANE,EAAA;AAAA,EADNC,EAAA;AAAA,EAQIC,OAAO,+BAA+B,CAAA;AAAA,GAP9BJ,CAAA;ACRN,MAAMK,EAAc;AAAA,EACzB,YAAYC,GAAsB;AAChC,IAAAA,EACG,KAAkB,aAAa,EAC/B,GAAGN,CAA6B,EAChC,iBAAA;AAAA,EACL;AACF;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".alerts-wrapper[data-v-
|
|
2
|
-
(function(a,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("inversify"),require("vue"),require("@xwiki/cristal-authentication-nextcloud-state"),require("vue-i18n")):typeof define=="function"&&define.amd?define(["exports","inversify","vue","@xwiki/cristal-authentication-nextcloud-state","vue-i18n"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a["cristal_authentication-nextcloud-ui"]={},a.inversify,a.Vue,a.cristalAuthenticationNextcloudState,a.vueI18n))})(this,function(a,c,e,w,g){"use strict";var h=document.createElement("style");h.textContent=`.alerts-wrapper[data-v-
|
|
3
|
-
/*$vite$:1*/`,document.head.appendChild(h);var b=Object.getOwnPropertyDescriptor,y=(o,t,r,n)=>{for(var i=n>1?void 0:n?b(t,r):t,s=o.length-1,d;s>=0;s--)(d=o[s])&&(i=d(i)||i);return i},N=(o,t)=>(r,n)=>t(r,n,o);let x=class{constructor(o){this.authenticationManager=o
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".alerts-wrapper[data-v-9d125113]{display:flex}.alerts[data-v-9d125113]{flex-grow:1;width:0}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
(function(a,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("inversify"),require("vue"),require("@xwiki/cristal-authentication-nextcloud-state"),require("vue-i18n")):typeof define=="function"&&define.amd?define(["exports","inversify","vue","@xwiki/cristal-authentication-nextcloud-state","vue-i18n"],c):(a=typeof globalThis<"u"?globalThis:a||self,c(a["cristal_authentication-nextcloud-ui"]={},a.inversify,a.Vue,a.cristalAuthenticationNextcloudState,a.vueI18n))})(this,(function(a,c,e,w,g){"use strict";var h=document.createElement("style");h.textContent=`.alerts-wrapper[data-v-9d125113]{display:flex}.alerts[data-v-9d125113]{flex-grow:1;width:0}
|
|
3
|
+
/*$vite$:1*/`,document.head.appendChild(h);var b=Object.getOwnPropertyDescriptor,y=(o,t,r,n)=>{for(var i=n>1?void 0:n?b(t,r):t,s=o.length-1,d;s>=0;s--)(d=o[s])&&(i=d(i)||i);return i},N=(o,t)=>(r,n)=>t(r,n,o);let x=class{constructor(o){this.authenticationManager=o}id="sidebar.actions.nextcloudLoginMenu";uixpName="sidebar.actions";order=2100;parameters={};async component(){return(await Promise.resolve().then(()=>k)).default}async enabled(){return!await this.authenticationManager.get()?.isAuthenticated()}};x=y([c.injectable(),N(0,c.inject("AuthenticationManagerProvider"))],x);class C{constructor(t){t.bind("UIExtension").to(x).inSingletonScope()}}const V={en:{"authentication.nextcloud.modal.title":"Nextcloud Login","authentication.nextcloud.modal.username.label":"Username","authentication.nextcloud.modal.username.help":"Enter your username.","authentication.nextcloud.modal.password.label":"Password","authentication.nextcloud.modal.password.help":"It is not recommended to enter your own personal password, you should enter a specific application password instead.","authentication.nextcloud.modal.submit.label":"Log-in","authentication.nextcloud.modal.error.invalid":"Invalid username or password.","authentication.nextcloud.modal.error.generic":"Login check failed. Response status: {status}."},fr:{"authentication.nextcloud.modal.title":"Connexion à Nextcloud","authentication.nextcloud.modal.username.label":"Nom d'utilisateur","authentication.nextcloud.modal.username.help":"Saisissez votre nom d'utilisateur.","authentication.nextcloud.modal.password.label":"Mot de passe","authentication.nextcloud.modal.password.help":"Il n'est pas recommandé de saisir votre mot de passe personnel, vous devriez saisir un mot de passe d'application à la place.","authentication.nextcloud.modal.submit.label":"Se connecter","authentication.nextcloud.modal.error.invalid":"Nom d'utilisateur ou mot de passe non valide.","authentication.nextcloud.modal.error.generic":"Échec d’authentification. Statut de la réponse : {status}."}},S={class:"alerts-wrapper"},M={class:"alerts"},k=Object.freeze(Object.defineProperty({__proto__:null,default:((o,t)=>{const r=o.__vccOpts||o;for(const[n,i]of t)r[n]=i;return r})(e.defineComponent({__name:"NextcloudLoginMenu",setup(o){const{t}=g.useI18n({messages:V}),n=e.inject("cristal").getContainer().get(w.NextcloudAuthenticationState),i=n.modalOpened,s=n.username,d=n.password,u=e.ref(void 0);async function I(){const m=await n.callback();m.success||(u.value=m.status)}return e.watch(n.modalOpened,async(m,l)=>{m&&!l&&(n.username.value="",n.password.value="",u.value=void 0)}),(m,l)=>{const f=e.resolveComponent("x-alert"),_=e.resolveComponent("x-text-field"),O=e.resolveComponent("x-form"),L=e.resolveComponent("x-btn"),j=e.resolveComponent("x-dialog");return e.openBlock(),e.createBlock(j,{modelValue:e.unref(i),"onUpdate:modelValue":l[2]||(l[2]=p=>e.isRef(i)?i.value=p:null),width:"auto",title:e.unref(t)("authentication.nextcloud.modal.title")},{default:e.withCtx(()=>[e.createElementVNode("div",S,[e.createElementVNode("div",M,[u.value===401?(e.openBlock(),e.createBlock(f,{key:0,type:"error"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(t)("authentication.nextcloud.modal.error.invalid")),1)]),_:1})):u.value!==void 0?(e.openBlock(),e.createBlock(f,{key:1,type:"error"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(t)("authentication.nextcloud.modal.error.generic",{status:u.value})),1)]),_:1})):e.createCommentVNode("",!0)])]),e.createVNode(O,{id:"nextcloud-login-form",onSubmit:I},{default:e.withCtx(()=>[e.createVNode(_,{modelValue:e.unref(s),"onUpdate:modelValue":l[0]||(l[0]=p=>e.isRef(s)?s.value=p:null),label:e.unref(t)("authentication.nextcloud.modal.username.label"),help:e.unref(t)("authentication.nextcloud.modal.username.help"),autofocus:"",required:""},null,8,["modelValue","label","help"]),e.createVNode(_,{modelValue:e.unref(d),"onUpdate:modelValue":l[1]||(l[1]=p=>e.isRef(d)?d.value=p:null),type:"password",label:e.unref(t)("authentication.nextcloud.modal.password.label"),help:e.unref(t)("authentication.nextcloud.modal.password.help")},null,8,["modelValue","label","help"])]),_:1})]),footer:e.withCtx(()=>[e.createVNode(L,{variant:"primary",type:"submit",form:"nextcloud-login-form"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(t)("authentication.nextcloud.modal.submit.label")),1)]),_:1})]),_:1},8,["modelValue","title"])}}}),[["__scopeId","data-v-9d125113"]])},Symbol.toStringTag,{value:"Module"}));a.ComponentInit=C,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
4
4
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/NextcloudLoginMenuUIExtension.ts","../src/index.ts","../src/translations.ts","../src/vue/NextcloudLoginMenu.vue"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { inject, injectable } from \"inversify\";\nimport type {\n AuthenticationManager,\n AuthenticationManagerProvider,\n} from \"@xwiki/cristal-authentication-api\";\nimport type { UIExtension } from \"@xwiki/cristal-uiextension-api\";\nimport type { Component } from \"vue\";\n\n/**\n * Login {@link UIExtension} for the Nextcloud backend.\n *\n * @since 0.16\n */\n@injectable()\nexport class NextcloudLoginMenuUIExtension implements UIExtension {\n id = \"sidebar.actions.nextcloudLoginMenu\";\n uixpName = \"sidebar.actions\";\n order = 2100;\n parameters = {};\n\n constructor(\n @inject(\"AuthenticationManagerProvider\")\n private authenticationManager: AuthenticationManagerProvider,\n ) {}\n\n async component(): Promise<Component> {\n return (await import(\"./vue/NextcloudLoginMenu.vue\")).default;\n }\n\n async enabled(): Promise<boolean> {\n const authenticationManager: AuthenticationManager =\n this.authenticationManager.get()!;\n const authenticated: boolean =\n await authenticationManager?.isAuthenticated();\n return !authenticated;\n }\n}\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { NextcloudLoginMenuUIExtension } from \"./NextcloudLoginMenuUIExtension\";\nimport { Container } from \"inversify\";\nimport type { UIExtension } from \"@xwiki/cristal-uiextension-api\";\n\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<UIExtension>(\"UIExtension\")\n .to(NextcloudLoginMenuUIExtension)\n .inSingletonScope();\n }\n}\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport en from \"../langs/translation-en.json\";\nimport fr from \"../langs/translation-fr.json\";\n\nconst translations = {\n en,\n fr,\n};\nexport default translations;\n","<!--\n See the LICENSE file distributed with this work for additional\n information regarding copyright ownership.\n\n This is free software; you can redistribute it and/or modify it\n under the terms of the GNU Lesser General Public License as\n published by the Free Software Foundation; either version 2.1 of\n the License, or (at your option) any later version.\n\n This software is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with this software; if not, write to the Free\n Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<script lang=\"ts\" setup>\nimport messages from \"../translations\";\nimport { CristalApp } from \"@xwiki/cristal-api\";\nimport { NextcloudAuthenticationState } from \"@xwiki/cristal-authentication-nextcloud-state\";\nimport { inject, ref, watch } from \"vue\";\nimport { useI18n } from \"vue-i18n\";\nimport type { Ref } from \"vue\";\n\nconst { t } = useI18n({\n messages,\n});\n\nconst cristal = inject<CristalApp>(\"cristal\")!;\n\nconst authenticationState = cristal\n .getContainer()\n .get<NextcloudAuthenticationState>(NextcloudAuthenticationState);\nconst modalOpened: Ref<boolean> = authenticationState.modalOpened;\nconst username: Ref<string> = authenticationState.username;\nconst password: Ref<string> = authenticationState.password;\nconst errorStatus: Ref<number | undefined> = ref(undefined);\n\nasync function callback() {\n const response = await authenticationState.callback();\n if (!response.success) {\n errorStatus.value = response.status;\n }\n}\n\nwatch(\n authenticationState.modalOpened,\n async (newValue: boolean, oldValue: boolean) => {\n if (newValue && !oldValue) {\n authenticationState.username.value = \"\";\n authenticationState.password.value = \"\";\n errorStatus.value = undefined;\n }\n },\n);\n</script>\n\n<template>\n <x-dialog\n v-model=\"modalOpened\"\n width=\"auto\"\n :title=\"t('authentication.nextcloud.modal.title')\"\n >\n <template #default>\n <!-- We need 2 different divs to implement the following behavior:\n - Use max available width from the parent\n - Do not resize the parent if the content is larger -->\n <div class=\"alerts-wrapper\">\n <div class=\"alerts\">\n <x-alert v-if=\"errorStatus === 401\" type=\"error\">\n {{ t(\"authentication.nextcloud.modal.error.invalid\") }}\n </x-alert>\n <x-alert v-else-if=\"errorStatus !== undefined\" type=\"error\">\n {{\n t(\"authentication.nextcloud.modal.error.generic\", {\n status: errorStatus,\n })\n }}\n </x-alert>\n </div>\n </div>\n <x-form id=\"nextcloud-login-form\" @submit=\"callback\">\n <x-text-field\n v-model=\"username\"\n :label=\"t('authentication.nextcloud.modal.username.label')\"\n :help=\"t('authentication.nextcloud.modal.username.help')\"\n autofocus\n required\n ></x-text-field>\n <x-text-field\n v-model=\"password\"\n type=\"password\"\n :label=\"t('authentication.nextcloud.modal.password.label')\"\n :help=\"t('authentication.nextcloud.modal.password.help')\"\n ></x-text-field>\n </x-form>\n </template>\n <template #footer>\n <x-btn variant=\"primary\" type=\"submit\" form=\"nextcloud-login-form\">{{\n t(\"authentication.nextcloud.modal.submit.label\")\n }}</x-btn>\n </template>\n </x-dialog>\n</template>\n\n<style scoped>\n.alerts-wrapper {\n display: flex;\n}\n.alerts {\n flex-grow: 1;\n width: 0;\n}\n</style>\n"],"names":["NextcloudLoginMenuUIExtension","authenticationManager","NextcloudLoginMenu$1","__decorateClass","injectable","__decorateParam","ComponentInit","container","translations","useI18n","messages","authenticationState","inject","NextcloudAuthenticationState","modalOpened","username","password","errorStatus","ref","callback","response","watch","newValue","oldValue","_createBlock","_component_x_dialog","_unref","$event","_createElementVNode","_hoisted_1","_hoisted_2","_component_x_alert","_createVNode","_component_x_form","_component_x_text_field","_component_x_btn"],"mappings":";gNAkCO,IAAMA,EAAN,KAA2D,CAMhE,YAEUC,EACR,CADQ,KAAA,sBAAAA,EAPV,KAAA,GAAK,qCACL,KAAA,SAAW,kBACX,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AW,mBAA1BO,EAAAA,YAEUO,EAAA,OAF0B,KAAK,OAAA,qBACvC,IAAuD,qCAApDL,EAAAA,MAAA,CAAA,EAAC,8CAAA,CAAA,EAAA,CAAA,CAAA,UAEcT,EAAA,QAAgB,sBAApCO,EAAAA,YAMUO,EAAA,OANqC,KAAK,OAAA,qBAClD,IAIE,qCAHAL,EAAAA,MAAA,CAAA,EAAC,+CAAA,QAA2ET,EAAA,KAAA,gDAOpFe,EAAAA,YAcSC,EAAA,CAdD,GAAG,uBAAwB,SAAQd,CAAA,qBACzC,IAMgB,CANhBa,EAAAA,YAMgBE,EAAA,YALLR,EAAAA,MAAAX,CAAA,kDAAAA,EAAQ,MAAAY,EAAA,MAChB,MAAOD,EAAAA,MAAA,CAAA,EAAC,+CAAA,EACR,KAAMA,EAAAA,MAAA,CAAA,EAAC,8CAAA,EACR,UAAA,GACA,SAAA,EAAA,wCAEFM,EAAAA,YAKgBE,EAAA,YAJLR,EAAAA,MAAAV,CAAA,kDAAAA,EAAQ,MAAAW,EAAA,MACjB,KAAK,WACJ,MAAOD,EAAAA,MAAA,CAAA,EAAC,+CAAA,EACR,KAAMA,EAAAA,MAAA,CAAA,EAAC,8CAAA,CAAA,kDAIH,iBACT,IAEU,CAFVM,EAAAA,YAEUG,EAAA,CAFH,QAAQ,UAAU,KAAK,SAAS,KAAK,sBAAA,qBAAuB,IAEjE,qCADAT,EAAAA,MAAA,CAAA,EAAC,6CAAA,CAAA,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/NextcloudLoginMenuUIExtension.ts","../src/index.ts","../src/translations.ts","../src/vue/NextcloudLoginMenu.vue"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { inject, injectable } from \"inversify\";\nimport type {\n AuthenticationManager,\n AuthenticationManagerProvider,\n} from \"@xwiki/cristal-authentication-api\";\nimport type { UIExtension } from \"@xwiki/cristal-uiextension-api\";\nimport type { Component } from \"vue\";\n\n/**\n * Login {@link UIExtension} for the Nextcloud backend.\n *\n * @since 0.16\n * @beta\n */\n@injectable()\nexport class NextcloudLoginMenuUIExtension implements UIExtension {\n id = \"sidebar.actions.nextcloudLoginMenu\";\n uixpName = \"sidebar.actions\";\n order = 2100;\n parameters = {};\n\n constructor(\n @inject(\"AuthenticationManagerProvider\")\n private authenticationManager: AuthenticationManagerProvider,\n ) {}\n\n async component(): Promise<Component> {\n return (await import(\"./vue/NextcloudLoginMenu.vue\")).default;\n }\n\n async enabled(): Promise<boolean> {\n const authenticationManager: AuthenticationManager =\n this.authenticationManager.get()!;\n const authenticated: boolean =\n await authenticationManager?.isAuthenticated();\n return !authenticated;\n }\n}\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { NextcloudLoginMenuUIExtension } from \"./NextcloudLoginMenuUIExtension\";\nimport { Container } from \"inversify\";\nimport type { UIExtension } from \"@xwiki/cristal-uiextension-api\";\n\n/**\n * @beta\n */\nexport class ComponentInit {\n constructor(container: Container) {\n container\n .bind<UIExtension>(\"UIExtension\")\n .to(NextcloudLoginMenuUIExtension)\n .inSingletonScope();\n }\n}\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport en from \"../langs/translation-en.json\";\nimport fr from \"../langs/translation-fr.json\";\n\nconst translations = {\n en,\n fr,\n};\nexport default translations;\n","<!--\n See the LICENSE file distributed with this work for additional\n information regarding copyright ownership.\n\n This is free software; you can redistribute it and/or modify it\n under the terms of the GNU Lesser General Public License as\n published by the Free Software Foundation; either version 2.1 of\n the License, or (at your option) any later version.\n\n This software is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with this software; if not, write to the Free\n Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<script lang=\"ts\" setup>\nimport messages from \"../translations\";\nimport { NextcloudAuthenticationState } from \"@xwiki/cristal-authentication-nextcloud-state\";\nimport { inject, ref, watch } from \"vue\";\nimport { useI18n } from \"vue-i18n\";\nimport type { CristalApp } from \"@xwiki/cristal-api\";\nimport type { Ref } from \"vue\";\n\nconst { t } = useI18n({\n messages,\n});\n\nconst cristal = inject<CristalApp>(\"cristal\")!;\n\nconst authenticationState = cristal\n .getContainer()\n .get<NextcloudAuthenticationState>(NextcloudAuthenticationState);\nconst modalOpened: Ref<boolean> = authenticationState.modalOpened;\nconst username: Ref<string> = authenticationState.username;\nconst password: Ref<string> = authenticationState.password;\nconst errorStatus: Ref<number | undefined> = ref(undefined);\n\nasync function callback() {\n const response = await authenticationState.callback();\n if (!response.success) {\n errorStatus.value = response.status;\n }\n}\n\nwatch(\n authenticationState.modalOpened,\n async (newValue: boolean, oldValue: boolean) => {\n if (newValue && !oldValue) {\n authenticationState.username.value = \"\";\n authenticationState.password.value = \"\";\n errorStatus.value = undefined;\n }\n },\n);\n</script>\n\n<template>\n <x-dialog\n v-model=\"modalOpened\"\n width=\"auto\"\n :title=\"t('authentication.nextcloud.modal.title')\"\n >\n <template #default>\n <!-- We need 2 different divs to implement the following behavior:\n - Use max available width from the parent\n - Do not resize the parent if the content is larger -->\n <div class=\"alerts-wrapper\">\n <div class=\"alerts\">\n <x-alert v-if=\"errorStatus === 401\" type=\"error\">\n {{ t(\"authentication.nextcloud.modal.error.invalid\") }}\n </x-alert>\n <x-alert v-else-if=\"errorStatus !== undefined\" type=\"error\">\n {{\n t(\"authentication.nextcloud.modal.error.generic\", {\n status: errorStatus,\n })\n }}\n </x-alert>\n </div>\n </div>\n <x-form id=\"nextcloud-login-form\" @submit=\"callback\">\n <x-text-field\n v-model=\"username\"\n :label=\"t('authentication.nextcloud.modal.username.label')\"\n :help=\"t('authentication.nextcloud.modal.username.help')\"\n autofocus\n required\n ></x-text-field>\n <x-text-field\n v-model=\"password\"\n type=\"password\"\n :label=\"t('authentication.nextcloud.modal.password.label')\"\n :help=\"t('authentication.nextcloud.modal.password.help')\"\n ></x-text-field>\n </x-form>\n </template>\n <template #footer>\n <x-btn variant=\"primary\" type=\"submit\" form=\"nextcloud-login-form\">{{\n t(\"authentication.nextcloud.modal.submit.label\")\n }}</x-btn>\n </template>\n </x-dialog>\n</template>\n\n<style scoped>\n.alerts-wrapper {\n display: flex;\n}\n.alerts {\n flex-grow: 1;\n width: 0;\n}\n</style>\n"],"names":["NextcloudLoginMenuUIExtension","authenticationManager","NextcloudLoginMenu$1","__decorateClass","injectable","__decorateParam","ComponentInit","container","translations","useI18n","messages","authenticationState","inject","NextcloudAuthenticationState","modalOpened","username","password","errorStatus","ref","callback","response","watch","newValue","oldValue","_createBlock","_component_x_dialog","_unref","$event","_createElementVNode","_hoisted_1","_hoisted_2","_component_x_alert","_createVNode","_component_x_form","_component_x_text_field","_component_x_btn"],"mappings":";gNAmCO,IAAMA,EAAN,KAA2D,CAMhE,YAEUC,EACR,CADQ,KAAA,sBAAAA,CACP,CARH,GAAK,qCACL,SAAW,kBACX,MAAQ,KACR,WAAa,CAAA,EAOb,MAAM,WAAgC,CACpC,OAAQ,MAAM,QAAA,QAAA,EAAA,KAAA,IAAAC,CAAA,GAAwC,OACxD,CAEA,MAAM,SAA4B,CAKhC,MAAO,CADL,MAFA,KAAK,sBAAsB,IAAA,GAEE,gBAAA,CAEjC,CACF,EAtBaF,EAANG,EAAA,CADNC,aAAA,EAQIC,aAAO,+BAA+B,CAAA,CAAA,EAP9BL,CAAA,ECRN,MAAMM,CAAc,CACzB,YAAYC,EAAsB,CAChCA,EACG,KAAkB,aAAa,EAC/B,GAAGP,CAA6B,EAChC,iBAAA,CACL,CACF,CCXA,MAAMQ,EAAe,CACnB,soBACA,itBACF,2OCEA,KAAM,CAAE,CAAA,EAAMC,UAAQ,CAAA,SACpBC,CAAA,CACD,EAIKC,EAFUC,EAAAA,OAAmB,SAAS,EAGzC,aAAA,EACA,IAAkCC,EAAAA,4BAA4B,EAC3DC,EAA4BH,EAAoB,YAChDI,EAAwBJ,EAAoB,SAC5CK,EAAwBL,EAAoB,SAC5C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AAA,MAAA,CAAA,EAAC,+CAAA,EACR,KAAMA,EAAAA,MAAA,CAAA,EAAC,8CAAA,CAAA,kDAIH,iBACT,IAEU,CAFVM,EAAAA,YAEUG,EAAA,CAFH,QAAQ,UAAU,KAAK,SAAS,KAAK,sBAAA,qBAAuB,IAEjE,qCADAT,EAAAA,MAAA,CAAA,EAAC,6CAAA,CAAA,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## API Report File for "@xwiki/cristal-authentication-nextcloud-ui"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { Container } from 'inversify';
|
|
8
|
+
|
|
9
|
+
// @beta (undocumented)
|
|
10
|
+
export class ComponentInit {
|
|
11
|
+
constructor(container: Container);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// (No @packageDocumentation comment for this package)
|
|
15
|
+
|
|
16
|
+
```
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"authentication.nextcloud.modal.title": "Connexion à Nextcloud",
|
|
3
|
+
"authentication.nextcloud.modal.username.label": "Nom d'utilisateur",
|
|
4
|
+
"authentication.nextcloud.modal.username.help": "Saisissez votre nom d'utilisateur.",
|
|
5
|
+
"authentication.nextcloud.modal.password.label": "Mot de passe",
|
|
6
|
+
"authentication.nextcloud.modal.password.help": "Il n'est pas recommandé de saisir votre mot de passe personnel, vous devriez saisir un mot de passe d'application à la place.",
|
|
7
|
+
"authentication.nextcloud.modal.submit.label": "Se connecter",
|
|
8
|
+
"authentication.nextcloud.modal.error.invalid": "Nom d'utilisateur ou mot de passe non valide.",
|
|
9
|
+
"authentication.nextcloud.modal.error.generic": "Échec d’authentification. Statut de la réponse : {status}."
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-authentication-nextcloud-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"license": "LGPL 2.1",
|
|
5
5
|
"author": "XWiki Org Community <contact@xwiki.org>",
|
|
6
6
|
"homepage": "https://cristal.xwiki.org/",
|
|
@@ -26,12 +26,13 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"main": "./dist/index.es.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"vue-i18n": "11.1.11",
|
|
31
|
-
"@xwiki/cristal-api": "0.
|
|
32
|
-
"@xwiki/cristal-
|
|
33
|
-
"@xwiki/cristal-
|
|
34
|
-
"@xwiki/cristal-authentication-
|
|
32
|
+
"@xwiki/cristal-api": "0.22.0",
|
|
33
|
+
"@xwiki/cristal-uiextension-api": "0.22.0",
|
|
34
|
+
"@xwiki/cristal-authentication-nextcloud-state": "0.22.0",
|
|
35
|
+
"@xwiki/cristal-authentication-api": "0.22.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"inversify": "7.x",
|
|
@@ -40,22 +41,23 @@
|
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@vue/test-utils": "2.4.6",
|
|
43
|
-
"inversify": "7.
|
|
44
|
+
"inversify": "7.9.0",
|
|
44
45
|
"reflect-metadata": "0.2.2",
|
|
45
46
|
"typescript": "5.9.2",
|
|
46
|
-
"vite": "7.
|
|
47
|
+
"vite": "7.1.5",
|
|
47
48
|
"vitest": "3.2.4",
|
|
48
|
-
"vue": "3.5.
|
|
49
|
+
"vue": "3.5.20",
|
|
49
50
|
"vue-tsc": "2.2.12",
|
|
50
|
-
"@xwiki/cristal-dev-config": "0.
|
|
51
|
-
"@xwiki/cristal-
|
|
52
|
-
"@xwiki/cristal-
|
|
51
|
+
"@xwiki/cristal-dev-config": "0.22.0",
|
|
52
|
+
"@xwiki/cristal-dev-test-utils": "0.22.0",
|
|
53
|
+
"@xwiki/cristal-dsapi": "0.22.0"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
55
|
-
"
|
|
56
|
+
"api-extractor:local": "api-extractor run --local",
|
|
57
|
+
"build": "vite build",
|
|
56
58
|
"clean": "rimraf dist",
|
|
57
59
|
"lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0",
|
|
58
|
-
"test": "vitest --run"
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
"test": "vitest --run",
|
|
61
|
+
"typecheck": "vue-tsc"
|
|
62
|
+
}
|
|
61
63
|
}
|
package/src/index.ts
CHANGED
|
@@ -22,6 +22,9 @@ import { NextcloudLoginMenuUIExtension } from "./NextcloudLoginMenuUIExtension";
|
|
|
22
22
|
import { Container } from "inversify";
|
|
23
23
|
import type { UIExtension } from "@xwiki/cristal-uiextension-api";
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* @beta
|
|
27
|
+
*/
|
|
25
28
|
export class ComponentInit {
|
|
26
29
|
constructor(container: Container) {
|
|
27
30
|
container
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
<script lang="ts" setup>
|
|
22
22
|
import messages from "../translations";
|
|
23
|
-
import { CristalApp } from "@xwiki/cristal-api";
|
|
24
23
|
import { NextcloudAuthenticationState } from "@xwiki/cristal-authentication-nextcloud-state";
|
|
25
24
|
import { inject, ref, watch } from "vue";
|
|
26
25
|
import { useI18n } from "vue-i18n";
|
|
26
|
+
import type { CristalApp } from "@xwiki/cristal-api";
|
|
27
27
|
import type { Ref } from "vue";
|
|
28
28
|
|
|
29
29
|
const { t } = useI18n({
|
package/vitest.config.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import localConfig from "./vite.config";
|
|
22
|
+
import { vitestVue as defaultConfig } from "@xwiki/cristal-dev-config";
|
|
22
23
|
import { mergeConfig } from "vitest/config";
|
|
23
|
-
import defaultConfig from "@xwiki/cristal-dev-config/vitest-vue.config";
|
|
24
24
|
|
|
25
25
|
export default mergeConfig(defaultConfig, localConfig);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextcloudLoginMenu-CuRSwx4-.js","sources":["../src/translations.ts","../src/vue/NextcloudLoginMenu.vue"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport en from \"../langs/translation-en.json\";\nimport fr from \"../langs/translation-fr.json\";\n\nconst translations = {\n en,\n fr,\n};\nexport default translations;\n","<!--\n See the LICENSE file distributed with this work for additional\n information regarding copyright ownership.\n\n This is free software; you can redistribute it and/or modify it\n under the terms of the GNU Lesser General Public License as\n published by the Free Software Foundation; either version 2.1 of\n the License, or (at your option) any later version.\n\n This software is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public\n License along with this software; if not, write to the Free\n Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n-->\n\n<script lang=\"ts\" setup>\nimport messages from \"../translations\";\nimport { CristalApp } from \"@xwiki/cristal-api\";\nimport { NextcloudAuthenticationState } from \"@xwiki/cristal-authentication-nextcloud-state\";\nimport { inject, ref, watch } from \"vue\";\nimport { useI18n } from \"vue-i18n\";\nimport type { Ref } from \"vue\";\n\nconst { t } = useI18n({\n messages,\n});\n\nconst cristal = inject<CristalApp>(\"cristal\")!;\n\nconst authenticationState = cristal\n .getContainer()\n .get<NextcloudAuthenticationState>(NextcloudAuthenticationState);\nconst modalOpened: Ref<boolean> = authenticationState.modalOpened;\nconst username: Ref<string> = authenticationState.username;\nconst password: Ref<string> = authenticationState.password;\nconst errorStatus: Ref<number | undefined> = ref(undefined);\n\nasync function callback() {\n const response = await authenticationState.callback();\n if (!response.success) {\n errorStatus.value = response.status;\n }\n}\n\nwatch(\n authenticationState.modalOpened,\n async (newValue: boolean, oldValue: boolean) => {\n if (newValue && !oldValue) {\n authenticationState.username.value = \"\";\n authenticationState.password.value = \"\";\n errorStatus.value = undefined;\n }\n },\n);\n</script>\n\n<template>\n <x-dialog\n v-model=\"modalOpened\"\n width=\"auto\"\n :title=\"t('authentication.nextcloud.modal.title')\"\n >\n <template #default>\n <!-- We need 2 different divs to implement the following behavior:\n - Use max available width from the parent\n - Do not resize the parent if the content is larger -->\n <div class=\"alerts-wrapper\">\n <div class=\"alerts\">\n <x-alert v-if=\"errorStatus === 401\" type=\"error\">\n {{ t(\"authentication.nextcloud.modal.error.invalid\") }}\n </x-alert>\n <x-alert v-else-if=\"errorStatus !== undefined\" type=\"error\">\n {{\n t(\"authentication.nextcloud.modal.error.generic\", {\n status: errorStatus,\n })\n }}\n </x-alert>\n </div>\n </div>\n <x-form id=\"nextcloud-login-form\" @submit=\"callback\">\n <x-text-field\n v-model=\"username\"\n :label=\"t('authentication.nextcloud.modal.username.label')\"\n :help=\"t('authentication.nextcloud.modal.username.help')\"\n autofocus\n required\n ></x-text-field>\n <x-text-field\n v-model=\"password\"\n type=\"password\"\n :label=\"t('authentication.nextcloud.modal.password.label')\"\n :help=\"t('authentication.nextcloud.modal.password.help')\"\n ></x-text-field>\n </x-form>\n </template>\n <template #footer>\n <x-btn variant=\"primary\" type=\"submit\" form=\"nextcloud-login-form\">{{\n t(\"authentication.nextcloud.modal.submit.label\")\n }}</x-btn>\n </template>\n </x-dialog>\n</template>\n\n<style scoped>\n.alerts-wrapper {\n display: flex;\n}\n.alerts {\n flex-grow: 1;\n width: 0;\n}\n</style>\n"],"names":["translations","en","fr","useI18n","messages","authenticationState","inject","NextcloudAuthenticationState","modalOpened","username","password","errorStatus","ref","callback","response","watch","newValue","oldValue","_createBlock","_component_x_dialog","_unref","$event","_createElementVNode","_hoisted_1","_hoisted_2","_component_x_alert","_createVNode","_component_x_form","_component_x_text_field","_component_x_btn"],"mappings":";;;;;;;;;;;;;;;;;;;;;GAuBMA,IAAe;AAAA,EACnB,IAAAC;AAAA,EACA,IAAAC;AACF;;;ACEA,UAAM,EAAE,EAAA,IAAMC,EAAQ;AAAA,MAAA,UACpBC;AAAAA,IAAA,CACD,GAIKC,IAFUC,EAAmB,SAAS,EAGzC,aAAA,EACA,IAAkCC,CAA4B,GAC3DC,IAA4BH,EAAoB,aAChDI,IAAwBJ,EAAoB,UAC5CK,IAAwBL,EAAoB,UAC5CM,IAAuCC,EAAI,MAAS;AAE1D,mBAAeC,IAAW;AACxB,YAAMC,IAAW,MAAMT,EAAoB,SAAA;AAC3C,MAAKS,EAAS,YACZH,EAAY,QAAQG,EAAS;AAAA,IAEjC;AAEA,WAAAC;AAAA,MACEV,EAAoB;AAAA,MACpB,OAAOW,GAAmBC,MAAsB;AAC9C,QAAID,KAAY,CAACC,MACfZ,EAAoB,SAAS,QAAQ,IACrCA,EAAoB,SAAS,QAAQ,IACrCM,EAAY,QAAQ;AAAA,MAExB;AAAA,IAAA;;kBAKAO,EA4CWC,GAAA;AAAA,oBA3CAC,EAAAZ,CAAA;AAAA,6DAAAA,EAAW,QAAAa,IAAA;AAAA,QACpB,OAAM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