alchemy_cms 5.3.2 → 5.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/alchemy/version.rb +1 -1
- data/package/src/page_sorter.js +1 -1
- data/package/src/sitemap.js +4 -4
- data/package/src/utils/__tests__/ajax.spec.js +25 -27
- data/package/src/utils/ajax.js +10 -5
- data/package.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f18c2fd116b7cecb0091d78a0e3d7bdad8a996e03b04c53e56e04a651a5d47b
|
4
|
+
data.tar.gz: 35f9e7ed5ef6c525348a5d885c50d448376ce03f2ce0955037ed3a05c4733ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23b529d54cdc27a766208ee9750e282349b184feec1cc21f398a01caccd970d2dc5a9bdd7f500f52fe165f306bf32052d8d48f2e892b83af92037d65fcec33c9
|
7
|
+
data.tar.gz: f733eee0bb31d47a489657d66c741fb983f1a363e017756f3be0ced53a589e3978e51f5240c8bdd3fa6d405a89bf8c89d6a7ff3b17d6de4631d638f7206dcb90
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 5.3.3 (2022-03-24)
|
2
|
+
|
3
|
+
- fix admin sitemap feature specs ([tvdeyen](https://github.com/tvdeyen))
|
4
|
+
- fix: Add support for ajax.get query params ([tvdeyen](https://github.com/tvdeyen))
|
5
|
+
- fix(Sitemap): Use response data ([tvdeyen](https://github.com/tvdeyen))
|
6
|
+
- Revert "Ajax: Send method override" ([tvdeyen](https://github.com/tvdeyen))
|
7
|
+
|
1
8
|
## 5.3.2 (2022-03-24)
|
2
9
|
|
3
10
|
- ImageLoader: Add error handling ([tvdeyen](https://github.com/tvdeyen))
|
data/lib/alchemy/version.rb
CHANGED
data/package/src/page_sorter.js
CHANGED
@@ -11,7 +11,7 @@ function onFinishDragging(evt) {
|
|
11
11
|
|
12
12
|
patch(url, data)
|
13
13
|
.then(async (response) => {
|
14
|
-
const pageData = await response.
|
14
|
+
const pageData = await response.data
|
15
15
|
const pageEl = document.getElementById(`page_${pageId}`)
|
16
16
|
const urlPathEl = pageEl.querySelector(".sitemap_url")
|
17
17
|
|
data/package/src/sitemap.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
// The admin sitemap Alchemy class
|
2
2
|
import PageSorter from "./page_sorter"
|
3
3
|
import { on } from "./utils/events"
|
4
|
-
import { patch } from "./utils/ajax"
|
4
|
+
import { get, patch } from "./utils/ajax"
|
5
5
|
import { createSortables, displayPageFolders } from "./page_sorter"
|
6
6
|
|
7
7
|
export default class Sitemap {
|
@@ -31,9 +31,9 @@ export default class Sitemap {
|
|
31
31
|
const spinTarget = this.sitemap_wrapper
|
32
32
|
spinTarget.innerHTML = ""
|
33
33
|
spinner.spin(spinTarget)
|
34
|
-
|
34
|
+
get(this.options.url, { id: pageId })
|
35
35
|
.then(async (response) => {
|
36
|
-
this.render(await response.
|
36
|
+
this.render(await response.data)
|
37
37
|
this.handlePageFolders()
|
38
38
|
spinner.stop()
|
39
39
|
})
|
@@ -55,7 +55,7 @@ export default class Sitemap {
|
|
55
55
|
|
56
56
|
patch(Alchemy.routes.fold_admin_page_path(pageId))
|
57
57
|
.then(async (response) => {
|
58
|
-
this.reRender(pageId, await response.
|
58
|
+
this.reRender(pageId, await response.data)
|
59
59
|
spinner.stop()
|
60
60
|
})
|
61
61
|
.catch(this.errorHandler)
|
@@ -10,7 +10,7 @@ beforeEach(() => {
|
|
10
10
|
|
11
11
|
describe("get", () => {
|
12
12
|
it("sends X-CSRF-TOKEN header", async () => {
|
13
|
-
xhrMock.get("/users", (req, res) => {
|
13
|
+
xhrMock.get("http://localhost/users", (req, res) => {
|
14
14
|
expect(req.header("X-CSRF-TOKEN")).toEqual(token)
|
15
15
|
return res.status(200).body('{"message":"Ok"}')
|
16
16
|
})
|
@@ -18,7 +18,7 @@ describe("get", () => {
|
|
18
18
|
})
|
19
19
|
|
20
20
|
it("sends Content-Type header", async () => {
|
21
|
-
xhrMock.get("/users", (req, res) => {
|
21
|
+
xhrMock.get("http://localhost/users", (req, res) => {
|
22
22
|
expect(req.header("Content-Type")).toEqual(
|
23
23
|
"application/json; charset=utf-8"
|
24
24
|
)
|
@@ -28,7 +28,7 @@ describe("get", () => {
|
|
28
28
|
})
|
29
29
|
|
30
30
|
it("sends Accept header", async () => {
|
31
|
-
xhrMock.get("/users", (req, res) => {
|
31
|
+
xhrMock.get("http://localhost/users", (req, res) => {
|
32
32
|
expect(req.header("Accept")).toEqual("application/json")
|
33
33
|
return res.status(200).body('{"message":"Ok"}')
|
34
34
|
})
|
@@ -36,7 +36,7 @@ describe("get", () => {
|
|
36
36
|
})
|
37
37
|
|
38
38
|
it("returns JSON", async () => {
|
39
|
-
xhrMock.get("/users", (_req, res) => {
|
39
|
+
xhrMock.get("http://localhost/users", (_req, res) => {
|
40
40
|
return res.status(200).body('{"email":"mail@example.com"}')
|
41
41
|
})
|
42
42
|
await get("/users").then((res) => {
|
@@ -45,7 +45,7 @@ describe("get", () => {
|
|
45
45
|
})
|
46
46
|
|
47
47
|
it("JSON parse errors get rejected", async () => {
|
48
|
-
xhrMock.get("/users", (_req, res) => {
|
48
|
+
xhrMock.get("http://localhost/users", (_req, res) => {
|
49
49
|
return res.status(200).body('email => "mail@example.com"')
|
50
50
|
})
|
51
51
|
expect.assertions(1)
|
@@ -55,7 +55,7 @@ describe("get", () => {
|
|
55
55
|
})
|
56
56
|
|
57
57
|
it("network errors get rejected", async () => {
|
58
|
-
xhrMock.get("/users", () => {
|
58
|
+
xhrMock.get("http://localhost/users", () => {
|
59
59
|
return Promise.reject(new Error())
|
60
60
|
})
|
61
61
|
expect.assertions(1)
|
@@ -65,7 +65,7 @@ describe("get", () => {
|
|
65
65
|
})
|
66
66
|
|
67
67
|
it("server errors get rejected", async () => {
|
68
|
-
xhrMock.get("/users", (_req, res) => {
|
68
|
+
xhrMock.get("http://localhost/users", (_req, res) => {
|
69
69
|
return res.status(401).body('{"error":"Unauthorized"}')
|
70
70
|
})
|
71
71
|
expect.assertions(1)
|
@@ -75,7 +75,7 @@ describe("get", () => {
|
|
75
75
|
})
|
76
76
|
|
77
77
|
it("server errors parsing errors get rejected", async () => {
|
78
|
-
xhrMock.get("/users", (_req, res) => {
|
78
|
+
xhrMock.get("http://localhost/users", (_req, res) => {
|
79
79
|
return res.status(401).body("Unauthorized")
|
80
80
|
})
|
81
81
|
expect.assertions(1)
|
@@ -83,11 +83,19 @@ describe("get", () => {
|
|
83
83
|
expect(e.message).toMatch("Unexpected token")
|
84
84
|
})
|
85
85
|
})
|
86
|
+
|
87
|
+
it("params get attached as query string", async () => {
|
88
|
+
xhrMock.get("http://localhost/users?name=foo", (_req, res) => {
|
89
|
+
return res.status(200).body(`{"name":"foo"}`)
|
90
|
+
})
|
91
|
+
const { data } = await get("/users", { name: "foo" })
|
92
|
+
expect(data.name).toEqual("foo")
|
93
|
+
})
|
86
94
|
})
|
87
95
|
|
88
96
|
describe("patch", () => {
|
89
97
|
it("sends X-CSRF-TOKEN header", async () => {
|
90
|
-
xhrMock.
|
98
|
+
xhrMock.patch("http://localhost/users", (req, res) => {
|
91
99
|
expect(req.header("X-CSRF-TOKEN")).toEqual(token)
|
92
100
|
return res.status(200).body('{"message":"Ok"}')
|
93
101
|
})
|
@@ -95,7 +103,7 @@ describe("patch", () => {
|
|
95
103
|
})
|
96
104
|
|
97
105
|
it("sends Content-Type header", async () => {
|
98
|
-
xhrMock.
|
106
|
+
xhrMock.patch("http://localhost/users", (req, res) => {
|
99
107
|
expect(req.header("Content-Type")).toEqual(
|
100
108
|
"application/json; charset=utf-8"
|
101
109
|
)
|
@@ -105,26 +113,16 @@ describe("patch", () => {
|
|
105
113
|
})
|
106
114
|
|
107
115
|
it("sends Accept header", async () => {
|
108
|
-
xhrMock.
|
116
|
+
xhrMock.patch("http://localhost/users", (req, res) => {
|
109
117
|
expect(req.header("Accept")).toEqual("application/json")
|
110
118
|
return res.status(200).body('{"message":"Ok"}')
|
111
119
|
})
|
112
120
|
await patch("/users")
|
113
121
|
})
|
114
122
|
|
115
|
-
it("sends method override data", async () => {
|
116
|
-
xhrMock.post("/users", (req, res) => {
|
117
|
-
expect(req.body()).toEqual('{"_method":"patch"}')
|
118
|
-
return res.status(200).body('{"message":"Ok"}')
|
119
|
-
})
|
120
|
-
await patch("/users")
|
121
|
-
})
|
122
|
-
|
123
123
|
it("sends JSON data", async () => {
|
124
|
-
xhrMock.
|
125
|
-
expect(req.body()).toEqual(
|
126
|
-
'{"email":"mail@example.com","_method":"patch"}'
|
127
|
-
)
|
124
|
+
xhrMock.patch("http://localhost/users", (req, res) => {
|
125
|
+
expect(req.body()).toEqual('{"email":"mail@example.com"}')
|
128
126
|
return res.status(200).body('{"message":"Ok"}')
|
129
127
|
})
|
130
128
|
await patch("/users", { email: "mail@example.com" })
|
@@ -133,7 +131,7 @@ describe("patch", () => {
|
|
133
131
|
|
134
132
|
describe("post", () => {
|
135
133
|
it("sends X-CSRF-TOKEN header", async () => {
|
136
|
-
xhrMock.post("/users", (req, res) => {
|
134
|
+
xhrMock.post("http://localhost/users", (req, res) => {
|
137
135
|
expect(req.header("X-CSRF-TOKEN")).toEqual(token)
|
138
136
|
return res.status(200).body('{"message":"Ok"}')
|
139
137
|
})
|
@@ -141,7 +139,7 @@ describe("post", () => {
|
|
141
139
|
})
|
142
140
|
|
143
141
|
it("sends Content-Type header", async () => {
|
144
|
-
xhrMock.post("/users", (req, res) => {
|
142
|
+
xhrMock.post("http://localhost/users", (req, res) => {
|
145
143
|
expect(req.header("Content-Type")).toEqual(
|
146
144
|
"application/json; charset=utf-8"
|
147
145
|
)
|
@@ -151,7 +149,7 @@ describe("post", () => {
|
|
151
149
|
})
|
152
150
|
|
153
151
|
it("sends Accept header", async () => {
|
154
|
-
xhrMock.post("/users", (req, res) => {
|
152
|
+
xhrMock.post("http://localhost/users", (req, res) => {
|
155
153
|
expect(req.header("Accept")).toEqual("application/json")
|
156
154
|
return res.status(200).body('{"message":"Ok"}')
|
157
155
|
})
|
@@ -159,7 +157,7 @@ describe("post", () => {
|
|
159
157
|
})
|
160
158
|
|
161
159
|
it("sends JSON data", async () => {
|
162
|
-
xhrMock.post("/users", (req, res) => {
|
160
|
+
xhrMock.post("http://localhost/users", (req, res) => {
|
163
161
|
expect(req.body()).toEqual('{"email":"mail@example.com"}')
|
164
162
|
return res.status(200).body('{"message":"Ok"}')
|
165
163
|
})
|
data/package/src/utils/ajax.js
CHANGED
@@ -33,24 +33,29 @@ export function get(url, params) {
|
|
33
33
|
return ajax("GET", url, params)
|
34
34
|
}
|
35
35
|
|
36
|
-
export function patch(url, data
|
37
|
-
return ajax("
|
36
|
+
export function patch(url, data) {
|
37
|
+
return ajax("PATCH", url, data)
|
38
38
|
}
|
39
39
|
|
40
40
|
export function post(url, data) {
|
41
41
|
return ajax("POST", url, data)
|
42
42
|
}
|
43
43
|
|
44
|
-
export default function ajax(method,
|
44
|
+
export default function ajax(method, path, data) {
|
45
45
|
const xhr = new XMLHttpRequest()
|
46
46
|
const promise = buildPromise(xhr)
|
47
|
+
const url = new URL(window.location.origin + path)
|
47
48
|
|
48
|
-
|
49
|
+
if (data && method.toLowerCase() === "get") {
|
50
|
+
url.search = new URLSearchParams(data).toString()
|
51
|
+
}
|
52
|
+
|
53
|
+
xhr.open(method, url.toString())
|
49
54
|
xhr.setRequestHeader("Content-type", "application/json; charset=utf-8")
|
50
55
|
xhr.setRequestHeader("Accept", "application/json")
|
51
56
|
xhr.setRequestHeader("X-CSRF-Token", getToken())
|
52
57
|
|
53
|
-
if (data) {
|
58
|
+
if (data && method.toLowerCase() !== "get") {
|
54
59
|
xhr.send(JSON.stringify(data))
|
55
60
|
} else {
|
56
61
|
xhr.send()
|
data/package.json
CHANGED