@webiny/app-mailer 6.3.0 → 6.4.0-beta.1

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/Module.js CHANGED
@@ -1,48 +1,36 @@
1
- import React, { lazy, Suspense } from "react";
2
- import { AdminConfig, Plugins, AdminLayout, useRouter } from "@webiny/app-admin";
3
- import { HasPermission } from "@webiny/app-admin";
1
+ import react, { Suspense, lazy } from "react";
2
+ import { AdminConfig, AdminLayout, HasPermission, Plugins, useRouter } from "@webiny/app-admin";
4
3
  import { OverlayLoader } from "@webiny/admin-ui";
5
4
  import { usePermission } from "./hooks/usePermission.js";
6
5
  import { Routes } from "./routes.js";
7
- const {
8
- Menu,
9
- Route
10
- } = AdminConfig;
11
- const Settings = /*#__PURE__*/lazy(() => import(/* webpackChunkName: "mailer-settings" */"./views/settings/index.js"));
12
- const Loader = ({
13
- children,
14
- ...props
15
- }) => /*#__PURE__*/React.createElement(Suspense, {
16
- fallback: /*#__PURE__*/React.createElement(OverlayLoader, null)
17
- }, /*#__PURE__*/React.cloneElement(children, props));
18
- const MailerSettings = () => {
19
- const router = useRouter();
20
- const {
21
- canChangeSettings
22
- } = usePermission();
23
- const changeSettings = canChangeSettings();
24
- if (!changeSettings) {
25
- return null;
26
- }
27
- return /*#__PURE__*/React.createElement(AdminConfig, null, /*#__PURE__*/React.createElement(HasPermission, {
28
- name: "mailer.settings"
29
- }, /*#__PURE__*/React.createElement(Route, {
30
- route: Routes.Settings,
31
- element: /*#__PURE__*/React.createElement(AdminLayout, {
32
- title: "Mailer - Settings"
33
- }, /*#__PURE__*/React.createElement(Loader, null, /*#__PURE__*/React.createElement(Settings, null)))
34
- }), /*#__PURE__*/React.createElement(Menu, {
35
- name: "mailer.settings",
36
- parent: "settings.system",
37
- element: /*#__PURE__*/React.createElement(Menu.Link, {
38
- text: "Mailer",
39
- to: router.getLink(Routes.Settings),
40
- pinnable: true
41
- })
42
- })));
43
- };
44
- export const Module = () => {
45
- return /*#__PURE__*/React.createElement(Plugins, null, /*#__PURE__*/React.createElement(MailerSettings, null));
6
+ const { Menu: Menu, Route: Route } = AdminConfig;
7
+ const Settings = /*#__PURE__*/ lazy(()=>import("./views/settings/index.js"));
8
+ const Loader = ({ children, ...props })=>/*#__PURE__*/ react.createElement(Suspense, {
9
+ fallback: /*#__PURE__*/ react.createElement(OverlayLoader, null)
10
+ }, /*#__PURE__*/ react.cloneElement(children, props));
11
+ const MailerSettings = ()=>{
12
+ const router = useRouter();
13
+ const { canChangeSettings } = usePermission();
14
+ const changeSettings = canChangeSettings();
15
+ if (!changeSettings) return null;
16
+ return /*#__PURE__*/ react.createElement(AdminConfig, null, /*#__PURE__*/ react.createElement(HasPermission, {
17
+ name: "mailer.settings"
18
+ }, /*#__PURE__*/ react.createElement(Route, {
19
+ route: Routes.Settings,
20
+ element: /*#__PURE__*/ react.createElement(AdminLayout, {
21
+ title: "Mailer - Settings"
22
+ }, /*#__PURE__*/ react.createElement(Loader, null, /*#__PURE__*/ react.createElement(Settings, null)))
23
+ }), /*#__PURE__*/ react.createElement(Menu, {
24
+ name: "mailer.settings",
25
+ parent: "settings.system",
26
+ element: /*#__PURE__*/ react.createElement(Menu.Link, {
27
+ text: "Mailer",
28
+ to: router.getLink(Routes.Settings),
29
+ pinnable: true
30
+ })
31
+ })));
46
32
  };
33
+ const Module = ()=>/*#__PURE__*/ react.createElement(Plugins, null, /*#__PURE__*/ react.createElement(MailerSettings, null));
34
+ export { Module };
47
35
 
48
36
  //# sourceMappingURL=Module.js.map
package/Module.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["React","lazy","Suspense","AdminConfig","Plugins","AdminLayout","useRouter","HasPermission","OverlayLoader","usePermission","Routes","Menu","Route","Settings","Loader","children","props","createElement","fallback","cloneElement","MailerSettings","router","canChangeSettings","changeSettings","name","route","element","title","parent","Link","text","to","getLink","pinnable","Module"],"sources":["Module.tsx"],"sourcesContent":["import React, { lazy, Suspense } from \"react\";\nimport { AdminConfig, Plugins, AdminLayout, useRouter } from \"@webiny/app-admin\";\nimport { HasPermission } from \"@webiny/app-admin\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { usePermission } from \"~/hooks/usePermission.js\";\nimport { Routes } from \"~/routes.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nconst Settings = lazy(\n () =>\n import(\n /* webpackChunkName: \"mailer-settings\" */\n \"~/views/settings/index.js\"\n )\n);\n\ninterface LoaderProps {\n children: React.ReactElement;\n}\n\nconst Loader = ({ children, ...props }: LoaderProps) => (\n <Suspense fallback={<OverlayLoader />}>{React.cloneElement(children, props)}</Suspense>\n);\n\nconst MailerSettings = () => {\n const router = useRouter();\n const { canChangeSettings } = usePermission();\n\n const changeSettings = canChangeSettings();\n\n if (!changeSettings) {\n return null;\n }\n\n return (\n <AdminConfig>\n <HasPermission name={\"mailer.settings\"}>\n <Route\n route={Routes.Settings}\n element={\n <AdminLayout title={\"Mailer - Settings\"}>\n <Loader>\n <Settings />\n </Loader>\n </AdminLayout>\n }\n />\n <Menu\n name={\"mailer.settings\"}\n parent={\"settings.system\"}\n element={\n <Menu.Link\n text={\"Mailer\"}\n to={router.getLink(Routes.Settings)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n </AdminConfig>\n );\n};\n\nexport const Module = () => {\n return (\n <Plugins>\n <MailerSettings />\n </Plugins>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,IAAI,EAAEC,QAAQ,QAAQ,OAAO;AAC7C,SAASC,WAAW,EAAEC,OAAO,EAAEC,WAAW,EAAEC,SAAS,QAAQ,mBAAmB;AAChF,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,aAAa;AACtB,SAASC,MAAM;AAEf,MAAM;EAAEC,IAAI;EAAEC;AAAM,CAAC,GAAGT,WAAW;AAEnC,MAAMU,QAAQ,gBAAGZ,IAAI,CACjB,MACI,MAAM,CACF,oEAEJ,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AO,MAAMC,MAAM,GAAGA,CAAA,KAAM;EACxB,oBACIlC,KAAA,CAAAiB,aAAA,CAACb,OAAO,qBACJJ,KAAA,CAAAiB,aAAA,CAACG,cAAc,MAAE,CACZ,CAAC;AAElB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Module.js","sources":["../src/Module.tsx"],"sourcesContent":["import React, { lazy, Suspense } from \"react\";\nimport { AdminConfig, Plugins, AdminLayout, useRouter } from \"@webiny/app-admin\";\nimport { HasPermission } from \"@webiny/app-admin\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { usePermission } from \"~/hooks/usePermission.js\";\nimport { Routes } from \"~/routes.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nconst Settings = lazy(\n () =>\n import(\n /* webpackChunkName: \"mailer-settings\" */\n \"~/views/settings/index.js\"\n )\n);\n\ninterface LoaderProps {\n children: React.ReactElement;\n}\n\nconst Loader = ({ children, ...props }: LoaderProps) => (\n <Suspense fallback={<OverlayLoader />}>{React.cloneElement(children, props)}</Suspense>\n);\n\nconst MailerSettings = () => {\n const router = useRouter();\n const { canChangeSettings } = usePermission();\n\n const changeSettings = canChangeSettings();\n\n if (!changeSettings) {\n return null;\n }\n\n return (\n <AdminConfig>\n <HasPermission name={\"mailer.settings\"}>\n <Route\n route={Routes.Settings}\n element={\n <AdminLayout title={\"Mailer - Settings\"}>\n <Loader>\n <Settings />\n </Loader>\n </AdminLayout>\n }\n />\n <Menu\n name={\"mailer.settings\"}\n parent={\"settings.system\"}\n element={\n <Menu.Link\n text={\"Mailer\"}\n to={router.getLink(Routes.Settings)}\n pinnable={true}\n />\n }\n />\n </HasPermission>\n </AdminConfig>\n );\n};\n\nexport const Module = () => {\n return (\n <Plugins>\n <MailerSettings />\n </Plugins>\n );\n};\n"],"names":["Menu","Route","AdminConfig","Settings","lazy","Loader","children","props","Suspense","OverlayLoader","React","MailerSettings","router","useRouter","canChangeSettings","usePermission","changeSettings","HasPermission","Routes","AdminLayout","Module","Plugins"],"mappings":";;;;;AAOA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC;AAExB,MAAMC,WAAW,WAAHA,GAAGC,KACb,IACI,MAAM,CAAN;AAUR,MAAMC,SAAS,CAAC,EAAEC,QAAQ,EAAE,GAAGC,OAAoB,iBAC/C,oBAACC,UAAQA;QAAC,wBAAU,oBAACC,eAAaA;qBAAMC,MAAAA,YAAkB,CAACJ,UAAUC;AAGzE,MAAMI,iBAAiB;IACnB,MAAMC,SAASC;IACf,MAAM,EAAEC,iBAAiB,EAAE,GAAGC;IAE9B,MAAMC,iBAAiBF;IAEvB,IAAI,CAACE,gBACD,OAAO;IAGX,OAAO,WAAP,GACI,oBAACd,aAAWA,MAAAA,WAAAA,GACR,oBAACe,eAAaA;QAAC,MAAM;qBACjB,oBAAChB,OAAKA;QACF,OAAOiB,OAAO,QAAQ;QACtB,uBACI,oBAACC,aAAWA;YAAC,OAAO;yBAChB,oBAACd,QAAMA,MAAAA,WAAAA,GACH,oBAACF,UAAQA;sBAKzB,oBAACH,MAAIA;QACD,MAAM;QACN,QAAQ;QACR,uBACI,oBAACA,KAAK,IAAI;YACN,MAAM;YACN,IAAIY,OAAO,OAAO,CAACM,OAAO,QAAQ;YAClC,UAAU;;;AAOtC;AAEO,MAAME,SAAS,IACX,WAAP,GACI,oBAACC,SAAOA,MAAAA,WAAAA,GACJ,oBAACV,gBAAcA"}
@@ -1,17 +1,17 @@
1
1
  import { useSecurity } from "@webiny/app-admin";
2
2
  import { useCallback } from "react";
3
- export const usePermission = () => {
4
- const {
5
- identity,
6
- getPermission
7
- } = useSecurity();
8
- const canChangeSettings = useCallback(() => {
9
- const permission = getPermission("mailer.settings");
10
- return !!permission;
11
- }, [identity]);
12
- return {
13
- canChangeSettings
14
- };
3
+ const usePermission = ()=>{
4
+ const { identity, getPermission } = useSecurity();
5
+ const canChangeSettings = useCallback(()=>{
6
+ const permission = getPermission("mailer.settings");
7
+ return !!permission;
8
+ }, [
9
+ identity
10
+ ]);
11
+ return {
12
+ canChangeSettings
13
+ };
15
14
  };
15
+ export { usePermission };
16
16
 
17
17
  //# sourceMappingURL=usePermission.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useSecurity","useCallback","usePermission","identity","getPermission","canChangeSettings","permission"],"sources":["usePermission.ts"],"sourcesContent":["import { useSecurity } from \"@webiny/app-admin\";\nimport { useCallback } from \"react\";\nimport type { MailerSecurityPermission } from \"~/types.js\";\n\nexport const usePermission = () => {\n const { identity, getPermission } = useSecurity();\n\n const canChangeSettings = useCallback((): boolean => {\n const permission = getPermission<MailerSecurityPermission>(\"mailer.settings\");\n return !!permission;\n }, [identity]);\n\n return {\n canChangeSettings\n };\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,WAAW,QAAQ,OAAO;AAGnC,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAGJ,WAAW,CAAC,CAAC;EAEjD,MAAMK,iBAAiB,GAAGJ,WAAW,CAAC,MAAe;IACjD,MAAMK,UAAU,GAAGF,aAAa,CAA2B,iBAAiB,CAAC;IAC7E,OAAO,CAAC,CAACE,UAAU;EACvB,CAAC,EAAE,CAACH,QAAQ,CAAC,CAAC;EAEd,OAAO;IACHE;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"hooks/usePermission.js","sources":["../../src/hooks/usePermission.ts"],"sourcesContent":["import { useSecurity } from \"@webiny/app-admin\";\nimport { useCallback } from \"react\";\nimport type { MailerSecurityPermission } from \"~/types.js\";\n\nexport const usePermission = () => {\n const { identity, getPermission } = useSecurity();\n\n const canChangeSettings = useCallback((): boolean => {\n const permission = getPermission<MailerSecurityPermission>(\"mailer.settings\");\n return !!permission;\n }, [identity]);\n\n return {\n canChangeSettings\n };\n};\n"],"names":["usePermission","identity","getPermission","useSecurity","canChangeSettings","useCallback","permission"],"mappings":";;AAIO,MAAMA,gBAAgB;IACzB,MAAM,EAAEC,QAAQ,EAAEC,aAAa,EAAE,GAAGC;IAEpC,MAAMC,oBAAoBC,YAAY;QAClC,MAAMC,aAAaJ,cAAwC;QAC3D,OAAO,CAAC,CAACI;IACb,GAAG;QAACL;KAAS;IAEb,OAAO;QACHG;IACJ;AACJ"}
package/index.js CHANGED
@@ -1,3 +1 @@
1
1
  export { Module } from "./Module.js";
2
-
3
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-mailer",
3
- "version": "6.3.0",
3
+ "version": "6.4.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -14,22 +14,22 @@
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
16
  "@apollo/react-components": "3.1.5",
17
- "@webiny/admin-ui": "6.3.0",
18
- "@webiny/app-admin": "6.3.0",
19
- "@webiny/form": "6.3.0",
20
- "@webiny/validation": "6.3.0",
17
+ "@webiny/admin-ui": "6.4.0-beta.1",
18
+ "@webiny/app-admin": "6.4.0-beta.1",
19
+ "@webiny/form": "6.4.0-beta.1",
20
+ "@webiny/validation": "6.4.0-beta.1",
21
21
  "apollo-cache": "1.3.5",
22
22
  "apollo-client": "2.6.10",
23
23
  "apollo-link": "1.2.14",
24
24
  "apollo-utilities": "1.3.4",
25
- "graphql": "16.13.2",
25
+ "graphql": "16.14.0",
26
26
  "graphql-tag": "2.12.6",
27
27
  "react": "18.3.1",
28
28
  "react-dom": "18.3.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/react": "18.3.28",
32
- "@webiny/build-tools": "6.3.0",
32
+ "@webiny/build-tools": "6.4.0-beta.1",
33
33
  "rimraf": "6.1.3",
34
34
  "typescript": "6.0.3"
35
35
  },
@@ -42,5 +42,5 @@
42
42
  "removeViewBox": false
43
43
  }
44
44
  },
45
- "gitHead": "7cefe15431dbd65504e1f58147dc9e55bcbfa693"
45
+ "gitHead": "73237b8243693038c072bae1c0b783387448cbbe"
46
46
  }
package/routes.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { Route } from "@webiny/app-admin";
2
- export const Routes = {
3
- Settings: new Route({
4
- name: "Mailer/Settings",
5
- path: "/mailer/settings"
6
- })
2
+ const Routes = {
3
+ Settings: new Route({
4
+ name: "Mailer/Settings",
5
+ path: "/mailer/settings"
6
+ })
7
7
  };
8
+ export { Routes };
8
9
 
9
10
  //# sourceMappingURL=routes.js.map
package/routes.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["Route","Routes","Settings","name","path"],"sources":["routes.ts"],"sourcesContent":["import { Route } from \"@webiny/app-admin\";\n\nexport const Routes = {\n Settings: new Route({\n name: \"Mailer/Settings\",\n path: \"/mailer/settings\"\n })\n};\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,mBAAmB;AAEzC,OAAO,MAAMC,MAAM,GAAG;EAClBC,QAAQ,EAAE,IAAIF,KAAK,CAAC;IAChBG,IAAI,EAAE,iBAAiB;IACvBC,IAAI,EAAE;EACV,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"routes.js","sources":["../src/routes.ts"],"sourcesContent":["import { Route } from \"@webiny/app-admin\";\n\nexport const Routes = {\n Settings: new Route({\n name: \"Mailer/Settings\",\n path: \"/mailer/settings\"\n })\n};\n"],"names":["Routes","Route"],"mappings":";AAEO,MAAMA,SAAS;IAClB,UAAU,IAAIC,MAAM;QAChB,MAAM;QACN,MAAM;IACV;AACJ"}
package/types.js CHANGED
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
@@ -1,223 +1,203 @@
1
- import React, { useEffect, useRef, useState } from "react";
2
- import { CenteredView, useSnackbar } from "@webiny/app-admin";
1
+ import react, { useEffect, useRef, useState } from "react";
2
+ import { CenteredView, SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader, useSnackbar } from "@webiny/app-admin";
3
3
  import { Mutation, Query } from "@apollo/react-components";
4
4
  import { Form } from "@webiny/form";
5
- import { SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader } from "@webiny/app-admin";
6
5
  import { validation } from "@webiny/validation";
7
6
  import { GET_SETTINGS_QUERY, SAVE_SETTINGS_MUTATION } from "./graphql.js";
8
7
  import { Alert, Button, Grid, Input, OverlayLoader } from "@webiny/admin-ui";
9
- const displayErrors = errors => {
10
- if (!errors) {
11
- return null;
12
- }
13
- return /*#__PURE__*/React.createElement(React.Fragment, null, errors.map(error => {
14
- const field = error.path[0];
15
- if (!field) {
16
- return null;
17
- }
18
- return /*#__PURE__*/React.createElement(Alert, {
19
- key: `${field}`,
20
- title: "Error",
21
- type: "danger"
22
- }, error.message);
23
- }));
8
+ const displayErrors = (errors)=>{
9
+ if (!errors) return null;
10
+ return /*#__PURE__*/ react.createElement(react.Fragment, null, errors.map((error)=>{
11
+ const field = error.path[0];
12
+ if (!field) return null;
13
+ return /*#__PURE__*/ react.createElement(Alert, {
14
+ key: `${field}`,
15
+ title: "Error",
16
+ type: "danger"
17
+ }, error.message);
18
+ }));
24
19
  };
25
- export const Settings = () => {
26
- const {
27
- showSnackbar
28
- } = useSnackbar();
29
- const password = useRef(null);
30
- const [errors, setErrors] = useState();
31
- useEffect(() => {
32
- const t = setTimeout(() => {
33
- if (!password.current) {
34
- return;
35
- }
36
- password.current.value = "";
37
- }, 300);
38
- return () => {
39
- clearTimeout(t);
40
- };
41
- }, []);
42
- return /*#__PURE__*/React.createElement(Query, {
43
- query: GET_SETTINGS_QUERY
44
- }, ({
45
- data: response,
46
- loading: queryInProgress
47
- }) => /*#__PURE__*/React.createElement(Mutation, {
48
- mutation: SAVE_SETTINGS_MUTATION
49
- }, (update, result) => {
50
- const {
51
- data: settingsData,
52
- error: settingsError
53
- } = response?.mailer.settings || {};
54
- const settingsSource = settingsData?.source;
55
- const {
56
- loading: mutationInProgress
57
- } = result;
58
- const onSubmit = async data => {
59
- setErrors([]);
60
- const response = await update({
61
- variables: {
62
- data
63
- },
64
- refetchQueries: [{
65
- query: GET_SETTINGS_QUERY
66
- }],
67
- awaitRefetchQueries: true
68
- });
69
- const saveError = response.data?.mailer.settings.error;
70
- if (saveError) {
71
- const validationErrors = saveError.data?.errors;
72
- if (validationErrors) {
73
- setErrors(validationErrors);
74
- }
75
- showSnackbar("Settings not updated! Please check your network and console logs for detailed information.");
76
- return;
77
- }
78
- showSnackbar("Settings updated successfully.");
79
- };
80
- if (settingsSource === "code") {
81
- return /*#__PURE__*/React.createElement(CenteredView, null, /*#__PURE__*/React.createElement(SimpleForm, null, /*#__PURE__*/React.createElement(SimpleFormHeader, {
82
- title: "Mailer Settings"
83
- }), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Grid.Column, {
84
- span: 12
85
- }, /*#__PURE__*/React.createElement(Alert, {
86
- title: "Managed by code",
87
- type: "info"
88
- }, "Mailer settings are managed by code. Edit", " ", /*#__PURE__*/React.createElement("code", null, "webiny.config.tsx"), " to change them.")), /*#__PURE__*/React.createElement(Grid.Column, {
89
- span: 12
90
- }, /*#__PURE__*/React.createElement(Input, {
91
- size: "lg",
92
- type: "text",
93
- label: "Hostname",
94
- value: settingsData?.host ?? "",
95
- disabled: true
96
- })), /*#__PURE__*/React.createElement(Grid.Column, {
97
- span: 12
98
- }, /*#__PURE__*/React.createElement(Input, {
99
- size: "lg",
100
- type: "number",
101
- label: "Port",
102
- value: String(settingsData?.port ?? ""),
103
- disabled: true
104
- })), /*#__PURE__*/React.createElement(Grid.Column, {
105
- span: 12
106
- }, /*#__PURE__*/React.createElement(Input, {
107
- size: "lg",
108
- type: "text",
109
- label: "User",
110
- value: settingsData?.user ?? "",
111
- disabled: true
112
- })), /*#__PURE__*/React.createElement(Grid.Column, {
113
- span: 12
114
- }, /*#__PURE__*/React.createElement(Input, {
115
- size: "lg",
116
- type: "text",
117
- label: "From",
118
- value: settingsData?.from ?? "",
119
- disabled: true
120
- })), /*#__PURE__*/React.createElement(Grid.Column, {
121
- span: 12
122
- }, /*#__PURE__*/React.createElement(Input, {
123
- size: "lg",
124
- type: "text",
125
- label: "Reply-To",
126
- value: settingsData?.replyTo ?? "",
127
- disabled: true
128
- })))), /*#__PURE__*/React.createElement(SimpleFormFooter, null, "")));
129
- }
130
- if (settingsError) {
131
- return /*#__PURE__*/React.createElement(SimpleForm, null, /*#__PURE__*/React.createElement(SimpleFormHeader, {
132
- title: "Mailer Settings"
133
- }), /*#__PURE__*/React.createElement(SimpleFormContent, null, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Grid.Column, {
134
- span: 12
135
- }, /*#__PURE__*/React.createElement(Alert, {
136
- title: settingsError.message,
137
- type: "danger"
138
- })))), /*#__PURE__*/React.createElement(SimpleFormFooter, null, ""));
139
- }
140
- const passwordValidators = [];
141
- if (!settingsData?.user) {
142
- passwordValidators.push(validation.create("required,minLength:5"));
143
- }
144
- return /*#__PURE__*/React.createElement(CenteredView, null, /*#__PURE__*/React.createElement(Form, {
145
- data: settingsData || {},
146
- onSubmit: data => {
147
- /**
148
- * We are positive that data is TransportSettings.
149
- */
150
- onSubmit(data);
151
- }
152
- }, ({
153
- Bind,
154
- form
155
- }) => /*#__PURE__*/React.createElement(SimpleForm, null, (queryInProgress || mutationInProgress) && /*#__PURE__*/React.createElement(OverlayLoader, null), /*#__PURE__*/React.createElement(SimpleFormHeader, {
156
- title: "Mailer Settings"
157
- }), /*#__PURE__*/React.createElement(SimpleFormContent, null, displayErrors(errors), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Grid.Column, {
158
- span: 12
159
- }, /*#__PURE__*/React.createElement(Bind, {
160
- name: "host",
161
- validators: [validation.create("required,minLength:1")]
162
- }, /*#__PURE__*/React.createElement(Input, {
163
- size: "lg",
164
- type: "text",
165
- label: "Hostname"
166
- }))), /*#__PURE__*/React.createElement(Grid.Column, {
167
- span: 12
168
- }, /*#__PURE__*/React.createElement(Bind, {
169
- name: "port"
170
- }, /*#__PURE__*/React.createElement(Input, {
171
- size: "lg",
172
- type: "number",
173
- label: "Port"
174
- }))), /*#__PURE__*/React.createElement(Grid.Column, {
175
- span: 12
176
- }, /*#__PURE__*/React.createElement(Bind, {
177
- name: "user",
178
- validators: [validation.create("required,minLength:1")]
179
- }, /*#__PURE__*/React.createElement(Input, {
180
- size: "lg",
181
- type: "text",
182
- label: "User",
183
- autoComplete: "new-password"
184
- }))), /*#__PURE__*/React.createElement(Grid.Column, {
185
- span: 12
186
- }, /*#__PURE__*/React.createElement(Bind, {
187
- name: "password",
188
- validators: passwordValidators
189
- }, /*#__PURE__*/React.createElement(Input, {
190
- size: "lg",
191
- label: "Password",
192
- type: "password",
193
- autoComplete: "new-password",
194
- value: "",
195
- inputRef: password
196
- }))), /*#__PURE__*/React.createElement(Grid.Column, {
197
- span: 12
198
- }, /*#__PURE__*/React.createElement(Bind, {
199
- name: "from",
200
- validators: [validation.create("required,minLength:1,email")]
201
- }, /*#__PURE__*/React.createElement(Input, {
202
- size: "lg",
203
- type: "text",
204
- label: "Mail from"
205
- }))), /*#__PURE__*/React.createElement(Grid.Column, {
206
- span: 12
207
- }, /*#__PURE__*/React.createElement(Bind, {
208
- name: "replyTo",
209
- validators: [validation.create("email")]
210
- }, /*#__PURE__*/React.createElement(Input, {
211
- size: "lg",
212
- type: "text",
213
- label: "Mail reply-to"
214
- }))))), /*#__PURE__*/React.createElement(SimpleFormFooter, null, /*#__PURE__*/React.createElement(Button, {
215
- text: "Save",
216
- onClick: ev => {
217
- form.submit(ev);
218
- }
219
- })))));
220
- }));
20
+ const Settings = ()=>{
21
+ const { showSnackbar } = useSnackbar();
22
+ const password = useRef(null);
23
+ const [errors, setErrors] = useState();
24
+ useEffect(()=>{
25
+ const t = setTimeout(()=>{
26
+ if (!password.current) return;
27
+ password.current.value = "";
28
+ }, 300);
29
+ return ()=>{
30
+ clearTimeout(t);
31
+ };
32
+ }, []);
33
+ return /*#__PURE__*/ react.createElement(Query, {
34
+ query: GET_SETTINGS_QUERY
35
+ }, ({ data: response, loading: queryInProgress })=>/*#__PURE__*/ react.createElement(Mutation, {
36
+ mutation: SAVE_SETTINGS_MUTATION
37
+ }, (update, result)=>{
38
+ const { data: settingsData, error: settingsError } = response?.mailer.settings || {};
39
+ const settingsSource = settingsData?.source;
40
+ const { loading: mutationInProgress } = result;
41
+ const onSubmit = async (data)=>{
42
+ setErrors([]);
43
+ const response = await update({
44
+ variables: {
45
+ data
46
+ },
47
+ refetchQueries: [
48
+ {
49
+ query: GET_SETTINGS_QUERY
50
+ }
51
+ ],
52
+ awaitRefetchQueries: true
53
+ });
54
+ const saveError = response.data?.mailer.settings.error;
55
+ if (saveError) {
56
+ const validationErrors = saveError.data?.errors;
57
+ if (validationErrors) setErrors(validationErrors);
58
+ showSnackbar("Settings not updated! Please check your network and console logs for detailed information.");
59
+ return;
60
+ }
61
+ showSnackbar("Settings updated successfully.");
62
+ };
63
+ if ("code" === settingsSource) return /*#__PURE__*/ react.createElement(CenteredView, null, /*#__PURE__*/ react.createElement(SimpleForm, null, /*#__PURE__*/ react.createElement(SimpleFormHeader, {
64
+ title: "Mailer Settings"
65
+ }), /*#__PURE__*/ react.createElement(SimpleFormContent, null, /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
66
+ span: 12
67
+ }, /*#__PURE__*/ react.createElement(Alert, {
68
+ title: "Managed by code",
69
+ type: "info"
70
+ }, "Mailer settings are managed by code. Edit", " ", /*#__PURE__*/ react.createElement("code", null, "webiny.config.tsx"), " to change them.")), /*#__PURE__*/ react.createElement(Grid.Column, {
71
+ span: 12
72
+ }, /*#__PURE__*/ react.createElement(Input, {
73
+ size: "lg",
74
+ type: "text",
75
+ label: "Hostname",
76
+ value: settingsData?.host ?? "",
77
+ disabled: true
78
+ })), /*#__PURE__*/ react.createElement(Grid.Column, {
79
+ span: 12
80
+ }, /*#__PURE__*/ react.createElement(Input, {
81
+ size: "lg",
82
+ type: "number",
83
+ label: "Port",
84
+ value: String(settingsData?.port ?? ""),
85
+ disabled: true
86
+ })), /*#__PURE__*/ react.createElement(Grid.Column, {
87
+ span: 12
88
+ }, /*#__PURE__*/ react.createElement(Input, {
89
+ size: "lg",
90
+ type: "text",
91
+ label: "User",
92
+ value: settingsData?.user ?? "",
93
+ disabled: true
94
+ })), /*#__PURE__*/ react.createElement(Grid.Column, {
95
+ span: 12
96
+ }, /*#__PURE__*/ react.createElement(Input, {
97
+ size: "lg",
98
+ type: "text",
99
+ label: "From",
100
+ value: settingsData?.from ?? "",
101
+ disabled: true
102
+ })), /*#__PURE__*/ react.createElement(Grid.Column, {
103
+ span: 12
104
+ }, /*#__PURE__*/ react.createElement(Input, {
105
+ size: "lg",
106
+ type: "text",
107
+ label: "Reply-To",
108
+ value: settingsData?.replyTo ?? "",
109
+ disabled: true
110
+ })))), /*#__PURE__*/ react.createElement(SimpleFormFooter, null, "")));
111
+ if (settingsError) return /*#__PURE__*/ react.createElement(SimpleForm, null, /*#__PURE__*/ react.createElement(SimpleFormHeader, {
112
+ title: "Mailer Settings"
113
+ }), /*#__PURE__*/ react.createElement(SimpleFormContent, null, /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
114
+ span: 12
115
+ }, /*#__PURE__*/ react.createElement(Alert, {
116
+ title: settingsError.message,
117
+ type: "danger"
118
+ })))), /*#__PURE__*/ react.createElement(SimpleFormFooter, null, ""));
119
+ const passwordValidators = [];
120
+ if (!settingsData?.user) passwordValidators.push(validation.create("required,minLength:5"));
121
+ return /*#__PURE__*/ react.createElement(CenteredView, null, /*#__PURE__*/ react.createElement(Form, {
122
+ data: settingsData || {},
123
+ onSubmit: (data)=>{
124
+ onSubmit(data);
125
+ }
126
+ }, ({ Bind, form })=>/*#__PURE__*/ react.createElement(SimpleForm, null, (queryInProgress || mutationInProgress) && /*#__PURE__*/ react.createElement(OverlayLoader, null), /*#__PURE__*/ react.createElement(SimpleFormHeader, {
127
+ title: "Mailer Settings"
128
+ }), /*#__PURE__*/ react.createElement(SimpleFormContent, null, displayErrors(errors), /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
129
+ span: 12
130
+ }, /*#__PURE__*/ react.createElement(Bind, {
131
+ name: "host",
132
+ validators: [
133
+ validation.create("required,minLength:1")
134
+ ]
135
+ }, /*#__PURE__*/ react.createElement(Input, {
136
+ size: "lg",
137
+ type: "text",
138
+ label: "Hostname"
139
+ }))), /*#__PURE__*/ react.createElement(Grid.Column, {
140
+ span: 12
141
+ }, /*#__PURE__*/ react.createElement(Bind, {
142
+ name: "port"
143
+ }, /*#__PURE__*/ react.createElement(Input, {
144
+ size: "lg",
145
+ type: "number",
146
+ label: "Port"
147
+ }))), /*#__PURE__*/ react.createElement(Grid.Column, {
148
+ span: 12
149
+ }, /*#__PURE__*/ react.createElement(Bind, {
150
+ name: "user",
151
+ validators: [
152
+ validation.create("required,minLength:1")
153
+ ]
154
+ }, /*#__PURE__*/ react.createElement(Input, {
155
+ size: "lg",
156
+ type: "text",
157
+ label: "User",
158
+ autoComplete: "new-password"
159
+ }))), /*#__PURE__*/ react.createElement(Grid.Column, {
160
+ span: 12
161
+ }, /*#__PURE__*/ react.createElement(Bind, {
162
+ name: "password",
163
+ validators: passwordValidators
164
+ }, /*#__PURE__*/ react.createElement(Input, {
165
+ size: "lg",
166
+ label: "Password",
167
+ type: "password",
168
+ autoComplete: "new-password",
169
+ value: "",
170
+ inputRef: password
171
+ }))), /*#__PURE__*/ react.createElement(Grid.Column, {
172
+ span: 12
173
+ }, /*#__PURE__*/ react.createElement(Bind, {
174
+ name: "from",
175
+ validators: [
176
+ validation.create("required,minLength:1,email")
177
+ ]
178
+ }, /*#__PURE__*/ react.createElement(Input, {
179
+ size: "lg",
180
+ type: "text",
181
+ label: "Mail from"
182
+ }))), /*#__PURE__*/ react.createElement(Grid.Column, {
183
+ span: 12
184
+ }, /*#__PURE__*/ react.createElement(Bind, {
185
+ name: "replyTo",
186
+ validators: [
187
+ validation.create("email")
188
+ ]
189
+ }, /*#__PURE__*/ react.createElement(Input, {
190
+ size: "lg",
191
+ type: "text",
192
+ label: "Mail reply-to"
193
+ }))))), /*#__PURE__*/ react.createElement(SimpleFormFooter, null, /*#__PURE__*/ react.createElement(Button, {
194
+ text: "Save",
195
+ onClick: (ev)=>{
196
+ form.submit(ev);
197
+ }
198
+ })))));
199
+ }));
221
200
  };
201
+ export { Settings };
222
202
 
223
203
  //# sourceMappingURL=Settings.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useRef","useState","CenteredView","useSnackbar","Mutation","Query","Form","SimpleForm","SimpleFormContent","SimpleFormFooter","SimpleFormHeader","validation","GET_SETTINGS_QUERY","SAVE_SETTINGS_MUTATION","Alert","Button","Grid","Input","OverlayLoader","displayErrors","errors","createElement","Fragment","map","error","field","path","key","title","type","message","Settings","showSnackbar","password","setErrors","t","setTimeout","current","value","clearTimeout","query","data","response","loading","queryInProgress","mutation","update","result","settingsData","settingsError","mailer","settings","settingsSource","source","mutationInProgress","onSubmit","variables","refetchQueries","awaitRefetchQueries","saveError","validationErrors","Column","span","size","label","host","disabled","String","port","user","from","replyTo","passwordValidators","push","create","Bind","form","name","validators","autoComplete","inputRef","text","onClick","ev","submit"],"sources":["Settings.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { CenteredView, useSnackbar } from \"@webiny/app-admin\";\nimport { Mutation, Query } from \"@apollo/react-components\";\nimport { Form } from \"@webiny/form\";\nimport {\n SimpleForm,\n SimpleFormContent,\n SimpleFormFooter,\n SimpleFormHeader\n} from \"@webiny/app-admin\";\nimport { validation } from \"@webiny/validation\";\nimport type {\n SaveSettingsMutationResponse,\n SaveSettingsMutationVariables,\n SettingsQueryResponse\n} from \"./graphql.js\";\nimport { GET_SETTINGS_QUERY, SAVE_SETTINGS_MUTATION } from \"./graphql.js\";\nimport type { TransportSettings, ValidationError } from \"~/types.js\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport { Alert, Button, Grid, Input, OverlayLoader } from \"@webiny/admin-ui\";\n\nconst displayErrors = (errors?: ValidationError[]) => {\n if (!errors) {\n return null;\n }\n return (\n <>\n {errors.map(error => {\n const field = error.path[0];\n if (!field) {\n return null;\n }\n return (\n <Alert key={`${field}`} title={\"Error\"} type=\"danger\">\n {error.message}\n </Alert>\n );\n })}\n </>\n );\n};\n\nexport const Settings = () => {\n const { showSnackbar } = useSnackbar();\n\n const password = useRef<HTMLInputElement>(null);\n\n const [errors, setErrors] = useState<ValidationError[] | undefined>();\n\n useEffect(() => {\n const t = setTimeout(() => {\n if (!password.current) {\n return;\n }\n password.current.value = \"\";\n }, 300);\n\n return () => {\n clearTimeout(t);\n };\n }, []);\n\n return (\n <Query<SettingsQueryResponse> query={GET_SETTINGS_QUERY}>\n {({ data: response, loading: queryInProgress }) => (\n <Mutation<SaveSettingsMutationResponse, SaveSettingsMutationVariables>\n mutation={SAVE_SETTINGS_MUTATION}\n >\n {(update, result) => {\n const { data: settingsData, error: settingsError } =\n response?.mailer.settings || {};\n const settingsSource = settingsData?.source;\n const { loading: mutationInProgress } = result;\n\n const onSubmit = async (data: TransportSettings): Promise<void> => {\n setErrors([]);\n const response = await update({\n variables: { data },\n refetchQueries: [{ query: GET_SETTINGS_QUERY }],\n awaitRefetchQueries: true\n });\n\n const saveError = response.data?.mailer.settings.error;\n if (saveError) {\n const validationErrors = saveError.data?.errors;\n if (validationErrors) {\n setErrors(validationErrors);\n }\n showSnackbar(\n \"Settings not updated! Please check your network and console logs for detailed information.\"\n );\n return;\n }\n showSnackbar(\"Settings updated successfully.\");\n };\n if (settingsSource === \"code\") {\n return (\n <CenteredView>\n <SimpleForm>\n <SimpleFormHeader title=\"Mailer Settings\" />\n <SimpleFormContent>\n <Grid>\n <Grid.Column span={12}>\n <Alert title=\"Managed by code\" type=\"info\">\n Mailer settings are managed by code. Edit{\" \"}\n <code>webiny.config.tsx</code> to change\n them.\n </Alert>\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"text\"\n label=\"Hostname\"\n value={settingsData?.host ?? \"\"}\n disabled\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"number\"\n label=\"Port\"\n value={String(settingsData?.port ?? \"\")}\n disabled\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"text\"\n label=\"User\"\n value={settingsData?.user ?? \"\"}\n disabled\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"text\"\n label=\"From\"\n value={settingsData?.from ?? \"\"}\n disabled\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"text\"\n label=\"Reply-To\"\n value={settingsData?.replyTo ?? \"\"}\n disabled\n />\n </Grid.Column>\n </Grid>\n </SimpleFormContent>\n <SimpleFormFooter>{\"\"}</SimpleFormFooter>\n </SimpleForm>\n </CenteredView>\n );\n }\n if (settingsError) {\n return (\n <SimpleForm>\n <SimpleFormHeader title=\"Mailer Settings\" />\n <SimpleFormContent>\n <Grid>\n <Grid.Column span={12}>\n <Alert\n title={settingsError.message}\n type=\"danger\"\n />\n </Grid.Column>\n </Grid>\n </SimpleFormContent>\n <SimpleFormFooter>{\"\"}</SimpleFormFooter>\n </SimpleForm>\n );\n }\n\n const passwordValidators: Validator[] = [];\n if (!settingsData?.user) {\n passwordValidators.push(validation.create(\"required,minLength:5\"));\n }\n\n return (\n <CenteredView>\n <Form\n data={settingsData || {}}\n onSubmit={data => {\n /**\n * We are positive that data is TransportSettings.\n */\n onSubmit(data as unknown as TransportSettings);\n }}\n >\n {({ Bind, form }) => (\n <SimpleForm>\n {(queryInProgress || mutationInProgress) && (\n <OverlayLoader />\n )}\n <SimpleFormHeader title=\"Mailer Settings\" />\n <SimpleFormContent>\n {displayErrors(errors)}\n <Grid>\n <Grid.Column span={12}>\n <Bind\n name={\"host\"}\n validators={[\n validation.create(\n \"required,minLength:1\"\n )\n ]}\n >\n <Input\n size={\"lg\"}\n type=\"text\"\n label=\"Hostname\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"port\"}>\n <Input\n size={\"lg\"}\n type=\"number\"\n label=\"Port\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"user\"}\n validators={[\n validation.create(\n \"required,minLength:1\"\n )\n ]}\n >\n <Input\n size={\"lg\"}\n type=\"text\"\n label=\"User\"\n autoComplete=\"new-password\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"password\"}\n validators={passwordValidators}\n >\n <Input\n size={\"lg\"}\n label=\"Password\"\n type=\"password\"\n autoComplete=\"new-password\"\n value={\"\"}\n inputRef={password}\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"from\"}\n validators={[\n validation.create(\n \"required,minLength:1,email\"\n )\n ]}\n >\n <Input\n size={\"lg\"}\n type=\"text\"\n label=\"Mail from\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"replyTo\"}\n validators={[\n validation.create(\"email\")\n ]}\n >\n <Input\n size={\"lg\"}\n type=\"text\"\n label=\"Mail reply-to\"\n />\n </Bind>\n </Grid.Column>\n </Grid>\n </SimpleFormContent>\n <SimpleFormFooter>\n <Button\n text={\"Save\"}\n onClick={ev => {\n form.submit(ev);\n }}\n />\n </SimpleFormFooter>\n </SimpleForm>\n )}\n </Form>\n </CenteredView>\n );\n }}\n </Mutation>\n )}\n </Query>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,SAASC,YAAY,EAAEC,WAAW,QAAQ,mBAAmB;AAC7D,SAASC,QAAQ,EAAEC,KAAK,QAAQ,0BAA0B;AAC1D,SAASC,IAAI,QAAQ,cAAc;A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,EAAE,CACRnE,UAAU,CAAC+D,MAAM,CACb,4BACJ,CAAC;IACH,gBAEF5E,KAAA,CAAAuB,aAAA,CAACJ,KAAK;MACF8C,IAAI,EAAE,IAAK;MACXlC,IAAI,EAAC,MAAM;MACXmC,KAAK,EAAC;IAAW,CACpB,CACC,CACG,CAAC,eACdlE,KAAA,CAAAuB,aAAA,CAACL,IAAI,CAAC6C,MAAM;MAACC,IAAI,EAAE;IAAG,gBAClBhE,KAAA,CAAAuB,aAAA,CAACsD,IAAI;MACDE,IAAI,EAAE,SAAU;MAChBC,UAAU,EAAE,CACRnE,UAAU,CAAC+D,MAAM,CAAC,OAAO,CAAC;IAC5B,gBAEF5E,KAAA,CAAAuB,aAAA,CAACJ,KAAK;MACF8C,IAAI,EAAE,IAAK;MACXlC,IAAI,EAAC,MAAM;MACXmC,KAAK,EAAC;IAAe,CACxB,CACC,CACG,CACX,CACS,CAAC,eACpBlE,KAAA,CAAAuB,aAAA,CAACZ,gBAAgB,qBACbX,KAAA,CAAAuB,aAAA,CAACN,MAAM;MACHkE,IAAI,EAAE,MAAO;MACbC,OAAO,EAAEC,EAAE,IAAI;QACXP,IAAI,CAACQ,MAAM,CAACD,EAAE,CAAC;MACnB;IAAE,CACL,CACa,CACV,CAEd,CACI,CAAC;EAEvB,CACM,CAEX,CAAC;AAEhB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"views/settings/Settings.js","sources":["../../../src/views/settings/Settings.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from \"react\";\nimport { CenteredView, useSnackbar } from \"@webiny/app-admin\";\nimport { Mutation, Query } from \"@apollo/react-components\";\nimport { Form } from \"@webiny/form\";\nimport {\n SimpleForm,\n SimpleFormContent,\n SimpleFormFooter,\n SimpleFormHeader\n} from \"@webiny/app-admin\";\nimport { validation } from \"@webiny/validation\";\nimport type {\n SaveSettingsMutationResponse,\n SaveSettingsMutationVariables,\n SettingsQueryResponse\n} from \"./graphql.js\";\nimport { GET_SETTINGS_QUERY, SAVE_SETTINGS_MUTATION } from \"./graphql.js\";\nimport type { TransportSettings, ValidationError } from \"~/types.js\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport { Alert, Button, Grid, Input, OverlayLoader } from \"@webiny/admin-ui\";\n\nconst displayErrors = (errors?: ValidationError[]) => {\n if (!errors) {\n return null;\n }\n return (\n <>\n {errors.map(error => {\n const field = error.path[0];\n if (!field) {\n return null;\n }\n return (\n <Alert key={`${field}`} title={\"Error\"} type=\"danger\">\n {error.message}\n </Alert>\n );\n })}\n </>\n );\n};\n\nexport const Settings = () => {\n const { showSnackbar } = useSnackbar();\n\n const password = useRef<HTMLInputElement>(null);\n\n const [errors, setErrors] = useState<ValidationError[] | undefined>();\n\n useEffect(() => {\n const t = setTimeout(() => {\n if (!password.current) {\n return;\n }\n password.current.value = \"\";\n }, 300);\n\n return () => {\n clearTimeout(t);\n };\n }, []);\n\n return (\n <Query<SettingsQueryResponse> query={GET_SETTINGS_QUERY}>\n {({ data: response, loading: queryInProgress }) => (\n <Mutation<SaveSettingsMutationResponse, SaveSettingsMutationVariables>\n mutation={SAVE_SETTINGS_MUTATION}\n >\n {(update, result) => {\n const { data: settingsData, error: settingsError } =\n response?.mailer.settings || {};\n const settingsSource = settingsData?.source;\n const { loading: mutationInProgress } = result;\n\n const onSubmit = async (data: TransportSettings): Promise<void> => {\n setErrors([]);\n const response = await update({\n variables: { data },\n refetchQueries: [{ query: GET_SETTINGS_QUERY }],\n awaitRefetchQueries: true\n });\n\n const saveError = response.data?.mailer.settings.error;\n if (saveError) {\n const validationErrors = saveError.data?.errors;\n if (validationErrors) {\n setErrors(validationErrors);\n }\n showSnackbar(\n \"Settings not updated! Please check your network and console logs for detailed information.\"\n );\n return;\n }\n showSnackbar(\"Settings updated successfully.\");\n };\n if (settingsSource === \"code\") {\n return (\n <CenteredView>\n <SimpleForm>\n <SimpleFormHeader title=\"Mailer Settings\" />\n <SimpleFormContent>\n <Grid>\n <Grid.Column span={12}>\n <Alert title=\"Managed by code\" type=\"info\">\n Mailer settings are managed by code. Edit{\" \"}\n <code>webiny.config.tsx</code> to change\n them.\n </Alert>\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"text\"\n label=\"Hostname\"\n value={settingsData?.host ?? \"\"}\n disabled\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"number\"\n label=\"Port\"\n value={String(settingsData?.port ?? \"\")}\n disabled\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"text\"\n label=\"User\"\n value={settingsData?.user ?? \"\"}\n disabled\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"text\"\n label=\"From\"\n value={settingsData?.from ?? \"\"}\n disabled\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <Input\n size=\"lg\"\n type=\"text\"\n label=\"Reply-To\"\n value={settingsData?.replyTo ?? \"\"}\n disabled\n />\n </Grid.Column>\n </Grid>\n </SimpleFormContent>\n <SimpleFormFooter>{\"\"}</SimpleFormFooter>\n </SimpleForm>\n </CenteredView>\n );\n }\n if (settingsError) {\n return (\n <SimpleForm>\n <SimpleFormHeader title=\"Mailer Settings\" />\n <SimpleFormContent>\n <Grid>\n <Grid.Column span={12}>\n <Alert\n title={settingsError.message}\n type=\"danger\"\n />\n </Grid.Column>\n </Grid>\n </SimpleFormContent>\n <SimpleFormFooter>{\"\"}</SimpleFormFooter>\n </SimpleForm>\n );\n }\n\n const passwordValidators: Validator[] = [];\n if (!settingsData?.user) {\n passwordValidators.push(validation.create(\"required,minLength:5\"));\n }\n\n return (\n <CenteredView>\n <Form\n data={settingsData || {}}\n onSubmit={data => {\n /**\n * We are positive that data is TransportSettings.\n */\n onSubmit(data as unknown as TransportSettings);\n }}\n >\n {({ Bind, form }) => (\n <SimpleForm>\n {(queryInProgress || mutationInProgress) && (\n <OverlayLoader />\n )}\n <SimpleFormHeader title=\"Mailer Settings\" />\n <SimpleFormContent>\n {displayErrors(errors)}\n <Grid>\n <Grid.Column span={12}>\n <Bind\n name={\"host\"}\n validators={[\n validation.create(\n \"required,minLength:1\"\n )\n ]}\n >\n <Input\n size={\"lg\"}\n type=\"text\"\n label=\"Hostname\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind name={\"port\"}>\n <Input\n size={\"lg\"}\n type=\"number\"\n label=\"Port\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"user\"}\n validators={[\n validation.create(\n \"required,minLength:1\"\n )\n ]}\n >\n <Input\n size={\"lg\"}\n type=\"text\"\n label=\"User\"\n autoComplete=\"new-password\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"password\"}\n validators={passwordValidators}\n >\n <Input\n size={\"lg\"}\n label=\"Password\"\n type=\"password\"\n autoComplete=\"new-password\"\n value={\"\"}\n inputRef={password}\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"from\"}\n validators={[\n validation.create(\n \"required,minLength:1,email\"\n )\n ]}\n >\n <Input\n size={\"lg\"}\n type=\"text\"\n label=\"Mail from\"\n />\n </Bind>\n </Grid.Column>\n <Grid.Column span={12}>\n <Bind\n name={\"replyTo\"}\n validators={[\n validation.create(\"email\")\n ]}\n >\n <Input\n size={\"lg\"}\n type=\"text\"\n label=\"Mail reply-to\"\n />\n </Bind>\n </Grid.Column>\n </Grid>\n </SimpleFormContent>\n <SimpleFormFooter>\n <Button\n text={\"Save\"}\n onClick={ev => {\n form.submit(ev);\n }}\n />\n </SimpleFormFooter>\n </SimpleForm>\n )}\n </Form>\n </CenteredView>\n );\n }}\n </Mutation>\n )}\n </Query>\n );\n};\n"],"names":["displayErrors","errors","error","field","Alert","Settings","showSnackbar","useSnackbar","password","useRef","setErrors","useState","useEffect","t","setTimeout","clearTimeout","Query","GET_SETTINGS_QUERY","response","queryInProgress","Mutation","SAVE_SETTINGS_MUTATION","update","result","settingsData","settingsError","settingsSource","mutationInProgress","onSubmit","data","saveError","validationErrors","CenteredView","SimpleForm","SimpleFormHeader","SimpleFormContent","Grid","Input","String","SimpleFormFooter","passwordValidators","validation","Form","Bind","form","OverlayLoader","Button","ev"],"mappings":";;;;;;;AAqBA,MAAMA,gBAAgB,CAACC;IACnB,IAAI,CAACA,QACD,OAAO;IAEX,OAAO,WAAP,GACI,0CACKA,OAAO,GAAG,CAACC,CAAAA;QACR,MAAMC,QAAQD,MAAM,IAAI,CAAC,EAAE;QAC3B,IAAI,CAACC,OACD,OAAO;QAEX,OAAO,WAAP,GACI,oBAACC,OAAKA;YAAC,KAAK,GAAGD,OAAO;YAAE,OAAO;YAAS,MAAK;WACxCD,MAAM,OAAO;IAG1B;AAGZ;AAEO,MAAMG,WAAW;IACpB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,WAAWC,OAAyB;IAE1C,MAAM,CAACR,QAAQS,UAAU,GAAGC;IAE5BC,UAAU;QACN,MAAMC,IAAIC,WAAW;YACjB,IAAI,CAACN,SAAS,OAAO,EACjB;YAEJA,SAAS,OAAO,CAAC,KAAK,GAAG;QAC7B,GAAG;QAEH,OAAO;YACHO,aAAaF;QACjB;IACJ,GAAG,EAAE;IAEL,OAAO,WAAP,GACI,oBAACG,OAAKA;QAAwB,OAAOC;OAChC,CAAC,EAAE,MAAMC,QAAQ,EAAE,SAASC,eAAe,EAAE,iBAC1C,oBAACC,UAAQA;YACL,UAAUC;WAET,CAACC,QAAQC;YACN,MAAM,EAAE,MAAMC,YAAY,EAAE,OAAOC,aAAa,EAAE,GAC9CP,UAAU,OAAO,YAAY,CAAC;YAClC,MAAMQ,iBAAiBF,cAAc;YACrC,MAAM,EAAE,SAASG,kBAAkB,EAAE,GAAGJ;YAExC,MAAMK,WAAW,OAAOC;gBACpBnB,UAAU,EAAE;gBACZ,MAAMQ,WAAW,MAAMI,OAAO;oBAC1B,WAAW;wBAAEO;oBAAK;oBAClB,gBAA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oBAACO,MAAAA;oBACG,MAAM;oBACN,YAAY;wBACRF,WAAW,MAAM,CACb;qBAEP;iCAED,oBAACJ,OAAKA;oBACF,MAAM;oBACN,MAAK;oBACL,OAAM;oBACN,cAAa;oCAIzB,oBAACD,KAAK,MAAM;oBAAC,MAAM;iCACf,oBAACO,MAAAA;oBACG,MAAM;oBACN,YAAYH;iCAEZ,oBAACH,OAAKA;oBACF,MAAM;oBACN,OAAM;oBACN,MAAK;oBACL,cAAa;oBACb,OAAO;oBACP,UAAU7B;oCAItB,oBAAC4B,KAAK,MAAM;oBAAC,MAAM;iCACf,oBAACO,MAAAA;oBACG,MAAM;oBACN,YAAY;wBACRF,WAAW,MAAM,CACb;qBAEP;iCAED,oBAACJ,OAAKA;oBACF,MAAM;oBACN,MAAK;oBACL,OAAM;oCAIlB,oBAACD,KAAK,MAAM;oBAAC,MAAM;iCACf,oBAACO,MAAAA;oBACG,MAAM;oBACN,YAAY;wBACRF,WAAW,MAAM,CAAC;qBACrB;iCAED,oBAACJ,OAAKA;oBACF,MAAM;oBACN,MAAK;oBACL,OAAM;sCAM1B,oBAACE,kBAAgBA,MAAAA,WAAAA,GACb,oBAACO,QAAMA;oBACH,MAAM;oBACN,SAASC,CAAAA;wBACLH,KAAK,MAAM,CAACG;oBAChB;;QAQhC;AAKpB"}
@@ -1,4 +1,4 @@
1
- import gql from "graphql-tag";
1
+ import graphql_tag from "graphql-tag";
2
2
  const SETTINGS_FIELDS = `
3
3
  {
4
4
  host
@@ -16,10 +16,7 @@ const ERROR_FIELDS = `
16
16
  data
17
17
  }
18
18
  `;
19
-
20
- /** Settings as they appear in GraphQL responses — never includes the password. */
21
-
22
- export const GET_SETTINGS_QUERY = gql`
19
+ const GET_SETTINGS_QUERY = graphql_tag`
23
20
  query GetMailerSettings {
24
21
  mailer {
25
22
  settings: getSettings {
@@ -29,7 +26,7 @@ export const GET_SETTINGS_QUERY = gql`
29
26
  }
30
27
  }
31
28
  `;
32
- export const SAVE_SETTINGS_MUTATION = gql`
29
+ const SAVE_SETTINGS_MUTATION = graphql_tag`
33
30
  mutation SaveTransportSettings($data: MailerTransportSettingsInput!) {
34
31
  mailer {
35
32
  settings: saveSettings(data: $data) {
@@ -39,5 +36,6 @@ export const SAVE_SETTINGS_MUTATION = gql`
39
36
  }
40
37
  }
41
38
  `;
39
+ export { GET_SETTINGS_QUERY, SAVE_SETTINGS_MUTATION };
42
40
 
43
41
  //# sourceMappingURL=graphql.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["gql","SETTINGS_FIELDS","ERROR_FIELDS","GET_SETTINGS_QUERY","SAVE_SETTINGS_MUTATION"],"sources":["graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type { ApiError, TransportSettings, ValidationErrors } from \"~/types.js\";\n\nconst SETTINGS_FIELDS = `\n {\n host\n port\n user\n from\n replyTo\n source\n }\n`;\n\nconst ERROR_FIELDS = `\n {\n message\n code\n data\n }\n`;\n\nexport type MailerSettingsSource = \"code\" | \"storage\" | null;\n\n/** Settings as they appear in GraphQL responses — never includes the password. */\nexport type PublicTransportSettings = Omit<TransportSettings, \"password\"> & {\n source?: MailerSettingsSource;\n};\n\nexport interface SettingsQueryResponse {\n mailer: {\n settings: {\n data: PublicTransportSettings | null;\n error: ApiError | null;\n };\n };\n}\nexport const GET_SETTINGS_QUERY = gql`\n query GetMailerSettings {\n mailer {\n settings: getSettings {\n data ${SETTINGS_FIELDS}\n error ${ERROR_FIELDS}\n }\n }\n }\n`;\n\nexport interface SaveSettingsMutationVariables {\n data: TransportSettings;\n}\n\nexport interface SaveSettingsMutationResponse {\n mailer: {\n settings: {\n data: PublicTransportSettings | null;\n error: ApiError<ValidationErrors> | null;\n };\n };\n}\nexport const SAVE_SETTINGS_MUTATION = gql`\n mutation SaveTransportSettings($data: MailerTransportSettingsInput!) {\n mailer {\n settings: saveSettings(data: $data) {\n data ${SETTINGS_FIELDS}\n error ${ERROR_FIELDS}\n }\n }\n }\n`;\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,aAAa;AAG7B,MAAMC,eAAe,GAAG;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,YAAY,GAAG;AACrB;AACA;AACA;AACA;AACA;AACA,CAAC;;AAID;;AAaA,OAAO,MAAMC,kBAAkB,GAAGH,GAAG;AACrC;AACA;AACA;AACA,uBAAuBC,eAAe;AACtC,wBAAwBC,YAAY;AACpC;AACA;AACA;AACA,CAAC;AAcD,OAAO,MAAME,sBAAsB,GAAGJ,GAAG;AACzC;AACA;AACA;AACA,uBAAuBC,eAAe;AACtC,wBAAwBC,YAAY;AACpC;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"views/settings/graphql.js","sources":["../../../src/views/settings/graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type { ApiError, TransportSettings, ValidationErrors } from \"~/types.js\";\n\nconst SETTINGS_FIELDS = `\n {\n host\n port\n user\n from\n replyTo\n source\n }\n`;\n\nconst ERROR_FIELDS = `\n {\n message\n code\n data\n }\n`;\n\nexport type MailerSettingsSource = \"code\" | \"storage\" | null;\n\n/** Settings as they appear in GraphQL responses — never includes the password. */\nexport type PublicTransportSettings = Omit<TransportSettings, \"password\"> & {\n source?: MailerSettingsSource;\n};\n\nexport interface SettingsQueryResponse {\n mailer: {\n settings: {\n data: PublicTransportSettings | null;\n error: ApiError | null;\n };\n };\n}\nexport const GET_SETTINGS_QUERY = gql`\n query GetMailerSettings {\n mailer {\n settings: getSettings {\n data ${SETTINGS_FIELDS}\n error ${ERROR_FIELDS}\n }\n }\n }\n`;\n\nexport interface SaveSettingsMutationVariables {\n data: TransportSettings;\n}\n\nexport interface SaveSettingsMutationResponse {\n mailer: {\n settings: {\n data: PublicTransportSettings | null;\n error: ApiError<ValidationErrors> | null;\n };\n };\n}\nexport const SAVE_SETTINGS_MUTATION = gql`\n mutation SaveTransportSettings($data: MailerTransportSettingsInput!) {\n mailer {\n settings: saveSettings(data: $data) {\n data ${SETTINGS_FIELDS}\n error ${ERROR_FIELDS}\n }\n }\n }\n`;\n"],"names":["SETTINGS_FIELDS","ERROR_FIELDS","GET_SETTINGS_QUERY","gql","SAVE_SETTINGS_MUTATION"],"mappings":";AAGA,MAAMA,kBAAkB,CAAC;;;;;;;;;AASzB,CAAC;AAED,MAAMC,eAAe,CAAC;;;;;;AAMtB,CAAC;AAiBM,MAAMC,qBAAqBC,WAAG,CAAC;;;;qBAIjB,EAAEH,gBAAgB;sBACjB,EAAEC,aAAa;;;;AAIrC,CAAC;AAcM,MAAMG,yBAAyBD,WAAG,CAAC;;;;qBAIrB,EAAEH,gBAAgB;sBACjB,EAAEC,aAAa;;;;AAIrC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Settings } from "./Settings.js";
2
- export default Settings;
2
+ const settings = Settings;
3
+ export default settings;
3
4
 
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Settings"],"sources":["index.ts"],"sourcesContent":["import { Settings } from \"./Settings.js\";\n\nexport default Settings;\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,eAAeA,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"views/settings/index.js","sources":["../../../src/views/settings/index.ts"],"sourcesContent":["import { Settings } from \"./Settings.js\";\n\nexport default Settings;\n"],"names":["Settings"],"mappings":";AAEA,iBAAeA"}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["Module"],"sources":["index.tsx"],"sourcesContent":["export { Module } from \"./Module.js\";\n"],"mappings":"AAAA,SAASA,MAAM","ignoreList":[]}
package/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { Identity } from \"@webiny/app-admin/domain/Identity.js\";\n\n/**\n * A base security permission for APW.\n *\n * @category SecurityPermission\n */\nexport interface MailerSecurityPermission extends Identity.Permission {\n changeSettings?: boolean;\n}\n\n/**\n * GraphQL API call response for the transport settings values\n * @category GraphQL\n */\nexport interface TransportSettings {\n host: string;\n port?: number;\n user: string;\n from: string;\n replyTo?: string;\n password?: string;\n}\n/**\n *\n * @category GraphQL\n */\nexport interface ApiError<T = Record<string, any>> {\n message: string;\n code: string;\n data: T;\n}\n\n/**\n * Description of the JOI validation errors received from the API.\n *\n * @category GraphQL\n */\nexport interface ValidationError {\n message: string;\n path: string[];\n}\n\nexport interface ValidationErrors {\n errors: ValidationError[];\n}\n"],"mappings":"","ignoreList":[]}